summaryrefslogtreecommitdiff
path: root/libavcodec/ffv1dec.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-11-15 23:26:07 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-11-16 12:56:31 +0100
commit4bb1070c154e49d35805fbcdac9c9e92f702ef96 (patch)
tree8feca3a3ab44d19cab72718c24bddb803bd12ce4 /libavcodec/ffv1dec.c
parent9fd2bf09dbc630484d9e88a1d27f7e8508b70a2c (diff)
ffv1: Explicitly name the coder type
FFv1 uses two types of coders, golomb and range with two different tables. This is exposed this in a rather convoluted way, for example mentioning to set coder type 1 while initializing the variable 'ac' to 2, because encoder does not use range coder with default table. Appropriate internal coder type values have been added and used in any check rather than using raw numbers. Initialization of avctx.coder_type in ffv1dec is removed because this field is encoder only. An unneeded validation check in the encoder is dropped too. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/ffv1dec.c')
-rw-r--r--libavcodec/ffv1dec.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 01c58a14ca..d32da60f85 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -120,7 +120,7 @@ static av_always_inline void decode_line(FFV1Context *s, int w,
av_assert2(context < p->context_count);
- if (s->ac) {
+ if (s->ac != AC_GOLOMB_RICE) {
diff = get_symbol_inline(c, p->state[context], 1);
} else {
if (context == 0 && run_mode == 0)
@@ -274,7 +274,7 @@ static int decode_slice_header(FFV1Context *f, FFV1Context *fs)
unsigned ps, i, context_count;
memset(state, 128, sizeof(state));
- if (fs->ac > 1) {
+ if (fs->ac == AC_RANGE_CUSTOM_TAB) {
for (i = 1; i < 256; i++) {
fs->c.one_state[i] = f->state_transition[i];
fs->c.zero_state[256 - i] = 256 - fs->c.one_state[i];
@@ -364,7 +364,7 @@ static int decode_slice(AVCodecContext *c, void *arg)
x = fs->slice_x;
y = fs->slice_y;
- if (!fs->ac) {
+ if (fs->ac == AC_GOLOMB_RICE) {
if (f->version == 3 && f->minor_version > 1 || f->version > 3)
get_rac(&fs->c, (uint8_t[]) { 129 });
fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0;
@@ -401,7 +401,7 @@ static int decode_slice(AVCodecContext *c, void *arg)
p->data[2] + ps * x + y * p->linesize[2] };
decode_rgb_frame(fs, planes, width, height, p->linesize);
}
- if (fs->ac && f->version > 2) {
+ if (fs->ac != AC_GOLOMB_RICE && f->version > 2) {
int v;
get_rac(&fs->c, (uint8_t[]) { 129 });
v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5 * f->ec;
@@ -477,9 +477,9 @@ static int read_extra_header(FFV1Context *f)
c->bytestream_end -= 4;
f->minor_version = get_symbol(c, state, 0);
}
- f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
+ f->ac = get_symbol(c, state, 0);
- if (f->ac > 1) {
+ if (f->ac == AC_RANGE_CUSTOM_TAB) {
for (i = 1; i < 256; i++)
f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
}
@@ -559,9 +559,9 @@ static int read_header(FFV1Context *f)
}
f->version = v;
- f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
+ f->ac = get_symbol(c, state, 0);
- if (f->ac > 1) {
+ if (f->ac == AC_RANGE_CUSTOM_TAB) {
for (i = 1; i < 256; i++)
f->state_transition[i] =
get_symbol(c, state, 1) + c->one_state[i];