[FFmpeg-devel] [PATCH 1/3] aacdec: move the LTP and TNS tables out of aacdectab.h

Rostislav Pehlivanov atomnuker at gmail.com
Fri Jul 17 23:20:13 CEST 2015


This commit moves the tables required for encoding and decoding
LTP and TNS AAC files out of the decoder's standalone tables file
and into the shared aactab.h, where they can be used by both the
encoder and the decoder.

This commit does not break the already-broken aac_fixed decoder.
All of the values in aactab.* are untouched by the INTFLOAT type
and this commit stays true to this by keeping all of the values
as floats. This will give a heads-up to the aac_fixed maintainers
to either keep the file as-is or to use INTFLOATS, depending on
their choice as long as they don't break the encoder.
---
 libavcodec/aacdectab.h | 43 -------------------------------------------
 libavcodec/aactab.c    | 40 ++++++++++++++++++++++++++++++++++++++++
 libavcodec/aactab.h    | 18 ++++++++++++++++--
 3 files changed, 56 insertions(+), 45 deletions(-)

diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h
index 62c7f87..baf51a7 100644
--- a/libavcodec/aacdectab.h
+++ b/libavcodec/aacdectab.h
@@ -35,49 +35,6 @@
 
 #include <stdint.h>
 
-/* @name ltp_coef
- * Table of the LTP coefficients
- */
-static const INTFLOAT ltp_coef[8] = {
-    Q30(0.570829f), Q30(0.696616f), Q30(0.813004f), Q30(0.911304f),
-    Q30(0.984900f), Q30(1.067894f), Q30(1.194601f), Q30(1.369533f),
-};
-
-/* @name tns_tmp2_map
- * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
- * The suffix _M_N[] indicate the values of coef_compress and coef_res
- * respectively.
- * @{
- */
-static const INTFLOAT tns_tmp2_map_1_3[4] = {
-     Q31(0.00000000f), Q31(-0.43388373f),  Q31(0.64278758f),  Q31(0.34202015f),
-};
-
-static const INTFLOAT tns_tmp2_map_0_3[8] = {
-     Q31(0.00000000f), Q31(-0.43388373f), Q31(-0.78183150f), Q31(-0.97492790f),
-     Q31(0.98480773f), Q31( 0.86602539f), Q31( 0.64278758f), Q31( 0.34202015f),
-};
-
-static const INTFLOAT tns_tmp2_map_1_4[8] = {
-     Q31(0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f),
-     Q31(0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f),
-};
-
-static const INTFLOAT tns_tmp2_map_0_4[16] = {
-    Q31( 0.00000000f), Q31(-0.20791170f), Q31(-0.40673664f), Q31(-0.58778524f),
-    Q31(-0.74314481f), Q31(-0.86602539f), Q31(-0.95105654f), Q31(-0.99452192f),
-    Q31( 0.99573416f), Q31( 0.96182561f), Q31( 0.89516330f), Q31( 0.79801720f),
-    Q31( 0.67369562f), Q31( 0.52643216f), Q31( 0.36124167f), Q31( 0.18374951f),
-};
-
-static const INTFLOAT * const tns_tmp2_map[4] = {
-    tns_tmp2_map_0_3,
-    tns_tmp2_map_0_4,
-    tns_tmp2_map_1_3,
-    tns_tmp2_map_1_4
-};
-// @}
-
 static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 4, 5, 0, 5, 0 };
 
 static const uint8_t aac_channel_layout_map[16][5][3] = {
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index deb9d91..7f25157 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -38,6 +38,46 @@ DECLARE_ALIGNED(32, float,  ff_aac_kbd_short_128)[128];
 DECLARE_ALIGNED(32, int,    ff_aac_kbd_long_1024_fixed)[1024];
 DECLARE_ALIGNED(32, int,    ff_aac_kbd_short_128_fixed)[128];
 
+const float ltp_coef[] = {
+    0.570829, 0.696616, 0.813004, 0.911304,
+    0.984900, 1.067894, 1.194601, 1.369533,
+};
+
+static const float tns_tmp2_map_1_3[4] = {
+    0.00000000, -0.43388373,  0.64278758,  0.34202015,
+};
+
+static const float tns_tmp2_map_0_3[8] = {
+    0.00000000, -0.43388373, -0.78183150, -0.97492790,
+    0.98480773,  0.86602539,  0.64278758,  0.34202015,
+};
+
+static const float tns_tmp2_map_1_4[8] = {
+    0.00000000, -0.20791170, -0.40673664, -0.58778524,
+    0.67369562,  0.52643216,  0.36124167,  0.18374951,
+};
+
+static const float tns_tmp2_map_0_4[16] = {
+    0.00000000, -0.20791170, -0.40673664, -0.58778524,
+    -0.74314481, -0.86602539, -0.95105654, -0.99452192,
+    0.99573416,  0.96182561,  0.89516330,  0.79801720,
+    0.67369562,  0.52643216,  0.36124167,  0.18374951,
+};
+
+const float *tns_tmp2_map[4] = {
+    tns_tmp2_map_0_3,
+    tns_tmp2_map_0_4,
+    tns_tmp2_map_1_3,
+    tns_tmp2_map_1_4
+};
+
+const float tns_tmp2_map_nums[4] = {
+    sizeof(tns_tmp2_map_0_3),
+    sizeof(tns_tmp2_map_0_4),
+    sizeof(tns_tmp2_map_1_3),
+    sizeof(tns_tmp2_map_1_4)
+};
+
 const uint8_t ff_aac_num_swb_1024[] = {
     41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
 };
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 380a1ac..bff5a3d 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -37,8 +37,7 @@
 #include <stdint.h>
 
 /* NOTE:
- * Tables in this file are used by the AAC decoder and will be used by the AAC
- * encoder.
+ * Tables in this file are used by both the AAC encoder and decoders.
  */
 
 /* @name window coefficients
@@ -54,6 +53,21 @@ const DECLARE_ALIGNED(32, extern int,   ff_aac_eld_window_512_fixed)[1920];
 const DECLARE_ALIGNED(32, extern float, ff_aac_eld_window_480)[1800];
 // @}
 
+/* @name ltp_coef
+ * Table of the LTP coefficients
+ */
+extern const float ltp_coef[];
+
+/* @name tns_tmp2_map
+ * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
+ * The suffix _M_N[] indicate the values of coef_compress and coef_res
+ * respectively.
+ * @{
+ */
+extern const float *tns_tmp2_map[4];
+extern const float  tns_tmp2_map_nums[4];
+// @}
+
 /* @name number of scalefactor window bands for long and short transform windows respectively
  * @{
  */
-- 
2.4.3.573.g4eafbef



More information about the ffmpeg-devel mailing list