mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-29 22:00:58 +02:00
lavc/ffv1: drop redundant FFV1Context.quant_table
In all cases except decoding version 1 it's either not used, or contains a copy of a table from quant_tables, which we can just as well use directly. When decoding version 1, we can just as well decode into quant_tables[0], which would otherwise be unused.
This commit is contained in:
parent
d2f507233a
commit
4b9f7c7e3a
@ -106,7 +106,6 @@ typedef struct FFV1Context {
|
||||
int ac; ///< 1=range coder <-> 0=golomb rice
|
||||
int ac_byte_count; ///< number of bytes used for AC coding
|
||||
PlaneContext plane[MAX_PLANES];
|
||||
int16_t quant_table[MAX_CONTEXT_INPUTS][256];
|
||||
int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256];
|
||||
int context_count[MAX_QUANT_TABLES];
|
||||
uint8_t state_transition[256];
|
||||
|
@ -764,7 +764,7 @@ static int read_header(FFV1Context *f)
|
||||
ff_dlog(f->avctx, "%d %d %d\n",
|
||||
f->chroma_h_shift, f->chroma_v_shift, f->avctx->pix_fmt);
|
||||
if (f->version < 2) {
|
||||
context_count = read_quant_tables(c, f->quant_table);
|
||||
context_count = read_quant_tables(c, f->quant_tables[0]);
|
||||
if (context_count < 0) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
@ -834,7 +834,7 @@ static int read_header(FFV1Context *f)
|
||||
sizeof(p->quant_table));
|
||||
context_count = f->context_count[idx];
|
||||
} else {
|
||||
memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table));
|
||||
memcpy(p->quant_table, f->quant_tables[0], sizeof(p->quant_table));
|
||||
}
|
||||
|
||||
if (f->version <= 2) {
|
||||
@ -1067,7 +1067,11 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
|
||||
fdst->use32bit = fsrc->use32bit;
|
||||
memcpy(fdst->state_transition, fsrc->state_transition,
|
||||
sizeof(fdst->state_transition));
|
||||
memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table));
|
||||
|
||||
// in version 1 there is a single per-keyframe quant table, so
|
||||
// we need to propagate it between threads
|
||||
if (fsrc->version < 2)
|
||||
memcpy(fdst->quant_tables[0], fsrc->quant_tables[0], sizeof(fsrc->quant_tables[0]));
|
||||
|
||||
for (int i = 0; i < fdst->num_h_slices * fdst->num_v_slices; i++) {
|
||||
FFV1Context *fssrc = fsrc->slice_context[i];
|
||||
|
@ -367,7 +367,7 @@ static void write_header(FFV1Context *f)
|
||||
put_symbol(c, state, f->chroma_v_shift, 0);
|
||||
put_rac(c, state, f->transparency);
|
||||
|
||||
write_quant_tables(c, f->quant_table);
|
||||
write_quant_tables(c, f->quant_tables[f->context_model]);
|
||||
} else if (f->version < 3) {
|
||||
put_symbol(c, state, f->slice_count, 0);
|
||||
for (i = 0; i < f->slice_count; i++) {
|
||||
@ -735,15 +735,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
s->context_count[0] = (11 * 11 * 11 + 1) / 2;
|
||||
s->context_count[1] = (11 * 11 * 5 * 5 * 5 + 1) / 2;
|
||||
memcpy(s->quant_table, s->quant_tables[s->context_model],
|
||||
sizeof(s->quant_table));
|
||||
|
||||
for (i = 0; i < s->plane_count; i++) {
|
||||
PlaneContext *const p = &s->plane[i];
|
||||
|
||||
memcpy(p->quant_table, s->quant_table, sizeof(p->quant_table));
|
||||
p->quant_table_index = s->context_model;
|
||||
p->context_count = s->context_count[p->quant_table_index];
|
||||
memcpy(p->quant_table, s->quant_tables[p->quant_table_index], sizeof(p->quant_table));
|
||||
}
|
||||
|
||||
if ((ret = ff_ffv1_allocate_initial_states(s)) < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user