1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-10-06 05:47:18 +02:00

avcodec/mjpegdec: Explain buf_size/width/height check

Suggested-by: Ramiro

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2025-09-11 20:12:55 +02:00
committed by michaelni
parent 1a02412170
commit 61b6877637

View File

@@ -340,6 +340,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height); av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
if (av_image_check_size(width, height, 0, s->avctx) < 0) if (av_image_check_size(width, height, 0, s->avctx) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
// A valid frame requires at least 1 bit for DC + 1 bit for AC for each 8x8 block.
if (s->buf_size && (width + 7) / 8 * ((height + 7) / 8) > s->buf_size * 4LL) if (s->buf_size && (width + 7) / 8 * ((height + 7) / 8) > s->buf_size * 4LL)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;