-
-/*****************************************************************************
- * CheckReordering: Check if we need to do some channel re-ordering (the ac3
- * channel order is different from the one chosen by
- * Microsoft).
- *****************************************************************************/
-static void CheckReordering( aout_instance_t *p_aout, int i_nb_channels )
-{
- int i, j, k, l;
-
-#define i_channel_mask p_aout->output.p_sys->i_channel_mask
-#define pi_chan_table p_aout->output.p_sys->pi_chan_table
-
- p_aout->output.p_sys->b_chan_reorder = VLC_FALSE;
-
- pi_chan_table = malloc( i_nb_channels * sizeof(int) );
- if( !pi_chan_table )
- {
- return;
- }
-
- for( i = 0, j = 0;
- i < (int)(sizeof(pi_channels_out)/sizeof(uint32_t)); i++ )
- {
- if( i_channel_mask & pi_channels_out[i] )
- {
- for( k = 0, l = 0;
- pi_channels_out[i] != pi_channels_ordered[k]; k++ )
- {
- if( i_channel_mask & pi_channels_ordered[k] )
- {
- l++;
- }
- }
-
- pi_chan_table[j] = l;
-
- j++;
- }
- }
-
- for( i = 0; i < i_nb_channels; i++ )
- {
- if( pi_chan_table[i] != i )
- {
- p_aout->output.p_sys->b_chan_reorder = VLC_TRUE;
- }
- }
-
- if( p_aout->output.p_sys->b_chan_reorder )
- {
- msg_Dbg( p_aout, "channel reordering needed" );
- }
-
-#undef pi_chan_table
-#undef waveformat
-}
-
-/*****************************************************************************
- * InterleaveFloat32/S16: change the channel order to the Microsoft one.
- *****************************************************************************/
-static void InterleaveFloat32( float *p_buf, float *p_buf_out,
- int *pi_chan_table, int i_nb_channels )
-{
- int i, j;
-
- for( i = 0; i < FRAME_SIZE; i++ )
- {
- for( j = 0; j < i_nb_channels; j++ )
- {
- p_buf_out[i*i_nb_channels + pi_chan_table[j]] =
- p_buf[i*i_nb_channels + j];
- }
- }
-}
-
-static void InterleaveS16( int16_t *p_buf, int16_t *p_buf_out,
- int *pi_chan_table, int i_nb_channels )
-{
- int i, j;
-
- for( i = 0; i < FRAME_SIZE; i++ )
- {
- for( j = 0; j < i_nb_channels; j++ )
- {
- p_buf_out[ i*i_nb_channels + pi_chan_table[j]] =
- p_buf[i*i_nb_channels + j];
- }
- }
-}