Mercurial > audlegacy
annotate Plugins/Input/aac/libfaad2/specrec.c @ 1458:f12d7e208b43 trunk
[svn] Update FSF address in copyright notices. Update autotools templates.
author | chainsaw |
---|---|
date | Wed, 02 Aug 2006 15:44:07 -0700 |
parents | 1e6c0a3f2d15 |
children | 705d4c089fce |
rev | line source |
---|---|
61 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
1021 | 4 ** |
61 | 5 ** This program is free software; you can redistribute it and/or modify |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
1021 | 9 ** |
61 | 10 ** This program is distributed in the hope that it will be useful, |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
1021 | 14 ** |
61 | 15 ** You should have received a copy of the GNU General Public License |
1021 | 16 ** along with this program; if not, write to the Free Software |
1458
f12d7e208b43
[svn] Update FSF address in copyright notices. Update autotools templates.
chainsaw
parents:
1021
diff
changeset
|
17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. |
61 | 18 ** |
19 ** Any non-GPL usage of this software or parts of this software is strictly | |
20 ** forbidden. | |
21 ** | |
22 ** Commercial non-GPL licensing of this software is possible. | |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | |
24 ** | |
1021 | 25 ** $Id: specrec.c,v 1.56 2004/09/08 09:43:11 gcp Exp $ |
61 | 26 **/ |
27 | |
28 /* | |
29 Spectral reconstruction: | |
30 - grouping/sectioning | |
31 - inverse quantization | |
32 - applying scalefactors | |
33 */ | |
34 | |
35 #include "common.h" | |
36 #include "structs.h" | |
37 | |
38 #include <string.h> | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
39 #include <stdlib.h> |
61 | 40 #include "specrec.h" |
1021 | 41 #include "filtbank.h" |
61 | 42 #include "syntax.h" |
43 #include "iq_table.h" | |
44 #include "ms.h" | |
45 #include "is.h" | |
46 #include "pns.h" | |
47 #include "tns.h" | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
48 #include "drc.h" |
61 | 49 #include "lt_predict.h" |
50 #include "ic_predict.h" | |
51 #ifdef SSR_DEC | |
52 #include "ssr.h" | |
53 #include "ssr_fb.h" | |
54 #endif | |
55 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
56 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
57 /* static function declarations */ |
1021 | 58 static uint8_t quant_to_spec(NeAACDecHandle hDecoder, |
59 ic_stream *ics, int16_t *quant_data, | |
60 real_t *spec_data, uint16_t frame_len); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
61 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
62 |
61 | 63 #ifdef LD_DEC |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
64 ALIGN static const uint8_t num_swb_512_window[] = |
61 | 65 { |
66 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0 | |
67 }; | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
68 ALIGN static const uint8_t num_swb_480_window[] = |
61 | 69 { |
70 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0 | |
71 }; | |
72 #endif | |
73 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
74 ALIGN static const uint8_t num_swb_960_window[] = |
61 | 75 { |
76 40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40 | |
77 }; | |
78 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
79 ALIGN static const uint8_t num_swb_1024_window[] = |
61 | 80 { |
81 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40 | |
82 }; | |
83 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
84 ALIGN static const uint8_t num_swb_128_window[] = |
61 | 85 { |
86 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15 | |
87 }; | |
88 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
89 ALIGN static const uint16_t swb_offset_1024_96[] = |
61 | 90 { |
91 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, | |
92 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, | |
93 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024 | |
94 }; | |
95 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
96 ALIGN static const uint16_t swb_offset_128_96[] = |
61 | 97 { |
98 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128 | |
99 }; | |
100 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
101 ALIGN static const uint16_t swb_offset_1024_64[] = |
61 | 102 { |
103 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, | |
104 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268, | |
105 304, 344, 384, 424, 464, 504, 544, 584, 624, 664, 704, 744, 784, 824, | |
106 864, 904, 944, 984, 1024 | |
107 }; | |
108 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
109 ALIGN static const uint16_t swb_offset_128_64[] = |
61 | 110 { |
111 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128 | |
112 }; | |
113 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
114 ALIGN static const uint16_t swb_offset_1024_48[] = |
61 | 115 { |
116 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, | |
117 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, | |
118 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, | |
119 768, 800, 832, 864, 896, 928, 1024 | |
120 }; | |
121 | |
122 #ifdef LD_DEC | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
123 ALIGN static const uint16_t swb_offset_512_48[] = |
61 | 124 { |
125 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 68, 76, 84, | |
126 92, 100, 112, 124, 136, 148, 164, 184, 208, 236, 268, 300, 332, 364, 396, | |
127 428, 460, 512 | |
128 }; | |
129 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
130 ALIGN static const uint16_t swb_offset_480_48[] = |
61 | 131 { |
132 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72 ,80 ,88, | |
133 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, 272, 304, 336, 368, 400, | |
134 432, 480 | |
135 }; | |
136 #endif | |
137 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
138 ALIGN static const uint16_t swb_offset_128_48[] = |
61 | 139 { |
140 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128 | |
141 }; | |
142 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
143 ALIGN static const uint16_t swb_offset_1024_32[] = |
61 | 144 { |
145 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, | |
146 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, | |
147 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, | |
148 768, 800, 832, 864, 896, 928, 960, 992, 1024 | |
149 }; | |
150 | |
151 #ifdef LD_DEC | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
152 ALIGN static const uint16_t swb_offset_512_32[] = |
61 | 153 { |
154 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72, 80, | |
155 88, 96, 108, 120, 132, 144, 160, 176, 192, 212, 236, 260, 288, 320, 352, | |
156 384, 416, 448, 480, 512 | |
157 }; | |
158 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
159 ALIGN static const uint16_t swb_offset_480_32[] = |
61 | 160 { |
161 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, | |
162 88, 96, 104, 112, 124, 136, 148, 164, 180, 200, 224, 256, 288, 320, 352, | |
163 384, 416, 448, 480 | |
164 }; | |
165 #endif | |
166 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
167 ALIGN static const uint16_t swb_offset_1024_24[] = |
61 | 168 { |
169 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, | |
170 76, 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220, | |
171 240, 260, 284, 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704, | |
172 768, 832, 896, 960, 1024 | |
173 }; | |
174 | |
175 #ifdef LD_DEC | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
176 ALIGN static const uint16_t swb_offset_512_24[] = |
61 | 177 { |
178 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, | |
179 80, 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, | |
180 448, 480, 512 | |
181 }; | |
182 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
183 ALIGN static const uint16_t swb_offset_480_24[] = |
61 | 184 { |
185 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 80, 92, 104, 120, | |
186 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480 | |
187 }; | |
188 #endif | |
189 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
190 ALIGN static const uint16_t swb_offset_128_24[] = |
61 | 191 { |
192 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128 | |
193 }; | |
194 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
195 ALIGN static const uint16_t swb_offset_1024_16[] = |
61 | 196 { |
197 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, | |
198 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, | |
199 368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024 | |
200 }; | |
201 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
202 ALIGN static const uint16_t swb_offset_128_16[] = |
61 | 203 { |
204 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128 | |
205 }; | |
206 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
207 ALIGN static const uint16_t swb_offset_1024_8[] = |
61 | 208 { |
209 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172, | |
210 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448, | |
211 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024 | |
212 }; | |
213 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
214 ALIGN static const uint16_t swb_offset_128_8[] = |
61 | 215 { |
216 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128 | |
217 }; | |
218 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
219 ALIGN static const uint16_t *swb_offset_1024_window[] = |
61 | 220 { |
221 swb_offset_1024_96, /* 96000 */ | |
222 swb_offset_1024_96, /* 88200 */ | |
223 swb_offset_1024_64, /* 64000 */ | |
224 swb_offset_1024_48, /* 48000 */ | |
225 swb_offset_1024_48, /* 44100 */ | |
226 swb_offset_1024_32, /* 32000 */ | |
227 swb_offset_1024_24, /* 24000 */ | |
228 swb_offset_1024_24, /* 22050 */ | |
229 swb_offset_1024_16, /* 16000 */ | |
230 swb_offset_1024_16, /* 12000 */ | |
231 swb_offset_1024_16, /* 11025 */ | |
232 swb_offset_1024_8 /* 8000 */ | |
233 }; | |
234 | |
235 #ifdef LD_DEC | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
236 ALIGN static const uint16_t *swb_offset_512_window[] = |
61 | 237 { |
238 0, /* 96000 */ | |
239 0, /* 88200 */ | |
240 0, /* 64000 */ | |
241 swb_offset_512_48, /* 48000 */ | |
242 swb_offset_512_48, /* 44100 */ | |
243 swb_offset_512_32, /* 32000 */ | |
244 swb_offset_512_24, /* 24000 */ | |
245 swb_offset_512_24, /* 22050 */ | |
246 0, /* 16000 */ | |
247 0, /* 12000 */ | |
248 0, /* 11025 */ | |
249 0 /* 8000 */ | |
250 }; | |
251 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
252 ALIGN static const uint16_t *swb_offset_480_window[] = |
61 | 253 { |
254 0, /* 96000 */ | |
255 0, /* 88200 */ | |
256 0, /* 64000 */ | |
257 swb_offset_480_48, /* 48000 */ | |
258 swb_offset_480_48, /* 44100 */ | |
259 swb_offset_480_32, /* 32000 */ | |
260 swb_offset_480_24, /* 24000 */ | |
261 swb_offset_480_24, /* 22050 */ | |
262 0, /* 16000 */ | |
263 0, /* 12000 */ | |
264 0, /* 11025 */ | |
265 0 /* 8000 */ | |
266 }; | |
267 #endif | |
268 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
269 ALIGN static const uint16_t *swb_offset_128_window[] = |
61 | 270 { |
271 swb_offset_128_96, /* 96000 */ | |
272 swb_offset_128_96, /* 88200 */ | |
273 swb_offset_128_64, /* 64000 */ | |
274 swb_offset_128_48, /* 48000 */ | |
275 swb_offset_128_48, /* 44100 */ | |
276 swb_offset_128_48, /* 32000 */ | |
277 swb_offset_128_24, /* 24000 */ | |
278 swb_offset_128_24, /* 22050 */ | |
279 swb_offset_128_16, /* 16000 */ | |
280 swb_offset_128_16, /* 12000 */ | |
281 swb_offset_128_16, /* 11025 */ | |
282 swb_offset_128_8 /* 8000 */ | |
283 }; | |
284 | |
285 #define bit_set(A, B) ((A) & (1<<(B))) | |
286 | |
287 /* 4.5.2.3.4 */ | |
288 /* | |
289 - determine the number of windows in a window_sequence named num_windows | |
290 - determine the number of window_groups named num_window_groups | |
291 - determine the number of windows in each group named window_group_length[g] | |
292 - determine the total number of scalefactor window bands named num_swb for | |
293 the actual window type | |
294 - determine swb_offset[swb], the offset of the first coefficient in | |
295 scalefactor window band named swb of the window actually used | |
296 - determine sect_sfb_offset[g][section],the offset of the first coefficient | |
297 in section named section. This offset depends on window_sequence and | |
298 scale_factor_grouping and is needed to decode the spectral_data(). | |
299 */ | |
1021 | 300 uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) |
61 | 301 { |
302 uint8_t i, g; | |
303 | |
304 uint8_t sf_index = hDecoder->sf_index; | |
305 | |
306 switch (ics->window_sequence) { | |
307 case ONLY_LONG_SEQUENCE: | |
308 case LONG_START_SEQUENCE: | |
309 case LONG_STOP_SEQUENCE: | |
310 ics->num_windows = 1; | |
311 ics->num_window_groups = 1; | |
312 ics->window_group_length[ics->num_window_groups-1] = 1; | |
313 #ifdef LD_DEC | |
314 if (hDecoder->object_type == LD) | |
315 { | |
316 if (hDecoder->frameLength == 512) | |
317 ics->num_swb = num_swb_512_window[sf_index]; | |
318 else /* if (hDecoder->frameLength == 480) */ | |
319 ics->num_swb = num_swb_480_window[sf_index]; | |
320 } else { | |
321 #endif | |
322 if (hDecoder->frameLength == 1024) | |
323 ics->num_swb = num_swb_1024_window[sf_index]; | |
324 else /* if (hDecoder->frameLength == 960) */ | |
325 ics->num_swb = num_swb_960_window[sf_index]; | |
326 #ifdef LD_DEC | |
327 } | |
328 #endif | |
329 | |
330 /* preparation of sect_sfb_offset for long blocks */ | |
331 /* also copy the last value! */ | |
332 #ifdef LD_DEC | |
333 if (hDecoder->object_type == LD) | |
334 { | |
335 if (hDecoder->frameLength == 512) | |
336 { | |
337 for (i = 0; i < ics->num_swb; i++) | |
338 { | |
339 ics->sect_sfb_offset[0][i] = swb_offset_512_window[sf_index][i]; | |
340 ics->swb_offset[i] = swb_offset_512_window[sf_index][i]; | |
341 } | |
342 } else /* if (hDecoder->frameLength == 480) */ { | |
343 for (i = 0; i < ics->num_swb; i++) | |
344 { | |
345 ics->sect_sfb_offset[0][i] = swb_offset_480_window[sf_index][i]; | |
346 ics->swb_offset[i] = swb_offset_480_window[sf_index][i]; | |
347 } | |
348 } | |
349 ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; | |
350 ics->swb_offset[ics->num_swb] = hDecoder->frameLength; | |
351 } else { | |
352 #endif | |
353 for (i = 0; i < ics->num_swb; i++) | |
354 { | |
355 ics->sect_sfb_offset[0][i] = swb_offset_1024_window[sf_index][i]; | |
356 ics->swb_offset[i] = swb_offset_1024_window[sf_index][i]; | |
357 } | |
358 ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; | |
359 ics->swb_offset[ics->num_swb] = hDecoder->frameLength; | |
360 #ifdef LD_DEC | |
361 } | |
362 #endif | |
363 return 0; | |
364 case EIGHT_SHORT_SEQUENCE: | |
365 ics->num_windows = 8; | |
366 ics->num_window_groups = 1; | |
367 ics->window_group_length[ics->num_window_groups-1] = 1; | |
368 ics->num_swb = num_swb_128_window[sf_index]; | |
369 | |
370 for (i = 0; i < ics->num_swb; i++) | |
371 ics->swb_offset[i] = swb_offset_128_window[sf_index][i]; | |
372 ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8; | |
373 | |
374 for (i = 0; i < ics->num_windows-1; i++) { | |
375 if (bit_set(ics->scale_factor_grouping, 6-i) == 0) | |
376 { | |
377 ics->num_window_groups += 1; | |
378 ics->window_group_length[ics->num_window_groups-1] = 1; | |
379 } else { | |
380 ics->window_group_length[ics->num_window_groups-1] += 1; | |
381 } | |
382 } | |
383 | |
384 /* preparation of sect_sfb_offset for short blocks */ | |
385 for (g = 0; g < ics->num_window_groups; g++) | |
386 { | |
387 uint16_t width; | |
388 uint8_t sect_sfb = 0; | |
389 uint16_t offset = 0; | |
390 | |
391 for (i = 0; i < ics->num_swb; i++) | |
392 { | |
393 if (i+1 == ics->num_swb) | |
394 { | |
395 width = (hDecoder->frameLength/8) - swb_offset_128_window[sf_index][i]; | |
396 } else { | |
397 width = swb_offset_128_window[sf_index][i+1] - | |
398 swb_offset_128_window[sf_index][i]; | |
399 } | |
400 width *= ics->window_group_length[g]; | |
401 ics->sect_sfb_offset[g][sect_sfb++] = offset; | |
402 offset += width; | |
403 } | |
404 ics->sect_sfb_offset[g][sect_sfb] = offset; | |
405 } | |
406 return 0; | |
407 default: | |
408 return 1; | |
409 } | |
410 } | |
411 | |
1021 | 412 /* iquant() * |
413 * output = sign(input)*abs(input)^(4/3) | |
414 */ | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
415 static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
416 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
417 #ifdef FIXED_POINT |
1021 | 418 /* For FIXED_POINT the iq_table is prescaled by 3 bits (iq_table[]/8) */ |
419 /* BIG_IQ_TABLE allows you to use the full 8192 value table, if this is not | |
420 * defined a 1026 value table and interpolation will be used | |
421 */ | |
422 #ifndef BIG_IQ_TABLE | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
423 static const real_t errcorr[] = { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
424 REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0), |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
425 REAL_CONST(4.0/8.0), REAL_CONST(5.0/8.0), REAL_CONST(6.0/8.0), REAL_CONST(7.0/8.0), |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
426 REAL_CONST(0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
427 }; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
428 real_t x1, x2; |
1021 | 429 #endif |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
430 int16_t sgn = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
431 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
432 if (q < 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
433 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
434 q = -q; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
435 sgn = -1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
436 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
437 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
438 if (q < IQ_TABLE_SIZE) |
1021 | 439 { |
440 //#define IQUANT_PRINT | |
441 #ifdef IQUANT_PRINT | |
442 //printf("0x%.8X\n", sgn * tab[q]); | |
443 printf("%d\n", sgn * tab[q]); | |
444 #endif | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
445 return sgn * tab[q]; |
1021 | 446 } |
447 | |
448 #ifndef BIG_IQ_TABLE | |
449 if (q >= 8192) | |
450 { | |
451 *error = 17; | |
452 return 0; | |
453 } | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
454 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
455 /* linear interpolation */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
456 x1 = tab[q>>3]; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
457 x2 = tab[(q>>3) + 1]; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
458 return sgn * 16 * (MUL_R(errcorr[q&7],(x2-x1)) + x1); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
459 #else |
1021 | 460 *error = 17; |
461 return 0; | |
462 #endif | |
463 | |
464 #else | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
465 if (q < 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
466 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
467 /* tab contains a value for all possible q [0,8192] */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
468 if (-q < IQ_TABLE_SIZE) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
469 return -tab[-q]; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
470 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
471 *error = 17; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
472 return 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
473 } else { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
474 /* tab contains a value for all possible q [0,8192] */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
475 if (q < IQ_TABLE_SIZE) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
476 return tab[q]; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
477 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
478 *error = 17; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
479 return 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
480 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
481 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
482 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
483 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
484 #ifndef FIXED_POINT |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
485 ALIGN static const real_t pow2sf_tab[] = { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
486 2.9802322387695313E-008, 5.9604644775390625E-008, 1.1920928955078125E-007, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
487 2.384185791015625E-007, 4.76837158203125E-007, 9.5367431640625E-007, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
488 1.9073486328125E-006, 3.814697265625E-006, 7.62939453125E-006, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
489 1.52587890625E-005, 3.0517578125E-005, 6.103515625E-005, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
490 0.0001220703125, 0.000244140625, 0.00048828125, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
491 0.0009765625, 0.001953125, 0.00390625, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
492 0.0078125, 0.015625, 0.03125, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
493 0.0625, 0.125, 0.25, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
494 0.5, 1.0, 2.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
495 4.0, 8.0, 16.0, 32.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
496 64.0, 128.0, 256.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
497 512.0, 1024.0, 2048.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
498 4096.0, 8192.0, 16384.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
499 32768.0, 65536.0, 131072.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
500 262144.0, 524288.0, 1048576.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
501 2097152.0, 4194304.0, 8388608.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
502 16777216.0, 33554432.0, 67108864.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
503 134217728.0, 268435456.0, 536870912.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
504 1073741824.0, 2147483648.0, 4294967296.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
505 8589934592.0, 17179869184.0, 34359738368.0, |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
506 68719476736.0, 137438953472.0, 274877906944.0 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
507 }; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
508 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
509 |
1021 | 510 /* quant_to_spec: perform dequantisation and scaling |
511 * and in case of short block it also does the deinterleaving | |
512 */ | |
513 /* | |
514 For ONLY_LONG_SEQUENCE windows (num_window_groups = 1, | |
515 window_group_length[0] = 1) the spectral data is in ascending spectral | |
516 order. | |
517 For the EIGHT_SHORT_SEQUENCE window, the spectral order depends on the | |
518 grouping in the following manner: | |
519 - Groups are ordered sequentially | |
520 - Within a group, a scalefactor band consists of the spectral data of all | |
521 grouped SHORT_WINDOWs for the associated scalefactor window band. To | |
522 clarify via example, the length of a group is in the range of one to eight | |
523 SHORT_WINDOWs. | |
524 - If there are eight groups each with length one (num_window_groups = 8, | |
525 window_group_length[0..7] = 1), the result is a sequence of eight spectra, | |
526 each in ascending spectral order. | |
527 - If there is only one group with length eight (num_window_groups = 1, | |
528 window_group_length[0] = 8), the result is that spectral data of all eight | |
529 SHORT_WINDOWs is interleaved by scalefactor window bands. | |
530 - Within a scalefactor window band, the coefficients are in ascending | |
531 spectral order. | |
532 */ | |
533 static uint8_t quant_to_spec(NeAACDecHandle hDecoder, | |
534 ic_stream *ics, int16_t *quant_data, | |
535 real_t *spec_data, uint16_t frame_len) | |
61 | 536 { |
1021 | 537 ALIGN static const real_t pow2_table[] = |
538 { | |
539 COEF_CONST(1.0), | |
540 COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */ | |
541 COEF_CONST(1.4142135623730950488016887242097), /* 2^0.5 */ | |
542 COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */ | |
543 }; | |
544 const real_t *tab = iq_table; | |
545 | |
546 uint8_t g, sfb, win; | |
547 uint16_t width, bin, k, gindex, wa, wb; | |
548 uint8_t error = 0; /* Init error flag */ | |
549 #ifndef FIXED_POINT | |
550 real_t scf; | |
1010 | 551 #endif |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
552 |
1021 | 553 k = 0; |
554 gindex = 0; | |
61 | 555 |
556 for (g = 0; g < ics->num_window_groups; g++) | |
557 { | |
1021 | 558 uint16_t j = 0; |
559 uint16_t gincrease = 0; | |
560 uint16_t win_inc = ics->swb_offset[ics->num_swb]; | |
61 | 561 |
1021 | 562 for (sfb = 0; sfb < ics->num_swb; sfb++) |
61 | 563 { |
1021 | 564 int32_t exp, frac; |
565 | |
566 width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb]; | |
61 | 567 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
568 /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
569 /* just ignore them */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
570 if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255) |
61 | 571 { |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
572 exp = 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
573 frac = 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
574 } else { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
575 /* ics->scale_factors[g][sfb] must be between 0 and 255 */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
576 exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2; |
1021 | 577 /* frac must always be > 0 */ |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
578 frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3; |
61 | 579 } |
580 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
581 #ifdef FIXED_POINT |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
582 exp -= 25; |
61 | 583 /* IMDCT pre-scaling */ |
584 if (hDecoder->object_type == LD) | |
585 { | |
586 exp -= 6 /*9*/; | |
587 } else { | |
588 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) | |
589 exp -= 4 /*7*/; | |
590 else | |
591 exp -= 7 /*10*/; | |
592 } | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
593 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
594 |
1021 | 595 wa = gindex + j; |
596 | |
597 #ifndef FIXED_POINT | |
598 scf = pow2sf_tab[exp/*+25*/] * pow2_table[frac]; | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
599 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
600 |
1021 | 601 for (win = 0; win < ics->window_group_length[g]; win++) |
602 { | |
603 for (bin = 0; bin < width; bin += 4) | |
604 { | |
605 #ifndef FIXED_POINT | |
606 wb = wa + bin; | |
607 | |
608 spec_data[wb+0] = iquant(quant_data[k+0], tab, &error) * scf; | |
609 spec_data[wb+1] = iquant(quant_data[k+1], tab, &error) * scf; | |
610 spec_data[wb+2] = iquant(quant_data[k+2], tab, &error) * scf; | |
611 spec_data[wb+3] = iquant(quant_data[k+3], tab, &error) * scf; | |
612 | |
613 #else | |
614 real_t iq0 = iquant(quant_data[k+0], tab, &error); | |
615 real_t iq1 = iquant(quant_data[k+1], tab, &error); | |
616 real_t iq2 = iquant(quant_data[k+2], tab, &error); | |
617 real_t iq3 = iquant(quant_data[k+3], tab, &error); | |
618 | |
619 wb = wa + bin; | |
620 | |
621 if (exp < 0) | |
622 { | |
623 spec_data[wb+0] = iq0 >>= -exp; | |
624 spec_data[wb+1] = iq1 >>= -exp; | |
625 spec_data[wb+2] = iq2 >>= -exp; | |
626 spec_data[wb+3] = iq3 >>= -exp; | |
627 } else { | |
628 spec_data[wb+0] = iq0 <<= exp; | |
629 spec_data[wb+1] = iq1 <<= exp; | |
630 spec_data[wb+2] = iq2 <<= exp; | |
631 spec_data[wb+3] = iq3 <<= exp; | |
632 } | |
633 if (frac != 0) | |
634 { | |
635 spec_data[wb+0] = MUL_C(spec_data[wb+0],pow2_table[frac]); | |
636 spec_data[wb+1] = MUL_C(spec_data[wb+1],pow2_table[frac]); | |
637 spec_data[wb+2] = MUL_C(spec_data[wb+2],pow2_table[frac]); | |
638 spec_data[wb+3] = MUL_C(spec_data[wb+3],pow2_table[frac]); | |
639 } | |
640 | |
641 //#define SCFS_PRINT | |
642 #ifdef SCFS_PRINT | |
643 printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+0]); | |
644 printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+1]); | |
645 printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+2]); | |
646 printf("%d\n", spec_data[gindex+(win*win_inc)+j+bin+3]); | |
647 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]); | |
648 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]); | |
649 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]); | |
650 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]); | |
651 #endif | |
652 #endif | |
653 | |
654 gincrease += 4; | |
655 k += 4; | |
656 } | |
657 wa += win_inc; | |
1010 | 658 } |
1021 | 659 j += width; |
1010 | 660 } |
1021 | 661 gindex += gincrease; |
1010 | 662 } |
1021 | 663 |
664 return error; | |
1010 | 665 } |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
666 |
1021 | 667 static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
668 uint8_t output_channels) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
669 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
670 uint8_t mul = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
671 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
672 #ifdef MAIN_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
673 /* MAIN object type prediction */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
674 if (hDecoder->object_type == MAIN) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
675 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
676 /* allocate the state only when needed */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
677 if (hDecoder->pred_stat[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
678 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
679 hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
680 reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
681 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
682 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
683 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
684 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
685 #ifdef LTP_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
686 if (is_ltp_ot(hDecoder->object_type)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
687 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
688 /* allocate the state only when needed */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
689 if (hDecoder->lt_pred_stat[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
690 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
691 hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
692 memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
693 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
694 } |
61 | 695 #endif |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
696 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
697 if (hDecoder->time_out[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
698 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
699 mul = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
700 #ifdef SBR_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
701 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
702 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
703 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
704 /* SBR requires 2 times as much output data */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
705 mul = 2; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
706 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
707 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
708 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
709 hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
710 memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
711 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
712 #if (defined(PS_DEC) || defined(DRM_PS)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
713 if (output_channels == 2) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
714 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
715 if (hDecoder->time_out[channel+1] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
716 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
717 hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
718 memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t)); |
61 | 719 } |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
720 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
721 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
722 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
723 if (hDecoder->fb_intermed[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
724 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
725 hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
726 memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); |
61 | 727 } |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
728 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
729 #ifdef SSR_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
730 if (hDecoder->object_type == SSR) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
731 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
732 if (hDecoder->ssr_overlap[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
733 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
734 hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
735 memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
736 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
737 if (hDecoder->prev_fmd[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
738 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
739 uint16_t k; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
740 hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
741 for (k = 0; k < 2*hDecoder->frameLength; k++) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
742 hDecoder->prev_fmd[channel][k] = REAL_CONST(-1); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
743 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
744 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
745 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
746 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
747 return 0; |
61 | 748 } |
749 | |
1021 | 750 static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
751 uint8_t channel, uint8_t paired_channel) |
61 | 752 { |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
753 uint8_t mul = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
754 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
755 #ifdef MAIN_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
756 /* MAIN object type prediction */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
757 if (hDecoder->object_type == MAIN) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
758 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
759 /* allocate the state only when needed */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
760 if (hDecoder->pred_stat[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
761 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
762 hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
763 reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
764 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
765 if (hDecoder->pred_stat[paired_channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
766 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
767 hDecoder->pred_stat[paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
768 reset_all_predictors(hDecoder->pred_stat[paired_channel], hDecoder->frameLength); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
769 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
770 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
771 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
772 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
773 #ifdef LTP_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
774 if (is_ltp_ot(hDecoder->object_type)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
775 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
776 /* allocate the state only when needed */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
777 if (hDecoder->lt_pred_stat[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
778 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
779 hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
780 memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
781 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
782 if (hDecoder->lt_pred_stat[paired_channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
783 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
784 hDecoder->lt_pred_stat[paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
785 memset(hDecoder->lt_pred_stat[paired_channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
786 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
787 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
788 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
789 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
790 if (hDecoder->time_out[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
791 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
792 mul = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
793 #ifdef SBR_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
794 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
795 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
796 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
797 /* SBR requires 2 times as much output data */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
798 mul = 2; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
799 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
800 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
801 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
802 hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
803 memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
804 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
805 if (hDecoder->time_out[paired_channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
806 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
807 hDecoder->time_out[paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
808 memset(hDecoder->time_out[paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
809 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
810 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
811 if (hDecoder->fb_intermed[channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
812 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
813 hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
814 memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
815 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
816 if (hDecoder->fb_intermed[paired_channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
817 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
818 hDecoder->fb_intermed[paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
819 memset(hDecoder->fb_intermed[paired_channel], 0, hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
820 } |
61 | 821 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
822 #ifdef SSR_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
823 if (hDecoder->object_type == SSR) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
824 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
825 if (hDecoder->ssr_overlap[cpe->channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
826 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
827 hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
828 memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
829 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
830 if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
831 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
832 hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
833 memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
834 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
835 if (hDecoder->prev_fmd[cpe->channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
836 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
837 uint16_t k; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
838 hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
839 for (k = 0; k < 2*hDecoder->frameLength; k++) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
840 hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
841 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
842 if (hDecoder->prev_fmd[cpe->paired_channel] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
843 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
844 uint16_t k; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
845 hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
846 for (k = 0; k < 2*hDecoder->frameLength; k++) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
847 hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
848 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
849 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
850 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
851 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
852 return 0; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
853 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
854 |
1021 | 855 uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
856 element *sce, int16_t *spec_data) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
857 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
858 uint8_t retval, output_channels; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
859 ALIGN real_t spec_coef[1024]; |
61 | 860 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
861 #ifdef PROFILE |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
862 int64_t count = faad_get_ts(); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
863 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
864 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
865 |
1021 | 866 /* always allocate 2 channels, PS can always "suddenly" turn up */ |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
867 #if (defined(PS_DEC) || defined(DRM_PS)) |
1021 | 868 output_channels = 2; |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
869 #else |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
870 output_channels = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
871 #endif |
1021 | 872 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
873 if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
874 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
875 /* element_output_channels not set yet */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
876 hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
877 } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
878 /* element inconsistency */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
879 return 21; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
880 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
881 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
882 if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
883 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
884 retval = allocate_single_channel(hDecoder, sce->channel, output_channels); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
885 if (retval > 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
886 return retval; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
887 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
888 hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
889 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
890 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
891 |
1021 | 892 /* dequantisation and scaling */ |
893 retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef, hDecoder->frameLength); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
894 if (retval > 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
895 return retval; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
896 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
897 #ifdef PROFILE |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
898 count = faad_get_ts() - count; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
899 hDecoder->requant_cycles += count; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
900 #endif |
61 | 901 |
902 | |
903 /* pns decoding */ | |
904 pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type); | |
905 | |
906 #ifdef MAIN_DEC | |
907 /* MAIN object type prediction */ | |
908 if (hDecoder->object_type == MAIN) | |
909 { | |
910 /* intra channel prediction */ | |
911 ic_prediction(ics, spec_coef, hDecoder->pred_stat[sce->channel], hDecoder->frameLength, | |
912 hDecoder->sf_index); | |
913 | |
914 /* In addition, for scalefactor bands coded by perceptual | |
915 noise substitution the predictors belonging to the | |
916 corresponding spectral coefficients are reset. | |
917 */ | |
918 pns_reset_pred_state(ics, hDecoder->pred_stat[sce->channel]); | |
919 } | |
920 #endif | |
921 | |
922 #ifdef LTP_DEC | |
923 if (is_ltp_ot(hDecoder->object_type)) | |
924 { | |
925 #ifdef LD_DEC | |
926 if (hDecoder->object_type == LD) | |
927 { | |
928 if (ics->ltp.data_present) | |
929 { | |
930 if (ics->ltp.lag_update) | |
931 hDecoder->ltp_lag[sce->channel] = ics->ltp.lag; | |
932 } | |
933 ics->ltp.lag = hDecoder->ltp_lag[sce->channel]; | |
934 } | |
935 #endif | |
936 | |
937 /* long term prediction */ | |
938 lt_prediction(ics, &(ics->ltp), spec_coef, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb, | |
939 ics->window_shape, hDecoder->window_shape_prev[sce->channel], | |
940 hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); | |
941 } | |
942 #endif | |
943 | |
944 /* tns decoding */ | |
945 tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type, | |
946 spec_coef, hDecoder->frameLength); | |
947 | |
948 /* drc decoding */ | |
949 if (hDecoder->drc->present) | |
950 { | |
951 if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present) | |
952 drc_decode(hDecoder->drc, spec_coef); | |
953 } | |
954 | |
955 /* filter bank */ | |
956 #ifdef SSR_DEC | |
957 if (hDecoder->object_type != SSR) | |
958 { | |
959 #endif | |
960 ifilter_bank(hDecoder->fb, ics->window_sequence, ics->window_shape, | |
961 hDecoder->window_shape_prev[sce->channel], spec_coef, | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
962 hDecoder->time_out[sce->channel], hDecoder->fb_intermed[sce->channel], |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
963 hDecoder->object_type, hDecoder->frameLength); |
61 | 964 #ifdef SSR_DEC |
965 } else { | |
966 ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape, | |
967 hDecoder->window_shape_prev[sce->channel], spec_coef, hDecoder->time_out[sce->channel], | |
968 hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel], | |
969 hDecoder->frameLength); | |
970 } | |
971 #endif | |
972 | |
973 /* save window shape for next frame */ | |
974 hDecoder->window_shape_prev[sce->channel] = ics->window_shape; | |
975 | |
976 #ifdef LTP_DEC | |
977 if (is_ltp_ot(hDecoder->object_type)) | |
978 { | |
979 lt_update_state(hDecoder->lt_pred_stat[sce->channel], hDecoder->time_out[sce->channel], | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
980 hDecoder->fb_intermed[sce->channel], hDecoder->frameLength, hDecoder->object_type); |
61 | 981 } |
982 #endif | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
983 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
984 #ifdef SBR_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
985 if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
986 && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
987 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
988 uint8_t ele = hDecoder->fr_ch_ele; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
989 uint8_t ch = sce->channel; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
990 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
991 /* following case can happen when forceUpSampling == 1 */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
992 if (hDecoder->sbr[ele] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
993 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
994 hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, |
1021 | 995 hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index), |
996 hDecoder->downSampledSBR | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
997 #ifdef DRM |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
998 , 0 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
999 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1000 ); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1001 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1002 |
1021 | 1003 if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) |
1004 hDecoder->sbr[ele]->maxAACLine = 8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; | |
1005 else | |
1006 hDecoder->sbr[ele]->maxAACLine = sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; | |
1007 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1008 /* check if any of the PS tools is used */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1009 #if (defined(PS_DEC) || defined(DRM_PS)) |
1021 | 1010 if (hDecoder->ps_used[ele] == 0) |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1011 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1012 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1013 retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch], |
1021 | 1014 hDecoder->postSeekResetFlag, hDecoder->downSampledSBR); |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1015 #if (defined(PS_DEC) || defined(DRM_PS)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1016 } else { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1017 retval = sbrDecodeSingleFramePS(hDecoder->sbr[ele], hDecoder->time_out[ch], |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1018 hDecoder->time_out[ch+1], hDecoder->postSeekResetFlag, |
1021 | 1019 hDecoder->downSampledSBR); |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1020 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1021 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1022 if (retval > 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1023 return retval; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1024 } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1025 && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1026 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1027 return 23; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1028 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1029 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1030 |
1021 | 1031 /* copy L to R when no PS is used */ |
1032 #if (defined(PS_DEC) || defined(DRM_PS)) | |
1033 if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0)) | |
1034 { | |
1035 uint8_t ele = hDecoder->fr_ch_ele; | |
1036 uint8_t ch = sce->channel; | |
1037 uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1; | |
1038 frame_size *= hDecoder->frameLength*sizeof(real_t); | |
1039 | |
1040 memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size); | |
1041 } | |
1042 #endif | |
1043 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1044 return 0; |
61 | 1045 } |
1046 | |
1021 | 1047 uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1048 element *cpe, int16_t *spec_data1, int16_t *spec_data2) |
61 | 1049 { |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1050 uint8_t retval; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1051 ALIGN real_t spec_coef1[1024]; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1052 ALIGN real_t spec_coef2[1024]; |
61 | 1053 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1054 #ifdef PROFILE |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1055 int64_t count = faad_get_ts(); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1056 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1057 if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1058 { |
1021 | 1059 retval = allocate_channel_pair(hDecoder, cpe->channel, (uint8_t)cpe->paired_channel); |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1060 if (retval > 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1061 return retval; |
61 | 1062 |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1063 hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1064 } |
61 | 1065 |
1021 | 1066 /* dequantisation and scaling */ |
1067 retval = quant_to_spec(hDecoder, ics1, spec_data1, spec_coef1, hDecoder->frameLength); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1068 if (retval > 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1069 return retval; |
1021 | 1070 retval = quant_to_spec(hDecoder, ics2, spec_data2, spec_coef2, hDecoder->frameLength); |
1071 if (retval > 0) | |
1072 return retval; | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1073 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1074 #ifdef PROFILE |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1075 count = faad_get_ts() - count; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1076 hDecoder->requant_cycles += count; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1077 #endif |
61 | 1078 |
1079 | |
1080 /* pns decoding */ | |
1081 if (ics1->ms_mask_present) | |
1082 { | |
1083 pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type); | |
1084 } else { | |
1085 pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); | |
1086 pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type); | |
1087 } | |
1088 | |
1089 /* mid/side decoding */ | |
1090 ms_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); | |
1091 | |
1021 | 1092 #if 0 |
1093 { | |
1094 int i; | |
1095 for (i = 0; i < 1024; i++) | |
1096 { | |
1097 //printf("%d\n", spec_coef1[i]); | |
1098 printf("0x%.8X\n", spec_coef1[i]); | |
1099 } | |
1100 for (i = 0; i < 1024; i++) | |
1101 { | |
1102 //printf("%d\n", spec_coef2[i]); | |
1103 printf("0x%.8X\n", spec_coef2[i]); | |
1104 } | |
1105 } | |
1106 #endif | |
1107 | |
61 | 1108 /* intensity stereo decoding */ |
1109 is_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); | |
1110 | |
1021 | 1111 #if 0 |
1112 { | |
1113 int i; | |
1114 for (i = 0; i < 1024; i++) | |
1115 { | |
1116 printf("%d\n", spec_coef1[i]); | |
1117 //printf("0x%.8X\n", spec_coef1[i]); | |
1118 } | |
1119 for (i = 0; i < 1024; i++) | |
1120 { | |
1121 printf("%d\n", spec_coef2[i]); | |
1122 //printf("0x%.8X\n", spec_coef2[i]); | |
1123 } | |
1124 } | |
1125 #endif | |
1126 | |
61 | 1127 #ifdef MAIN_DEC |
1128 /* MAIN object type prediction */ | |
1129 if (hDecoder->object_type == MAIN) | |
1130 { | |
1131 /* intra channel prediction */ | |
1132 ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength, | |
1133 hDecoder->sf_index); | |
1134 ic_prediction(ics2, spec_coef2, hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength, | |
1135 hDecoder->sf_index); | |
1136 | |
1137 /* In addition, for scalefactor bands coded by perceptual | |
1138 noise substitution the predictors belonging to the | |
1139 corresponding spectral coefficients are reset. | |
1140 */ | |
1141 pns_reset_pred_state(ics1, hDecoder->pred_stat[cpe->channel]); | |
1142 pns_reset_pred_state(ics2, hDecoder->pred_stat[cpe->paired_channel]); | |
1143 } | |
1144 #endif | |
1145 | |
1146 #ifdef LTP_DEC | |
1147 if (is_ltp_ot(hDecoder->object_type)) | |
1148 { | |
1149 ltp_info *ltp1 = &(ics1->ltp); | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1150 ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp); |
61 | 1151 #ifdef LD_DEC |
1152 if (hDecoder->object_type == LD) | |
1153 { | |
1154 if (ltp1->data_present) | |
1155 { | |
1156 if (ltp1->lag_update) | |
1157 hDecoder->ltp_lag[cpe->channel] = ltp1->lag; | |
1158 } | |
1159 ltp1->lag = hDecoder->ltp_lag[cpe->channel]; | |
1160 if (ltp2->data_present) | |
1161 { | |
1162 if (ltp2->lag_update) | |
1163 hDecoder->ltp_lag[cpe->paired_channel] = ltp2->lag; | |
1164 } | |
1165 ltp2->lag = hDecoder->ltp_lag[cpe->paired_channel]; | |
1166 } | |
1167 #endif | |
1168 | |
1169 /* long term prediction */ | |
1170 lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb, | |
1171 ics1->window_shape, hDecoder->window_shape_prev[cpe->channel], | |
1172 hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); | |
1173 lt_prediction(ics2, ltp2, spec_coef2, hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->fb, | |
1174 ics2->window_shape, hDecoder->window_shape_prev[cpe->paired_channel], | |
1175 hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); | |
1176 } | |
1177 #endif | |
1178 | |
1179 /* tns decoding */ | |
1180 tns_decode_frame(ics1, &(ics1->tns), hDecoder->sf_index, hDecoder->object_type, | |
1181 spec_coef1, hDecoder->frameLength); | |
1182 tns_decode_frame(ics2, &(ics2->tns), hDecoder->sf_index, hDecoder->object_type, | |
1183 spec_coef2, hDecoder->frameLength); | |
1184 | |
1185 /* drc decoding */ | |
1186 if (hDecoder->drc->present) | |
1187 { | |
1188 if (!hDecoder->drc->exclude_mask[cpe->channel] || !hDecoder->drc->excluded_chns_present) | |
1189 drc_decode(hDecoder->drc, spec_coef1); | |
1190 if (!hDecoder->drc->exclude_mask[cpe->paired_channel] || !hDecoder->drc->excluded_chns_present) | |
1191 drc_decode(hDecoder->drc, spec_coef2); | |
1192 } | |
1193 | |
1194 /* filter bank */ | |
1195 #ifdef SSR_DEC | |
1196 if (hDecoder->object_type != SSR) | |
1197 { | |
1198 #endif | |
1199 ifilter_bank(hDecoder->fb, ics1->window_sequence, ics1->window_shape, | |
1200 hDecoder->window_shape_prev[cpe->channel], spec_coef1, | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1201 hDecoder->time_out[cpe->channel], hDecoder->fb_intermed[cpe->channel], |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1202 hDecoder->object_type, hDecoder->frameLength); |
61 | 1203 ifilter_bank(hDecoder->fb, ics2->window_sequence, ics2->window_shape, |
1204 hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1205 hDecoder->time_out[cpe->paired_channel], hDecoder->fb_intermed[cpe->paired_channel], |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1206 hDecoder->object_type, hDecoder->frameLength); |
61 | 1207 #ifdef SSR_DEC |
1208 } else { | |
1209 ssr_decode(&(ics1->ssr), hDecoder->fb, ics1->window_sequence, ics1->window_shape, | |
1210 hDecoder->window_shape_prev[cpe->channel], spec_coef1, hDecoder->time_out[cpe->channel], | |
1211 hDecoder->ssr_overlap[cpe->channel], hDecoder->ipqf_buffer[cpe->channel], | |
1212 hDecoder->prev_fmd[cpe->channel], hDecoder->frameLength); | |
1213 ssr_decode(&(ics2->ssr), hDecoder->fb, ics2->window_sequence, ics2->window_shape, | |
1214 hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, hDecoder->time_out[cpe->paired_channel], | |
1215 hDecoder->ssr_overlap[cpe->paired_channel], hDecoder->ipqf_buffer[cpe->paired_channel], | |
1216 hDecoder->prev_fmd[cpe->paired_channel], hDecoder->frameLength); | |
1217 } | |
1218 #endif | |
1219 | |
1220 /* save window shape for next frame */ | |
1221 hDecoder->window_shape_prev[cpe->channel] = ics1->window_shape; | |
1222 hDecoder->window_shape_prev[cpe->paired_channel] = ics2->window_shape; | |
1223 | |
1224 #ifdef LTP_DEC | |
1225 if (is_ltp_ot(hDecoder->object_type)) | |
1226 { | |
1227 lt_update_state(hDecoder->lt_pred_stat[cpe->channel], hDecoder->time_out[cpe->channel], | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1228 hDecoder->fb_intermed[cpe->channel], hDecoder->frameLength, hDecoder->object_type); |
61 | 1229 lt_update_state(hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->time_out[cpe->paired_channel], |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1230 hDecoder->fb_intermed[cpe->paired_channel], hDecoder->frameLength, hDecoder->object_type); |
61 | 1231 } |
1232 #endif | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1233 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1234 #ifdef SBR_DEC |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1235 if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1236 && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1237 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1238 uint8_t ele = hDecoder->fr_ch_ele; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1239 uint8_t ch0 = cpe->channel; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1240 uint8_t ch1 = cpe->paired_channel; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1241 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1242 /* following case can happen when forceUpSampling == 1 */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1243 if (hDecoder->sbr[ele] == NULL) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1244 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1245 hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, |
1021 | 1246 hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index), |
1247 hDecoder->downSampledSBR | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1248 #ifdef DRM |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1249 , 0 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1250 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1251 ); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1252 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1253 |
1021 | 1254 if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) |
1255 hDecoder->sbr[ele]->maxAACLine = 8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; | |
1256 else | |
1257 hDecoder->sbr[ele]->maxAACLine = cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; | |
1258 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1259 retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele], |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1260 hDecoder->time_out[ch0], hDecoder->time_out[ch1], |
1021 | 1261 hDecoder->postSeekResetFlag, hDecoder->downSampledSBR); |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1262 if (retval > 0) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1263 return retval; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1264 } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1265 && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1266 { |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1267 return 23; |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1268 } |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1269 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1270 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
1271 return 0; |
61 | 1272 } |