[FFmpeg-devel] [PATCH] lavc/utils: extend feedback provided by avcodec_open2()

Michael Niedermayer michaelni at gmx.at
Sat Oct 20 14:06:11 CEST 2012


On Wed, Oct 17, 2012 at 12:33:51PM +0200, Stefano Sabatini wrote:
> On date Monday 2012-10-15 15:37:38 +0200, Stefano Sabatini encoded:
> > ---
> >  libavcodec/utils.c |   30 ++++++++++++++++++++++--------
> >  1 files changed, 22 insertions(+), 8 deletions(-)
> > 
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index d64de0e..a7d2bc7 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -960,7 +960,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
> >                  }
> >              }
> >              if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
> > -                av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
> > +                av_log(avctx, AV_LOG_ERROR, "Specified sample format '%s' is not supported\n",
> > +                       av_get_sample_fmt_name(avctx->sample_fmt));
> >                  ret = AVERROR(EINVAL);
> >                  goto free_and_end;
> >              }
> > @@ -972,7 +973,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
> >              if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE
> >                  && !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG)
> >                       && avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) {
> > -                av_log(avctx, AV_LOG_ERROR, "Specified pix_fmt is not supported\n");
> > +                av_log(avctx, AV_LOG_ERROR, "Specified pixel format '%s' is not supported\n",
> > +                       av_get_pix_fmt_name(avctx->pix_fmt));
> >                  ret = AVERROR(EINVAL);
> >                  goto free_and_end;
> 
> Updated in order to avoid null printing in case of invalid
> pix/sample_fmt.
> 
> Will push it soon if I read no comments.
> -- 
> FFmpeg = Faithful and Fanciful Merciful Picky Empowered Gospel

>  utils.c |   38 +++++++++++++++++++++++++++++---------
>  1 file changed, 29 insertions(+), 9 deletions(-)
> e36b9ce7c968407be0f88e1b4dd62453cccb7304  0001-lavc-utils-extend-feedback-provided-by-avcodec_open2.patch
> From d1fa3f24960aa0870a706920f1a19e1afbbe6331 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Mon, 15 Oct 2012 15:21:00 +0200
> Subject: [PATCH] lavc/utils: extend feedback provided by avcodec_open2()
> 
> ---
>  libavcodec/utils.c |   38 +++++++++++++++++++++++++++++---------
>  1 files changed, 29 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index d64de0e..a4584b8 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -865,7 +865,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
>  
>      if (codec->capabilities & CODEC_CAP_EXPERIMENTAL)
>          if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
> -            av_log(avctx, AV_LOG_ERROR, "Codec is experimental but experimental codecs are not enabled, try -strict -2\n");
> +            av_log(avctx, AV_LOG_ERROR,
> +                   "Codec %s is experimental but experimental codecs are not enabled, try -strict -2\n",
> +                   avctx->codec->name);
>              ret = -1;
>              goto free_and_end;
>          }

null ptr derefernce (broke fate thus i reverted this hunk)


> @@ -960,7 +962,10 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
>                  }
>              }
>              if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
> -                av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
> +                char buf[128];
> +                snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt);
> +                av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n",
> +                       av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf));

This is simpler and provides more information and more consistent
syntax in case someone wants to parse it:

av_log(avctx, AV_LOG_ERROR, "Specified sample format %s (%d) is invalid or not supported\n",
       av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), "?"), avctx->sample_fmt);

same for similar cases


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121020/b13320ab/attachment.asc>


More information about the ffmpeg-devel mailing list