[FFmpeg-devel] [PATCH 4/5] lavfi: add audio convert filter

Mina Nagy Zaki mnzaki at gmail.com
Sat Aug 20 13:59:45 CEST 2011


On Mon, Aug 08, 2011 at 07:57:10PM +0200, Stefano Sabatini wrote:
> On date Monday 2011-08-08 11:11:48 +0300, Mina Nagy Zaki encoded:
[....]
> > +        memcpy(aconvert->out_samplesref->data[1],
> > +               nb_channels == 1 ? curbuf->data[0] : curbuf->data[1],
> > +               size);
> 
> this is meant for *up*mixing (1 -> 2), right?

I've restructured the code (see below), but I'm still calling this
stereo_downmix, for lack of a better name.

> 
> > +
> > +        curbuf = aconvert->out_samplesref;
> > +    }
> > +
> > +    avfilter_copy_buffer_ref_props(curbuf, insamplesref);
> > +    curbuf->audio->channel_layout = outlink->channel_layout;
> > +    curbuf->audio->planar         = outlink->planar;
> > +
> > +    avfilter_filter_samples(inlink->dst->outputs[0],
> > +                            avfilter_ref_buffer(curbuf, ~0));
> > +    avfilter_unref_buffer(insamplesref);
> > +}
> [...]
> 
> In general, the code is somehow convoluted and I had an hard time at
> getting how it works. I see the complexity is required for
> optimization purposes, but from the maintainability point of view this
> code will be painful.
> 
> The general layout:
> 
> * channel mixing/rematrixing (we have packed and planar routines, so no
>   need to convert from planar<->packed)
> 
> * conversion/requantization
>   av_audio_convert() is general enough so it can deal with both planar
>   and packed formats, you just need to fill an intermediary struct
>   (data+strides) for it, no memcpies should be needed. This should also
>   be able to perform planar<->packed if needed, so the next step won't
>   be necessary
> 
> * planar<->packed conversion if needed, if conversion was done it
>   shouldn't be necessary 
> 
> Possibly each stage shouldn't be intermixed with the previous one, so
> you have a simpler code path.
> 
> In general I'm not sure I like the idea of doing downmixing/upmixing
> in the conversion phase and adding too many special cases, since
> that's making the code flow really hard to follow.

Things have been restructured. I think it's quite a bit clearer now. I kept the
deinterleave/interleave in av_audio_convert though because I can't see a reason
not to... There's a structure that holds info about the rematrixing funcs now,
and one is chosen appropriately before filtering. No more special cases for
downmixing.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavfi-add-audio-convert-filter.patch
Type: text/x-diff
Size: 24363 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110820/3f6f8310/attachment.bin>


More information about the ffmpeg-devel mailing list