[FFmpeg-devel] [PATCH] libavfilter-soc: make scale algorithm configurable

Stefano Sabatini stefano.sabatini-lala
Tue Feb 24 01:26:07 CET 2009


On date Sunday 2009-02-22 23:54:14 +0100, Michael Niedermayer encoded:
> On Sun, Feb 22, 2009 at 10:46:16PM +0100, Stefano Sabatini wrote:
> > On date Sunday 2009-02-22 20:43:14 +0100, Michael Niedermayer encoded:
> > > On Sun, Feb 22, 2009 at 07:32:19PM +0100, Stefano Sabatini wrote:
> > > > On date Tuesday 2009-02-17 01:40:47 +0100, Stefano Sabatini encoded:
> > > > [...]
> > > > > New round, no hurry to review it since I want to think something more
> > > > > about it.
> > > > 
> > > > Patches cleaned-up, some bug fixed, choosen a better name for
> > > > AVFilterGraph::sws_opts (now is scale_sws_opts).
> > > > 
> > > > Summary:
> > > > * vf-scale-use-getcached-ctx.patch
> > > >   Use sws_getCacehdContext() in config_props, the context is alloced
> > > >   in the first place in init(), while the srcSlice h/w, dst h/w are
> > > >   set in config_props.
> > > > 
> > > >   This allows to avoid to create a context just to store the
> > > >   sws_flags.
> > > > 
> > > > * vf-scale-cosmetics.patch
> > > >   Reindent + minor cosmetics.
> > > > 
> > > > * vf-scale-set-scale-sws-opts.patch
> > > > 
> > > >   Implement the sws-opts parsing, in particular parse the sws_flags
> > > >   option in the sws_opts eventually provided in the args (mmh, maybe
> > > >   this should be split).
> > > > 
> > > >   The sws_flags is set in the context, this value is re-set in
> > > >   config_props() when sws_getCachedContext() is used to create the new
> > > >   sws context with the srcSlice h/w, dst h/w parameters.
> > > > 
> > > > * filtergraph-scale-sws-opts.patch
> > > >   Implement the scale_sws_opts in the graph, the scale_sws_opts will
> > > >   be appended to the args to pass to the auto-inserted scale filters.
> > > > 
> > > > * ffmpeg-send-scale-sws-opts.patch
> > > >   Make possible to set in ffmpeg the scale_sws_opts to use for the
> > > >   auto-inserted scale filters, and set the sws_flags CLI option in the
> > > >   filters graph.
> > > > 
> > > >   Fixes regressions test.
> > > > 
> > > > * ffplay-send-sws-flags.patch
> > > >   Set the scale_sws_opts value to use in the auto-inserted scale filters,
> > > >   setting it in the graph.
> > > > 
> > > >   IMO it should be possible for the user to set this value in some way
> > > >   similar to what ffmpeg does after the last patch, now it is
> > > >   currently hardcoded.
> > [...]
> > > 
> > > > Index: libavfilter-soc/ffmpeg/libavfilter/avfiltergraph.c
> > > > ===================================================================
> > > > --- libavfilter-soc.orig/ffmpeg/libavfilter/avfiltergraph.c	2009-02-22 19:11:44.000000000 +0100
> > > > +++ libavfilter-soc/ffmpeg/libavfilter/avfiltergraph.c	2009-02-22 19:14:12.000000000 +0100
> > > > @@ -111,13 +111,15 @@
> > > >                  if(!avfilter_merge_formats(link->in_formats,
> > > >                                             link->out_formats)) {
> > > >                      AVFilterContext *scale;
> > > > +                    char scale_args[256];
> > > >                      /* couldn't merge format lists. auto-insert scale filter */
> > > >                      snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d",
> > > >                               scaler_count);
> > > >                      scale =
> > > >                          avfilter_open(avfilter_get_by_name("scale"),inst_name);
> > > >  
> > > > -                    if(!scale || scale->filter->init(scale, NULL, NULL) ||
> > > > +                    snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts);
> > > > +                    if(!scale || scale->filter->init(scale, scale_args, NULL) ||
> > > >                                   avfilter_insert_filter(link, scale, 0, 0)) {
> > > >                          avfilter_destroy(scale);
> > > >                          return -1;
> > > > Index: libavfilter-soc/ffmpeg/libavfilter/avfiltergraph.h
> > > > ===================================================================
> > > > --- libavfilter-soc.orig/ffmpeg/libavfilter/avfiltergraph.h	2009-02-22 19:11:44.000000000 +0100
> > > > +++ libavfilter-soc/ffmpeg/libavfilter/avfiltergraph.h	2009-02-22 19:13:12.000000000 +0100
> > > > @@ -27,6 +27,8 @@
> > > >  typedef struct AVFilterGraph {
> > > >      unsigned filter_count;
> > > >      AVFilterContext **filters;
> > > > +
> > > > +    const char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
> > > >  } AVFilterGraph;
> > > >  
> > > >  /**
> > > 
> > > ok
> > 
> > Changed from const char * to char *, the string is freed when
> > destroying the graph.
> >  
> > > > Index: libavfilter-soc/ffmpeg/ffmpeg.c
> > > > ===================================================================
> > > > --- libavfilter-soc.orig/ffmpeg/ffmpeg.c	2009-02-22 19:11:44.000000000 +0100
> > > > +++ libavfilter-soc/ffmpeg/ffmpeg.c	2009-02-22 19:16:45.000000000 +0100
> > [...]
> > > > @@ -473,6 +474,12 @@
> > > >              return -1;
> > > >      }
> > > >  
> > > > +    {
> > > > +        char scale_sws_opts[128];
> > > > +        snprintf(scale_sws_opts, sizeof(scale_sws_opts), "sws_flags=%d", (int)av_get_int(sws_opts, "sws_flags", NULL));
> > > > +        filt_graph_all->scale_sws_opts = scale_sws_opts;
> > > > +    }
> > > > +
> > > >      /* configure all the filter links */
> > > >      if(avfilter_graph_check_validity(filt_graph_all, NULL))
> > > >          return -1;
> > > 
> > > ehm, you are storing a pointer to the stack in the context ...
> > 
> > Ugh, now is strdup()ed.
> 
> fine

Applied all.

Next step I think is to fix the problem pointed out by Victor, then I
think we're ready for the integration in SVN (just after the release)?

Regards.
-- 
FFmpeg = Freak and Foolish Martial Peaceful Evanescent Gadget




More information about the ffmpeg-devel mailing list