summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/Makefile2
-rw-r--r--libavcodec/aaccoder.c32
-rw-r--r--libavcodec/aacenc.c118
-rw-r--r--libavcodec/aacenctab.c108
-rw-r--r--libavcodec/aacenctab.h100
5 files changed, 212 insertions, 148 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e61b9cd4eb..59060cf0b6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -130,7 +130,7 @@ OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float
OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \
aacadtsdec.o mpeg4audio.o kbdwin.o \
sbrdsp_fixed.o aacpsdsp_fixed.o
-OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
+OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacpsy.o aactab.o \
psymodel.o mpeg4audio.o kbdwin.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 04419716cd..d55b1a73cb 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -39,6 +39,7 @@
#include "aac.h"
#include "aacenc.h"
#include "aactab.h"
+#include "aacenctab.h"
#include "aac_tablegen_decl.h"
/** Frequency in Hz for lower limit of noise substitution **/
@@ -56,37 +57,9 @@
/** Frequency in Hz for lower limit of intensity stereo **/
#define INT_STEREO_LOW_LIMIT 6100
-/** Total number of usable codebooks **/
-#define CB_TOT 12
-
-/** Total number of codebooks, including special ones **/
-#define CB_TOT_ALL 15
-
-/** bits needed to code codebook run value for long windows */
-static const uint8_t run_value_bits_long[64] = {
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15
-};
-
-/** bits needed to code codebook run value for short windows */
-static const uint8_t run_value_bits_short[16] = {
- 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 9
-};
-
-static const uint8_t * const run_value_bits[2] = {
- run_value_bits_long, run_value_bits_short
-};
-
#define ROUND_STANDARD 0.4054f
#define ROUND_TO_ZERO 0.1054f
-/** Map to convert values from BandCodingPath index to a codebook index **/
-static const uint8_t aac_cb_out_map[CB_TOT_ALL] = {0,1,2,3,4,5,6,7,8,9,10,11,13,14,15};
-/** Inverse map to convert from codebooks to BandCodingPath indices **/
-static const uint8_t aac_cb_in_map[CB_TOT_ALL+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,12,13,14};
-
/**
* Quantize one coefficient.
* @return absolute value of the quantized coefficient
@@ -123,9 +96,6 @@ static void abs_pow34_v(float *out, const float *in, const int size)
#endif /* USE_REALLY_FULL_SEARCH */
}
-static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17};
-static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16};
-
/**
* Calculate rate distortion cost for quantizing with given codebook
*
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 0d84a82001..febd661484 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -42,11 +42,10 @@
#include "aac.h"
#include "aactab.h"
#include "aacenc.h"
+#include "aacenctab.h"
#include "psymodel.h"
-#define AAC_MAX_CHANNELS 6
-
#define ERROR_IF(cond, ...) \
if (cond) { \
av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
@@ -58,110 +57,6 @@
av_log(avctx, AV_LOG_WARNING, __VA_ARGS__); \
}
-
-static const uint8_t swb_size_1024_96[] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
- 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
- 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
-};
-
-static const uint8_t swb_size_1024_64[] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
- 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
-};
-
-static const uint8_t swb_size_1024_48[] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
- 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 96
-};
-
-static const uint8_t swb_size_1024_32[] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
- 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
-};
-
-static const uint8_t swb_size_1024_24[] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
- 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
-};
-
-static const uint8_t swb_size_1024_16[] = {
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28,
- 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
-};
-
-static const uint8_t swb_size_1024_8[] = {
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
- 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
-};
-
-static const uint8_t *swb_size_1024[] = {
- swb_size_1024_96, swb_size_1024_96, swb_size_1024_64,
- swb_size_1024_48, swb_size_1024_48, swb_size_1024_32,
- swb_size_1024_24, swb_size_1024_24, swb_size_1024_16,
- swb_size_1024_16, swb_size_1024_16, swb_size_1024_8,
- swb_size_1024_8
-};
-
-static const uint8_t swb_size_128_96[] = {
- 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
-};
-
-static const uint8_t swb_size_128_48[] = {
- 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
-};
-
-static const uint8_t swb_size_128_24[] = {
- 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
-};
-
-static const uint8_t swb_size_128_16[] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
-};
-
-static const uint8_t swb_size_128_8[] = {
- 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
-};
-
-static const uint8_t *swb_size_128[] = {
- /* the last entry on the following row is swb_size_128_64 but is a
- duplicate of swb_size_128_96 */
- swb_size_128_96, swb_size_128_96, swb_size_128_96,
- swb_size_128_48, swb_size_128_48, swb_size_128_48,
- swb_size_128_24, swb_size_128_24, swb_size_128_16,
- swb_size_128_16, swb_size_128_16, swb_size_128_8,
- swb_size_128_8
-};
-
-/** default channel configurations */
-static const uint8_t aac_chan_configs[6][5] = {
- {1, TYPE_SCE}, // 1 channel - single channel element
- {1, TYPE_CPE}, // 2 channels - channel pair
- {2, TYPE_SCE, TYPE_CPE}, // 3 channels - center + stereo
- {3, TYPE_SCE, TYPE_CPE, TYPE_SCE}, // 4 channels - front center + stereo + back center
- {3, TYPE_SCE, TYPE_CPE, TYPE_CPE}, // 5 channels - front center + stereo + back stereo
- {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE
-};
-
-/**
- * Table to remap channels from libavcodec's default order to AAC order.
- */
-static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
- { 0 },
- { 0, 1 },
- { 2, 0, 1 },
- { 2, 0, 1, 3 },
- { 2, 0, 1, 3, 4 },
- { 2, 0, 1, 4, 5, 3 },
-};
-
/**
* Make AAC audio config object.
* @see 1.6.2.1 "Syntax - AudioSpecificConfig"
@@ -843,9 +738,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
s->channels = avctx->channels;
- ERROR_IF(i == 16
- || i >= (sizeof(swb_size_1024) / sizeof(*swb_size_1024))
- || i >= (sizeof(swb_size_128) / sizeof(*swb_size_128)),
+ ERROR_IF(i == 16 || i >= swb_size_1024_len || i >= swb_size_128_len,
"Unsupported sample rate %d\n", avctx->sample_rate);
ERROR_IF(s->channels > AAC_MAX_CHANNELS,
"Unsupported number of channels: %d\n", s->channels);
@@ -926,13 +819,6 @@ static const AVClass aacenc_class = {
LIBAVUTIL_VERSION_INT,
};
-/* duplicated from avpriv_mpeg4audio_sample_rates to avoid shared build
- * failures */
-static const int mpeg4audio_sample_rates[16] = {
- 96000, 88200, 64000, 48000, 44100, 32000,
- 24000, 22050, 16000, 12000, 11025, 8000, 7350
-};
-
AVCodec ff_aac_encoder = {
.name = "aac",
.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
diff --git a/libavcodec/aacenctab.c b/libavcodec/aacenctab.c
new file mode 100644
index 0000000000..39e8376021
--- /dev/null
+++ b/libavcodec/aacenctab.c
@@ -0,0 +1,108 @@
+/*
+ * AAC encoder data
+ * Copyright (c) 2015 Rostislav Pehlivanov ( atomnuker gmail com )
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "aacenctab.h"
+
+static const uint8_t swb_size_128_96[] = {
+ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
+};
+
+static const uint8_t swb_size_128_64[] = {
+ 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
+};
+
+static const uint8_t swb_size_128_48[] = {
+ 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
+};
+
+static const uint8_t swb_size_128_24[] = {
+ 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
+};
+
+static const uint8_t swb_size_128_16[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
+};
+
+static const uint8_t swb_size_128_8[] = {
+ 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
+};
+
+static const uint8_t swb_size_1024_96[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
+ 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
+};
+
+static const uint8_t swb_size_1024_64[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
+ 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
+};
+
+static const uint8_t swb_size_1024_48[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
+ 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 96
+};
+
+static const uint8_t swb_size_1024_32[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
+ 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
+};
+
+static const uint8_t swb_size_1024_24[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
+ 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
+};
+
+static const uint8_t swb_size_1024_16[] = {
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28,
+ 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
+};
+
+static const uint8_t swb_size_1024_8[] = {
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
+ 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
+};
+
+const uint8_t *swb_size_128[] = {
+ swb_size_128_96, swb_size_128_96, swb_size_128_64,
+ swb_size_128_48, swb_size_128_48, swb_size_128_48,
+ swb_size_128_24, swb_size_128_24, swb_size_128_16,
+ swb_size_128_16, swb_size_128_16, swb_size_128_8,
+ swb_size_128_8
+};
+
+const uint8_t *swb_size_1024[] = {
+ swb_size_1024_96, swb_size_1024_96, swb_size_1024_64,
+ swb_size_1024_48, swb_size_1024_48, swb_size_1024_32,
+ swb_size_1024_24, swb_size_1024_24, swb_size_1024_16,
+ swb_size_1024_16, swb_size_1024_16, swb_size_1024_8,
+ swb_size_1024_8
+};
+
+const int swb_size_128_len = sizeof(swb_size_128)/sizeof(*swb_size_128);
+const int swb_size_1024_len = sizeof(swb_size_1024)/sizeof(*swb_size_1024);
diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h
new file mode 100644
index 0000000000..25c523ee40
--- /dev/null
+++ b/libavcodec/aacenctab.h
@@ -0,0 +1,100 @@
+/*
+ * AAC encoder data
+ * Copyright (c) 2015 Rostislav Pehlivanov ( atomnuker gmail com )
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * AAC encoder data
+ * @author Rostislav Pehlivanov ( atomnuker gmail com )
+ */
+
+#ifndef AVCODEC_AACENCTAB_H
+#define AVCODEC_AACENCTAB_H
+
+#include "aac.h"
+
+/** Total number of usable codebooks **/
+#define CB_TOT 12
+
+/** Total number of codebooks, including special ones **/
+#define CB_TOT_ALL 15
+
+#define AAC_MAX_CHANNELS 6
+
+extern const uint8_t *swb_size_1024[];
+extern const int swb_size_1024_len;
+extern const uint8_t *swb_size_128[];
+extern const int swb_size_128_len;
+
+/** default channel configurations */
+static const uint8_t aac_chan_configs[6][5] = {
+ {1, TYPE_SCE}, // 1 channel - single channel element
+ {1, TYPE_CPE}, // 2 channels - channel pair
+ {2, TYPE_SCE, TYPE_CPE}, // 3 channels - center + stereo
+ {3, TYPE_SCE, TYPE_CPE, TYPE_SCE}, // 4 channels - front center + stereo + back center
+ {3, TYPE_SCE, TYPE_CPE, TYPE_CPE}, // 5 channels - front center + stereo + back stereo
+ {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE
+};
+
+/**
+ * Table to remap channels from libavcodec's default order to AAC order.
+ */
+static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
+ { 0 },
+ { 0, 1 },
+ { 2, 0, 1 },
+ { 2, 0, 1, 3 },
+ { 2, 0, 1, 3, 4 },
+ { 2, 0, 1, 4, 5, 3 },
+};
+
+/* duplicated from avpriv_mpeg4audio_sample_rates to avoid shared build
+ * failures */
+static const int mpeg4audio_sample_rates[16] = {
+ 96000, 88200, 64000, 48000, 44100, 32000,
+ 24000, 22050, 16000, 12000, 11025, 8000, 7350
+};
+
+/** bits needed to code codebook run value for long windows */
+static const uint8_t run_value_bits_long[64] = {
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15
+};
+
+/** bits needed to code codebook run value for short windows */
+static const uint8_t run_value_bits_short[16] = {
+ 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 9
+};
+
+static const uint8_t * const run_value_bits[2] = {
+ run_value_bits_long, run_value_bits_short
+};
+
+/** Map to convert values from BandCodingPath index to a codebook index **/
+static const uint8_t aac_cb_out_map[CB_TOT_ALL] = {0,1,2,3,4,5,6,7,8,9,10,11,13,14,15};
+/** Inverse map to convert from codebooks to BandCodingPath indices **/
+static const uint8_t aac_cb_in_map[CB_TOT_ALL+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,12,13,14};
+
+static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17};
+static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16};
+
+#endif /* AVCODEC_AACENCTAB_H */