[FFmpeg-cvslog] avcodec/proresdec: Don't use LONG_BITSTREAM_READER

Andreas Rheinhardt git at videolan.org
Thu Feb 27 16:54:53 EET 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Feb 23 23:21:00 2025 +0100| [8ad2daec587b805e3a98cdeb6ed88bc94938e7fa] | committer: Andreas Rheinhardt

avcodec/proresdec: Don't use LONG_BITSTREAM_READER

Using LONG_BITSTREAM_READER means that every get_bits() call
uses an AV_RB64() to ensure that cache always contains 32 valid bits
(as opposed to the ordinary 25 guaranteed by reading 32 bits);
yet this is unnecessary when unpacking alpha. So only use these
64bit reads where necessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ad2daec587b805e3a98cdeb6ed88bc94938e7fa
---

 libavcodec/proresdec.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index 6a256107b4..b2517bd5a4 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -26,8 +26,6 @@
 
 //#define DEBUG
 
-#define LONG_BITSTREAM_READER
-
 #include "config_components.h"
 
 #include "libavutil/internal.h"
@@ -428,7 +426,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
         unsigned int rice_order, exp_order, switch_bits;                \
         unsigned int q, buf, bits;                                      \
                                                                         \
-        UPDATE_CACHE(re, gb);                                           \
+        UPDATE_CACHE_32(re, gb); /* We really need 32 bits */           \
         buf = GET_CACHE(re, gb);                                        \
                                                                         \
         /* number of bits to switch between rice and exp golomb */      \
@@ -440,7 +438,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons
                                                                         \
         if (q > switch_bits) { /* exp golomb */                         \
             bits = exp_order - switch_bits + (q<<1);                    \
-            if (bits > FFMIN(MIN_CACHE_BITS, 31))                       \
+            if (bits > 31)                                              \
                 return AVERROR_INVALIDDATA;                             \
             val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) +         \
                 ((switch_bits + 1) << rice_order);                      \
@@ -502,7 +500,7 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex
     int log2_block_count = av_log2(blocks_per_slice);
 
     OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);                                           \
+    UPDATE_CACHE_32(re, gb);
     run   = 4;
     level = 2;
 



More information about the ffmpeg-cvslog mailing list