[FFmpeg-devel] [PATCH] Factorize code from video_thread() and put it in configure_video_filters().

Michael Niedermayer michaelni
Tue Feb 1 17:32:48 CET 2011


On Sun, Jan 30, 2011 at 07:15:29PM +0100, Stefano Sabatini wrote:
> On date Sunday 2011-01-16 03:44:24 +0100, Michael Niedermayer encoded:
> > On Sat, Jan 15, 2011 at 01:52:47PM +0100, Stefano Sabatini wrote:
> > [...]
> > > @@ -2068,10 +2084,8 @@ static int video_thread(void *arg)
> > >                  stream_pause(cur_stream);
> > >      }
> > >   the_end:
> > > -#if CONFIG_AVFILTER
> > > -    avfilter_graph_free(graph);
> > > -    av_freep(&graph);
> > > -#endif
> > > +    avfilter_graph_free(is->vgraph);
> > > +    av_freep(&is->vgraph);
> > >      av_free(frame);
> > >      return 0;
> > 
> > is this not moving avfilter code outside the #ifdef and break compilation?
> 
> Fixed and updated.
> -- 
> FFmpeg = Formidable Fierce Mind-dumbing Pitiless Earthshaking Goblin

>  ffplay.c |   69 ++++++++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 42 insertions(+), 27 deletions(-)
> fc2c89e6a08bea09964b0c92bccd7011a9316bb7  0001-Implement-ffplay.c-configure_video_filters.patch
> From ccc5e635e75a9fc258ffcdf23d695b1febf3d21e Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Sun, 30 Jan 2011 19:09:40 +0100
> Subject: [PATCH] Implement ffplay.c:configure_video_filters().
> 
> Factorize code from ffplay.c:video_thread() and put it in the new
> function configure_video_filters().
> ---
>  ffplay.c |   69 +++++++++++++++++++++++++++++++++++++------------------------
>  1 files changed, 42 insertions(+), 27 deletions(-)
> 
> diff --git a/ffplay.c b/ffplay.c
> index 840df66..64b069f 100644
> --- a/ffplay.c
> +++ b/ffplay.c
> @@ -211,6 +211,7 @@ typedef struct VideoState {
>  
>  #if CONFIG_AVFILTER
>      AVFilterContext *out_video_filter;          ///<the last filter in the video chain
> +    AVFilterGraph *vgraph;                      ///<the video filter graph
>  #endif
>  
>      float skip_frames;
> @@ -1782,33 +1783,24 @@ static AVFilter input_filter =
>                                    { .name = NULL }},
>  };
>  
> -#endif  /* CONFIG_AVFILTER */
> -
> -static int video_thread(void *arg)
> +static int configure_video_filters(VideoState *is, const char *vfilters)
>  {
> -    VideoState *is = arg;
> -    AVFrame *frame= avcodec_alloc_frame();
> -    int64_t pts_int;
> -    double pts;
> -    int ret;
> -
> -#if CONFIG_AVFILTER
> -    int64_t pos;
>      char sws_flags_str[128];
> +    int ret;
>      FFSinkContext ffsink_ctx = { .pix_fmt = PIX_FMT_YUV420P };
>      AVFilterContext *filt_src = NULL, *filt_out = NULL;
> -    AVFilterGraph *graph = avfilter_graph_alloc();
> +    is->vgraph = avfilter_graph_alloc();
>      snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
> -    graph->scale_sws_opts = av_strdup(sws_flags_str);
> +    is->vgraph->scale_sws_opts = av_strdup(sws_flags_str);
>

> -    if (avfilter_graph_create_filter(&filt_src, &input_filter, "src",
> -                                     NULL, is, graph) < 0)
> -        goto the_end;
> -    if (avfilter_graph_create_filter(&filt_out, &ffsink, "out",
> -                                     NULL, &ffsink_ctx, graph) < 0)
> -        goto the_end;
> +    if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
> +                                            NULL, is, is->vgraph)) < 0)
> +        goto fail;
> +    if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out",
> +                                            NULL, &ffsink_ctx, is->vgraph)) < 0)
> +        goto fail;
>  
> -    if(vfilters) {
> +    if (vfilters) {
>          AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
>          AVFilterInOut *inputs  = av_malloc(sizeof(AVFilterInOut));
>  

I dont want to nitpick but this has nothing to do with factorizing the code

Also vgraph was a local variable before and can stay one, it doesnt need to be
moved to VideoState
AVFilterGraph *graph = avfilter_graph_alloc();
can stay outside configure_video_filters(graph)

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110201/513ba318/attachment.pgp>



More information about the ffmpeg-devel mailing list