This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new b21727ae6f avcodec/opus/rc: avoid a 32-bit shift when flushing raw bits
b21727ae6f is described below

commit b21727ae6f097b9ca31cd0167e2d006dc9c09e63
Author:     Romain Beauxis <[email protected]>
AuthorDate: Sun Nov 1 10:54:42 2026 -0600
Commit:     Romain Beauxis <[email protected]>
CommitDate: Tue Nov 3 13:32:51 2026 +0000

    avcodec/opus/rc: avoid a 32-bit shift when flushing raw bits
    
    ff_opus_rc_enc_end() pads the raw bits to a full word, which asks
    ff_opus_rc_put_raw() for 32 bits when the cache is empty and shifts a
    32-bit value by 32.
    
    Use the value whole when all 32 bits fit, which writes the same output
    without the undefined shift that aborts with --assert-level=2.
---
 libavcodec/opus/rc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/opus/rc.c b/libavcodec/opus/rc.c
index 57ac272934..f64078af3d 100644
--- a/libavcodec/opus/rc.c
+++ b/libavcodec/opus/rc.c
@@ -163,7 +163,7 @@ void ff_opus_rc_put_raw(OpusRangeCoder *rc, uint32_t val, 
uint32_t count)
     const int to_write = FFMIN(32 - rc->rb.cachelen, count);
 
     rc->total_bits += count;
-    rc->rb.cacheval |= av_zero_extend(val, to_write) << rc->rb.cachelen;
+    rc->rb.cacheval |= (to_write < 32 ? av_zero_extend(val, to_write) : val) 
<< rc->rb.cachelen;
     rc->rb.cachelen = (rc->rb.cachelen + to_write) % 32;
 
     if (!rc->rb.cachelen && count) {
@@ -171,7 +171,7 @@ void ff_opus_rc_put_raw(OpusRangeCoder *rc, uint32_t val, 
uint32_t count)
         rc->rb.bytes    += 4;
         rc->rb.position -= 4;
         rc->rb.cachelen = count - to_write;
-        rc->rb.cacheval = av_zero_extend(val >> to_write, rc->rb.cachelen);
+        rc->rb.cacheval = to_write < 32 ? av_zero_extend(val >> to_write, 
rc->rb.cachelen) : 0;
         av_assert0(rc->rng_cur < rc->rb.position);
     }
 }

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to