[FFmpeg-devel] [RFC] libavfilter audio - af_resample

Måns Rullgård mans
Sat Jul 10 13:05:43 CEST 2010


"S.N. Hemanth Meenakshisundaram" <smeenaks at ucsd.edu> writes:

> Michael Niedermayer wrote:
>> On Wed, Jul 07, 2010 at 04:31:04AM -0700, S.N. Hemanth Meenakshisundaram wrote:
>>
>>> On 07/04/2010 07:57 AM, Stefano Sabatini wrote:
>>>
>>>> On date Thursday 2010-07-01 01:42:51 -0700, S.N. Hemanth
>>>> Meenakshisundaram encoded:
>>>>
>>>>> On 06/25/2010 05:10 PM, Stefano Sabatini wrote:
>>>>>
>>>>>> On date Friday 2010-06-25 03:52:45 -0700, S.N. Hemanth
>>>>>> Meenakshisundaram encoded:
>>>>>>
>>>>> Hi All,
>>>>>
>>>>> Here is the working af_resample.c [...]
>>
> Hi All,
>
> I am attaching a reworked af_resample.c
> The following are the major changes:
>
> 1. Samples are now copied only when a conversion (of channels or
> sample format) is needed, else the same buffer is passed along.

That's not what I call copying.  I hope you're not copying the samples
and then converting them.

> 2. Earlier, the channel conversion functions only worked for short
> (SAMPLE_FMT_S16) pointers but writing a different version for each
> will increase the number of functions required by 5x. To get around
> this, I have chosen to always convert incoming audio data to
> SAMPLE_FMT_S16. Most of the times, this conversion is not necessary
> since most codecs output S16 data. Once we ensure data is in S16
> format, channel downmix/upmix is done and finally this data is
> converted to required output sample format (in case it is not
> SAMPLE_FMT_S16).

Entirely unacceptable.

> Although this seems wasteful, most of the times there should be only
> one or zero sample format conversions since at least one of codec
> output or required SDL output is likely to be S16. Please let me know
> what you think of this.

Who cares what SDL does or doesn't do?

> The a52dec library for instance has the sample format fixed at compile
> time and hence has only one version of all channel downmix/upmix
> conversion routines.

liba52 is dead.  Forget what it used to do.  There's a reason it died.

> 3. For the channel conversion, I have changed all routines to work
> only for packed format for the time being. Again this is because,
> there seems to be no way sending planar data to SDL audio and ffplay
> also currently assumes data from codecs is in packed format. However,
> support for planar data only requires additional channel xonversion
> routines and no change to the af_resample framework.

The first thing we must do is add support for planar audio.

> 4. There is now a 1. existing stereo to mono, 2. existing mono to
> stereo, 3. generic mono downmix that uses only 2 of the incoming
> channels, 4. generic stereo downmix that uses only 2 of the incoming
> channels and 5. the existing stereo to ac3 (5.1) converters.
>
> Please review and comment. The A52 library seems to have the required
> formula for a lot of downmix/upmix fuunctions and it also uses
> separate routines for different channel conversions. I also plan to
> add additional channel conversion routines using mixing formulae from
> this and other sources.
> All downmix/upmix routines will have the same return type and argument
> list and a function pointer in the context gets initialized to the
> required routine whenever input channels change.

I dislike the idea of having basic mixing functionality only available
as a full-blown filter.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list