ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Thu Apr 17 12:54:44 2025 +0200| [0e4d513f99de8916501365f514c669d1b2431257] | 
committer: Andreas Rheinhardt

avcodec/magicyuvenc: Restrict number of slice-planes to 256

Every frame contains an array of uint8_t with values
0..(s->planes * s->nb_slices - 1), so this needs to fit
into an uint8_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>

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

 libavcodec/magicyuvenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index a10da9684f..ba39bbb89f 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -206,6 +206,7 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
     s->nb_slices = FFMAX(1, s->nb_slices);
     s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / 
s->nb_slices, 1 << s->vshift[1]);
     s->nb_slices = (avctx->height + s->slice_height - 1) / s->slice_height;
+    s->nb_slices = FFMIN(256U / s->planes, s->nb_slices);
     s->slices = av_calloc(s->nb_slices * s->planes, sizeof(*s->slices));
     if (!s->slices)
         return AVERROR(ENOMEM);

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to