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

Git pushed a commit to branch release/4.4
in repository ffmpeg.

commit faec49b44c909a1fac675c9aa6565de12ada307e
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sun Jun 21 17:45:03 2026 +0200
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Sun Jun 21 17:59:33 2026 +0200

    avcodec/jpeg2000dec: jpeg2000 has its own lowres option
    
    Backported to 4.4: shift dimensions by lowres so the frame buffer is
    full-size, and reconcile reduction_factor with avctx->lowres in init.
    Without this, -lowres allocated a shrunk buffer while the decoder wrote
    full-size pixels -> heap out-of-bounds write.
    
    (cherry picked from commit c012d1f2bb... adapted to 4.4)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/jpeg2000dec.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 167ff33d9d..7c3aecb36d 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -419,7 +419,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
         dimy = FFMAX(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i]));
     }
 
-    ret = ff_set_dimensions(s->avctx, dimx, dimy);
+    ret = ff_set_dimensions(s->avctx, dimx << s->avctx->lowres, dimy << 
s->avctx->lowres);
     if (ret < 0)
         return ret;
 
@@ -2524,6 +2524,14 @@ static av_cold int jpeg2000_decode_init(AVCodecContext 
*avctx)
     static AVOnce init_static_once = AV_ONCE_INIT;
     Jpeg2000DecoderContext *s = avctx->priv_data;
 
+    if (avctx->lowres)
+        av_log(avctx, AV_LOG_WARNING, "lowres is overriden by reduction_factor 
but set anyway\n");
+    if (!s->reduction_factor && avctx->lowres < JPEG2000_MAX_RESLEVELS) {
+        s->reduction_factor = avctx->lowres;
+    }
+    if (avctx->lowres != s->reduction_factor && avctx->lowres)
+        return AVERROR(EINVAL);
+
     ff_thread_once(&init_static_once, jpeg2000_init_static_data);
     ff_jpeg2000dsp_init(&s->dsp);
 

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

Reply via email to