[vlc-commits] aout: factor out the default channel maps
Rémi Denis-Courmont
git at videolan.org
Tue May 15 18:47:41 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 6 18:10:51 2012 +0200| [05ba3c15d1f71c70da7ed5253b3458cda6c0d248] | committer: Rémi Denis-Courmont
aout: factor out the default channel maps
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=05ba3c15d1f71c70da7ed5253b3458cda6c0d248
---
include/vlc_es.h | 14 ++++++++++++++
modules/codec/adpcm.c | 13 +------------
modules/codec/araw.c | 14 ++------------
modules/codec/dmo/dmo.c | 16 +---------------
modules/codec/omxil/omxil.c | 21 +--------------------
modules/codec/speex.c | 15 ++-------------
6 files changed, 21 insertions(+), 72 deletions(-)
diff --git a/include/vlc_es.h b/include/vlc_es.h
index 3f867641cc..ae533d0820 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -154,6 +154,20 @@ struct audio_format_t
/* Maximum number of unmapped channels */
#define INPUT_CHAN_MAX 64
+static const uint16_t vlc_chan_maps[] =
+{
+ 0,
+ AOUT_CHAN_CENTER,
+ AOUT_CHANS_2_0,
+ AOUT_CHANS_3_0,
+ AOUT_CHANS_4_0,
+ AOUT_CHANS_5_0,
+ AOUT_CHANS_5_1,
+ AOUT_CHANS_7_0,
+ AOUT_CHANS_7_1,
+ AOUT_CHANS_8_1,
+};
+
/* Values available for i_chan_mode only */
#define AOUT_CHANMODE_DUALMONO 0x1
#define AOUT_CHANMODE_DOLBYSTEREO 0x2
diff --git a/modules/codec/adpcm.c b/modules/codec/adpcm.c
index c81fb28249..f478d235c5 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -83,17 +83,6 @@ static void DecodeAdpcmDk4 ( decoder_t *, int16_t *, uint8_t * );
static void DecodeAdpcmDk3 ( decoder_t *, int16_t *, uint8_t * );
static void DecodeAdpcmEA ( decoder_t *, int16_t *, uint8_t * );
-static const int pi_channels_maps[6] =
-{
- 0,
- AOUT_CHAN_CENTER,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARLEFT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARLEFT
-};
-
/* Various table from http://www.pcisys.net/~melanson/codecs/adpcm.txt */
static const int i_index_table[16] =
{
@@ -278,7 +267,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
p_dec->fmt_out.audio.i_channels = i_channels;
- p_dec->fmt_out.audio.i_physical_channels = pi_channels_maps[i_channels];
+ p_dec->fmt_out.audio.i_physical_channels = vlc_chan_maps[i_channels];
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
diff --git a/modules/codec/araw.c b/modules/codec/araw.c
index 7d2bc67f18..53a361e8e0 100644
--- a/modules/codec/araw.c
+++ b/modules/codec/araw.c
@@ -76,16 +76,6 @@ typedef struct
date_t end_date;
} decoder_sys_t;
-static const uint16_t pi_channels_maps[] =
-{
- 0,
- AOUT_CHAN_CENTER, AOUT_CHANS_2_0, AOUT_CHANS_3_0,
- AOUT_CHANS_4_0, AOUT_CHANS_5_0, AOUT_CHANS_5_1,
- AOUT_CHANS_7_0, AOUT_CHANS_7_1, AOUT_CHANS_8_1,
-};
-static_assert( ARRAY_SIZE( pi_channels_maps ) - 1 <= AOUT_CHAN_MAX,
- "channel count mismatch" );
-
static void S8Decode( void *, const uint8_t *, unsigned );
static void U16BDecode( void *, const uint8_t *, unsigned );
static void U16LDecode( void *, const uint8_t *, unsigned );
@@ -277,14 +267,14 @@ static int DecoderOpen( vlc_object_t *p_this )
p_dec->fmt_out.audio.channel_type = p_dec->fmt_in.audio.channel_type;
p_dec->fmt_out.audio.i_format = format;
p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
- if( p_dec->fmt_in.audio.i_channels <= ARRAY_SIZE( pi_channels_maps ) - 1 )
+ if( p_dec->fmt_in.audio.i_channels < ARRAY_SIZE(vlc_chan_maps) )
{
if( p_dec->fmt_in.audio.i_physical_channels )
p_dec->fmt_out.audio.i_physical_channels =
p_dec->fmt_in.audio.i_physical_channels;
else
p_dec->fmt_out.audio.i_physical_channels =
- pi_channels_maps[p_dec->fmt_in.audio.i_channels];
+ vlc_chan_maps[p_dec->fmt_in.audio.i_channels];
}
else
{
diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c
index d51961ce4e..fbb00bfa8b 100644
--- a/modules/codec/dmo/dmo.c
+++ b/modules/codec/dmo/dmo.c
@@ -57,20 +57,6 @@
typedef long (STDCALL *GETCLASS) ( const GUID*, const GUID*, void** );
-static const int pi_channels_maps[7] =
-{
- 0,
- AOUT_CHAN_CENTER,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_CENTER | AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE
-};
-
/*****************************************************************************
* Module descriptor
*****************************************************************************/
@@ -461,7 +447,7 @@ static int DecOpen( decoder_t *p_dec )
if( p_dec->fmt_in.audio.i_channels > 8 )
goto error;
p_dec->fmt_out.audio.i_physical_channels =
- pi_channels_maps[p_dec->fmt_out.audio.i_channels];
+ vlc_chan_maps[p_dec->fmt_out.audio.i_channels];
p_wf->wFormatTag = WAVE_FORMAT_PCM;
p_wf->nSamplesPerSec = p_dec->fmt_out.audio.i_rate;
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 630ad8d87c..92f7c1d258 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -595,27 +595,8 @@ static OMX_ERRORTYPE GetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
omx_error, ErrorToString(omx_error));
if(p_fmt->audio.i_channels < 9)
- {
- static const int pi_channels_maps[9] =
- {
- 0, AOUT_CHAN_CENTER, AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_CENTER | AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_MIDDLELEFT
- | AOUT_CHAN_MIDDLERIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT | AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT
- | AOUT_CHAN_LFE
- };
p_fmt->audio.i_physical_channels =
- pi_channels_maps[p_fmt->audio.i_channels];
- }
+ vlc_chan_maps[p_fmt->audio.i_channels];
date_Init( &p_sys->end_date, p_fmt->audio.i_rate, 1 );
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index 2ef0326f98..bcb692260c 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -174,17 +174,6 @@ typedef struct
} decoder_sys_t;
-static const int pi_channels_maps[6] =
-{
- 0,
- AOUT_CHAN_CENTER, AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_CENTER | AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
-};
-
/****************************************************************************
* Local prototypes
****************************************************************************/
@@ -549,7 +538,7 @@ static int ProcessInitialHeader( decoder_t *p_dec, ogg_packet *p_oggpacket )
/* Setup the format */
p_dec->fmt_out.audio.i_physical_channels =
- pi_channels_maps[p_header->nb_channels];
+ vlc_chan_maps[p_header->nb_channels];
p_dec->fmt_out.audio.i_channels = p_header->nb_channels;
p_dec->fmt_out.audio.i_rate = p_header->rate;
@@ -718,7 +707,7 @@ static int DecodeRtpSpeexPacket( decoder_t *p_dec, block_t *p_speex_bit_block )
p_dec->fmt_out.audio.i_channels = p_sys->p_header->nb_channels;
p_dec->fmt_out.audio.i_physical_channels =
- pi_channels_maps[p_sys->p_header->nb_channels];
+ vlc_chan_maps[p_sys->p_header->nb_channels];
p_dec->fmt_out.audio.i_rate = p_sys->p_header->rate;
if ( speex_mode_query( &speex_nb_mode,
More information about the vlc-commits
mailing list