]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/msmpeg4dec: Avoid duplication of VLC init code
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Thu, 8 Apr 2021 19:01:05 +0000 (21:01 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Mon, 12 Apr 2021 16:29:11 +0000 (18:29 +0200)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
libavcodec/msmpeg4dec.c

index 63f9faa1bb3d26b1b1a3cd691e56e88c0b6d8dd5..8fcd5b94cdd24f705f1fd4752bd1ef88579a8e0e 100644 (file)
@@ -356,18 +356,16 @@ av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
                  &ff_v2_mb_type[0][1], 2, 1,
                  &ff_v2_mb_type[0][0], 2, 1, 128);
 
-        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
-                     &ff_wmv2_inter_table[0][0][1], 8, 4,
-                     &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
-        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
-                     &ff_wmv2_inter_table[1][0][1], 8, 4,
-                     &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
-        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
-                     &ff_wmv2_inter_table[2][0][1], 8, 4,
-                     &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
-        INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
-                     &ff_wmv2_inter_table[3][0][1], 8, 4,
-                     &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
+        for (unsigned i = 0, offset = 0; i < 4; i++) {
+            static VLC_TYPE vlc_buf[1636 + 2648 + 1532 + 2488][2];
+            ff_mb_non_intra_vlc[i].table           = &vlc_buf[offset];
+            ff_mb_non_intra_vlc[i].table_allocated = FF_ARRAY_ELEMS(vlc_buf) - offset;
+            init_vlc(&ff_mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128,
+                     &ff_wmv2_inter_table[i][0][1], 8, 4,
+                     &ff_wmv2_inter_table[i][0][0], 8, 4,
+                     INIT_VLC_STATIC_OVERLONG);
+            offset += ff_mb_non_intra_vlc[i].table_size;
+        }
 
         INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
                  &ff_msmp4_mb_i_table[0][1], 4, 2,