diff mbox series

[FFmpeg-devel,35/61] avcodec/4xm: Avoid unnecessary VLC structures

Message ID GV1P250MB073765981E8834358C8D1F0D8FC3A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 25b9ff2780fdf1fbce914aeb68e77699d47147b6
Headers show
Series [FFmpeg-devel,01/61] avcodec/vlc: Add functions to init static VLCElem[] without VLC | expand

Commit Message

Andreas Rheinhardt Sept. 26, 2023, 10:17 p.m. UTC
Everything besides VLC.table is basically write-only
and even VLC.table can be removed by accessing the
underlying table directly.

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

Patch

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index c3e3a45df5..158b37a38b 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -125,7 +125,7 @@  static const uint8_t dequant_table[64] = {
     20, 35, 34, 32, 31, 22, 15,  8,
 };
 
-static VLC block_type_vlc[2][4];
+static VLCElem block_type_vlc[2][4][32];
 
 
 typedef struct CFrameBuffer {
@@ -250,17 +250,15 @@  static void idct(int16_t block[64])
 
 static av_cold void init_vlcs(void)
 {
-    static VLCElem table[2][4][32];
     int i, j;
 
     for (i = 0; i < 2; i++) {
         for (j = 0; j < 4; j++) {
-            block_type_vlc[i][j].table           = table[i][j];
-            block_type_vlc[i][j].table_allocated = 32;
-            vlc_init(&block_type_vlc[i][j], BLOCK_TYPE_VLC_BITS, 7,
-                     &block_type_tab[i][j][0][1], 2, 1,
-                     &block_type_tab[i][j][0][0], 2, 1,
-                     VLC_INIT_USE_STATIC);
+            ff_vlc_init_table_sparse(block_type_vlc[i][j], FF_ARRAY_ELEMS(block_type_vlc[i][j]),
+                                     BLOCK_TYPE_VLC_BITS, 7,
+                                     &block_type_tab[i][j][0][1], 2, 1,
+                                     &block_type_tab[i][j][0][0], 2, 1,
+                                     NULL, 0, 0, 0);
         }
     }
 }
@@ -357,7 +355,7 @@  static int decode_p_block(FourXContext *f, uint16_t *dst, const uint16_t *src,
     if (get_bits_left(&f->gb) < 1)
         return AVERROR_INVALIDDATA;
     h     = 1 << log2h;
-    code  = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table,
+    code  = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index],
                      BLOCK_TYPE_VLC_BITS, 1);
     av_assert0(code >= 0 && code <= 6);