diff mbox series

[FFmpeg-devel,09/13] avcodec/dca_core: Inline number of bits of scale factor VLCs

Message ID GV1P250MB0737227E1DD9A46CE20608008F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 9dbc37076978c2127606c70e0d6b6004a3224426
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
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dca_core.c | 6 ++++--
 libavcodec/dcahuff.c  | 7 +++----
 libavcodec/dcahuff.h  | 3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 96787fe95d..7dff6633df 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -362,7 +362,8 @@  static inline int parse_scale(DCACoreDecoder *s, int *scale_index, int sel)
 
     // If Huffman code was used, the difference of scales was encoded
     if (sel < 5)
-        *scale_index += dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel);
+        *scale_index += get_vlc2(&s->gb, ff_dca_vlc_scale_factor[sel].table,
+                                 DCA_SCALES_VLC_BITS, 2);
     else
         *scale_index = get_bits(&s->gb, sel + 1);
 
@@ -381,7 +382,8 @@  static inline int parse_joint_scale(DCACoreDecoder *s, int sel)
 
     // Absolute value was encoded even when Huffman code was used
     if (sel < 5)
-        scale_index = dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel);
+        scale_index = get_vlc2(&s->gb, ff_dca_vlc_scale_factor[sel].table,
+                               DCA_SCALES_VLC_BITS, 2);
     else
         scale_index = get_bits(&s->gb, sel + 1);
 
diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c
index 7a5b054dd5..a7518aded8 100644
--- a/libavcodec/dcahuff.c
+++ b/libavcodec/dcahuff.c
@@ -770,7 +770,7 @@  const uint8_t ff_dca_vlc_src_tables[][2] = {
 
 DCAVLC  ff_dca_vlc_bit_allocation;
 VLC     ff_dca_vlc_transition_mode[4];
-DCAVLC  ff_dca_vlc_scale_factor;
+VLC     ff_dca_vlc_scale_factor[5];
 DCAVLC  ff_dca_vlc_quant_index[DCA_CODE_BOOKS];
 
 VLC     ff_dca_vlc_tnl_grp[5];
@@ -815,9 +815,8 @@  av_cold void ff_dca_init_vlcs(void)
     for (i = 0; i < 5; i++)
         DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, 1);
 
-    ff_dca_vlc_scale_factor.max_depth = 2;
-    for (i = 0; i < 5; i++)
-        DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129, -64);
+    for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_scale_factor); i++)
+        DCA_INIT_VLC(ff_dca_vlc_scale_factor[i], DCA_SCALES_VLC_BITS, 129, -64);
 
     for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++)
         DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4, 0);
diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h
index a50d49d6dd..8663f8ba12 100644
--- a/libavcodec/dcahuff.h
+++ b/libavcodec/dcahuff.h
@@ -43,7 +43,8 @@  typedef struct 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;
+#define DCA_SCALES_VLC_BITS 9
+extern VLC  ff_dca_vlc_scale_factor[5];
 extern DCAVLC   ff_dca_vlc_quant_index[DCA_CODE_BOOKS];
 
 extern VLC  ff_dca_vlc_tnl_grp[5];