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

Git pushed a commit to branch master
in repository ffmpeg.

commit 9edd06f8612c242b83bf9e3d14aa85180015a211
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Mon Sep 14 03:32:13 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Mon Sep 28 03:36:07 2026 +0000

    avcodec/proresenc_kostya: fill macroblock rows past the end of the bottom 
field
    
    Fixes: ftWCoBQxUw0P
    Fixes: out of array read
    Found-by: Zheng Yu @ Depthfirst
---
 libavcodec/proresenc_kostya.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index ccb41c0d23..847a47bd2c 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -323,7 +323,7 @@ static int encode_slice(AVCodecContext *avctx, const 
AVFrame *pic,
     int i, xp, yp;
     int total_size = 0;
     const uint16_t *src;
-    int num_cblocks, pwidth, line_add;
+    int num_cblocks, pwidth, line_add, picture_height;
     ptrdiff_t linesize;
     int is_chroma;
     uint16_t *qmat;
@@ -334,6 +334,10 @@ static int encode_slice(AVCodecContext *avctx, const 
AVFrame *pic,
     else
         line_add = ctx->cur_picture_idx ^ !(pic->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST);
 
+    if ((y << 4) * ctx->pictures_per_frame + line_add >= avctx->height)
+        line_add = 0;
+    picture_height = (avctx->height - line_add + ctx->pictures_per_frame - 1) 
/ ctx->pictures_per_frame;
+
     if (ctx->force_quant) {
         qmat = ctx->quants[0];
         qmat_chroma = ctx->quants_chroma[0];
@@ -369,7 +373,7 @@ static int encode_slice(AVCodecContext *avctx, const 
AVFrame *pic,
 
         if (i < 3) {
             get_slice_data(ctx, src, linesize, xp, yp,
-                           pwidth, avctx->height / ctx->pictures_per_frame,
+                           pwidth, picture_height,
                            ctx->blocks[0], ctx->emu_buf,
                            mbs_per_slice, num_cblocks, is_chroma);
             if (!is_chroma) {/* luma quant */
@@ -383,7 +387,7 @@ static int encode_slice(AVCodecContext *avctx, const 
AVFrame *pic,
             }
         } else {
             get_alpha_data(ctx, src, linesize, xp, yp,
-                           pwidth, avctx->height / ctx->pictures_per_frame,
+                           pwidth, picture_height,
                            ctx->blocks[0], mbs_per_slice, ctx->alpha_bits);
             encode_alpha_plane(ctx, pb, mbs_per_slice, ctx->blocks[0], quant);
         }
@@ -570,13 +574,17 @@ static int find_slice_quant(AVCodecContext *avctx,
     int overquant;
     uint16_t *qmat;
     uint16_t *qmat_chroma;
-    int linesize[4], line_add;
+    int linesize[4], line_add, picture_height;
     int alpha_bits = 0;
 
     if (ctx->pictures_per_frame == 1)
         line_add = 0;
     else
         line_add = ctx->cur_picture_idx ^ !(ctx->pic->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST);
+
+    if ((y << 4) * ctx->pictures_per_frame + line_add >= avctx->height)
+        line_add = 0;
+    picture_height = (avctx->height - line_add + ctx->pictures_per_frame - 1) 
/ ctx->pictures_per_frame;
     mbs = x + mbs_per_slice;
 
     for (i = 0; i < ctx->num_planes; i++) {
@@ -599,12 +607,12 @@ static int find_slice_quant(AVCodecContext *avctx,
 
         if (i < 3) {
             get_slice_data(ctx, src, linesize[i], xp, yp,
-                           pwidth, avctx->height / ctx->pictures_per_frame,
+                           pwidth, picture_height,
                            td->blocks[i], td->emu_buf,
                            mbs_per_slice, num_cblocks[i], is_chroma[i]);
         } else {
             get_alpha_data(ctx, src, linesize[i], xp, yp,
-                           pwidth, avctx->height / ctx->pictures_per_frame,
+                           pwidth, picture_height,
                            td->blocks[i], mbs_per_slice, ctx->alpha_bits);
         }
     }

-- 
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