Browse code

Move TNS and swb_offset tables from aacdectab.h to aactab.c so that they can be shared with the AAC encoder.

Originally committed as revision 19174 to svn://svn.ffmpeg.org/ffmpeg/trunk

Alex Converse authored on 2009/06/13 06:14:45
Showing 4 changed files
... ...
@@ -565,16 +565,16 @@ static int decode_ics_info(AACContext * ac, IndividualChannelStream * ics, GetBi
565 565
             }
566 566
         }
567 567
         ics->num_windows   = 8;
568
-        ics->swb_offset    =      swb_offset_128[ac->m4ac.sampling_index];
568
+        ics->swb_offset    =   ff_swb_offset_128[ac->m4ac.sampling_index];
569 569
         ics->num_swb       =  ff_aac_num_swb_128[ac->m4ac.sampling_index];
570
-        ics->tns_max_bands =   tns_max_bands_128[ac->m4ac.sampling_index];
570
+        ics->tns_max_bands = ff_tns_max_bands_128[ac->m4ac.sampling_index];
571 571
         ics->predictor_present = 0;
572 572
     } else {
573 573
         ics->max_sfb       = get_bits(gb, 6);
574 574
         ics->num_windows   = 1;
575
-        ics->swb_offset    =     swb_offset_1024[ac->m4ac.sampling_index];
575
+        ics->swb_offset    =  ff_swb_offset_1024[ac->m4ac.sampling_index];
576 576
         ics->num_swb       = ff_aac_num_swb_1024[ac->m4ac.sampling_index];
577
-        ics->tns_max_bands =  tns_max_bands_1024[ac->m4ac.sampling_index];
577
+        ics->tns_max_bands = ff_tns_max_bands_1024[ac->m4ac.sampling_index];
578 578
         ics->predictor_present = get_bits1(gb);
579 579
         ics->predictor_reset_group = 0;
580 580
         if (ics->predictor_present) {
... ...
@@ -34,145 +34,6 @@
34 34
 
35 35
 #include <stdint.h>
36 36
 
37
-/* @name swb_offsets
38
- * Sample offset into the window indicating the beginning of a scalefactor
39
- * window band
40
- *
41
- * scalefactor window band - term for scalefactor bands within a window,
42
- * given in Table 4.110 to Table 4.128.
43
- *
44
- * scalefactor band - a set of spectral coefficients which are scaled by one
45
- * scalefactor. In case of EIGHT_SHORT_SEQUENCE and grouping a scalefactor band
46
- * may contain several scalefactor window bands of corresponding frequency. For
47
- * all other window_sequences scalefactor bands and scalefactor window bands are
48
- * identical.
49
- * @{
50
- */
51
-
52
-static const uint16_t swb_offset_1024_96[] = {
53
-      0,   4,   8,  12,  16,  20,  24,  28,
54
-     32,  36,  40,  44,  48,  52,  56,  64,
55
-     72,  80,  88,  96, 108, 120, 132, 144,
56
-    156, 172, 188, 212, 240, 276, 320, 384,
57
-    448, 512, 576, 640, 704, 768, 832, 896,
58
-    960, 1024
59
-};
60
-
61
-static const uint16_t swb_offset_128_96[] = {
62
-    0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
63
-};
64
-
65
-static const uint16_t swb_offset_1024_64[] = {
66
-      0,   4,   8,  12,  16,  20,  24,  28,
67
-     32,  36,  40,  44,  48,  52,  56,  64,
68
-     72,  80,  88, 100, 112, 124, 140, 156,
69
-    172, 192, 216, 240, 268, 304, 344, 384,
70
-    424, 464, 504, 544, 584, 624, 664, 704,
71
-    744, 784, 824, 864, 904, 944, 984, 1024
72
-};
73
-
74
-static const uint16_t swb_offset_1024_48[] = {
75
-      0,   4,   8,  12,  16,  20,  24,  28,
76
-     32,  36,  40,  48,  56,  64,  72,  80,
77
-     88,  96, 108, 120, 132, 144, 160, 176,
78
-    196, 216, 240, 264, 292, 320, 352, 384,
79
-    416, 448, 480, 512, 544, 576, 608, 640,
80
-    672, 704, 736, 768, 800, 832, 864, 896,
81
-    928, 1024
82
-};
83
-
84
-static const uint16_t swb_offset_128_48[] = {
85
-     0,   4,   8,  12,  16,  20,  28,  36,
86
-    44,  56,  68,  80,  96, 112, 128
87
-};
88
-
89
-static const uint16_t swb_offset_1024_32[] = {
90
-      0,   4,   8,  12,  16,  20,  24,  28,
91
-     32,  36,  40,  48,  56,  64,  72,  80,
92
-     88,  96, 108, 120, 132, 144, 160, 176,
93
-    196, 216, 240, 264, 292, 320, 352, 384,
94
-    416, 448, 480, 512, 544, 576, 608, 640,
95
-    672, 704, 736, 768, 800, 832, 864, 896,
96
-    928, 960, 992, 1024
97
-};
98
-
99
-static const uint16_t swb_offset_1024_24[] = {
100
-      0,   4,   8,  12,  16,  20,  24,  28,
101
-     32,  36,  40,  44,  52,  60,  68,  76,
102
-     84,  92, 100, 108, 116, 124, 136, 148,
103
-    160, 172, 188, 204, 220, 240, 260, 284,
104
-    308, 336, 364, 396, 432, 468, 508, 552,
105
-    600, 652, 704, 768, 832, 896, 960, 1024
106
-};
107
-
108
-static const uint16_t swb_offset_128_24[] = {
109
-     0,   4,   8,  12,  16,  20,  24,  28,
110
-    36,  44,  52,  64,  76,  92, 108, 128
111
-};
112
-
113
-static const uint16_t swb_offset_1024_16[] = {
114
-      0,   8,  16,  24,  32,  40,  48,  56,
115
-     64,  72,  80,  88, 100, 112, 124, 136,
116
-    148, 160, 172, 184, 196, 212, 228, 244,
117
-    260, 280, 300, 320, 344, 368, 396, 424,
118
-    456, 492, 532, 572, 616, 664, 716, 772,
119
-    832, 896, 960, 1024
120
-};
121
-
122
-static const uint16_t swb_offset_128_16[] = {
123
-     0,   4,   8,  12,  16,  20,  24,  28,
124
-    32,  40,  48,  60,  72,  88, 108, 128
125
-};
126
-
127
-static const uint16_t swb_offset_1024_8[] = {
128
-      0,  12,  24,  36,  48,  60,  72,  84,
129
-     96, 108, 120, 132, 144, 156, 172, 188,
130
-    204, 220, 236, 252, 268, 288, 308, 328,
131
-    348, 372, 396, 420, 448, 476, 508, 544,
132
-    580, 620, 664, 712, 764, 820, 880, 944,
133
-    1024
134
-};
135
-
136
-static const uint16_t swb_offset_128_8[] = {
137
-     0,   4,   8,  12,  16,  20,  24,  28,
138
-    36,  44,  52,  60,  72,  88, 108, 128
139
-};
140
-
141
-static const uint16_t *swb_offset_1024[] = {
142
-    swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64,
143
-    swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32,
144
-    swb_offset_1024_24, swb_offset_1024_24, swb_offset_1024_16,
145
-    swb_offset_1024_16, swb_offset_1024_16, swb_offset_1024_8,
146
-    swb_offset_1024_8
147
-};
148
-
149
-static const uint16_t *swb_offset_128[] = {
150
-    /* The last entry on the following row is swb_offset_128_64 but is a
151
-       duplicate of swb_offset_128_96. */
152
-    swb_offset_128_96, swb_offset_128_96, swb_offset_128_96,
153
-    swb_offset_128_48, swb_offset_128_48, swb_offset_128_48,
154
-    swb_offset_128_24, swb_offset_128_24, swb_offset_128_16,
155
-    swb_offset_128_16, swb_offset_128_16, swb_offset_128_8,
156
-    swb_offset_128_8
157
-};
158
-
159
-// @}
160
-
161
-/* @name tns_max_bands
162
- * The maximum number of scalefactor bands on which TNS can operate for the long
163
- * and short transforms respectively. The index to these tables is related to
164
- * the sample rate of the audio.
165
- * @{
166
- */
167
-static const uint8_t tns_max_bands_1024[] = {
168
-    31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, 39
169
-};
170
-
171
-static const uint8_t tns_max_bands_128[] = {
172
-    9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
173
-};
174
-// @}
175
-
176 37
 /* @name tns_tmp2_map
177 38
  * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
178 39
  * The suffix _M_N[] indicate the values of coef_compress and coef_res
... ...
@@ -899,6 +899,146 @@ const float * const ff_aac_codebook_vectors[] = {
899 899
     codebook_vector8, codebook_vector10,
900 900
 };
901 901
 
902
+/* @name swb_offsets
903
+ * Sample offset into the window indicating the beginning of a scalefactor
904
+ * window band
905
+ *
906
+ * scalefactor window band - term for scalefactor bands within a window,
907
+ * given in Table 4.110 to Table 4.128.
908
+ *
909
+ * scalefactor band - a set of spectral coefficients which are scaled by one
910
+ * scalefactor. In case of EIGHT_SHORT_SEQUENCE and grouping a scalefactor band
911
+ * may contain several scalefactor window bands of corresponding frequency. For
912
+ * all other window_sequences scalefactor bands and scalefactor window bands are
913
+ * identical.
914
+ * @{
915
+ */
916
+
917
+static const uint16_t swb_offset_1024_96[] = {
918
+      0,   4,   8,  12,  16,  20,  24,  28,
919
+     32,  36,  40,  44,  48,  52,  56,  64,
920
+     72,  80,  88,  96, 108, 120, 132, 144,
921
+    156, 172, 188, 212, 240, 276, 320, 384,
922
+    448, 512, 576, 640, 704, 768, 832, 896,
923
+    960, 1024
924
+};
925
+
926
+static const uint16_t swb_offset_128_96[] = {
927
+    0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
928
+};
929
+
930
+static const uint16_t swb_offset_1024_64[] = {
931
+      0,   4,   8,  12,  16,  20,  24,  28,
932
+     32,  36,  40,  44,  48,  52,  56,  64,
933
+     72,  80,  88, 100, 112, 124, 140, 156,
934
+    172, 192, 216, 240, 268, 304, 344, 384,
935
+    424, 464, 504, 544, 584, 624, 664, 704,
936
+    744, 784, 824, 864, 904, 944, 984, 1024
937
+};
938
+
939
+static const uint16_t swb_offset_1024_48[] = {
940
+      0,   4,   8,  12,  16,  20,  24,  28,
941
+     32,  36,  40,  48,  56,  64,  72,  80,
942
+     88,  96, 108, 120, 132, 144, 160, 176,
943
+    196, 216, 240, 264, 292, 320, 352, 384,
944
+    416, 448, 480, 512, 544, 576, 608, 640,
945
+    672, 704, 736, 768, 800, 832, 864, 896,
946
+    928, 1024
947
+};
948
+
949
+static const uint16_t swb_offset_128_48[] = {
950
+     0,   4,   8,  12,  16,  20,  28,  36,
951
+    44,  56,  68,  80,  96, 112, 128
952
+};
953
+
954
+static const uint16_t swb_offset_1024_32[] = {
955
+      0,   4,   8,  12,  16,  20,  24,  28,
956
+     32,  36,  40,  48,  56,  64,  72,  80,
957
+     88,  96, 108, 120, 132, 144, 160, 176,
958
+    196, 216, 240, 264, 292, 320, 352, 384,
959
+    416, 448, 480, 512, 544, 576, 608, 640,
960
+    672, 704, 736, 768, 800, 832, 864, 896,
961
+    928, 960, 992, 1024
962
+};
963
+
964
+static const uint16_t swb_offset_1024_24[] = {
965
+      0,   4,   8,  12,  16,  20,  24,  28,
966
+     32,  36,  40,  44,  52,  60,  68,  76,
967
+     84,  92, 100, 108, 116, 124, 136, 148,
968
+    160, 172, 188, 204, 220, 240, 260, 284,
969
+    308, 336, 364, 396, 432, 468, 508, 552,
970
+    600, 652, 704, 768, 832, 896, 960, 1024
971
+};
972
+
973
+static const uint16_t swb_offset_128_24[] = {
974
+     0,   4,   8,  12,  16,  20,  24,  28,
975
+    36,  44,  52,  64,  76,  92, 108, 128
976
+};
977
+
978
+static const uint16_t swb_offset_1024_16[] = {
979
+      0,   8,  16,  24,  32,  40,  48,  56,
980
+     64,  72,  80,  88, 100, 112, 124, 136,
981
+    148, 160, 172, 184, 196, 212, 228, 244,
982
+    260, 280, 300, 320, 344, 368, 396, 424,
983
+    456, 492, 532, 572, 616, 664, 716, 772,
984
+    832, 896, 960, 1024
985
+};
986
+
987
+static const uint16_t swb_offset_128_16[] = {
988
+     0,   4,   8,  12,  16,  20,  24,  28,
989
+    32,  40,  48,  60,  72,  88, 108, 128
990
+};
991
+
992
+static const uint16_t swb_offset_1024_8[] = {
993
+      0,  12,  24,  36,  48,  60,  72,  84,
994
+     96, 108, 120, 132, 144, 156, 172, 188,
995
+    204, 220, 236, 252, 268, 288, 308, 328,
996
+    348, 372, 396, 420, 448, 476, 508, 544,
997
+    580, 620, 664, 712, 764, 820, 880, 944,
998
+    1024
999
+};
1000
+
1001
+static const uint16_t swb_offset_128_8[] = {
1002
+     0,   4,   8,  12,  16,  20,  24,  28,
1003
+    36,  44,  52,  60,  72,  88, 108, 128
1004
+};
1005
+
1006
+const uint16_t *ff_swb_offset_1024[] = {
1007
+    swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64,
1008
+    swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32,
1009
+    swb_offset_1024_24, swb_offset_1024_24, swb_offset_1024_16,
1010
+    swb_offset_1024_16, swb_offset_1024_16, swb_offset_1024_8,
1011
+    swb_offset_1024_8
1012
+};
1013
+
1014
+const uint16_t *ff_swb_offset_128[] = {
1015
+    /* The last entry on the following row is swb_offset_128_64 but is a
1016
+       duplicate of swb_offset_128_96. */
1017
+    swb_offset_128_96, swb_offset_128_96, swb_offset_128_96,
1018
+    swb_offset_128_48, swb_offset_128_48, swb_offset_128_48,
1019
+    swb_offset_128_24, swb_offset_128_24, swb_offset_128_16,
1020
+    swb_offset_128_16, swb_offset_128_16, swb_offset_128_8,
1021
+    swb_offset_128_8
1022
+};
1023
+
1024
+// @}
1025
+
1026
+/* @name ff_tns_max_bands
1027
+ * The maximum number of scalefactor bands on which TNS can operate for the long
1028
+ * and short transforms respectively. The index to these tables is related to
1029
+ * the sample rate of the audio.
1030
+ * @{
1031
+ */
1032
+const uint8_t ff_tns_max_bands_1024[] = {
1033
+    31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, 39
1034
+};
1035
+
1036
+const uint8_t ff_tns_max_bands_128[] = {
1037
+    9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
1038
+};
1039
+// @}
1040
+
1041
+
902 1042
 #if CONFIG_HARDCODED_TABLES
903 1043
 
904 1044
 /**
... ...
@@ -65,6 +65,12 @@ extern const uint16_t  ff_aac_spectral_sizes[11];
65 65
 
66 66
 extern const float *ff_aac_codebook_vectors[];
67 67
 
68
+extern const uint16_t *ff_swb_offset_1024[13];
69
+extern const uint16_t *ff_swb_offset_128 [13];
70
+
71
+extern const uint8_t ff_tns_max_bands_1024[13];
72
+extern const uint8_t ff_tns_max_bands_128 [13];
73
+
68 74
 #if CONFIG_HARDCODED_TABLES
69 75
 extern const float ff_aac_pow2sf_tab[428];
70 76
 #else