Commit 978d581b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Shrink channel reordering tables to 9-10 bytes (from 36-40 bytes)

parent 784b1bd3
......@@ -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
......
......@@ -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 */
......
......@@ -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. */
......
......@@ -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 );
......
......@@ -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 );
}
......
......@@ -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 );
......
......@@ -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];
}
/*****************************************************************************
......
......@@ -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,
......
......@@ -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 );
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment