diff mbox series

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

Message ID AM7PR03MB66600C84CE26A1E9B8400AC38F209@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 9953fc9a2372cb09ec8e3d9395611f4285916d46
Headers show
Series [FFmpeg-devel,01/21] avcodec/h263: Remove declaration for inexistent function | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 26, 2022, 9:34 p.m. UTC
Fixes visual corruptions on two macroblocks from two frames from
https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4447/A003C003_SR_422_23.98p.mxf

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kieran Kunhya Jan. 27, 2022, 10:13 a.m. UTC | #1
On Wed, 26 Jan 2022 at 21:35, Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Fixes visual corruptions on two macroblocks from two frames from
>
> https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4447/A003C003_SR_422_23.98p.mxf
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  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;
>                          }
> --
> 2.32.0
>

Seems fine

Kieran
diff mbox series

Patch

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