]> git.sesse.net Git - vlc/commitdiff
Shrink channel reordering tables to 9-10 bytes (from 36-40 bytes)
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 11 Nov 2012 10:52:20 +0000 (12:52 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 11 Nov 2012 11:17:43 +0000 (13:17 +0200)
include/vlc_aout.h
modules/audio_filter/converter/a52tofloat32.c
modules/audio_filter/converter/dtstofloat32.c
modules/audio_output/directx.c
modules/audio_output/waveout.c
modules/codec/opus.c
modules/codec/vorbis.c
modules/demux/wav.c
modules/mux/wav.c
src/audio_output/common.c

index 27d5bb0192a8df241ef0c1eb3e00a7e0c7738d67..1dd42f37b226a9423d498d37adec382c69e8dcac 100644 (file)
@@ -179,8 +179,8 @@ static const uint32_t pi_vlc_chan_order_wg4[] =
  * internal (WG4) order is requested.
  */
 VLC_API unsigned aout_CheckChannelReorder( const uint32_t *, const uint32_t *,
-                                           uint32_t mask, int *table );
-VLC_API void aout_ChannelReorder( void *, size_t, unsigned, const int *, unsigned );
+                                           uint32_t mask, uint8_t *table );
+VLC_API void aout_ChannelReorder( void *, size_t, unsigned, const uint8_t *, unsigned );
 
 /**
  * This fonction will compute the extraction parameter into pi_selection to go
index 939131891d263df4cd6eb12e5ebdbd532ce94e72..7df13b5f7061adf5d42b7342edf44d3fd00a4a38 100644 (file)
@@ -73,7 +73,7 @@ struct filter_sys_t
     bool b_dontwarn;
     int i_nb_channels; /* number of float32 per sample */
 
-    int pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */
+    uint8_t pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */
 };
 
 /*****************************************************************************
@@ -223,7 +223,7 @@ static int Open( vlc_object_t *p_this, filter_sys_t *p_sys,
  * Interleave: helper function to interleave channels
  *****************************************************************************/
 static void Interleave( sample_t * p_out, const sample_t * p_in,
-                        int i_nb_channels, int *pi_chan_table )
+                        int i_nb_channels, uint8_t *pi_chan_table )
 {
     /* We do not only have to interleave, but also reorder the channels */
 
index 4df568910b650d968bb367fa6bd347eab8ea62eb..e759d672508f2b8e0c01b8829751a71420dd53ea 100644 (file)
@@ -66,7 +66,7 @@ struct filter_sys_t
     bool b_dontwarn;
     int i_nb_channels; /* number of float32 per sample */
 
-    int pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */
+    uint8_t pi_chan_table[AOUT_CHAN_MAX]; /* channel reordering */
 };
 
 /*****************************************************************************
@@ -185,7 +185,7 @@ static int Open( vlc_object_t *p_this, filter_sys_t *p_sys,
  * Interleave: helper function to interleave channels
  *****************************************************************************/
 static void Interleave( float * p_out, const float * p_in, int i_nb_channels,
-                        int *pi_chan_table )
+                        uint8_t *pi_chan_table )
 {
     /* We do not only have to interleave, but also reorder the channels. */
 
index 5a26d784b90690b0656480d60cbb853429245876..55c5a6c3b16a1a21639738d208e0f93eea44d8dc 100644 (file)
@@ -83,8 +83,8 @@ struct aout_sys_t
 
     int      i_speaker_setup;                      /* Speaker setup override */
 
-    bool     b_chan_reorder;                /* do we need channel reordering */
-    int      pi_chan_table[AOUT_CHAN_MAX];
+    uint8_t  chans_to_reorder;              /* do we need channel reordering */
+    uint8_t  chan_table[AOUT_CHAN_MAX];
     uint32_t i_channel_mask;
     uint32_t i_bits_per_sample;
     uint32_t i_channels;
@@ -785,12 +785,11 @@ static int CreateDSBuffer( audio_output_t *p_aout, int i_format,
 
     p_aout->sys->i_frame_size = i_bytes_per_frame;
     p_aout->sys->i_channel_mask = waveformat.dwChannelMask;
-    p_aout->sys->b_chan_reorder =
+    p_aout->sys->chans_to_reorder =
         aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
                                   waveformat.dwChannelMask,
-                                  p_aout->sys->pi_chan_table );
-
-    if( p_aout->sys->b_chan_reorder )
+                                  p_aout->sys->chan_table );
+    if( p_aout->sys->chans_to_reorder )
     {
         msg_Dbg( p_aout, "channel reordering needed" );
     }
