diff mbox series

[FFmpeg-devel,v2,2/2] avcodec/libx264: return error if unknown picture type encountered

Message ID 20200117223825.12936-1-lance.lmwang@gmail.com
State New
Headers show
Series None | expand

Commit Message

Lance Wang Jan. 17, 2020, 10:38 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/libx264.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Jan. 18, 2020, 2:27 p.m. UTC | #1
On Sat, Jan 18, 2020 at 06:38:25AM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/libx264.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index ca8f6c0..4fef0be 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -471,7 +471,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
>          pict_type = AV_PICTURE_TYPE_B;
>          break;
>      default:
> -        pict_type = AV_PICTURE_TYPE_NONE;
> +        av_log(ctx, AV_LOG_ERROR, "Unknown picture type encountered.\n");
> +        return AVERROR_EXTERNAL;
>      }

This builds now but it does not work

./ffmpeg -i mm-short.mpg  -t 1 test.mp4

[libx264 @ 0x2d2c1c0] Unknown picture type encountered.
Video encoding failed

[...]
Lance Wang Jan. 18, 2020, 11:23 p.m. UTC | #2
On Sat, Jan 18, 2020 at 03:27:12PM +0100, Michael Niedermayer wrote:
> On Sat, Jan 18, 2020 at 06:38:25AM +0800, lance.lmwang@gmail.com wrote:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavcodec/libx264.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> > index ca8f6c0..4fef0be 100644
> > --- a/libavcodec/libx264.c
> > +++ b/libavcodec/libx264.c
> > @@ -471,7 +471,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
> >          pict_type = AV_PICTURE_TYPE_B;
> >          break;
> >      default:
> > -        pict_type = AV_PICTURE_TYPE_NONE;
> > +        av_log(ctx, AV_LOG_ERROR, "Unknown picture type encountered.\n");
> > +        return AVERROR_EXTERNAL;
> >      }
> 
> This builds now but it does not work
> 
> ./ffmpeg -i mm-short.mpg  -t 1 test.mp4
> 
> [libx264 @ 0x2d2c1c0] Unknown picture type encountered.
> Video encoding failed
Sorry, please ignore the patch, libx264 can return 0.
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Republics decline into democracies and democracies degenerate into
> despotisms. -- Aristotle



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Lance Wang Jan. 19, 2020, 3:58 p.m. UTC | #3
On Sat, Jan 18, 2020 at 03:27:12PM +0100, Michael Niedermayer wrote:
> On Sat, Jan 18, 2020 at 06:38:25AM +0800, lance.lmwang@gmail.com wrote:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavcodec/libx264.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> > index ca8f6c0..4fef0be 100644
> > --- a/libavcodec/libx264.c
> > +++ b/libavcodec/libx264.c
> > @@ -471,7 +471,8 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
> >          pict_type = AV_PICTURE_TYPE_B;
> >          break;
> >      default:
> > -        pict_type = AV_PICTURE_TYPE_NONE;
> > +        av_log(ctx, AV_LOG_ERROR, "Unknown picture type encountered.\n");
> > +        return AVERROR_EXTERNAL;
> >      }
> 
> This builds now but it does not work
> 
> ./ffmpeg -i mm-short.mpg  -t 1 test.mp4
> 
> [libx264 @ 0x2d2c1c0] Unknown picture type encountered.
> Video encoding failed
I have submit a patch to fix the unknown picture type issue. I have do some basic valid testing.
Please help to review it. I'm not sure whether it's better to check the nnal zero to return immediately.

> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Republics decline into democracies and democracies degenerate into
> despotisms. -- Aristotle



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index ca8f6c0..4fef0be 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -471,7 +471,8 @@  static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
         pict_type = AV_PICTURE_TYPE_B;
         break;
     default:
-        pict_type = AV_PICTURE_TYPE_NONE;
+        av_log(ctx, AV_LOG_ERROR, "Unknown picture type encountered.\n");
+        return AVERROR_EXTERNAL;
     }
 #if FF_API_CODED_FRAME
 FF_DISABLE_DEPRECATION_WARNINGS