annotate libfaad2/specrec.c @ 11336:65b73210f2ec

etc/cygwin_inttypes.h moved to ftp.
author diego
date Fri, 31 Oct 2003 18:14:06 +0000
parents 3185f64f6350
children 4a370c80fe5c
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
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
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 **
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
25 ** $Id: specrec.c,v 1.27 2003/09/30 12:43:05 menno Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 Spectral reconstruction:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 - grouping/sectioning
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 - inverse quantization
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 - applying scalefactors
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "specrec.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "iq_table.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 static uint8_t num_swb_512_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 static uint8_t num_swb_480_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 static uint8_t num_swb_960_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 static uint8_t num_swb_1024_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 static uint8_t num_swb_128_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 static uint16_t swb_offset_1024_96[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 static uint16_t swb_offset_128_96[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 static uint16_t swb_offset_1024_64[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 304, 344, 384, 424, 464, 504, 544, 584, 624, 664, 704, 744, 784, 824,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 864, 904, 944, 984, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 static uint16_t swb_offset_128_64[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 static uint16_t swb_offset_1024_48[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 768, 800, 832, 864, 896, 928, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 static uint16_t swb_offset_512_48[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 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
107 92, 100, 112, 124, 136, 148, 164, 184, 208, 236, 268, 300, 332, 364, 396,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 428, 460, 512
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 static uint16_t swb_offset_480_48[] =
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, 28, 32, 36, 40, 44, 48, 52, 56, 64, 72 ,80 ,88,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 96, 108, 120, 132, 144, 156, 172, 188, 212, 240, 272, 304, 336, 368, 400,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 432, 480
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 static uint16_t swb_offset_128_48[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128
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 static uint16_t swb_offset_1024_32[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 768, 800, 832, 864, 896, 928, 960, 992, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 static uint16_t swb_offset_512_32[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 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
136 88, 96, 108, 120, 132, 144, 160, 176, 192, 212, 236, 260, 288, 320, 352,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 384, 416, 448, 480, 512
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 static uint16_t swb_offset_480_32[] =
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, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 88, 96, 104, 112, 124, 136, 148, 164, 180, 200, 224, 256, 288, 320, 352,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 384, 416, 448, 480
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 static uint16_t swb_offset_1024_24[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 76, 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 240, 260, 284, 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 768, 832, 896, 960, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 static uint16_t swb_offset_512_24[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160 80, 92, 104, 120, 140, 164, 192, 224, 256, 288, 320, 352, 384, 416,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 448, 480, 512
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 static uint16_t swb_offset_480_24[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 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
167 140, 164, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171 static uint16_t swb_offset_128_24[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 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
174 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 static uint16_t swb_offset_1024_16[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 static uint16_t swb_offset_128_16[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 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
186 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 static uint16_t swb_offset_1024_8[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 static uint16_t swb_offset_128_8[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 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
198 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 static uint16_t *swb_offset_1024_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 swb_offset_1024_96, /* 96000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203 swb_offset_1024_96, /* 88200 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 swb_offset_1024_64, /* 64000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 swb_offset_1024_48, /* 48000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 swb_offset_1024_48, /* 44100 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 swb_offset_1024_32, /* 32000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 swb_offset_1024_24, /* 24000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 swb_offset_1024_24, /* 22050 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 swb_offset_1024_16, /* 16000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 swb_offset_1024_16, /* 12000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 swb_offset_1024_16, /* 11025 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 swb_offset_1024_8 /* 8000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 static uint16_t *swb_offset_512_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 0, /* 96000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 0, /* 88200 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 0, /* 64000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 swb_offset_512_48, /* 48000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 swb_offset_512_48, /* 44100 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224 swb_offset_512_32, /* 32000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 swb_offset_512_24, /* 24000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 swb_offset_512_24, /* 22050 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 0, /* 16000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 0, /* 12000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 0, /* 11025 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 0 /* 8000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 static uint16_t *swb_offset_480_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 0, /* 96000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 0, /* 88200 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 0, /* 64000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 swb_offset_480_48, /* 48000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239 swb_offset_480_48, /* 44100 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240 swb_offset_480_32, /* 32000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 swb_offset_480_24, /* 24000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 swb_offset_480_24, /* 22050 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 0, /* 16000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 0, /* 12000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 0, /* 11025 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 0 /* 8000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 static uint16_t *swb_offset_128_window[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 swb_offset_128_96, /* 96000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 swb_offset_128_96, /* 88200 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254 swb_offset_128_64, /* 64000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 swb_offset_128_48, /* 48000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256 swb_offset_128_48, /* 44100 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 swb_offset_128_48, /* 32000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 swb_offset_128_24, /* 24000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259 swb_offset_128_24, /* 22050 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 swb_offset_128_16, /* 16000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261 swb_offset_128_16, /* 12000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 swb_offset_128_16, /* 11025 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263 swb_offset_128_8 /* 8000 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 #define bit_set(A, B) ((A) & (1<<(B)))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 /* 4.5.2.3.4 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 - determine the number of windows in a window_sequence named num_windows
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 - determine the number of window_groups named num_window_groups
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 - determine the number of windows in each group named window_group_length[g]
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 - determine the total number of scalefactor window bands named num_swb for
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 the actual window type
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 - determine swb_offset[swb], the offset of the first coefficient in
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 scalefactor window band named swb of the window actually used
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 - determine sect_sfb_offset[g][section],the offset of the first coefficient
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 in section named section. This offset depends on window_sequence and
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 scale_factor_grouping and is needed to decode the spectral_data().
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281 uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 uint8_t i, g;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 uint8_t sf_index = hDecoder->sf_index;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287 switch (ics->window_sequence) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288 case ONLY_LONG_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 case LONG_START_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290 case LONG_STOP_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 ics->num_windows = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292 ics->num_window_groups = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 ics->window_group_length[ics->num_window_groups-1] = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 if (hDecoder->frameLength == 512)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 ics->num_swb = num_swb_512_window[sf_index];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 else /* if (hDecoder->frameLength == 480) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 ics->num_swb = num_swb_480_window[sf_index];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 if (hDecoder->frameLength == 1024)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 ics->num_swb = num_swb_1024_window[sf_index];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305 else /* if (hDecoder->frameLength == 960) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 ics->num_swb = num_swb_960_window[sf_index];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311 /* preparation of sect_sfb_offset for long blocks */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312 /* also copy the last value! */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 if (hDecoder->frameLength == 512)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 for (i = 0; i < ics->num_swb; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320 ics->sect_sfb_offset[0][i] = swb_offset_512_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 ics->swb_offset[i] = swb_offset_512_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 } else /* if (hDecoder->frameLength == 480) */ {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324 for (i = 0; i < ics->num_swb; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 ics->sect_sfb_offset[0][i] = swb_offset_480_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
327 ics->swb_offset[i] = swb_offset_480_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 for (i = 0; i < ics->num_swb; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336 ics->sect_sfb_offset[0][i] = swb_offset_1024_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337 ics->swb_offset[i] = swb_offset_1024_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339 ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 case EIGHT_SHORT_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346 ics->num_windows = 8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 ics->num_window_groups = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
348 ics->window_group_length[ics->num_window_groups-1] = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
349 ics->num_swb = num_swb_128_window[sf_index];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 for (i = 0; i < ics->num_swb; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
352 ics->swb_offset[i] = swb_offset_128_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
353 ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355 for (i = 0; i < ics->num_windows-1; i++) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
356 if (bit_set(ics->scale_factor_grouping, 6-i) == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 ics->num_window_groups += 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 ics->window_group_length[ics->num_window_groups-1] = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 ics->window_group_length[ics->num_window_groups-1] += 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
365 /* preparation of sect_sfb_offset for short blocks */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
366 for (g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
368 uint16_t width;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369 uint8_t sect_sfb = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
370 uint16_t offset = 0;
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 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 if (i+1 == ics->num_swb)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
375 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
376 width = (hDecoder->frameLength/8) - swb_offset_128_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
377 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378 width = swb_offset_128_window[sf_index][i+1] -
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379 swb_offset_128_window[sf_index][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
381 width *= ics->window_group_length[g];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
382 ics->sect_sfb_offset[g][sect_sfb++] = offset;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
383 offset += width;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 ics->sect_sfb_offset[g][sect_sfb] = offset;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
387 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 return 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
394 For ONLY_LONG_SEQUENCE windows (num_window_groups = 1,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
395 window_group_length[0] = 1) the spectral data is in ascending spectral
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
396 order.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397 For the EIGHT_SHORT_SEQUENCE window, the spectral order depends on the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398 grouping in the following manner:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399 - Groups are ordered sequentially
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
400 - Within a group, a scalefactor band consists of the spectral data of all
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
401 grouped SHORT_WINDOWs for the associated scalefactor window band. To
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
402 clarify via example, the length of a group is in the range of one to eight
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 SHORT_WINDOWs.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404 - If there are eight groups each with length one (num_window_groups = 8,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 window_group_length[0..7] = 1), the result is a sequence of eight spectra,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406 each in ascending spectral order.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407 - If there is only one group with length eight (num_window_groups = 1,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 window_group_length[0] = 8), the result is that spectral data of all eight
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409 SHORT_WINDOWs is interleaved by scalefactor window bands.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 - Within a scalefactor window band, the coefficients are in ascending
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 spectral order.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
413 void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415 uint8_t g, sfb, win;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
416 uint16_t width, bin, k, gindex;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
417
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
418 real_t tmp_spec[1024];
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
419
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
420 memset(tmp_spec, 0, frame_len*sizeof(real_t));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
421
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
422 k = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
423 gindex = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
424
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
425 for (g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
426 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
427 uint16_t j = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
428 uint16_t gincrease = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
429 uint16_t win_inc = ics->swb_offset[ics->num_swb];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
430
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
431 for (sfb = 0; sfb < ics->num_swb; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
432 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
433 width = ics->swb_offset[sfb+1] - ics->swb_offset[sfb];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
434
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
435 for (win = 0; win < ics->window_group_length[g]; win++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
436 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
437 for (bin = 0; bin < width; bin += 4)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
438 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
439 tmp_spec[gindex+(win*win_inc)+j+bin+0] = spec_data[k+0];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
440 tmp_spec[gindex+(win*win_inc)+j+bin+1] = spec_data[k+1];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
441 tmp_spec[gindex+(win*win_inc)+j+bin+2] = spec_data[k+2];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
442 tmp_spec[gindex+(win*win_inc)+j+bin+3] = spec_data[k+3];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
443 gincrease += 4;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
444 k += 4;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
445 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
446 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
447 j += width;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
448 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
449 gindex += gincrease;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
450 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
451
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
452 memcpy(spec_data, tmp_spec, frame_len*sizeof(real_t));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
453 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
454
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
455 #ifndef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
456 void build_tables(real_t *pow2_table)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
457 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
458 uint16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
460 /* build pow(2, 0.25*x) table for scalefactors */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
461 for(i = 0; i < POW_TABLE_SIZE; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
462 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
463 pow2_table[i] = REAL_CONST(pow(2.0, 0.25 * (i-100)));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
465 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
466 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 static INLINE real_t iquant(int16_t q, real_t *tab)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
470 #ifdef FIXED_POINT
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
471 int16_t sgn = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
472
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473 if (q == 0) return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
475 if (q < 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 q = -q;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
478 sgn = -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
479 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481 if (q >= IQ_TABLE_SIZE)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
482 return 0; /* sgn * tab[q>>3] * 16; */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484 return sgn * tab[q];
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
485 #else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
486 int16_t sgn = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
487
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
488 if (q == 0) return 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
489
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
490 if (q < 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
491 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
492 q = -q;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
493 sgn = -1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
494 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
495
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
496 if (q < IQ_TABLE_SIZE)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
497 return sgn * tab[q];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
498
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
499 return sgn * pow(q, 4./3.);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
500 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
501 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
503 void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
504 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505 int16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506 real_t *tab = iq_table;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
507
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
508 for(i = 0; i < frame_len; i+=4)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
510 x_invquant[i] = iquant(x_quant[i], tab);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
511 x_invquant[i+1] = iquant(x_quant[i+1], tab);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
512 x_invquant[i+2] = iquant(x_quant[i+2], tab);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
513 x_invquant[i+3] = iquant(x_quant[i+3], tab);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
514 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
515 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
517 #ifndef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518 static INLINE real_t get_scale_factor_gain(uint16_t scale_factor, real_t *pow2_table)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
519 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
520 if (scale_factor < POW_TABLE_SIZE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
521 return pow2_table[scale_factor];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
523 return REAL_CONST(pow(2.0, 0.25 * (scale_factor - 100)));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
525 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
526 static real_t pow2_table[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
527 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
528 COEF_CONST(0.59460355750136),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
529 COEF_CONST(0.70710678118655),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
530 COEF_CONST(0.84089641525371),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 COEF_CONST(1.0),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532 COEF_CONST(1.18920711500272),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533 COEF_CONST(1.41421356237310),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 COEF_CONST(1.68179283050743)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
536 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538 void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 uint16_t frame_len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 uint8_t g, sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
542 uint16_t top;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543 #ifndef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
544 real_t scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 int32_t exp, frac;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 uint8_t groups = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549 uint16_t nshort = frame_len/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
550
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
551 static real_t max_fp = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
552 static real_t max_exp = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
553 static real_t max_frac = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
554
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555 for (g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557 uint16_t k = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
559 /* using this nshort*groups doesn't hurt long blocks, because
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 long blocks only have 1 group, so that means 'groups' is
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 always 0 for long blocks
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 for (sfb = 0; sfb < ics->max_sfb; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
564 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565 top = ics->sect_sfb_offset[g][sfb+1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 #ifndef FIXED_POINT
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
568 scale = get_scale_factor_gain(ics->scale_factors[g][sfb], hDecoder->pow2_table);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 exp = (ics->scale_factors[g][sfb] - 100) / 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571 frac = (ics->scale_factors[g][sfb] - 100) % 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
573 /* IMDCT pre-scaling */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576 exp -= 6 /*9*/;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
577 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579 exp -= 4 /*7*/;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
581 exp -= 7 /*10*/;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
582 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
585 /* minimum size of a sf band is 4 and always a multiple of 4 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
586 for ( ; k < top; k += 4)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
587 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
588 #ifndef FIXED_POINT
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
589 x_invquant[k+(groups*nshort)] = x_invquant[k+(groups*nshort)] * scale;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
590 x_invquant[k+(groups*nshort)+1] = x_invquant[k+(groups*nshort)+1] * scale;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
591 x_invquant[k+(groups*nshort)+2] = x_invquant[k+(groups*nshort)+2] * scale;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
592 x_invquant[k+(groups*nshort)+3] = x_invquant[k+(groups*nshort)+3] * scale;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
594 if (exp < 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
596 x_invquant[k+(groups*nshort)] >>= -exp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
597 x_invquant[k+(groups*nshort)+1] >>= -exp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
598 x_invquant[k+(groups*nshort)+2] >>= -exp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
599 x_invquant[k+(groups*nshort)+3] >>= -exp;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
600 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
601 x_invquant[k+(groups*nshort)] <<= exp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
602 x_invquant[k+(groups*nshort)+1] <<= exp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
603 x_invquant[k+(groups*nshort)+2] <<= exp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
604 x_invquant[k+(groups*nshort)+3] <<= exp;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
605 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
606
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
607 if (frac)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
608 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
609 x_invquant[k+(groups*nshort)] = MUL_R_C(x_invquant[k+(groups*nshort)],pow2_table[frac + 3]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
610 x_invquant[k+(groups*nshort)+1] = MUL_R_C(x_invquant[k+(groups*nshort)+1],pow2_table[frac + 3]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
611 x_invquant[k+(groups*nshort)+2] = MUL_R_C(x_invquant[k+(groups*nshort)+2],pow2_table[frac + 3]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
612 x_invquant[k+(groups*nshort)+3] = MUL_R_C(x_invquant[k+(groups*nshort)+3],pow2_table[frac + 3]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
614 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
615 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
617 groups += ics->window_group_length[g];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
619 }