@@ -900,13 +899,11 @@ static int FillBuffer( audio_output_t *p_aout, int i_frame, block_t *p_buffer )
     }
     else
     {
-        if( p_sys->b_chan_reorder )
-        {
+        if( p_sys->chans_to_reorder )
             /* Do the channel reordering here */
             aout_ChannelReorder( p_buffer->p_buffer, p_buffer->i_buffer,
-                                 p_sys->i_channels, p_sys->pi_chan_table,
+                                 p_sys->chans_to_reorder, p_sys->chan_table,
                                  p_sys->i_bits_per_sample );
-        }
 
         memcpy( p_write_position, p_buffer->p_buffer, l_bytes1 );
         block_Release( p_buffer );
index 4ec5d44db0e6da7be06817d16a0a52b7cf1ca6bc..90f968168e5d79a0ae702e0c96298dbc272f68c6 100644 (file)
@@ -119,8 +119,8 @@ struct aout_sys_t
         bool soft_mute;
     };
 
-    bool b_chan_reorder;              /* do we need channel reordering */
-    int pi_chan_table[AOUT_CHAN_MAX];
+    uint8_t chans_to_reorder;              /* do we need channel reordering */
+    uint8_t chan_table[AOUT_CHAN_MAX];
 };
 
 #include "volume.h"
@@ -657,15 +657,12 @@ static int OpenWaveOut( audio_output_t *p_aout, uint32_t i_device_id, int i_form
         return VLC_EGENERIC;
     }
 
-    p_aout->sys->b_chan_reorder =
+    p_aout->sys->chans_to_reorder =
         aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
                                   waveformat.dwChannelMask,
-                                  p_aout->sys->pi_chan_table );
-
-    if( p_aout->sys->b_chan_reorder )
-    {
+                                  p_aout->sys->chan_table );
+    if( p_aout->sys->chans_to_reorder )
         msg_Dbg( p_aout, "channel reordering needed" );
-    }
 
     return VLC_SUCCESS;
 
@@ -924,12 +921,12 @@ static void* WaveOutThread( void *data )
                 }
 
                 /* Do the channel reordering */
-                if( p_buffer && p_sys->b_chan_reorder )
+                if( p_buffer && p_sys->chans_to_reorder )
                 {
                     aout_ChannelReorder( p_buffer->p_buffer,
                         p_buffer->i_buffer,
                         p_sys->waveformat.Format.nChannels,
-                        p_sys->pi_chan_table,
+                        p_sys->chan_table,
                         p_sys->waveformat.Format.wBitsPerSample );
                 }
 
index 81569765e3dec3ca00b1fbcd461d3bdee398a709..890b7420129cfdb8c7f8a76b8578e57f847f9671 100644 (file)
@@ -263,7 +263,6 @@ end:
 static int ProcessInitialHeader( decoder_t *p_dec, ogg_packet *p_oggpacket )
 {
     int err;
-    int pi_chan_table[AOUT_CHAN_MAX];
     unsigned char new_stream_map[8];
     decoder_sys_t *p_sys = p_dec->p_sys;
 
@@ -296,6 +295,8 @@ static int ProcessInitialHeader( decoder_t *p_dec, ogg_packet *p_oggpacket )
         static const uint32_t *pi_ch[6] = { pi_3channels_in, pi_4channels_in,
                                             pi_5channels_in, pi_6channels_in,
                                             pi_7channels_in, pi_8channels_in };
+        uint8_t pi_chan_table[AOUT_CHAN_MAX];
+
         aout_CheckChannelReorder( pi_ch[p_header->channels-3], NULL,
                                   p_dec->fmt_out.audio.i_physical_channels,
                                   pi_chan_table );
index 5d6cd613ad43bccdba1681f007be9086b16d442d..0d711f3fcfb22bfabc150819e9b883dabfb7724e 100644 (file)
@@ -88,7 +88,7 @@ struct decoder_sys_t
     /*
     ** Channel reordering
     */
-    int pi_chan_table[AOUT_CHAN_MAX];
+    uint8_t pi_chan_table[AOUT_CHAN_MAX];
 };
 
 static const int pi_channels_maps[9] =
