annotate libfaad2/specrec.c @ 13941:00d6903e0c56

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