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

S.N. Hemanth Meenakshisundaram smeenaks
Sat Jul 10 12:05:10 CEST 2010


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.

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).

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.

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.

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.

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.

Note: I have made this dependent on lavc again for the time being as 
Stefano suggested since the libavutil changes may not go in anytime soon.

I am making some more cleanup/patches to the lavfi audio framework and 
ffplay audio reinit (when channel/sample format changes) . Will send 
that out once tested.

Regards,
Hemanth

>
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: af_resample_rework.diff
Type: text/x-patch
Size: 18827 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100710/0473956f/attachment.bin>



More information about the ffmpeg-devel mailing list