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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Oct 23 22:36:01 EEST 2022


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 at outlook.com>
---
 libavcodec/mpeg12enc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

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 */
-- 
2.34.1



More information about the ffmpeg-devel mailing list