[FFmpeg-devel] [PATCH 05/13] avcodec/dcahuff: Always use three bits for transition mode VLCs

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Sep 13 14:33:02 EEST 2022


It increases the size of one VLC from two to three bits, thereby
requiring four more VLCEntries (16 bytes .bss), but it allows to
inline the number of bits used when reading them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/dca_core.c | 2 +-
 libavcodec/dcahuff.c  | 5 ++---
 libavcodec/dcahuff.h  | 1 +
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 499afc8204..069d428fff 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -457,7 +457,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf,
             for (band = 0; band < s->subband_vq_start[ch]; band++)
                 if (s->bit_allocation[ch][band])
                     s->transition_mode[sf][ch][band] = get_vlc2(&s->gb, ff_dca_vlc_transition_mode[sel].table,
-                                                                ff_dca_vlc_transition_mode[sel].bits,1);
+                                                                DCA_TMODE_VLC_BITS, 1);
         }
     }
 
diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c
index 49fb06eeb4..842b1401dd 100644
--- a/libavcodec/dcahuff.c
+++ b/libavcodec/dcahuff.c
@@ -29,7 +29,6 @@
 #include "put_bits.h"
 
 #define TMODE_COUNT 4
-static const uint8_t tmode_vlc_bits[TMODE_COUNT] = { 3, 3, 3, 2 };
 static const uint16_t tmode_codes[TMODE_COUNT][4] = {
     { 0x0000, 0x0002, 0x0006, 0x0007 },
     { 0x0002, 0x0006, 0x0007, 0x0000 },
@@ -1252,7 +1251,7 @@ VLC     ff_dca_vlc_rsd;
 
 av_cold void ff_dca_init_vlcs(void)
 {
-    static VLCElem dca_table[30214];
+    static VLCElem dca_table[30218];
     unsigned offset = 0;
     int i, j;
 
@@ -1277,7 +1276,7 @@ av_cold void ff_dca_init_vlcs(void)
                      scales_bits[i], scales_codes[i]);
 
     for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++)
-        DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], tmode_vlc_bits[i], 4,
+        DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4,
                      tmode_bits[i], tmode_codes[i]);
 
     for (i = 0; i < DCA_CODE_BOOKS; i++) {
diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h
index 87e1fd1cea..1f13b6f443 100644
--- a/libavcodec/dcahuff.h
+++ b/libavcodec/dcahuff.h
@@ -40,6 +40,7 @@ typedef struct DCAVLC {
 } DCAVLC;
 
 extern DCAVLC   ff_dca_vlc_bit_allocation;
+#define DCA_TMODE_VLC_BITS 3
 extern VLC  ff_dca_vlc_transition_mode[4];
 extern DCAVLC   ff_dca_vlc_scale_factor;
 extern DCAVLC   ff_dca_vlc_quant_index[DCA_CODE_BOOKS];
-- 
2.34.1



More information about the ffmpeg-devel mailing list