On 09/09/2010 10:24 PM, Tiger Xu wrote:
>> From: John Stebbins <[email protected]>
>> Last time I checked, ffmpeg couldn't do this.  So we
>> implemented out own general purpose downmixer that is used
>> whenever
>> ffmpeg can't do the job.
>> https://trac.handbrake.fr/browser/trunk/libhb/downmix.c
> How can i use your code? Thanks.
>
Well, first you would probably have to make some changes to it to work in your 
code base.  Mostly changes in naming
conventions since everything is hb_* this and HB_* that for HandBrake.  General 
usage is:

Initialize the downmixer once:
    downmixer = hb_downmix_init( input_layout, mixdown );
    hb_downmix_set_chan_map( downmixer, map_in, map_out );

input_layout is a #define that says how many input channels and how they are 
laid out. See HB_INPUT_CH_*

mixdown is a #define that says what kind of mixdown you are going to do. See 
HB_AMIXDOWN_*

map_in and map_out define how the channels get rearranged during the mixdown.  
For example, if you need to map SMPTE
channel order (used by ffmpeg) to QuickTime channel order, there are predefined 
maps hb_smpte_chan_map and
hb_qt_chan_map that can be set.  The default is input and output are QT order.

Then to mixdown samples:
    hb_downmix( downmixer, out_samples, in_samples, n_samples );

downmixer is what you got from hb_downmix_init

out_samples and in_samples are channel interleaved audio samples in floating 
point format.

n_samples is the number of samples.  All channels collectively are considered a 
single sample.  So if you have 5.1
audio, there are 6 individual channels samples, with are viewed as 1 sample 
here.

When you are done, close the downmixer:
    hb_downmix_close( &downmixer );

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to