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

Git pushed a commit to branch master
in repository ffmpeg.

commit 2df0ef601a7d3fa985bd173e3177ff820a663bda
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Thu Jan 8 15:13:05 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Tue Feb 3 12:39:32 2026 +0100

    avcodec/jpeg2000dec: allow bpno of -1
    
    Fixes: tickets/4663/levels30.jp2
    
    The file decodes without error messages and no integer overflows
    The file before the broader M_b check did decode with error messages and 
integer overflows but also no visual artifacts
    
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/jpeg2000dec.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 374881ec37..017be6f025 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1900,7 +1900,7 @@ static void decode_sigpass(Jpeg2000T1Context *t1, int 
width, int height,
                            int bpno, int bandno,
                            int vert_causal_ctx_csty_symbol)
 {
-    int mask = 3 << (bpno - 1), y0, x, y;
+    int mask = (3u << bpno)>>1, y0, x, y;
 
     for (y0 = 0; y0 < height; y0 += 4)
         for (x = 0; x < width; x++)
@@ -1933,7 +1933,7 @@ static void decode_refpass(Jpeg2000T1Context *t1, int 
width, int height,
     int phalf;
     int y0, x, y;
 
-    phalf = 1 << (bpno - 1);
+    phalf = 1 << bpno;
 
     for (y0 = 0; y0 < height; y0 += 4)
         for (x = 0; x < width; x++)
@@ -1942,11 +1942,11 @@ static void decode_refpass(Jpeg2000T1Context *t1, int 
width, int height,
                     int flags_mask = (vert_causal_ctx_csty_symbol && y == y0 + 
3) ?
                         ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | 
JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S) : -1;
                     int ctxno = ff_jpeg2000_getrefctxno(t1->flags[(y + 1) * 
t1->stride + x + 1] & flags_mask);
-                    t1->data[(y) * t1->stride + x] |= phalf;
+                    t1->data[(y) * t1->stride + x] |= phalf >> 1;
                     if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno))
-                        t1->data[(y) * t1->stride + x] |= phalf << 1;
+                        t1->data[(y) * t1->stride + x] |= phalf;
                     else {
-                        t1->data[(y) * t1->stride + x] &= ~(phalf << 1);
+                        t1->data[(y) * t1->stride + x] &= ~(phalf);
 
                     }
                     t1->flags[(y + 1) * t1->stride + x + 1] |= JPEG2000_T1_REF;
@@ -2043,7 +2043,7 @@ static int decode_cblk(const Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *cod
     ff_mqc_initdec(&t1->mqc, cblk->data, 0, 1);
 
     while (passno--) {
-        if (bpno < 0 || bpno > 29) {
+        if (bpno < -1 || bpno > 29) {
             av_log(s->avctx, AV_LOG_ERROR, "bpno (%d) became invalid\n", bpno);
             return AVERROR_INVALIDDATA;
         }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to