mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/mpeg12: Pass parameters explicitly in ff_init_2d_vlc_rl()
This allows to exploit that ff_rl_mpeg1 and ff_rl_mpeg2 only differ in their VLC table. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
06fafbe01e
commit
4a8fe21ab4
|
@ -63,14 +63,15 @@ static const uint8_t table_mb_btype[11][2] = {
|
|||
{ 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
|
||||
};
|
||||
|
||||
av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
|
||||
unsigned static_size, int flags)
|
||||
av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc[],
|
||||
const int8_t table_run[], const uint8_t table_level[],
|
||||
int n, unsigned static_size, int flags)
|
||||
{
|
||||
int i;
|
||||
VLCElem table[680] = { 0 };
|
||||
VLC vlc = { .table = table, .table_allocated = static_size };
|
||||
av_assert0(static_size <= FF_ARRAY_ELEMS(table));
|
||||
init_vlc(&vlc, TEX_VLC_BITS, rl->n + 2, &rl->table_vlc[0][1], 4, 2, &rl->table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | flags);
|
||||
init_vlc(&vlc, TEX_VLC_BITS, n + 2, &table_vlc[0][1], 4, 2, &table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | flags);
|
||||
|
||||
for (i = 0; i < vlc.table_size; i++) {
|
||||
int code = vlc.table[i].sym;
|
||||
|
@ -84,15 +85,15 @@ av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
|
|||
run = 0;
|
||||
level = code;
|
||||
} else {
|
||||
if (code == rl->n) { //esc
|
||||
if (code == n) { //esc
|
||||
run = 65;
|
||||
level = 0;
|
||||
} else if (code == rl->n+1) { //eob
|
||||
} else if (code == n + 1) { //eob
|
||||
run = 0;
|
||||
level = 127;
|
||||
} else {
|
||||
run = rl->table_run [code] + 1;
|
||||
level = rl->table_level[code];
|
||||
run = table_run [code] + 1;
|
||||
level = table_level[code];
|
||||
}
|
||||
}
|
||||
rl_vlc[i].len = len;
|
||||
|
@ -151,8 +152,12 @@ static av_cold void mpeg12_init_vlcs(void)
|
|||
&table_mb_btype[0][1], 2, 1,
|
||||
&table_mb_btype[0][0], 2, 1, 64);
|
||||
|
||||
INIT_2D_VLC_RL(ff_rl_mpeg1, ff_mpeg1_rl_vlc, 0);
|
||||
INIT_2D_VLC_RL(ff_rl_mpeg2, ff_mpeg2_rl_vlc, 0);
|
||||
ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_rl_mpeg1.table_run,
|
||||
ff_rl_mpeg1.table_level, ff_rl_mpeg1.n,
|
||||
FF_ARRAY_ELEMS(ff_mpeg1_rl_vlc), 0);
|
||||
ff_init_2d_vlc_rl(ff_mpeg2_vlc_table, ff_mpeg2_rl_vlc, ff_rl_mpeg1.table_run,
|
||||
ff_rl_mpeg1.table_level, ff_rl_mpeg1.n,
|
||||
FF_ARRAY_ELEMS(ff_mpeg2_rl_vlc), 0);
|
||||
}
|
||||
|
||||
av_cold void ff_mpeg12_init_vlcs(void)
|
||||
|
|
|
@ -50,9 +50,6 @@ extern VLC ff_mv_vlc;
|
|||
|
||||
void ff_mpeg12_init_vlcs(void);
|
||||
|
||||
#define INIT_2D_VLC_RL(rl, rl_vlc, flags)\
|
||||
ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags)
|
||||
|
||||
#define MPEG12_RL_NB_ELEMS 111
|
||||
|
||||
extern RLTable ff_rl_mpeg1;
|
||||
|
@ -64,8 +61,9 @@ extern const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
|
|||
extern RL_VLC_ELEM ff_mpeg1_rl_vlc[];
|
||||
extern RL_VLC_ELEM ff_mpeg2_rl_vlc[];
|
||||
|
||||
void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
|
||||
unsigned static_size, int flags);
|
||||
void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc[],
|
||||
const int8_t table_run[], const uint8_t table_level[],
|
||||
int n, unsigned static_size, int flags);
|
||||
|
||||
void ff_mpeg1_init_uni_ac_vlc(const int8_t max_level[], const uint8_t index_run[],
|
||||
const uint16_t table_vlc[][2], uint8_t uni_ac_vlc_len[]);
|
||||
|
|
|
@ -566,7 +566,9 @@ static av_cold void speedhq_static_init(void)
|
|||
ff_mpeg12_vlc_dc_chroma_code, 2, 2,
|
||||
INIT_VLC_OUTPUT_LE, 514);
|
||||
|
||||
INIT_2D_VLC_RL(ff_rl_speedhq, speedhq_rl_vlc, INIT_VLC_LE);
|
||||
ff_init_2d_vlc_rl(ff_speedhq_vlc_table, speedhq_rl_vlc, ff_rl_speedhq.table_run,
|
||||
ff_rl_speedhq.table_level, ff_rl_speedhq.n,
|
||||
FF_ARRAY_ELEMS(speedhq_rl_vlc), INIT_VLC_LE);
|
||||
|
||||
compute_alpha_vlcs();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue