2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
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.
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.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ** Any non-GPL usage of this software or parts of this software is strictly
22 ** Commercial non-GPL licensing of this software is possible.
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
29 Spectral reconstruction:
31 - inverse quantization
32 - applying scalefactors
49 #include "lt_predict.h"
50 #include "ic_predict.h"
57 /* static function declarations */
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
);
64 ALIGN
static const uint8_t num_swb_512_window
[] =
66 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0
68 ALIGN
static const uint8_t num_swb_480_window
[] =
70 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0
74 ALIGN
static const uint8_t num_swb_960_window
[] ICONST_ATTR
=
76 40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40
79 ALIGN
static const uint8_t num_swb_1024_window
[] ICONST_ATTR
=
81 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
84 ALIGN
static const uint8_t num_swb_128_window
[] ICONST_ATTR
=
86 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
89 ALIGN
static const uint16_t swb_offset_1024_96
[] =
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
96 ALIGN
static const uint16_t swb_offset_128_96
[] =
98 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
101 ALIGN
static const uint16_t swb_offset_1024_64
[] =
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
109 ALIGN
static const uint16_t swb_offset_128_64
[] =
111 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
114 ALIGN
static const uint16_t swb_offset_1024_48
[] ICONST_ATTR
=
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
123 ALIGN
static const uint16_t swb_offset_512_48
[] =
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,
130 ALIGN
static const uint16_t swb_offset_480_48
[] =
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,
138 ALIGN
static const uint16_t swb_offset_128_48
[] ICONST_ATTR
=
140 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128
143 ALIGN
static const uint16_t swb_offset_1024_32
[] ICONST_ATTR
=
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
152 ALIGN
static const uint16_t swb_offset_512_32
[] =
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
159 ALIGN
static const uint16_t swb_offset_480_32
[] =
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,
167 ALIGN
static const uint16_t swb_offset_1024_24
[] ICONST_ATTR
=
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
176 ALIGN
static const uint16_t swb_offset_512_24
[] =
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,
183 ALIGN
static const uint16_t swb_offset_480_24
[] =
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
190 ALIGN
static const uint16_t swb_offset_128_24
[] ICONST_ATTR
=
192 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128
195 ALIGN
static const uint16_t swb_offset_1024_16
[] ICONST_ATTR
=
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
202 ALIGN
static const uint16_t swb_offset_128_16
[] ICONST_ATTR
=
204 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128
207 ALIGN
static const uint16_t swb_offset_1024_8
[] ICONST_ATTR
=
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
214 ALIGN
static const uint16_t swb_offset_128_8
[] ICONST_ATTR
=
216 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
219 ALIGN
static const uint16_t *const swb_offset_1024_window
[] ICONST_ATTR
=
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 */
236 ALIGN
static const uint16_t *swb_offset_512_window
[] =
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 */
252 ALIGN
static const uint16_t *swb_offset_480_window
[] =
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 */
269 ALIGN
static const uint16_t *const swb_offset_128_window
[] ICONST_ATTR
=
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 */
285 #define bit_set(A, B) ((A) & (1<<(B)))
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().
300 uint8_t window_grouping_info(NeAACDecHandle hDecoder
, ic_stream
*ics
)
304 uint8_t sf_index
= hDecoder
->sf_index
;
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;
314 if (hDecoder
->object_type
== LD
)
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
];
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
];
330 /* preparation of sect_sfb_offset for long blocks */
331 /* also copy the last value! */
333 if (hDecoder
->object_type
== LD
)
335 if (hDecoder
->frameLength
== 512)
337 for (i
= 0; i
< ics
->num_swb
; i
++)
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
];
342 } else /* if (hDecoder->frameLength == 480) */ {
343 for (i
= 0; i
< ics
->num_swb
; i
++)
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
];
349 ics
->sect_sfb_offset
[0][ics
->num_swb
] = hDecoder
->frameLength
;
350 ics
->swb_offset
[ics
->num_swb
] = hDecoder
->frameLength
;
353 for (i
= 0; i
< ics
->num_swb
; i
++)
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
];
358 ics
->sect_sfb_offset
[0][ics
->num_swb
] = hDecoder
->frameLength
;
359 ics
->swb_offset
[ics
->num_swb
] = hDecoder
->frameLength
;
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
];
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;
374 for (i
= 0; i
< ics
->num_windows
-1; i
++) {
375 if (bit_set(ics
->scale_factor_grouping
, 6-i
) == 0)
377 ics
->num_window_groups
+= 1;
378 ics
->window_group_length
[ics
->num_window_groups
-1] = 1;
380 ics
->window_group_length
[ics
->num_window_groups
-1] += 1;
384 /* preparation of sect_sfb_offset for short blocks */
385 for (g
= 0; g
< ics
->num_window_groups
; g
++)
388 uint8_t sect_sfb
= 0;
391 for (i
= 0; i
< ics
->num_swb
; i
++)
393 if (i
+1 == ics
->num_swb
)
395 width
= (hDecoder
->frameLength
/8) - swb_offset_128_window
[sf_index
][i
];
397 width
= swb_offset_128_window
[sf_index
][i
+1] -
398 swb_offset_128_window
[sf_index
][i
];
400 width
*= ics
->window_group_length
[g
];
401 ics
->sect_sfb_offset
[g
][sect_sfb
++] = offset
;
404 ics
->sect_sfb_offset
[g
][sect_sfb
] = offset
;
413 /* output = sign(input)*abs(input)^(4/3) */
415 static INLINE real_t
iquant(int16_t q
, const real_t
*tab
, uint8_t *error
)
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
423 static const real_t errcorr
[] = {
424 REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0),
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),
438 if (q
< IQ_TABLE_SIZE
)
440 //#define IQUANT_PRINT
442 //printf("0x%.8X\n", sgn * tab[q]);
443 printf("%d\n", sgn
* tab
[q
]);
455 /* linear interpolation */
457 x2
= tab
[(q
>>3) + 1];
458 return sgn
* 16 * (MUL_R(errcorr
[q
&7],(x2
-x1
)) + x1
);
467 /* tab contains a value for all possible q [0,8192] */
468 if (-q
< IQ_TABLE_SIZE
)
474 /* tab contains a value for all possible q [0,8192] */
475 if (q
< IQ_TABLE_SIZE
)
485 ALIGN
static const real_t pow2sf_tab
[] = {
486 2.9802322387695313E-008, 5.9604644775390625E-008, 1.1920928955078125E-007,
487 2.384185791015625E-007, 4.76837158203125E-007, 9.5367431640625E-007,
488 1.9073486328125E-006, 3.814697265625E-006, 7.62939453125E-006,
489 1.52587890625E-005, 3.0517578125E-005, 6.103515625E-005,
490 0.0001220703125, 0.000244140625, 0.00048828125,
491 0.0009765625, 0.001953125, 0.00390625,
492 0.0078125, 0.015625, 0.03125,
495 4.0, 8.0, 16.0, 32.0,
497 512.0, 1024.0, 2048.0,
498 4096.0, 8192.0, 16384.0,
499 32768.0, 65536.0, 131072.0,
500 262144.0, 524288.0, 1048576.0,
501 2097152.0, 4194304.0, 8388608.0,
502 16777216.0, 33554432.0, 67108864.0,
503 134217728.0, 268435456.0, 536870912.0,
504 1073741824.0, 2147483648.0, 4294967296.0,
505 8589934592.0, 17179869184.0, 34359738368.0,
506 68719476736.0, 137438953472.0, 274877906944.0
510 /* quant_to_spec: perform dequantisation and scaling
511 * and in case of short block it also does the deinterleaving
514 For ONLY_LONG_SEQUENCE windows (num_window_groups = 1,
515 window_group_length[0] = 1) the spectral data is in ascending spectral
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
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
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
)
537 ALIGN
static const real_t pow2_table
[] ICONST_ATTR
=
540 COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */
541 COEF_CONST(1.4142135623730950488016887242097), /* 2^0.5 */
542 COEF_CONST(1.6817928305074290860622509524664) /* 2^0.75 */
544 const real_t
*tab
= iq_table
;
548 uint16_t width
, bin
, k
, gindex
, wa
, wb
;
549 uint8_t error
= 0; /* Init error flag */
557 for (g
= 0; g
< ics
->num_window_groups
; g
++)
560 uint16_t gincrease
= 0;
561 uint16_t win_inc
= ics
->swb_offset
[ics
->num_swb
];
563 for (sfb
= 0; sfb
< ics
->num_swb
; sfb
++)
567 width
= ics
->swb_offset
[sfb
+1] - ics
->swb_offset
[sfb
];
569 /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */
570 /* just ignore them */
571 if (ics
->scale_factors
[g
][sfb
] < 0 || ics
->scale_factors
[g
][sfb
] > 255)
576 /* ics->scale_factors[g][sfb] must be between 0 and 255 */
577 exp
= (ics
->scale_factors
[g
][sfb
] /* - 100 */) >> 2;
578 /* frac must always be > 0 */
579 frac
= (ics
->scale_factors
[g
][sfb
] /* - 100 */) & 3;
584 /* IMDCT pre-scaling */
585 if (hDecoder
->object_type
== LD
)
589 if (ics
->window_sequence
== EIGHT_SHORT_SEQUENCE
)
599 scf
= pow2sf_tab
[exp
/*+25*/] * pow2_table
[frac
];
602 for (win
= 0; win
< ics
->window_group_length
[g
]; win
++)
604 for (bin
= 0; bin
< width
; bin
+= 4)
609 spec_data
[wb
+0] = iquant(quant_data
[k
+0], tab
, &error
) * scf
;
610 spec_data
[wb
+1] = iquant(quant_data
[k
+1], tab
, &error
) * scf
;
611 spec_data
[wb
+2] = iquant(quant_data
[k
+2], tab
, &error
) * scf
;
612 spec_data
[wb
+3] = iquant(quant_data
[k
+3], tab
, &error
) * scf
;
615 real_t iq0
= iquant(quant_data
[k
+0], tab
, &error
);
616 real_t iq1
= iquant(quant_data
[k
+1], tab
, &error
);
617 real_t iq2
= iquant(quant_data
[k
+2], tab
, &error
);
618 real_t iq3
= iquant(quant_data
[k
+3], tab
, &error
);
624 spec_data
[wb
+0] = iq0
>>= -exp
;
625 spec_data
[wb
+1] = iq1
>>= -exp
;
626 spec_data
[wb
+2] = iq2
>>= -exp
;
627 spec_data
[wb
+3] = iq3
>>= -exp
;
629 spec_data
[wb
+0] = iq0
<<= exp
;
630 spec_data
[wb
+1] = iq1
<<= exp
;
631 spec_data
[wb
+2] = iq2
<<= exp
;
632 spec_data
[wb
+3] = iq3
<<= exp
;
636 spec_data
[wb
+0] = MUL_C(spec_data
[wb
+0],pow2_table
[frac
]);
637 spec_data
[wb
+1] = MUL_C(spec_data
[wb
+1],pow2_table
[frac
]);
638 spec_data
[wb
+2] = MUL_C(spec_data
[wb
+2],pow2_table
[frac
]);
639 spec_data
[wb
+3] = MUL_C(spec_data
[wb
+3],pow2_table
[frac
]);
644 printf("%d\n", spec_data
[gindex
+(win
*win_inc
)+j
+bin
+0]);
645 printf("%d\n", spec_data
[gindex
+(win
*win_inc
)+j
+bin
+1]);
646 printf("%d\n", spec_data
[gindex
+(win
*win_inc
)+j
+bin
+2]);
647 printf("%d\n", spec_data
[gindex
+(win
*win_inc
)+j
+bin
+3]);
648 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+0]);
649 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+1]);
650 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+2]);
651 //printf("0x%.8X\n", spec_data[gindex+(win*win_inc)+j+bin+3]);
668 static uint8_t allocate_single_channel(NeAACDecHandle hDecoder
, uint8_t channel
,
669 uint8_t output_channels
)
674 /* MAIN object type prediction */
675 if (hDecoder
->object_type
== MAIN
)
677 /* allocate the state only when needed */
678 if (hDecoder
->pred_stat
[channel
] == NULL
)
680 hDecoder
->pred_stat
[channel
] = (pred_state
*)faad_malloc(hDecoder
->frameLength
* sizeof(pred_state
));
681 reset_all_predictors(hDecoder
->pred_stat
[channel
], hDecoder
->frameLength
);
687 if (is_ltp_ot(hDecoder
->object_type
))
689 /* allocate the state only when needed */
690 if (hDecoder
->lt_pred_stat
[channel
] == NULL
)
692 hDecoder
->lt_pred_stat
[channel
] = (int16_t*)faad_malloc(hDecoder
->frameLength
*4 * sizeof(int16_t));
693 memset(hDecoder
->lt_pred_stat
[channel
], 0, hDecoder
->frameLength
*4 * sizeof(int16_t));
698 if (hDecoder
->time_out
[channel
] == NULL
)
702 hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
] = 0;
703 if ((hDecoder
->sbr_present_flag
== 1) || (hDecoder
->forceUpSampling
== 1))
705 /* SBR requires 2 times as much output data */
707 hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
] = 1;
710 hDecoder
->time_out
[channel
] = (real_t
*)faad_malloc(mul
*hDecoder
->frameLength
*sizeof(real_t
));
711 memset(hDecoder
->time_out
[channel
], 0, mul
*hDecoder
->frameLength
*sizeof(real_t
));
713 #if (defined(PS_DEC) || defined(DRM_PS))
714 if (output_channels
== 2)
716 if (hDecoder
->time_out
[channel
+1] == NULL
)
718 hDecoder
->time_out
[channel
+1] = (real_t
*)faad_malloc(mul
*hDecoder
->frameLength
*sizeof(real_t
));
719 memset(hDecoder
->time_out
[channel
+1], 0, mul
*hDecoder
->frameLength
*sizeof(real_t
));
723 (void)output_channels
; /*silence warning when PS disabled*/
726 if (hDecoder
->fb_intermed
[channel
] == NULL
)
728 hDecoder
->fb_intermed
[channel
] = (real_t
*)faad_malloc(hDecoder
->frameLength
*sizeof(real_t
));
729 memset(hDecoder
->fb_intermed
[channel
], 0, hDecoder
->frameLength
*sizeof(real_t
));
733 if (hDecoder
->object_type
== SSR
)
735 if (hDecoder
->ssr_overlap
[channel
] == NULL
)
737 hDecoder
->ssr_overlap
[channel
] = (real_t
*)faad_malloc(2*hDecoder
->frameLength
*sizeof(real_t
));
738 memset(hDecoder
->ssr_overlap
[channel
], 0, 2*hDecoder
->frameLength
*sizeof(real_t
));
740 if (hDecoder
->prev_fmd
[channel
] == NULL
)
743 hDecoder
->prev_fmd
[channel
] = (real_t
*)faad_malloc(2*hDecoder
->frameLength
*sizeof(real_t
));
744 for (k
= 0; k
< 2*hDecoder
->frameLength
; k
++)
745 hDecoder
->prev_fmd
[channel
][k
] = REAL_CONST(-1);
753 static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder
,
754 uint8_t channel
, uint8_t paired_channel
)
759 /* MAIN object type prediction */
760 if (hDecoder
->object_type
== MAIN
)
762 /* allocate the state only when needed */
763 if (hDecoder
->pred_stat
[channel
] == NULL
)
765 hDecoder
->pred_stat
[channel
] = (pred_state
*)faad_malloc(hDecoder
->frameLength
* sizeof(pred_state
));
766 reset_all_predictors(hDecoder
->pred_stat
[channel
], hDecoder
->frameLength
);
768 if (hDecoder
->pred_stat
[paired_channel
] == NULL
)
770 hDecoder
->pred_stat
[paired_channel
] = (pred_state
*)faad_malloc(hDecoder
->frameLength
* sizeof(pred_state
));
771 reset_all_predictors(hDecoder
->pred_stat
[paired_channel
], hDecoder
->frameLength
);
777 if (is_ltp_ot(hDecoder
->object_type
))
779 /* allocate the state only when needed */
780 if (hDecoder
->lt_pred_stat
[channel
] == NULL
)
782 hDecoder
->lt_pred_stat
[channel
] = (int16_t*)faad_malloc(hDecoder
->frameLength
*4 * sizeof(int16_t));
783 memset(hDecoder
->lt_pred_stat
[channel
], 0, hDecoder
->frameLength
*4 * sizeof(int16_t));
785 if (hDecoder
->lt_pred_stat
[paired_channel
] == NULL
)
787 hDecoder
->lt_pred_stat
[paired_channel
] = (int16_t*)faad_malloc(hDecoder
->frameLength
*4 * sizeof(int16_t));
788 memset(hDecoder
->lt_pred_stat
[paired_channel
], 0, hDecoder
->frameLength
*4 * sizeof(int16_t));
793 if (hDecoder
->time_out
[channel
] == NULL
)
797 hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
] = 0;
798 if ((hDecoder
->sbr_present_flag
== 1) || (hDecoder
->forceUpSampling
== 1))
800 /* SBR requires 2 times as much output data */
802 hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
] = 1;
805 hDecoder
->time_out
[channel
] = (real_t
*)faad_malloc(mul
*hDecoder
->frameLength
*sizeof(real_t
));
806 memset(hDecoder
->time_out
[channel
], 0, mul
*hDecoder
->frameLength
*sizeof(real_t
));
808 if (hDecoder
->time_out
[paired_channel
] == NULL
)
810 hDecoder
->time_out
[paired_channel
] = (real_t
*)faad_malloc(mul
*hDecoder
->frameLength
*sizeof(real_t
));
811 memset(hDecoder
->time_out
[paired_channel
], 0, mul
*hDecoder
->frameLength
*sizeof(real_t
));
814 if (hDecoder
->fb_intermed
[channel
] == NULL
)
816 hDecoder
->fb_intermed
[channel
] = (real_t
*)faad_malloc(hDecoder
->frameLength
*sizeof(real_t
));
817 memset(hDecoder
->fb_intermed
[channel
], 0, hDecoder
->frameLength
*sizeof(real_t
));
819 if (hDecoder
->fb_intermed
[paired_channel
] == NULL
)
821 hDecoder
->fb_intermed
[paired_channel
] = (real_t
*)faad_malloc(hDecoder
->frameLength
*sizeof(real_t
));
822 memset(hDecoder
->fb_intermed
[paired_channel
], 0, hDecoder
->frameLength
*sizeof(real_t
));
826 if (hDecoder
->object_type
== SSR
)
828 if (hDecoder
->ssr_overlap
[cpe
->channel
] == NULL
)
830 hDecoder
->ssr_overlap
[cpe
->channel
] = (real_t
*)faad_malloc(2*hDecoder
->frameLength
*sizeof(real_t
));
831 memset(hDecoder
->ssr_overlap
[cpe
->channel
], 0, 2*hDecoder
->frameLength
*sizeof(real_t
));
833 if (hDecoder
->ssr_overlap
[cpe
->paired_channel
] == NULL
)
835 hDecoder
->ssr_overlap
[cpe
->paired_channel
] = (real_t
*)faad_malloc(2*hDecoder
->frameLength
*sizeof(real_t
));
836 memset(hDecoder
->ssr_overlap
[cpe
->paired_channel
], 0, 2*hDecoder
->frameLength
*sizeof(real_t
));
838 if (hDecoder
->prev_fmd
[cpe
->channel
] == NULL
)
841 hDecoder
->prev_fmd
[cpe
->channel
] = (real_t
*)faad_malloc(2*hDecoder
->frameLength
*sizeof(real_t
));
842 for (k
= 0; k
< 2*hDecoder
->frameLength
; k
++)
843 hDecoder
->prev_fmd
[cpe
->channel
][k
] = REAL_CONST(-1);
845 if (hDecoder
->prev_fmd
[cpe
->paired_channel
] == NULL
)
848 hDecoder
->prev_fmd
[cpe
->paired_channel
] = (real_t
*)faad_malloc(2*hDecoder
->frameLength
*sizeof(real_t
));
849 for (k
= 0; k
< 2*hDecoder
->frameLength
; k
++)
850 hDecoder
->prev_fmd
[cpe
->paired_channel
][k
] = REAL_CONST(-1);
858 uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder
, ic_stream
*ics
,
859 element
*sce
, int16_t *spec_data
)
861 uint8_t retval
, output_channels
;
862 ALIGN
static real_t spec_coef
[1024];
865 int64_t count
= faad_get_ts();
869 /* always allocate 2 channels, PS can always "suddenly" turn up */
870 #if (defined(PS_DEC) || defined(DRM_PS))
876 if (hDecoder
->element_output_channels
[hDecoder
->fr_ch_ele
] == 0)
878 /* element_output_channels not set yet */
879 hDecoder
->element_output_channels
[hDecoder
->fr_ch_ele
] = output_channels
;
880 } else if (hDecoder
->element_output_channels
[hDecoder
->fr_ch_ele
] != output_channels
) {
881 /* element inconsistency */
885 if (hDecoder
->element_alloced
[hDecoder
->fr_ch_ele
] == 0)
887 retval
= allocate_single_channel(hDecoder
, sce
->channel
, output_channels
);
891 hDecoder
->element_alloced
[hDecoder
->fr_ch_ele
] = 1;
895 /* dequantisation and scaling */
896 retval
= quant_to_spec(hDecoder
, ics
, spec_data
, spec_coef
, hDecoder
->frameLength
);
901 count
= faad_get_ts() - count
;
902 hDecoder
->requant_cycles
+= count
;
907 pns_decode(ics
, NULL
, spec_coef
, NULL
, hDecoder
->frameLength
, 0, hDecoder
->object_type
);
910 /* MAIN object type prediction */
911 if (hDecoder
->object_type
== MAIN
)
913 /* intra channel prediction */
914 ic_prediction(ics
, spec_coef
, hDecoder
->pred_stat
[sce
->channel
], hDecoder
->frameLength
,
917 /* In addition, for scalefactor bands coded by perceptual
918 noise substitution the predictors belonging to the
919 corresponding spectral coefficients are reset.
921 pns_reset_pred_state(ics
, hDecoder
->pred_stat
[sce
->channel
]);
926 if (is_ltp_ot(hDecoder
->object_type
))
929 if (hDecoder
->object_type
== LD
)
931 if (ics
->ltp
.data_present
)
933 if (ics
->ltp
.lag_update
)
934 hDecoder
->ltp_lag
[sce
->channel
] = ics
->ltp
.lag
;
936 ics
->ltp
.lag
= hDecoder
->ltp_lag
[sce
->channel
];
940 /* long term prediction */
941 lt_prediction(ics
, &(ics
->ltp
), spec_coef
, hDecoder
->lt_pred_stat
[sce
->channel
], hDecoder
->fb
,
942 ics
->window_shape
, hDecoder
->window_shape_prev
[sce
->channel
],
943 hDecoder
->sf_index
, hDecoder
->object_type
, hDecoder
->frameLength
);
948 tns_decode_frame(ics
, &(ics
->tns
), hDecoder
->sf_index
, hDecoder
->object_type
,
949 spec_coef
, hDecoder
->frameLength
);
952 if (hDecoder
->drc
->present
)
954 if (!hDecoder
->drc
->exclude_mask
[sce
->channel
] || !hDecoder
->drc
->excluded_chns_present
)
955 drc_decode(hDecoder
->drc
, spec_coef
);
960 if (hDecoder
->object_type
!= SSR
)
963 ifilter_bank(ics
->window_sequence
,ics
->window_shape
,
964 hDecoder
->window_shape_prev
[sce
->channel
],spec_coef
,
965 hDecoder
->time_out
[sce
->channel
], hDecoder
->fb_intermed
[sce
->channel
],
966 hDecoder
->object_type
, hDecoder
->frameLength
);
969 ssr_decode(&(ics
->ssr
), hDecoder
->fb
, ics
->window_sequence
, ics
->window_shape
,
970 hDecoder
->window_shape_prev
[sce
->channel
], spec_coef
, hDecoder
->time_out
[sce
->channel
],
971 hDecoder
->ssr_overlap
[sce
->channel
], hDecoder
->ipqf_buffer
[sce
->channel
], hDecoder
->prev_fmd
[sce
->channel
],
972 hDecoder
->frameLength
);
976 /* save window shape for next frame */
977 hDecoder
->window_shape_prev
[sce
->channel
] = ics
->window_shape
;
980 if (is_ltp_ot(hDecoder
->object_type
))
982 lt_update_state(hDecoder
->lt_pred_stat
[sce
->channel
], hDecoder
->time_out
[sce
->channel
],
983 hDecoder
->fb_intermed
[sce
->channel
], hDecoder
->frameLength
, hDecoder
->object_type
);
988 if (((hDecoder
->sbr_present_flag
== 1) || (hDecoder
->forceUpSampling
== 1))
989 && hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
])
991 uint8_t ele
= hDecoder
->fr_ch_ele
;
992 uint8_t ch
= sce
->channel
;
994 /* following case can happen when forceUpSampling == 1 */
995 if (hDecoder
->sbr
[ele
] == NULL
)
997 hDecoder
->sbr
[ele
] = sbrDecodeInit(hDecoder
->frameLength
,
998 hDecoder
->element_id
[ele
], 2*get_sample_rate(hDecoder
->sf_index
),
999 hDecoder
->downSampledSBR
1006 if (sce
->ics1
.window_sequence
== EIGHT_SHORT_SEQUENCE
)
1007 hDecoder
->sbr
[ele
]->maxAACLine
= 8*sce
->ics1
.swb_offset
[max(sce
->ics1
.max_sfb
-1, 0)];
1009 hDecoder
->sbr
[ele
]->maxAACLine
= sce
->ics1
.swb_offset
[max(sce
->ics1
.max_sfb
-1, 0)];
1011 /* check if any of the PS tools is used */
1012 #if (defined(PS_DEC) || defined(DRM_PS))
1013 if (hDecoder
->ps_used
[ele
] == 0)
1016 retval
= sbrDecodeSingleFrame(hDecoder
->sbr
[ele
], hDecoder
->time_out
[ch
],
1017 hDecoder
->postSeekResetFlag
, hDecoder
->downSampledSBR
);
1018 #if (defined(PS_DEC) || defined(DRM_PS))
1020 retval
= sbrDecodeSingleFramePS(hDecoder
->sbr
[ele
], hDecoder
->time_out
[ch
],
1021 hDecoder
->time_out
[ch
+1], hDecoder
->postSeekResetFlag
,
1022 hDecoder
->downSampledSBR
);
1027 } else if (((hDecoder
->sbr_present_flag
== 1) || (hDecoder
->forceUpSampling
== 1))
1028 && !hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
])
1034 /* copy L to R when no PS is used */
1035 #if (defined(PS_DEC) || defined(DRM_PS))
1036 if ((hDecoder
->ps_used
[hDecoder
->fr_ch_ele
] == 0))
1038 uint8_t ele
= hDecoder
->fr_ch_ele
;
1039 uint8_t ch
= sce
->channel
;
1040 uint16_t frame_size
= (hDecoder
->sbr_alloced
[ele
]) ? 2 : 1;
1041 frame_size
*= hDecoder
->frameLength
*sizeof(real_t
);
1043 memcpy(hDecoder
->time_out
[ch
+1], hDecoder
->time_out
[ch
], frame_size
);
1050 uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder
, ic_stream
*ics1
, ic_stream
*ics2
,
1051 element
*cpe
, int16_t *spec_data1
, int16_t *spec_data2
)
1054 ALIGN
static real_t spec_coef1
[1024] IBSS_ATTR
;
1055 ALIGN
static real_t spec_coef2
[1024] IBSS_ATTR
;
1058 int64_t count
= faad_get_ts();
1060 if (hDecoder
->element_alloced
[hDecoder
->fr_ch_ele
] == 0)
1062 retval
= allocate_channel_pair(hDecoder
, cpe
->channel
, (uint8_t)cpe
->paired_channel
);
1066 hDecoder
->element_alloced
[hDecoder
->fr_ch_ele
] = 1;
1069 /* dequantisation and scaling */
1070 retval
= quant_to_spec(hDecoder
, ics1
, spec_data1
, spec_coef1
, hDecoder
->frameLength
);
1073 retval
= quant_to_spec(hDecoder
, ics2
, spec_data2
, spec_coef2
, hDecoder
->frameLength
);
1078 count
= faad_get_ts() - count
;
1079 hDecoder
->requant_cycles
+= count
;
1084 if (ics1
->ms_mask_present
)
1086 pns_decode(ics1
, ics2
, spec_coef1
, spec_coef2
, hDecoder
->frameLength
, 1, hDecoder
->object_type
);
1088 pns_decode(ics1
, NULL
, spec_coef1
, NULL
, hDecoder
->frameLength
, 0, hDecoder
->object_type
);
1089 pns_decode(ics2
, NULL
, spec_coef2
, NULL
, hDecoder
->frameLength
, 0, hDecoder
->object_type
);
1092 /* mid/side decoding */
1093 ms_decode(ics1
, ics2
, spec_coef1
, spec_coef2
, hDecoder
->frameLength
);
1098 for (i
= 0; i
< 1024; i
++)
1100 //printf("%d\n", spec_coef1[i]);
1101 printf("0x%.8X\n", spec_coef1
[i
]);
1103 for (i
= 0; i
< 1024; i
++)
1105 //printf("%d\n", spec_coef2[i]);
1106 printf("0x%.8X\n", spec_coef2
[i
]);
1111 /* intensity stereo decoding */
1112 is_decode(ics1
, ics2
, spec_coef1
, spec_coef2
, hDecoder
->frameLength
);
1117 for (i
= 0; i
< 1024; i
++)
1119 printf("%d\n", spec_coef1
[i
]);
1120 //printf("0x%.8X\n", spec_coef1[i]);
1122 for (i
= 0; i
< 1024; i
++)
1124 printf("%d\n", spec_coef2
[i
]);
1125 //printf("0x%.8X\n", spec_coef2[i]);
1131 /* MAIN object type prediction */
1132 if (hDecoder
->object_type
== MAIN
)
1134 /* intra channel prediction */
1135 ic_prediction(ics1
, spec_coef1
, hDecoder
->pred_stat
[cpe
->channel
], hDecoder
->frameLength
,
1136 hDecoder
->sf_index
);
1137 ic_prediction(ics2
, spec_coef2
, hDecoder
->pred_stat
[cpe
->paired_channel
], hDecoder
->frameLength
,
1138 hDecoder
->sf_index
);
1140 /* In addition, for scalefactor bands coded by perceptual
1141 noise substitution the predictors belonging to the
1142 corresponding spectral coefficients are reset.
1144 pns_reset_pred_state(ics1
, hDecoder
->pred_stat
[cpe
->channel
]);
1145 pns_reset_pred_state(ics2
, hDecoder
->pred_stat
[cpe
->paired_channel
]);
1150 if (is_ltp_ot(hDecoder
->object_type
))
1152 ltp_info
*ltp1
= &(ics1
->ltp
);
1153 ltp_info
*ltp2
= (cpe
->common_window
) ? &(ics2
->ltp2
) : &(ics2
->ltp
);
1155 if (hDecoder
->object_type
== LD
)
1157 if (ltp1
->data_present
)
1159 if (ltp1
->lag_update
)
1160 hDecoder
->ltp_lag
[cpe
->channel
] = ltp1
->lag
;
1162 ltp1
->lag
= hDecoder
->ltp_lag
[cpe
->channel
];
1163 if (ltp2
->data_present
)
1165 if (ltp2
->lag_update
)
1166 hDecoder
->ltp_lag
[cpe
->paired_channel
] = ltp2
->lag
;
1168 ltp2
->lag
= hDecoder
->ltp_lag
[cpe
->paired_channel
];
1172 /* long term prediction */
1173 lt_prediction(ics1
, ltp1
, spec_coef1
, hDecoder
->lt_pred_stat
[cpe
->channel
], hDecoder
->fb
,
1174 ics1
->window_shape
, hDecoder
->window_shape_prev
[cpe
->channel
],
1175 hDecoder
->sf_index
, hDecoder
->object_type
, hDecoder
->frameLength
);
1176 lt_prediction(ics2
, ltp2
, spec_coef2
, hDecoder
->lt_pred_stat
[cpe
->paired_channel
], hDecoder
->fb
,
1177 ics2
->window_shape
, hDecoder
->window_shape_prev
[cpe
->paired_channel
],
1178 hDecoder
->sf_index
, hDecoder
->object_type
, hDecoder
->frameLength
);
1183 tns_decode_frame(ics1
, &(ics1
->tns
), hDecoder
->sf_index
, hDecoder
->object_type
,
1184 spec_coef1
, hDecoder
->frameLength
);
1185 tns_decode_frame(ics2
, &(ics2
->tns
), hDecoder
->sf_index
, hDecoder
->object_type
,
1186 spec_coef2
, hDecoder
->frameLength
);
1189 if (hDecoder
->drc
->present
)
1191 if (!hDecoder
->drc
->exclude_mask
[cpe
->channel
] || !hDecoder
->drc
->excluded_chns_present
)
1192 drc_decode(hDecoder
->drc
, spec_coef1
);
1193 if (!hDecoder
->drc
->exclude_mask
[cpe
->paired_channel
] || !hDecoder
->drc
->excluded_chns_present
)
1194 drc_decode(hDecoder
->drc
, spec_coef2
);
1199 if (hDecoder
->object_type
!= SSR
)
1202 ifilter_bank(ics1
->window_sequence
,ics1
->window_shape
,
1203 hDecoder
->window_shape_prev
[cpe
->channel
],spec_coef1
,
1204 hDecoder
->time_out
[cpe
->channel
], hDecoder
->fb_intermed
[cpe
->channel
],
1205 hDecoder
->object_type
, hDecoder
->frameLength
);
1206 ifilter_bank(ics2
->window_sequence
,ics2
->window_shape
,
1207 hDecoder
->window_shape_prev
[cpe
->paired_channel
], spec_coef2
,
1208 hDecoder
->time_out
[cpe
->paired_channel
], hDecoder
->fb_intermed
[cpe
->paired_channel
],
1209 hDecoder
->object_type
, hDecoder
->frameLength
);
1212 ssr_decode(&(ics1
->ssr
), hDecoder
->fb
, ics1
->window_sequence
, ics1
->window_shape
,
1213 hDecoder
->window_shape_prev
[cpe
->channel
], spec_coef1
, hDecoder
->time_out
[cpe
->channel
],
1214 hDecoder
->ssr_overlap
[cpe
->channel
], hDecoder
->ipqf_buffer
[cpe
->channel
],
1215 hDecoder
->prev_fmd
[cpe
->channel
], hDecoder
->frameLength
);
1216 ssr_decode(&(ics2
->ssr
), hDecoder
->fb
, ics2
->window_sequence
, ics2
->window_shape
,
1217 hDecoder
->window_shape_prev
[cpe
->paired_channel
], spec_coef2
, hDecoder
->time_out
[cpe
->paired_channel
],
1218 hDecoder
->ssr_overlap
[cpe
->paired_channel
], hDecoder
->ipqf_buffer
[cpe
->paired_channel
],
1219 hDecoder
->prev_fmd
[cpe
->paired_channel
], hDecoder
->frameLength
);
1223 /* save window shape for next frame */
1224 hDecoder
->window_shape_prev
[cpe
->channel
] = ics1
->window_shape
;
1225 hDecoder
->window_shape_prev
[cpe
->paired_channel
] = ics2
->window_shape
;
1228 if (is_ltp_ot(hDecoder
->object_type
))
1230 lt_update_state(hDecoder
->lt_pred_stat
[cpe
->channel
], hDecoder
->time_out
[cpe
->channel
],
1231 hDecoder
->fb_intermed
[cpe
->channel
], hDecoder
->frameLength
, hDecoder
->object_type
);
1232 lt_update_state(hDecoder
->lt_pred_stat
[cpe
->paired_channel
], hDecoder
->time_out
[cpe
->paired_channel
],
1233 hDecoder
->fb_intermed
[cpe
->paired_channel
], hDecoder
->frameLength
, hDecoder
->object_type
);
1238 if (((hDecoder
->sbr_present_flag
== 1) || (hDecoder
->forceUpSampling
== 1))
1239 && hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
])
1241 uint8_t ele
= hDecoder
->fr_ch_ele
;
1242 uint8_t ch0
= cpe
->channel
;
1243 uint8_t ch1
= cpe
->paired_channel
;
1245 /* following case can happen when forceUpSampling == 1 */
1246 if (hDecoder
->sbr
[ele
] == NULL
)
1248 hDecoder
->sbr
[ele
] = sbrDecodeInit(hDecoder
->frameLength
,
1249 hDecoder
->element_id
[ele
], 2*get_sample_rate(hDecoder
->sf_index
),
1250 hDecoder
->downSampledSBR
1257 if (cpe
->ics1
.window_sequence
== EIGHT_SHORT_SEQUENCE
)
1258 hDecoder
->sbr
[ele
]->maxAACLine
= 8*cpe
->ics1
.swb_offset
[max(cpe
->ics1
.max_sfb
-1, 0)];
1260 hDecoder
->sbr
[ele
]->maxAACLine
= cpe
->ics1
.swb_offset
[max(cpe
->ics1
.max_sfb
-1, 0)];
1262 retval
= sbrDecodeCoupleFrame(hDecoder
->sbr
[ele
],
1263 hDecoder
->time_out
[ch0
], hDecoder
->time_out
[ch1
],
1264 hDecoder
->postSeekResetFlag
, hDecoder
->downSampledSBR
);
1267 } else if (((hDecoder
->sbr_present_flag
== 1) || (hDecoder
->forceUpSampling
== 1))
1268 && !hDecoder
->sbr_alloced
[hDecoder
->fr_ch_ele
])