[FFmpeg-cvslog] avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4

Andreas Rheinhardt git at videolan.org
Sat Jan 29 21:02:54 EET 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Jan 26 00:22:50 2022 +0100| [9953fc9a2372cb09ec8e3d9395611f4285916d46] | committer: Andreas Rheinhardt

avcodec/mpegvideo: Fix off-by-one error when decoding >8 bit MPEG-4

Fixes visual corruptions on two macroblocks from two frames from
https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4447/A003C003_SR_422_23.98p.mxf

Reviewed-by: Kieran Kunhya <kierank at obe.tv>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/mpegvideo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index e9f2fb212a..47603c2991 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1648,8 +1648,8 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
                         int vsub = i ? s->chroma_y_shift : 0;
                         int hsub = i ? s->chroma_x_shift : 0;
                         dest_pcm[i] += (linesize[i] / 2) * ((16 >> vsub) - 1);
-                        for(h = (16 >> vsub)-1; h >= 1; h--){
-                            for(w = (16 >> hsub)-1; w >= 1; w--)
+                        for (h = (16 >> vsub) - 1; h >= 0; h--) {
+                            for (w = (16 >> hsub) - 1; w >= 0; w--)
                                 dest_pcm[i][w] = (*s->dpcm_macroblock)[i][idx++];
                             dest_pcm[i] -= linesize[i] / 2;
                         }



More information about the ffmpeg-cvslog mailing list