@@ -658,12 +658,15 @@ static void ConfigureChannelOrder(int *pi_chan_table, int i_channels, uint32_t i
             }
     }
 
+    uint8_t tab[AOUT_CHAN_MAX];
     if( b_decode )
         aout_CheckChannelReorder( pi_channels_in, NULL,
-                                  i_channel_mask, pi_chan_table );
+                                  i_channel_mask, tab );
     else
         aout_CheckChannelReorder( NULL, pi_channels_in,
-                                  i_channel_mask, pi_chan_table );
+                                  i_channel_mask, tab );
+    for( int i = 0; i < i_channels; i++)
+         pi_chan_table[i] = tab[i];
 }
 
 /*****************************************************************************
index 0bd3adbaa44439e2ca2d0af5a4180179171c1519..3db65b4f2cf398a4c541f342bc16e5a38711d8a4 100644 (file)
@@ -69,8 +69,8 @@ struct demux_sys_t
     date_t          pts;
 
     uint32_t i_channel_mask;
-    bool b_chan_reorder;              /* do we need channel reordering */
-    int pi_chan_table[AOUT_CHAN_MAX];
+    uint8_t i_chans_to_reorder;            /* do we need channel reordering */
+    uint8_t pi_chan_table[AOUT_CHAN_MAX];
 };
 
 static int ChunkFind( demux_t *, const char *, unsigned int * );
@@ -123,7 +123,7 @@ static int Open( vlc_object_t * p_this )
         return VLC_ENOMEM;
 
     p_sys->p_es           = NULL;
-    p_sys->b_chan_reorder = false;
+    p_sys->i_chans_to_reorder = 0;
     p_sys->i_channel_mask = 0;
 
     /* skip riff header */
@@ -270,13 +270,13 @@ static int Open( vlc_object_t * p_this )
         if( p_sys->fmt.i_codec == VLC_FOURCC('a','r','a','w') ||
             p_sys->fmt.i_codec == VLC_FOURCC('p','c','m',' ') ||
             p_sys->fmt.i_codec == VLC_FOURCC('a','f','l','t') )
-            p_sys->b_chan_reorder =
+            p_sys->i_chans_to_reorder =
                 aout_CheckChannelReorder( pi_channels_in, NULL,
                                           p_sys->i_channel_mask,
                                           p_sys->pi_chan_table );
 
-        msg_Dbg( p_demux, "channel mask: %x, reordering: %i",
-                 p_sys->i_channel_mask, (int)p_sys->b_chan_reorder );
+        msg_Dbg( p_demux, "channel mask: %x, reordering: %u",
+                 p_sys->i_channel_mask, p_sys->i_chans_to_reorder );
     }
 
     p_sys->fmt.audio.i_physical_channels =
@@ -427,7 +427,7 @@ static int Demux( demux_t *p_demux )
     es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
 
     /* Do the channel reordering */
-    if( p_sys->b_chan_reorder )
+    if( p_sys->i_chans_to_reorder )
         aout_ChannelReorder( p_block->p_buffer, p_block->i_buffer,
                              p_sys->fmt.audio.i_channels,
                              p_sys->pi_chan_table,
index bb585ab596319d80459065cd3b35d81b8c493b95..fff319e96c1c200954da9b9f59704c0559d17a38 100644 (file)
@@ -75,8 +75,8 @@ struct sout_mux_sys_t
     uint32_t waveheader2[2];
 
     uint32_t i_channel_mask;
-    bool b_chan_reorder;              /* do we need channel reordering */
-    int pi_chan_table[AOUT_CHAN_MAX];
+    uint8_t i_chans_to_reorder;            /* do we need channel reordering */
+    uint8_t pi_chan_table[AOUT_CHAN_MAX];
 };
 
 static const uint32_t pi_channels_in[] =
@@ -111,7 +111,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_header = true;
     p_sys->i_data   = 0;
 
-    p_sys->b_chan_reorder = 0;
+    p_sys->i_chans_to_reorder = 0;
 
     return VLC_SUCCESS;
 }
