Changeset 03f2c9e9a08a765667d872d9d5ecae85b64d3726

Show
Ignore:
Timestamp:
30/09/04 19:42:27 (4 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1096566147 +0000
git-parent:

[754e4b9260b87a174c94409eca37e844db470e9c]

git-author:
Gildas Bazin <gbazin@videolan.org> 1096566147 +0000
Message:

* modules/audio_filter/converter/a52tofloat32.c,dtstofloat32.c: proper channel re-ordering using aout_ChannelReorder().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/audio_filter/converter/a52tofloat32.c

    rb28de53 r03f2c9e  
    6666static block_t *Convert( filter_t *, block_t * ); 
    6767 
     68/* liba52 channel order */ 
     69static const uint32_t pi_channels_in[] = 
     70{ AOUT_CHAN_LFE, AOUT_CHAN_LEFT, AOUT_CHAN_CENTER, AOUT_CHAN_RIGHT, 
     71  AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, 0 }; 
     72/* our internal channel order (WG-4 order) */ 
     73static const uint32_t pi_channels_out[] = 
     74{ AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, 
     75  AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 }; 
     76 
    6877/***************************************************************************** 
    6978 * Local structures 
     
    7685    vlc_bool_t b_dontwarn; 
    7786    int i_nb_channels; /* number of float32 per sample */ 
     87 
     88    int pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */ 
    7889}; 
    7990 
     
    143154 *****************************************************************************/ 
    144155static int Open( vlc_object_t *p_this, filter_sys_t *p_sys, 
    145         audio_format_t input, audio_format_t output ) 
     156                audio_format_t input, audio_format_t output ) 
    146157{ 
    147158    p_sys->b_dynrng = config_GetInt( p_this, "a52-dynrng" ); 
     
    240251    } 
    241252 
     253    aout_CheckChannelReorder( pi_channels_in, pi_channels_out, 
     254                              output.i_physical_channels & AOUT_CHAN_PHYSMASK, 
     255                              p_sys->i_nb_channels, 
     256                              p_sys->pi_chan_table ); 
     257 
    242258    return VLC_SUCCESS; 
    243259} 
     
    246262 * Interleave: helper function to interleave channels 
    247263 *****************************************************************************/ 
    248 static void Interleave( float * p_out, const float * p_in, int i_nb_channels ) 
    249 
    250     /* We do not only have to interleave, but also reorder the channels 
    251      * Channel reordering according to number of output channels of libA52 
    252      * The reordering needs to be different for different channel configurations 
    253      * (3F2R, 1F2R etc), so this is only temporary. 
    254      * The WG-4 order is appropriate for stereo, quadrophonia, and 5.1 surround. 
    255      * 
    256      * 6 channel mode 
    257      * channel  liba52 order    WG-4 order 
    258      * 0        LFE             // L 
    259      * 1        L               // R 
    260      * 2        C               // LS 
    261      * 3        R               // RS 
    262      * 4        LS              // C 
    263      * 5        RS              // LFE 
    264      * 
    265      * The liba52 moves channels to the front if there are unused spaces, so 
    266      * there is no gap between channels. The translation table says which 
    267      * channel of the new stream is taken from which original channel [use 
    268      * the new channel as the array index, use the number you get from the 
    269      * array to address the original channel]. 
    270      */ 
    271  
    272     static const int translation[7][6] = 
    273     {{ 0, 0, 0, 0, 0, 0 },      /* 0 channels (rarely used) */ 
    274     { 0, 0, 0, 0, 0, 0 },       /* 1 ch */ 
    275     { 0, 1, 0, 0, 0, 0 },       /* 2 */ 
    276     { 1, 2, 0, 0, 0, 0 },       /* 3 */ 
    277     { 1, 3, 2, 0, 0, 0 },       /* 4 */ 
    278     { 1, 3, 4, 2, 0, 0 },       /* 5 */ 
    279     { 1, 3, 4, 5, 2, 0 }};      /* 6 */ 
     264static void Interleave( float * p_out, const float * p_in, int i_nb_channels, 
     265                        int *pi_chan_table ) 
     266
     267    /* We do not only have to interleave, but also reorder the channels */ 
    280268 
    281269    int i, j; 
     
    284272        for ( i = 0; i < 256; i++ ) 
    285273        { 
    286             p_out[i * i_nb_channels + j] = p_in[translation[i_nb_channels][j] 
    287                                                  * 256 + i]; 
     274            p_out[i * i_nb_channels + pi_chan_table[j]] = p_in[j * 256 + i]; 
    288275        } 
    289276    } 
     
    384371            /* Interleave the *$�%�ples. */ 
    385372            Interleave( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block), 
    386                         p_samples, p_sys->i_nb_channels ); 
     373                        p_samples, p_sys->i_nb_channels, p_sys->pi_chan_table); 
    387374        } 
    388375    } 
  • modules/audio_filter/converter/dtstofloat32.c

    rb28de53 r03f2c9e  
    5353static block_t *Convert( filter_t *, block_t * ); 
    5454 
     55/* libdts channel order */ 
     56static const uint32_t pi_channels_in[] = 
     57{ AOUT_CHAN_CENTER, AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, 
     58  AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, AOUT_CHAN_LFE, 0 }; 
     59/* our internal channel order (WG-4 order) */ 
     60static const uint32_t pi_channels_out[] = 
     61{ AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT, AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, 
     62  AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 }; 
     63 
    5564/***************************************************************************** 
    5665 * Local structures 
     
    6372    vlc_bool_t b_dontwarn; 
    6473    int i_nb_channels; /* number of float32 per sample */ 
     74 
     75    int pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */ 
    6576}; 
    6677 
     
    210221    } 
    211222 
     223    aout_CheckChannelReorder( pi_channels_in, pi_channels_out, 
     224                              output.i_physical_channels & AOUT_CHAN_PHYSMASK, 
     225                              p_sys->i_nb_channels, 
     226                              p_sys->pi_chan_table ); 
     227 
    212228    return VLC_SUCCESS; 
    213229} 
     
    216232 * Interleave: helper function to interleave channels 
    217233 *****************************************************************************/ 
    218 static void Interleave( float * p_out, const float * p_in, int i_nb_channels ) 
    219 
    220     /* We do not only have to interleave, but also reorder the channels 
    221      * Channel reordering according to number of output channels of libdts 
    222      * The reordering needs to be different for different channel configurations 
    223      * (3F2R, 1F2R etc), so this is only temporary. 
    224      * The WG-4 order is appropriate for stereo, quadrophonia, and 5.1 surround. 
    225      * 
    226      * 6 channel mode 
    227      * channel  libdts order    WG-4 order 
    228      * 0        C               // L 
    229      * 1        L               // R 
    230      * 2        R               // LS 
    231      * 3        LS              // RS 
    232      * 4        RS              // C 
    233      * 5        LFE             // LFE 
    234      * 
    235      * The libdts moves channels to the front if there are unused spaces, so 
    236      * there is no gap between channels. The translation table says which 
    237      * channel of the new stream is taken from which original channel [use 
    238      * the new channel as the array index, use the number you get from the 
    239      * array to address the original channel]. 
    240      */ 
    241  
    242     static const int translation[7][6] = 
    243     {{ 0, 0, 0, 0, 0, 0 },      /* 0 channels (rarely used) */ 
    244     { 0, 0, 0, 0, 0, 0 },       /* 1 ch */ 
    245     { 0, 1, 0, 0, 0, 0 },       /* 2 */ 
    246     { 1, 2, 0, 0, 0, 0 },       /* 3 */ 
    247     { 0, 1, 2, 3, 0, 0 },       /* 4 */ 
    248     { 1, 2, 3, 4, 0, 0 },       /* 5 */ 
    249     { 1, 2, 3, 4, 0, 5 }};      /* 6 */ 
     234static void Interleave( float * p_out, const float * p_in, int i_nb_channels, 
     235                        int *pi_chan_table ) 
     236
     237    /* We do not only have to interleave, but also reorder the channels. */ 
    250238 
    251239    int i, j; 
     
    254242        for ( i = 0; i < 256; i++ ) 
    255243        { 
    256             p_out[i * i_nb_channels + j] = p_in[translation[i_nb_channels][j] 
    257                                                  * 256 + i]; 
     244            p_out[i * i_nb_channels + pi_chan_table[j]] = p_in[j * 256 + i]; 
    258245        } 
    259246    } 
     
    368355            /* Interleave the *$�%�ples. */ 
    369356            Interleave( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block), 
    370                         p_samples, p_sys->i_nb_channels ); 
     357                        p_samples, p_sys->i_nb_channels, p_sys->pi_chan_table); 
    371358        } 
    372359    }