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

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Jul 9 15:18:15 CEST 2011


On date Friday 2011-07-08 11:17:12 +0200, Stefano Sabatini encoded:
> 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

> From 0f302f57e0bc52791fddb3da0728f84da7425a9c Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Tue, 21 Jun 2011 00:33:37 +0200
> Subject: [PATCH] doc/examples: add decoding/filtering example program
> 
> ---
>  doc/examples/Makefile    |    2 +-
>  doc/examples/filtering.c |  230 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 231 insertions(+), 1 deletions(-)
>  create mode 100644 doc/examples/filtering.c

Updated again, no need for the other patch, call avfilter_poll_frame()
in the external look rather than require a possible pointless
avfilter_poll_frame() call in vsink_buffer (this is the same technique
adopted in ffmpeg.c).

I'll push in a few days if I see no comments.
-- 
FFmpeg = Furious & Free Minimal Ponderous Explosive Gymnast
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-doc-examples-add-decoding-filtering-example-program.patch
Type: text/x-diff
Size: 8899 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110709/175b3c8c/attachment.bin>


More information about the ffmpeg-devel mailing list