[FFmpeg-devel] [PATCH] api-example for libavfilter

Nicolas George nicolas.george at normalesup.org
Tue Jun 21 17:21:43 CEST 2011


Le tridi 3 messidor, an CCXIX, Stefano Sabatini a écrit :
> Updated patch, not yet ready.

Thank you to have taken up the task.

>  doc/examples/decoding+filtering-example.c |  232 +++++++++++++++++++++++++++++

Is the "-example" part really necessary, considering the file is itself in
the examples directory; decoding_and_filtering.c would be IMHO more elegant.

> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.

It may be a good idea to set a less restrictive licence on simple examples
programs, possibly even Public Domain.

> +    /* select the video stream */
> +    if ((ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO,
> +                                   -1, -1, NULL, 0)) < 0) {
> +        av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n");
> +        return ret;
> +    }
> +    video_stream_index = ret;
> +    dec_ctx = fmt_ctx->streams[video_stream_index]->codec;
> +
> +    /* init the video decoder */
> +    if (dec_ctx) {
> +        dec = avcodec_find_decoder(dec_ctx->codec_id);
> +        if (!dec) {
> +            av_log(NULL, AV_LOG_ERROR, "Unable to find video decoder\n");
> +            return AVERROR(EINVAL);
> +        }

This could be made slightly simpler by using something like that:

    ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0);

> +            ret = avcodec_decode_video2(dec_ctx, &frame, &got_frame, &packet);
> +            if (ret < 0) {

Nit: The code sometimes uses "if ((ret = ...) < 0)" and sometimes this
version.

> +        av_free_packet(&packet);

Couldn't it be nearer avcodec_decode_video2 (this was a flaw in the original
version).

Regards,

-- 
  Nicolas George
-------------- 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/20110621/c3510a69/attachment.asc>


More information about the ffmpeg-devel mailing list