diff mbox

[FFmpeg-devel,v2] avcodec/mpegpicture: fix "stride changed" failures in gray mode

Message ID 20180410225336.12763-1-ffmpeg@tmm1.net
State Accepted
Commit 19128408ac3ab6524a9a519c12acef457baef2b9
Headers show

Commit Message

Aman Gupta April 10, 2018, 10:53 p.m. UTC
From: Aman Gupta <aman@tmm1.net>

Before adding uvlinesize check, I was seeing failures decoding
some video with ffmpeg compiled with --enable-gray and using AV_CODEC_FLAG_GRAY.

[mpeg2video @ 0x7fa193818c00] get_buffer() failed (stride changed: linesize=1280/1280 uvlinesize=0/640)
[mpeg2video @ 0x7fa193818c00] get_buffer() failed (stride changed: linesize=1280/1280 uvlinesize=0/640)
---
 libavcodec/mpegpicture.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer April 11, 2018, 11:16 p.m. UTC | #1
On Tue, Apr 10, 2018 at 03:53:36PM -0700, Aman Gupta wrote:
> From: Aman Gupta <aman@tmm1.net>
> 
> Before adding uvlinesize check, I was seeing failures decoding
> some video with ffmpeg compiled with --enable-gray and using AV_CODEC_FLAG_GRAY.
> 
> [mpeg2video @ 0x7fa193818c00] get_buffer() failed (stride changed: linesize=1280/1280 uvlinesize=0/640)
> [mpeg2video @ 0x7fa193818c00] get_buffer() failed (stride changed: linesize=1280/1280 uvlinesize=0/640)
> ---
>  libavcodec/mpegpicture.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

should be ok

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 2be670cdbc..c0e06900fe 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -148,10 +148,12 @@  static int alloc_frame_buffer(AVCodecContext *avctx,  Picture *pic,
         }
     }
 
-    if (linesize && (linesize   != pic->f->linesize[0] ||
-                     uvlinesize != pic->f->linesize[1])) {
+    if ((linesize   &&   linesize != pic->f->linesize[0]) ||
+        (uvlinesize && uvlinesize != pic->f->linesize[1])) {
         av_log(avctx, AV_LOG_ERROR,
-               "get_buffer() failed (stride changed)\n");
+               "get_buffer() failed (stride changed: linesize=%d/%d uvlinesize=%d/%d)\n",
+               linesize,   pic->f->linesize[0],
+               uvlinesize, pic->f->linesize[1]);
         ff_mpeg_unref_picture(avctx, pic);
         return -1;
     }