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

Stefano Sabatini stefano.sabatini-lala
Tue Feb 1 22:12:49 CET 2011


On date Tuesday 2011-02-01 22:08:35 +0100, Michael Niedermayer encoded:
> On Tue, Feb 01, 2011 at 08:28:09PM +0100, Stefano Sabatini wrote:
[...]
> > -#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();
> >      snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
> >      graph->scale_sws_opts = av_strdup(sws_flags_str);
> >  
> > -    if (avfilter_graph_create_filter(&filt_src, &input_filter, "src",
> > -                                     NULL, is, graph) < 0)
> > +    if ((ret = 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)
> > +    if ((ret = avfilter_graph_create_filter(&filt_out, &ffsink, "out",
> > +                                            NULL, &ffsink_ctx, graph)) < 0)
> >          goto the_end;
> >  
> >      if(vfilters) {
> > @@ -1822,17 +1812,40 @@ static int video_thread(void *arg)
> >          inputs->pad_idx = 0;
> >          inputs->next    = NULL;
> >  
> > -        if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0)
> > +        if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
> >              goto the_end;
> >          av_freep(&vfilters);
> >      } else {
> > -        if(avfilter_link(filt_src, 0, filt_out, 0) < 0)          goto the_end;
> > +        if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
> > +            goto the_end;
> >      }
> >  
> > -    if (avfilter_graph_config(graph, NULL) < 0)
> > +    if ((ret = avfilter_graph_config(graph, NULL)) < 0)
> >          goto the_end;
> >  
> >      is->out_video_filter = filt_out;
> 
> > +the_end:
> > +    return ret;
> 
> LGTM but
> you really should replace the gotos by returns at some point

Yes, trying to keep the patch short, I'll have another look when I'll
be looking again at that code.
-- 
FFmpeg = Furious and Fanciful Mind-dumbing Portable Encoding/decoding Geisha



More information about the ffmpeg-devel mailing list