@@ -185,13 +185,13 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             if( p_input->p_fmt->audio.i_physical_channels & pi_vlc_chan_order_wg4[i])
                 p_sys->i_channel_mask |= pi_channels_in[i];
 
-        p_sys->b_chan_reorder =
+        p_sys->i_chans_to_reorder =
             aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
                                       p_sys->i_channel_mask,
                                       p_sys->pi_chan_table );
 
-        msg_Dbg( p_mux, "channel mask: %x, reordering: %i",
-                 p_sys->i_channel_mask, (int)p_sys->b_chan_reorder );
+        msg_Dbg( p_mux, "channel mask: %x, reordering: %u",
+                 p_sys->i_channel_mask, p_sys->i_chans_to_reorder );
     }
 
     fourcc_to_wf_tag( p_input->p_fmt->i_codec, &i_format );
@@ -290,9 +290,9 @@ static int Mux( sout_mux_t *p_mux )
         p_sys->i_data += p_block->i_buffer;
 
         /* Do the channel reordering */
-        if( p_sys->b_chan_reorder )
+        if( p_sys->i_chans_to_reorder )
             aout_ChannelReorder( p_block->p_buffer, p_block->i_buffer,
-                                 p_input->p_fmt->audio.i_channels,
+                                 p_sys->i_chans_to_reorder,
                                  p_sys->pi_chan_table,
                                  p_input->p_fmt->audio.i_bitspersample );
 
index 720d6ff5c0b79a2fb05fbcf45c06671cc48a1bb6..3f16894778ae618a95e2ee254ef76450680a84d2 100644 (file)
@@ -243,7 +243,7 @@ void aout_FormatsPrint( vlc_object_t *obj, const char * psz_text,
  *****************************************************************************/
 unsigned aout_CheckChannelReorder( const uint32_t *chans_in,
                                    const uint32_t *chans_out,
-                                   uint32_t mask, int *restrict table )
+                                   uint32_t mask, uint8_t *restrict table )
 {
     unsigned channels = 0;
 
@@ -276,7 +276,7 @@ unsigned aout_CheckChannelReorder( const uint32_t *chans_in,
  * aout_ChannelReorder :
  *****************************************************************************/
 void aout_ChannelReorder( void *ptr, size_t bytes, unsigned channels,
-                          const int *pi_chan_table, unsigned bits_per_sample )
+                          const uint8_t *chans_table, unsigned bits_per_sample )
 {
     size_t samples = bytes / (channels * (bits_per_sample >> 3));
 
@@ -293,7 +293,7 @@ void aout_ChannelReorder( void *ptr, size_t bytes, unsigned channels,
                 uint32_t tmp[AOUT_CHAN_MAX];
 
                 for( size_t j = 0; j < channels; j++ )
-                    tmp[pi_chan_table[j]] = buf[j];
+                    tmp[chans_table[j]] = buf[j];
 
                 memcpy( buf, tmp, 4 * channels );
                 buf += channels;
@@ -310,7 +310,7 @@ void aout_ChannelReorder( void *ptr, size_t bytes, unsigned channels,
                 uint16_t tmp[AOUT_CHAN_MAX];
 
                 for( size_t j = 0; j < channels; j++ )
-                    tmp[pi_chan_table[j]] = buf[j];
+                    tmp[chans_table[j]] = buf[j];
 
                 memcpy( buf, tmp, 2 * channels );
                 buf += channels;
@@ -327,7 +327,7 @@ void aout_ChannelReorder( void *ptr, size_t bytes, unsigned channels,
                 uint8_t tmp[AOUT_CHAN_MAX];
 
                 for( size_t j = 0; j < channels; j++ )
-                    tmp[pi_chan_table[j]] = buf[j];
+                    tmp[chans_table[j]] = buf[j];
 
                 memcpy( buf, tmp, channels );
                 buf += channels;
@@ -344,7 +344,7 @@ void aout_ChannelReorder( void *ptr, size_t bytes, unsigned channels,
                 uint8_t tmp[3 * AOUT_CHAN_MAX];
 
                 for( size_t j = 0; j < channels; j++ )
-                    memcpy( tmp + (3 * pi_chan_table[j]), buf + (3 * j), 3 );
+                    memcpy( tmp + (3 * chans_table[j]), buf + (3 * j), 3 );
 
                 memcpy( buf, tmp, 3 * channels );
                 buf += 3 * channels;