diff mbox series

[FFmpeg-devel] avcodec/dnxhddec: Use VLC symbol table to avoid lookup

Message ID GV1P250MB07378269436C2EC1113199C68FF5A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 4dae62f7081eda648adb76d47aef90e872606905
Headers show
Series [FFmpeg-devel] avcodec/dnxhddec: Use VLC symbol table to avoid lookup | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 16, 2023, 2:25 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dnxhddec.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Paul B Mahol Sept. 16, 2023, 8:36 a.m. UTC | #1
LGTM
diff mbox series

Patch

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index b5f4e053c0..703d0e341c 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -142,9 +142,10 @@  static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
                  ctx->cid_table->dc_bits, 1, 1,
                  ctx->cid_table->dc_codes, 1, 1, 0)) < 0)
             goto out;
-        if ((ret = vlc_init(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
+        if ((ret = ff_vlc_init_sparse(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
                  ctx->cid_table->run_bits, 1, 1,
-                 ctx->cid_table->run_codes, 2, 2, 0)) < 0)
+                 ctx->cid_table->run_codes, 2, 2,
+                 ctx->cid_table->run, 1, 1, 0)) < 0)
             goto out;
 
         ctx->cid = cid;
@@ -358,7 +359,7 @@  static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx,
                                                    int level_shift,
                                                    int dc_shift)
 {
-    int i, j, index1, index2, len, flags;
+    int i, j, index1, len, flags;
     int level, component, sign;
     const int *scale;
     const uint8_t *weight_matrix;
@@ -425,10 +426,11 @@  static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx,
         }
 
         if (flags & 2) {
+            int run;
             UPDATE_CACHE(bs, &row->gb);
-            GET_VLC(index2, bs, &row->gb, ctx->run_vlc.table,
+            GET_VLC(run, bs, &row->gb, ctx->run_vlc.table,
                     DNXHD_VLC_BITS, 2);
-            i += ctx->cid_table->run[index2];
+            i += run;
         }
 
         if (++i > 63) {