avcodec/rl: Allow to create only a few VLC tables

It is not uncommon that only the first one is used; this is similar to
ff_init_2d_vlc_rl().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-12-08 22:38:05 +01:00
parent f741bd0674
commit 8f04988e46
2 changed files with 11 additions and 0 deletions

View File

@ -80,6 +80,9 @@ av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size)
int qmul = q * 2; int qmul = q * 2;
int qadd = (q - 1) | 1; int qadd = (q - 1) | 1;
if (!rl->rl_vlc[q])
return;
if (q == 0) { if (q == 0) {
qmul = 1; qmul = 1;
qadd = 0; qadd = 0;

View File

@ -68,6 +68,14 @@ void ff_rl_init_vlc(RLTable *rl, unsigned static_size);
}\ }\
} }
#define INIT_FIRST_VLC_RL(rl, static_size) \
do { \
static RL_VLC_ELEM rl_vlc_table[static_size]; \
\
rl.rl_vlc[0] = rl_vlc_table; \
ff_rl_init_vlc(&rl, static_size); \
} while (0)
static inline int get_rl_index(const RLTable *rl, int last, int run, int level) static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
{ {
int index; int index;