aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-22 01:33:11 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-27 15:44:38 +0200
commit178dcbb96fd9fe11896e468e42e68559ea01d92f (patch)
tree38573106b99815540e708c8a51a12fe41b6c4654
parent18412c76e6f087d15a26864999fd2d63df72cdc6 (diff)
downloadffmpeg-178dcbb96fd9fe11896e468e42e68559ea01d92f.tar.gz
avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc
This will allow to remove ff_rl_mpeg2 soon and remove all uses of RLTable in MPEG-1/2/SpeedHQ later. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/mpeg12enc.c19
-rw-r--r--libavcodec/mpeg12vlc.h3
-rw-r--r--libavcodec/speedhqenc.c3
3 files changed, 16 insertions, 9 deletions
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 5d991ac99e..e0775d6b96 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -94,7 +94,10 @@ typedef struct MPEG12EncContext {
#define A53_MAX_CC_COUNT 0x1f
#endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
-av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len)
+av_cold 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[])
{
int i;
@@ -107,16 +110,16 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len
int len, code;
int alevel = FFABS(level);
- if (alevel > rl->max_level[0][run])
+ if (alevel > max_level[run])
code = 111; /* rl->n */
else
- code = rl->index_run[0][run] + alevel - 1;
+ code = index_run[run] + alevel - 1;
if (code < 111) { /* rl->n */
/* length of VLC and sign */
- len = rl->table_vlc[code][1] + 1;
+ len = table_vlc[code][1] + 1;
} else {
- len = rl->table_vlc[111 /* rl->n */][1] + 6;
+ len = table_vlc[MPEG12_RL_NB_ELEMS][1] + 6;
if (alevel < 128)
len += 8;
@@ -1078,8 +1081,10 @@ static av_cold void mpeg12_encode_init_static(void)
ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store[0]);
ff_rl_init(&ff_rl_mpeg2, mpeg12_static_rl_table_store[1]);
- ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
- ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
+ ff_mpeg1_vlc_table, uni_mpeg1_ac_vlc_len);
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg2.max_level[0], ff_rl_mpeg2.index_run[0],
+ ff_mpeg2_vlc_table, uni_mpeg2_ac_vlc_len);
/* build unified dc encoding tables */
for (int i = -255; i < 256; i++) {
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index c810697370..5a04834bee 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -67,6 +67,7 @@ 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_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len);
+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[]);
#endif /* AVCODEC_MPEG12VLC_H */
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 58b5e858a8..44ee62b9c2 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -88,7 +88,8 @@ static av_cold void speedhq_init_static_data(void)
speedhq_chr_dc_uni[i + 255] = bits + (code << 8);
}
- ff_mpeg1_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len);
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_speedhq.max_level[0], ff_rl_speedhq.index_run[0],
+ ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);
}
av_cold int ff_speedhq_encode_init(MpegEncContext *s)