[FFmpeg-cvslog] avcodec/msmpeg4dec: Reuse identical RL VLCs

Andreas Rheinhardt git at videolan.org
Mon Jan 25 17:02:57 EET 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Wed Dec  9 01:41:31 2020 +0100| [d90d0a715f08384bf44b004da60c6d1760a30beb] | committer: Andreas Rheinhardt

avcodec/msmpeg4dec: Reuse identical RL VLCs

Some of the RLTables used by msmpeg4dec actually coincide with other
RLTables: ff_rl_table[5] coincides with ff_h263_rl_inter (and
ff_rl_table[2] with ff_mpeg4_rl_intra). Given that ff_h263_rl_inter is
always initialized before msmpeg4dec's RLTables are initialized, one can
just reuse the VLC tables by copying the pointers; after all, there are
no ownership issues for static data. This saves 70912B from the .bss
segment, translating into actual memory savings when this decoder is
actually used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d90d0a715f08384bf44b004da60c6d1760a30beb
---

 libavcodec/msmpeg4dec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 882dd22dbd..06e9707b65 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -322,7 +322,10 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
         INIT_FIRST_VLC_RL(ff_rl_table[2], 554);
         INIT_VLC_RL(ff_rl_table[3], 940);
         INIT_VLC_RL(ff_rl_table[4], 962);
-        INIT_VLC_RL(ff_rl_table[5], 554);
+        /* ff_rl_table[5] coincides with ff_h263_rl_inter which has just been
+         * initialized in ff_h263_decode_init() above. So just copy the VLCs. */
+        av_assert1(ff_h263_rl_inter.rl_vlc[0]);
+        memcpy(ff_rl_table[5].rl_vlc, ff_h263_rl_inter.rl_vlc, sizeof(ff_rl_table[5].rl_vlc));
 
         mv = &ff_mv_tables[0];
         INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,



More information about the ffmpeg-cvslog mailing list