]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mpeg12: Don't initialize encoder-only parts of RLTable
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 8 Dec 2020 19:25:23 +0000 (20:25 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 31 Dec 2020 10:11:59 +0000 (11:11 +0100)
ff_mpeg12_init_vlcs() currently initializes index_run, max_level and
max_run of ff_rl_mpeg1/2; yet the only user of these fields is the
MPEG-1/2 encoder which already initializes these tables on its own.
So remove the initializations in ff_mpeg12_init_vlcs(); this also
simplifies making ff_mpeg12_init_vlcs() thread-safe.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/mpeg12.c
libavcodec/mpeg12.h
libavcodec/mpeg12enc.c

index e4f007aec575a15b07df57cabdb40964f0950509..b4ef41e12d62db3b1aed41e5faf70a18b90072e7 100644 (file)
@@ -41,8 +41,6 @@
 #include "bytestream.h"
 #include "thread.h"
 
-uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
-
 static const uint8_t table_mb_ptype[7][2] = {
     { 3, 5 }, // 0x01 MB_INTRA
     { 1, 2 }, // 0x02 MB_PAT
@@ -163,8 +161,6 @@ av_cold void ff_mpeg12_init_vlcs(void)
         INIT_VLC_STATIC(&ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
                         &table_mb_btype[0][1], 2, 1,
                         &table_mb_btype[0][0], 2, 1, 64);
-        ff_rl_init(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
-        ff_rl_init(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
 
         INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0);
         INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0);
index 9a7c2b66b38c74ce5e2e4054d166eca4494a7c52..4cd48b5d206c714e979c026e1a18599650fd34b1 100644 (file)
@@ -25,8 +25,6 @@
 #include "mpeg12vlc.h"
 #include "mpegvideo.h"
 
-extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
-
 void ff_mpeg12_common_init(MpegEncContext *s);
 
 #define INIT_2D_VLC_RL(rl, static_size, flags)\
index d399e9e75ec7b551eefc56f769118f678b3ac0af..155971fecdc02e8f2309f68d116f777528146e47 100644 (file)
@@ -1041,8 +1041,10 @@ void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
 
 static av_cold void mpeg12_encode_init_static(void)
 {
-    ff_rl_init(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
-    ff_rl_init(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
+    static uint8_t mpeg12_static_rl_table_store[2][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]);
 
     for (int i = 0; i < 64; i++) {
         mpeg1_max_level[0][i] = ff_rl_mpeg1.max_level[0][i];