Merge commit '4bb1070c154e49d35805fbcdac9c9e92f702ef96'

* commit '4bb1070c154e49d35805fbcdac9c9e92f702ef96':
  ffv1: Explicitly name the coder type

  Conflicts:
      libavcodec/ffv1.h
      libavcodec/ffv1dec.c
      libavcodec/ffv1enc.c

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2015-11-22 16:55:56 +00:00
commit bba2488f07
4 changed files with 33 additions and 33 deletions

View File

@ -73,7 +73,7 @@ av_cold int ff_ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
for (j = 0; j < f->plane_count; j++) {
PlaneContext *const p = &fs->plane[j];
if (fs->ac) {
if (fs->ac != AC_GOLOMB_RICE) {
if (!p->state)
p->state = av_malloc_array(p->context_count, CONTEXT_SIZE *
sizeof(uint8_t));
@ -92,7 +92,7 @@ av_cold int ff_ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
}
}
if (fs->ac > 1) {
if (fs->ac == AC_RANGE_CUSTOM_TAB) {
//FIXME only redo if state_transition changed
for (j = 1; j < 256; j++) {
fs->c. one_state[ j] = f->state_transition[j];
@ -184,7 +184,7 @@ void ff_ffv1_clear_slice_state(FFV1Context *f, FFV1Context *fs)
p->interlace_bit_state[0] = 128;
p->interlace_bit_state[1] = 128;
if (fs->ac) {
if (fs->ac != AC_GOLOMB_RICE) {
if (f->initial_states[p->quant_table_index]) {
memcpy(p->state, f->initial_states[p->quant_table_index],
CONTEXT_SIZE * p->context_count);

View File

@ -53,6 +53,10 @@
#define MAX_QUANT_TABLES 8
#define MAX_CONTEXT_INPUTS 5
#define AC_GOLOMB_RICE 0
#define AC_RANGE_DEFAULT_TAB 1
#define AC_RANGE_CUSTOM_TAB 2
typedef struct VlcState {
int16_t drift;
uint16_t error_sum;

View File

@ -133,7 +133,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)
@ -423,7 +423,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->micro_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;
@ -452,7 +452,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;
@ -539,8 +539,9 @@ static int read_extra_header(FFV1Context *f)
if (f->micro_version < 0)
return AVERROR_INVALIDDATA;
}
f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
if (f->ac > 1) {
f->ac = get_symbol(c, state, 0);
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];
}
@ -646,8 +647,9 @@ static int read_header(FFV1Context *f)
return AVERROR_INVALIDDATA;
}
f->version = v;
f->ac = f->avctx->coder_type = get_symbol(c, state, 0);
if (f->ac > 1) {
f->ac = get_symbol(c, state, 0);
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];
}

View File

@ -274,7 +274,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w,
int run_count = 0;
int run_mode = 0;
if (s->ac) {
if (s->ac != AC_GOLOMB_RICE) {
if (c->bytestream_end - c->bytestream < w * 35) {
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return AVERROR_INVALIDDATA;
@ -311,7 +311,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w,
diff = fold(diff, bits);
if (s->ac) {
if (s->ac != AC_GOLOMB_RICE) {
if (s->flags & AV_CODEC_FLAG_PASS1) {
put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat,
s->rc_stat2[p->quant_table_index][context]);
@ -501,7 +501,7 @@ static void write_header(FFV1Context *f)
if (f->version < 2) {
put_symbol(c, state, f->version, 0);
put_symbol(c, state, f->ac, 0);
if (f->ac > 1) {
if (f->ac == AC_RANGE_CUSTOM_TAB) {
for (i = 1; i < 256; i++)
put_symbol(c, state,
f->state_transition[i] - c->one_state[i], 1);
@ -566,7 +566,7 @@ static int write_extradata(FFV1Context *f)
}
put_symbol(c, state, f->ac, 0);
if (f->ac > 1)
if (f->ac == AC_RANGE_CUSTOM_TAB)
for (i = 1; i < 256; i++)
put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1);
@ -700,7 +700,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
s->ac = avctx->coder_type > 0 ? 2 : 0;
s->ac = avctx->coder_type > 0 ? AC_RANGE_CUSTOM_TAB : AC_GOLOMB_RICE;
s->plane_count = 3;
switch(avctx->pix_fmt) {
@ -737,13 +737,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample invalid\n");
return AVERROR_INVALIDDATA;
}
if (!s->ac && avctx->coder_type == -1) {
av_log(avctx, AV_LOG_INFO, "bits_per_raw_sample > 8, forcing coder 1\n");
s->ac = 2;
}
if (!s->ac) {
av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample of more than 8 needs -coder 1 currently\n");
return AVERROR(ENOSYS);
if (s->ac == AC_GOLOMB_RICE) {
av_log(avctx, AV_LOG_INFO,
"bits_per_raw_sample > 8, forcing range coder\n");
s->ac = AC_RANGE_CUSTOM_TAB;
}
s->version = FFMAX(s->version, 1);
case AV_PIX_FMT_GRAY8:
@ -794,13 +791,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->colorspace = 1;
s->chroma_planes = 1;
s->version = FFMAX(s->version, 1);
if (!s->ac && avctx->coder_type == -1) {
av_log(avctx, AV_LOG_INFO, "bits_per_raw_sample > 8, forcing coder 1\n");
s->ac = 2;
}
if (!s->ac) {
av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample of more than 8 needs -coder 1 currently\n");
return AVERROR(ENOSYS);
if (s->ac == AC_GOLOMB_RICE) {
av_log(avctx, AV_LOG_INFO,
"bits_per_raw_sample > 8, forcing coder 1\n");
s->ac = AC_RANGE_CUSTOM_TAB;
}
break;
default:
@ -817,7 +811,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
if (s->ac > 1)
if (s->ac == AC_RANGE_CUSTOM_TAB)
for (i = 1; i < 256; i++)
s->state_transition[i] = ver2_state[i];
@ -1150,7 +1144,7 @@ retry:
if (f->version > 2) {
encode_slice_header(f, fs);
}
if (!fs->ac) {
if (fs->ac == AC_GOLOMB_RICE) {
if (f->version > 2)
put_rac(&fs->c, (uint8_t[]) { 129 }, 0);
fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&fs->c) : 0;
@ -1276,7 +1270,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
f->key_frame = 0;
}
if (f->ac > 1) {
if (f->ac == AC_RANGE_CUSTOM_TAB) {
int i;
for (i = 1; i < 256; i++) {
c->one_state[i] = f->state_transition[i];
@ -1298,7 +1292,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
FFV1Context *fs = f->slice_context[i];
int bytes;
if (fs->ac) {
if (fs->ac != AC_GOLOMB_RICE) {
uint8_t state = 129;
put_rac(&fs->c, &state, 0);
bytes = ff_rac_terminate(&fs->c);