avcodec/ffv1: add a named constant for the quant table size

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
master
Michael Niedermayer 2 months ago
parent 2542e9296c
commit 81a360a5ed
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
  1. 4
      libavcodec/ffv1.h
  2. 18
      libavcodec/ffv1_template.c
  3. 6
      libavcodec/ffv1enc.c

@ -44,6 +44,8 @@
#define CONTEXT_SIZE 32
#define MAX_QUANT_TABLES 8
#define MAX_QUANT_TABLE_SIZE 256
#define MAX_QUANT_TABLE_MASK (MAX_QUANT_TABLE_SIZE - 1)
#define MAX_CONTEXT_INPUTS 5
#define AC_GOLOMB_RICE 0
@ -124,7 +126,7 @@ typedef struct FFV1Context {
const AVFrame *cur_enc_frame;
int plane_count;
int ac; ///< 1=range coder <-> 0=golomb rice
int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256];
int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];
int context_count[MAX_QUANT_TABLES];
uint8_t state_transition[256];
uint8_t (*initial_states[MAX_QUANT_TABLES])[32];

@ -29,7 +29,7 @@ static inline int RENAME(predict)(TYPE *src, TYPE *last)
return mid_pred(L, L + T - LT, T);
}
static inline int RENAME(get_context)(const int16_t quant_table[MAX_CONTEXT_INPUTS][256],
static inline int RENAME(get_context)(const int16_t quant_table[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE],
TYPE *src, TYPE *last, TYPE *last2)
{
const int LT = last[-1];
@ -40,14 +40,14 @@ static inline int RENAME(get_context)(const int16_t quant_table[MAX_CONTEXT_INPU
if (quant_table[3][127] || quant_table[4][127]) {
const int TT = last2[0];
const int LL = src[-2];
return quant_table[0][(L - LT) & 0xFF] +
quant_table[1][(LT - T) & 0xFF] +
quant_table[2][(T - RT) & 0xFF] +
quant_table[3][(LL - L) & 0xFF] +
quant_table[4][(TT - T) & 0xFF];
return quant_table[0][(L - LT) & MAX_QUANT_TABLE_MASK] +
quant_table[1][(LT - T) & MAX_QUANT_TABLE_MASK] +
quant_table[2][(T - RT) & MAX_QUANT_TABLE_MASK] +
quant_table[3][(LL - L) & MAX_QUANT_TABLE_MASK] +
quant_table[4][(TT - T) & MAX_QUANT_TABLE_MASK];
} else
return quant_table[0][(L - LT) & 0xFF] +
quant_table[1][(LT - T) & 0xFF] +
quant_table[2][(T - RT) & 0xFF];
return quant_table[0][(L - LT) & MAX_QUANT_TABLE_MASK] +
quant_table[1][(LT - T) & MAX_QUANT_TABLE_MASK] +
quant_table[2][(T - RT) & MAX_QUANT_TABLE_MASK];
}

@ -317,7 +317,7 @@ static void write_quant_table(RangeCoder *c, int16_t *quant_table)
uint8_t state[CONTEXT_SIZE];
memset(state, 128, sizeof(state));
for (i = 1; i < 128; i++)
for (i = 1; i < MAX_QUANT_TABLE_SIZE/2; i++)
if (quant_table[i] != quant_table[i - 1]) {
put_symbol(c, state, i - last - 1, 0);
last = i;
@ -326,7 +326,7 @@ static void write_quant_table(RangeCoder *c, int16_t *quant_table)
}
static void write_quant_tables(RangeCoder *c,
int16_t quant_table[MAX_CONTEXT_INPUTS][256])
int16_t quant_table[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE])
{
int i;
for (i = 0; i < 5; i++)
@ -726,7 +726,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->state_transition[i] = c.one_state[i];
}
for (i = 0; i < 256; i++) {
for (i = 0; i < MAX_QUANT_TABLE_SIZE; i++) {
s->quant_table_count = 2;
if (s->bits_per_raw_sample <= 8) {
s->quant_tables[0][0][i]= quant11[i];

Loading…
Cancel
Save