diff mbox series

[FFmpeg-devel,08/17] avcodec/mpeg12enc: Don't initialize ff_rl_mpeg2 unnecessarily

Message ID AS8P250MB074426C9428277517CC192D18F2F9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 06fafbe01e2a07dd636f512101d95caaa58302b1
Headers show
Series [FFmpeg-devel,01/17] avcodec/mpeg12dec: Remove redundant function call | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 23, 2022, 7:36 p.m. UTC
ff_rl_mpeg1 and ff_rl_mpeg2 differ only in RLTable.table_vlc,
which ff_rl_init() does not use to initialize RLTable.max_level,
RLTable.max_run and RLTable.index_run. This implies
that these tables agree for ff_rl_mpeg1 and ff_rl_mpeg2;
hence one can just use one of them and avoid calling ff_rl_init()
ff_rl_mpeg2 alltogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg12enc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e0775d6b96..4d10b42bf2 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1076,14 +1076,13 @@  void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
 
 static av_cold void mpeg12_encode_init_static(void)
 {
-    static uint8_t mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
+    static uint8_t mpeg12_static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
 
-    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_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store);
 
     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_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
                              ff_mpeg2_vlc_table, uni_mpeg2_ac_vlc_len);
 
     /* build unified dc encoding tables */