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(CONTEXT_SIZE * p->context_count *
sizeof(uint8_t));
}
}
- 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];
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);
#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
+
extern const uint8_t ff_log2_run[41];
extern const int8_t ffv1_quant5_10bit[256];
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)
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];
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;
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;
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];
}
}
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];
int run_count = 0;
int run_mode = 0;
- if (s->ac) {
+ if (s->ac != AC_GOLOMB_RICE) {
if (c->bytestream_end - c->bytestream < w * 20) {
av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
return AVERROR_INVALIDDATA;
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]);
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);
}
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);
return AVERROR(ENOSYS);
}
- 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) {
av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample invalid\n");
return AVERROR_INVALIDDATA;
}
- if (!s->ac && avctx->coder_type == -1) {
+ if (s->ac == AC_GOLOMB_RICE) {
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_INVALIDDATA;
+ "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:
return AVERROR(EINVAL);
}
- if (s->ac > 1)
+ if (s->ac == AC_RANGE_CUSTOM_TAB)
for (i = 1; i < 256; i++)
s->state_transition[i] = ffv1_ver2_state[i];
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;
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];
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);