[FFmpeg-devel] [PATCH] display warning if rawvideo encoder cannot find codec_tag for the given input format

Stefano Sabatini stefano.sabatini-lala at poste.it
Wed Mar 23 17:21:33 CET 2011


On date Wednesday 2011-03-23 23:11:50 +1100, Peter Ross encoded:
> ---
>  libavcodec/rawenc.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
> index 630df0f..8c8e1d2 100644
> --- a/libavcodec/rawenc.c
> +++ b/libavcodec/rawenc.c
> @@ -35,8 +35,11 @@ static av_cold int raw_init_encoder(AVCodecContext *avctx)
>      avctx->coded_frame->pict_type = FF_I_TYPE;
>      avctx->coded_frame->key_frame = 1;
>      avctx->bits_per_coded_sample = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]);
> -    if(!avctx->codec_tag)
> +    if(!avctx->codec_tag) {

Nit++: if_(...) {

>          avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
> +        if (!avctx->codec_tag)
> +            av_log(avctx, AV_LOG_WARNING, "no codec_tag associated with pix_fmt %i\n", avctx->pix_fmt);

Nit+++: maybe "No " capitalized is better.

Also I suggest:

char *pix_fmt_name = (unsigned int)avctx->pix_fmt < PIX_FMT_NB ? "unknown";
av_log(avctx, AV_LOG_WARNING,
       "No codec_tag associated with pix_fmt '%s' and index %i\n",
       pix_fmt_name, avctx->pix_fmt);

but do as if fits you better.

> +    }
>      return 0;
>  }

LGTM otherwise.
-- 
FFmpeg = Furious Furious Majestic Ponderous Educated Gadget



More information about the ffmpeg-devel mailing list