diff mbox series

[FFmpeg-devel,04/13] avcodec/dca_core, dcahuff: Don't use DCAVLC unnecessarily

Message ID GV1P250MB07372C43697EFD4993196E068F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 8819860f34bb2065ec82d3b39d5053c13fb9ab31
Headers show
Series [FFmpeg-devel,01/13] avcodec/dolby_e_parser: Remove unnecessary headers | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 13, 2022, 11:33 a.m. UTC
The ff_dca_vlc_transition_mode VLCs don't use an offset at all,
so just use ordinary VLCs for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dca_core.c | 3 ++-
 libavcodec/dcahuff.c  | 8 +++-----
 libavcodec/dcahuff.h  | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index bbf36ea678..499afc8204 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -456,7 +456,8 @@  static int parse_subframe_header(DCACoreDecoder *s, int sf,
             int sel = s->transition_mode_sel[ch];
             for (band = 0; band < s->subband_vq_start[ch]; band++)
                 if (s->bit_allocation[ch][band])
-                    s->transition_mode[sf][ch][band] = dca_get_vlc(&s->gb, &ff_dca_vlc_transition_mode, sel);
+                    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);
         }
     }
 
diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c
index 9b809cc415..49fb06eeb4 100644
--- a/libavcodec/dcahuff.c
+++ b/libavcodec/dcahuff.c
@@ -1233,7 +1233,7 @@  static const uint8_t rsd_bitvals[18] = {
 };
 
 DCAVLC  ff_dca_vlc_bit_allocation;
-DCAVLC  ff_dca_vlc_transition_mode;
+VLC     ff_dca_vlc_transition_mode[4];
 DCAVLC  ff_dca_vlc_scale_factor;
 DCAVLC  ff_dca_vlc_quant_index[DCA_CODE_BOOKS];
 
@@ -1276,10 +1276,8 @@  av_cold void ff_dca_init_vlcs(void)
         DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129,
                      scales_bits[i], scales_codes[i]);
 
-    ff_dca_vlc_transition_mode.offset    = 0;
-    ff_dca_vlc_transition_mode.max_depth = 1;
-    for (i = 0; i < 4; i++)
-        DCA_INIT_VLC(ff_dca_vlc_transition_mode.vlc[i], tmode_vlc_bits[i], 4,
+    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,
                      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 c0e04b725a..87e1fd1cea 100644
--- a/libavcodec/dcahuff.h
+++ b/libavcodec/dcahuff.h
@@ -40,7 +40,7 @@  typedef struct DCAVLC {
 } DCAVLC;
 
 extern DCAVLC   ff_dca_vlc_bit_allocation;
-extern DCAVLC   ff_dca_vlc_transition_mode;
+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];