[FFmpeg-devel] [PATCH 4/7] proresdec2: offset VLCs by 1 to avoid 1 add

Christophe Gisquet christophe.gisquet at gmail.com
Fri Sep 8 11:15:05 EEST 2023


Pretty harmless, but not much gained either.
---
 libavcodec/proresdec2.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 91c689d9ef..e3cef402d7 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -152,7 +152,9 @@ static av_cold void init_vlcs(void)
         switch_val  = (switch_bits+1) << rice_order;
 
         // Values are actually transformed, but this is more a wrapping
-        for (ac = 0; ac <1<<AC_BITS; ac++) {
+        ac_codes[0] = 0;
+        ac_bits[0] = 0;
+        for (ac = 0; ac < (1<<AC_BITS)-1; ac++) {
             int exponent, bits, val = ac;
             unsigned int code;
 
@@ -169,8 +171,8 @@ static av_cold void init_vlcs(void)
                 code = 1;
             }
             if (bits > max_bits) max_bits = bits;
-            ac_bits [ac] = bits;
-            ac_codes[ac] = code;
+            ac_bits [ac+1] = bits;
+            ac_codes[ac+1] = code;
         }
 
         ff_free_vlc(ac_vlc+i);
@@ -609,7 +611,6 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex
         }
 
         level = get_vlc2(gb, tbl->table, PRORES_LEV_BITS, 3);
-        level += 1;
 
         i = pos >> log2_block_count;
 
-- 
2.42.0



More information about the ffmpeg-devel mailing list