[vlc-commits] codec: faad: move away mpeg4 audiospecific table
Francois Cartegnie
git at videolan.org
Mon Feb 27 23:08:22 CET 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Feb 27 17:14:34 2017 +0100| [065258d411b4c34f56b550589f576c339f146241] | committer: Francois Cartegnie
codec: faad: move away mpeg4 audiospecific table
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=065258d411b4c34f56b550589f576c339f146241
---
modules/codec/Makefile.am | 2 +-
modules/codec/faad.c | 46 +++++++++------------------
modules/packetizer/mpeg4audio.h | 69 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 32 deletions(-)
diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index c3be95a..343f17e 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -40,7 +40,7 @@ libaraw_plugin_la_SOURCES = codec/araw.c
libaraw_plugin_la_LIBADD = $(LIBM)
codec_LTLIBRARIES += libaraw_plugin.la
-libfaad_plugin_la_SOURCES = codec/faad.c
+libfaad_plugin_la_SOURCES = codec/faad.c packetizer/mpeg4audio.h
libfaad_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_faad)
libfaad_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
libfaad_plugin_la_LIBADD = $(LIBS_faad) $(LIBM)
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index adb5069..b10c957 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -41,6 +41,7 @@
#include <vlc_cpu.h>
#include <neaacdec.h>
+#include "../packetizer/mpeg4audio.h"
/*****************************************************************************
* Module descriptor
@@ -63,8 +64,6 @@ static int DecodeBlock( decoder_t *, block_t * );
static void Flush( decoder_t * );
static void DoReordering( uint32_t *, uint32_t *, int, int, uint32_t * );
-#define MAX_CHANNEL_POSITIONS 9
-
struct decoder_sys_t
{
/* faad handler */
@@ -77,43 +76,28 @@ struct decoder_sys_t
block_t *p_block;
/* Channel positions of the current stream (for re-ordering) */
- uint32_t pi_channel_positions[MAX_CHANNEL_POSITIONS];
+ uint32_t pi_channel_positions[MPEG4_ASC_MAX_INDEXEDPOS];
bool b_sbr, b_ps, b_discontinuity;
};
-static const uint32_t pi_channels_in[MAX_CHANNEL_POSITIONS] =
+/* Channels positions values as output by faad */
+static const uint32_t pi_channels_in[MPEG4_ASC_MAX_INDEXEDPOS] =
{ FRONT_CHANNEL_CENTER, FRONT_CHANNEL_LEFT, FRONT_CHANNEL_RIGHT,
SIDE_CHANNEL_LEFT, SIDE_CHANNEL_RIGHT,
BACK_CHANNEL_LEFT, BACK_CHANNEL_RIGHT,
BACK_CHANNEL_CENTER, LFE_CHANNEL };
-static const uint32_t pi_channels_out[MAX_CHANNEL_POSITIONS] =
+static const uint32_t pi_channels_out[MPEG4_ASC_MAX_INDEXEDPOS] =
{ AOUT_CHAN_CENTER, AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
AOUT_CHAN_REARCENTER, AOUT_CHAN_LFE };
-static const uint32_t pi_channels_ordered[MAX_CHANNEL_POSITIONS] =
+static const uint32_t pi_channels_ordered[MPEG4_ASC_MAX_INDEXEDPOS] =
{ AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
AOUT_CHAN_CENTER, AOUT_CHAN_REARCENTER, AOUT_CHAN_LFE
};
-static const uint32_t pi_channels_guessed[MAX_CHANNEL_POSITIONS] =
- { 0, AOUT_CHAN_CENTER, AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_LFE,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT | AOUT_CHAN_CENTER,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
- | AOUT_CHAN_REARRIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_LFE,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_MIDDLELEFT
- | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
- | AOUT_CHAN_CENTER,
- AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_MIDDLELEFT
- | AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
- | AOUT_CHAN_CENTER | AOUT_CHAN_LFE
- };
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
@@ -170,7 +154,7 @@ static int Open( vlc_object_t *p_this )
p_dec->fmt_out.audio.i_channels = i_channels;
p_dec->fmt_out.audio.i_physical_channels
= p_dec->fmt_out.audio.i_original_channels
- = pi_channels_guessed[i_channels];
+ = mpeg4_asc_channelsbyindex[i_channels];
date_Init( &p_sys->date, i_rate, 1 );
}
else
@@ -305,7 +289,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
p_dec->fmt_out.audio.i_channels = i_channels;
p_dec->fmt_out.audio.i_physical_channels
= p_dec->fmt_out.audio.i_original_channels
- = pi_channels_guessed[i_channels];
+ = mpeg4_asc_channelsbyindex[i_channels];
date_Init( &p_sys->date, i_rate, 1 );
}
@@ -328,7 +312,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
p_dec->fmt_out.audio.i_channels = i_channels;
p_dec->fmt_out.audio.i_physical_channels
= p_dec->fmt_out.audio.i_original_channels
- = pi_channels_guessed[i_channels];
+ = mpeg4_asc_channelsbyindex[i_channels];
date_Init( &p_sys->date, i_rate, 1 );
}
@@ -397,7 +381,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
p_dec->fmt_out.audio.i_channels = i_channels;
p_dec->fmt_out.audio.i_physical_channels
= p_dec->fmt_out.audio.i_original_channels
- = pi_channels_guessed[i_channels];
+ = mpeg4_asc_channelsbyindex[i_channels];
date_Init( &p_sys->date, i_rate, 1 );
}
}
@@ -460,12 +444,12 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
for( unsigned i = 0; i < nbChannels; i++ )
{
/* Find the channel code */
- for( j = 0; j < MAX_CHANNEL_POSITIONS; j++ )
+ for( j = 0; j < MPEG4_ASC_MAX_INDEXEDPOS; j++ )
{
if( frame.channel_position[i] == pi_channels_in[j] )
break;
}
- if( j >= MAX_CHANNEL_POSITIONS )
+ if( j >= MPEG4_ASC_MAX_INDEXEDPOS )
{
msg_Warn( p_dec, "unknown channel ordering" );
/* Invent something */
@@ -482,7 +466,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
{
p_dec->fmt_out.audio.i_physical_channels
= p_dec->fmt_out.audio.i_original_channels
- = pi_channels_guessed[nbChannels];
+ = mpeg4_asc_channelsbyindex[nbChannels];
}
else
{
@@ -549,11 +533,11 @@ static void Close( vlc_object_t *p_this )
static void DoReordering( uint32_t *p_out, uint32_t *p_in, int i_samples,
int i_nb_channels, uint32_t *pi_chan_positions )
{
- int pi_chan_table[MAX_CHANNEL_POSITIONS] = {0};
+ int pi_chan_table[MPEG4_ASC_MAX_INDEXEDPOS] = {0};
int i, j, k;
/* Find the channels mapping */
- for( i = 0, j = 0; i < MAX_CHANNEL_POSITIONS; i++ )
+ for( i = 0, j = 0; i < MPEG4_ASC_MAX_INDEXEDPOS; i++ )
{
for( k = 0; k < i_nb_channels; k++ )
{
diff --git a/modules/packetizer/mpeg4audio.h b/modules/packetizer/mpeg4audio.h
new file mode 100644
index 0000000..27f1b24
--- /dev/null
+++ b/modules/packetizer/mpeg4audio.h
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * mpeg4audio.h: MPEG 4 audio definitions
+ *****************************************************************************
+ * Copyright (C) 2001-2017 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+enum
+{
+ AOT_AAC_MAIN = 1,
+ AOT_AAC_LC,
+ AOT_AAC_SSR,
+ AOT_AAC_LTP,
+ AOT_AAC_SBR,
+ AOT_AAC_SC,
+ AOT_ER_AAC_LC = 17,
+ AOT_ER_AAC_LTP = 19,
+ AOT_ER_AAC_SC = 20,
+ AOT_ER_AAC_LD = 23,
+ AOT_AAC_PS = 29,
+ AOT_ER_AAC_ELD = 39,
+};
+
+enum
+{
+ AAC_PROFILE_MAIN = AOT_AAC_MAIN - 1,
+ AAC_PROFILE_LC,
+ AAC_PROFILE_SSR,
+ AAC_PROFILE_LTP,
+};
+
+#define MPEG4_ASC_MAX_INDEXEDPOS 9
+
+static const uint32_t mpeg4_asc_channelsbyindex[MPEG4_ASC_MAX_INDEXEDPOS] =
+{
+ 0, /* Set later */
+
+ AOUT_CHAN_CENTER, AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
+
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_LFE,
+
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
+
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
+ AOUT_CHAN_CENTER,
+
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
+ AOUT_CHAN_CENTER | AOUT_CHAN_LFE,
+
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_MIDDLELEFT |
+ AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
+ AOUT_CHAN_CENTER,
+
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_MIDDLELEFT |
+ AOUT_CHAN_MIDDLERIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
+ AOUT_CHAN_CENTER | AOUT_CHAN_LFE
+};
More information about the vlc-commits
mailing list