[FFmpeg-devel] [libav-devel] [PATCH 2/2] lavfi: add layout negotiation fields and helper functions.

Mina Nagy Zaki mnzaki at gmail.com
Thu Jun 9 15:53:32 CEST 2011


On Thursday 09 June 2011 17:31:19 Stefano Sabatini wrote:
> On date Thursday 2011-06-09 13:27:50 +0300, Mina Nagy Zaki encoded:
> > ---
> > 
> >  libavfilter/avfilter.c      |    3 ++
> >  libavfilter/avfilter.h      |   30 +++++++++++++++++-------
> >  libavfilter/avfiltergraph.c |   10 +++++++-
> >  libavfilter/defaults.c      |   52
> >  +++++++++++++++++++++++++++--------------- libavfilter/formats.c      
> >  |   22 ++++++++++++++++++
> >  5 files changed, 88 insertions(+), 29 deletions(-)
> 
> [...]
> 
> > diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
> > index c98dfa9..505a24f 100644
> > --- a/libavfilter/defaults.c
> > +++ b/libavfilter/defaults.c
> > @@ -204,28 +204,38 @@ int
> > avfilter_default_config_output_link(AVFilterLink *link)
> > 
> >   * FIXME: this will need changed for filters with a mix of pad types
> >   * (video + audio, etc)
> >   */
> > 
> > +
> > +#define SET_COMMON_ELEMS(type) do {                                     
> >    \ +    int count = 0, i;                                             
> >          \ +                                                            
> >                \ +    for (i = 0; i < ctx->input_count; i++) {          
> >                      \ +        if (ctx->inputs[i]) {                   
> >                            \ +            avfilter_formats_ref(formats,
> > &ctx->inputs[i]->out_##type);     \ +            count++;               
> >                                         \ +        }                    
> >                                               \ +    }                  
> >                                                     \ +    for (i = 0; i
> > < ctx->output_count; i++) {                               \ +        if
> > (ctx->outputs[i]) {                                              \ +    
> >        avfilter_formats_ref(formats, &ctx->outputs[i]->in_##type);     \
> > +            count++;                                                   
> >     \ +        }                                                        
> >           \ +    }                                                      
> >                 \ +                                                     
> >                       \ +    if (!count) {                              
> >                             \ +        av_free(formats->formats);       
> >                                   \ +        av_free(formats->refs);    
> >                                         \ +        av_free(formats);    
> >                                               \ +    }                  
> >                                                     \ +} while(0)
> > +
> > 
> >  void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats
> > 
> > *formats)
> > 
> >  {
> > 
> > -    int count = 0, i;
> > -
> > -    for (i = 0; i < ctx->input_count; i++) {
> > -        if (ctx->inputs[i]) {
> > -            avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats);
> > -            count++;
> > -        }
> > -    }
> > -    for (i = 0; i < ctx->output_count; i++) {
> > -        if (ctx->outputs[i]) {
> > -            avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats);
> > -            count++;
> > -        }
> > -    }
> > +    SET_COMMON_ELEMS(formats);
> > +}
> > 
> > -    if (!count) {
> > -        av_free(formats->formats);
> > -        av_free(formats->refs);
> > -        av_free(formats);
> > -    }
> > +void avfilter_set_common_chlayouts(AVFilterContext *ctx, AVFilterFormats
> > *formats)
> > +{
> > +    SET_COMMON_ELEMS(chlayouts);
> > 
> >  }
> 
> Is this required? Can't you have a single
> avfilter_set_common_formats() for setting channel layouts as well?
> 

It could be: avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats 
*formats, AVFilterFormats *chlayouts) for example
but video filters will have to add a NULL param at the end as it is not 
applicable.

Not sure.

-- 
Mina


More information about the ffmpeg-devel mailing list