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

Stefano Sabatini stefano.sabatini-lala at poste.it
Fri Jul 8 11:17:12 CEST 2011


On date Tuesday 2011-06-21 17:21:43 +0200, Nicolas George encoded:
> 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.

Changed to filtering.c.

> > + * 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.

Done (same license as muxing.c and metadata.c in the same dir).

> > +    /* 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) {

Yes, fixed.

> 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).

Done.

Also fixed the timestamp issue, the warning issue was fixed in a separate
vsink_buffer patch.
-- 
FFmpeg = Fundamentalist and Forgiving Multimedia Puristic Extroverse Gargoyle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-doc-examples-add-decoding-filtering-example-program.patch
Type: text/x-diff
Size: 8865 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110708/51557253/attachment.bin>


More information about the ffmpeg-devel mailing list