Mercurial > audlegacy
annotate Plugins/Input/aac/libfaad2/sbr_tf_grid.c @ 1010:29feaace84d0 trunk
[svn] - synchronize audacious-faad with FAAD2 CVS.
author | nenolod |
---|---|
date | Mon, 08 May 2006 06:56:47 -0700 |
parents | 0a2ad94e8607 |
children | 1e6c0a3f2d15 |
rev | line source |
---|---|
61 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
61 | 4 ** |
5 ** This program is free software; you can redistribute it and/or modify | |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
9 ** | |
10 ** This program is distributed in the hope that it will be useful, | |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
14 ** | |
15 ** You should have received a copy of the GNU General Public License | |
16 ** along with this program; if not, write to the Free Software | |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 ** | |
19 ** Any non-GPL usage of this software or parts of this software is strictly | |
20 ** forbidden. | |
21 ** | |
22 ** Commercial non-GPL licensing of this software is possible. | |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | |
24 ** | |
1010 | 25 ** $Id: sbr_tf_grid.c,v 1.10 2004/01/05 14:05:12 menno Exp $ |
61 | 26 **/ |
27 | |
28 /* Time/Frequency grid */ | |
29 | |
30 #include "common.h" | |
31 #include "structs.h" | |
32 | |
33 #ifdef SBR_DEC | |
34 | |
35 #include <stdlib.h> | |
36 | |
37 #include "sbr_syntax.h" | |
38 #include "sbr_tf_grid.h" | |
39 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
40 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
41 /* static function declarations */ |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
42 #if 0 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
43 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
44 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
45 #endif |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
46 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch); |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
47 |
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
48 |
61 | 49 uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) |
50 { | |
51 uint8_t l, border, temp; | |
52 | |
1010 | 53 for (l = 0; l <= sbr->L_E[ch]; l++) |
54 { | |
55 sbr->t_E[ch][l] = 0; | |
56 } | |
57 | |
58 sbr->t_E[ch][0] = sbr->rate * sbr->abs_bord_lead[ch]; | |
59 sbr->t_E[ch][sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch]; | |
61 | 60 |
61 switch (sbr->bs_frame_class[ch]) | |
62 { | |
63 case FIXFIX: | |
64 switch (sbr->L_E[ch]) | |
65 { | |
66 case 4: | |
67 temp = (int) (sbr->numTimeSlots / 4); | |
1010 | 68 sbr->t_E[ch][3] = sbr->rate * 3 * temp; |
69 sbr->t_E[ch][2] = sbr->rate * 2 * temp; | |
70 sbr->t_E[ch][1] = sbr->rate * temp; | |
61 | 71 break; |
72 case 2: | |
1010 | 73 sbr->t_E[ch][1] = sbr->rate * (int) (sbr->numTimeSlots / 2); |
61 | 74 break; |
75 default: | |
76 break; | |
77 } | |
78 break; | |
79 | |
80 case FIXVAR: | |
81 if (sbr->L_E[ch] > 1) | |
82 { | |
83 int8_t i = sbr->L_E[ch]; | |
84 border = sbr->abs_bord_trail[ch]; | |
85 | |
86 for (l = 0; l < (sbr->L_E[ch] - 1); l++) | |
87 { | |
88 if (border < sbr->bs_rel_bord[ch][l]) | |
89 return 1; | |
90 | |
91 border -= sbr->bs_rel_bord[ch][l]; | |
1010 | 92 sbr->t_E[ch][--i] = sbr->rate * border; |
61 | 93 } |
94 } | |
95 break; | |
96 | |
97 case VARFIX: | |
98 if (sbr->L_E[ch] > 1) | |
99 { | |
100 int8_t i = 1; | |
101 border = sbr->abs_bord_lead[ch]; | |
102 | |
103 for (l = 0; l < (sbr->L_E[ch] - 1); l++) | |
104 { | |
105 border += sbr->bs_rel_bord[ch][l]; | |
106 | |
107 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
108 return 1; | |
109 | |
1010 | 110 sbr->t_E[ch][i++] = sbr->rate * border; |
61 | 111 } |
112 } | |
113 break; | |
114 | |
115 case VARVAR: | |
116 if (sbr->bs_num_rel_0[ch]) | |
117 { | |
118 int8_t i = 1; | |
119 border = sbr->abs_bord_lead[ch]; | |
120 | |
121 for (l = 0; l < sbr->bs_num_rel_0[ch]; l++) | |
122 { | |
123 border += sbr->bs_rel_bord_0[ch][l]; | |
124 | |
125 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
126 return 1; | |
127 | |
1010 | 128 sbr->t_E[ch][i++] = sbr->rate * border; |
61 | 129 } |
130 } | |
131 | |
132 if (sbr->bs_num_rel_1[ch]) | |
133 { | |
134 int8_t i = sbr->L_E[ch]; | |
135 border = sbr->abs_bord_trail[ch]; | |
136 | |
137 for (l = 0; l < sbr->bs_num_rel_1[ch]; l++) | |
138 { | |
139 if (border < sbr->bs_rel_bord_1[ch][l]) | |
140 return 1; | |
141 | |
142 border -= sbr->bs_rel_bord_1[ch][l]; | |
1010 | 143 sbr->t_E[ch][--i] = sbr->rate * border; |
61 | 144 } |
145 } | |
146 break; | |
147 } | |
148 | |
149 return 0; | |
150 } | |
151 | |
152 void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) | |
153 { | |
154 sbr->t_Q[ch][0] = sbr->t_E[ch][0]; | |
155 | |
156 if (sbr->L_E[ch] == 1) | |
157 { | |
158 sbr->t_Q[ch][1] = sbr->t_E[ch][1]; | |
159 sbr->t_Q[ch][2] = 0; | |
160 } else { | |
161 uint8_t index = middleBorder(sbr, ch); | |
162 sbr->t_Q[ch][1] = sbr->t_E[ch][index]; | |
163 sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; | |
164 } | |
165 } | |
166 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
167 #if 0 |
61 | 168 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) |
169 { | |
170 uint8_t i; | |
171 int16_t acc = 0; | |
172 | |
173 switch (sbr->bs_frame_class[ch]) | |
174 { | |
175 case FIXFIX: | |
176 return sbr->numTimeSlots/sbr->L_E[ch]; | |
177 case FIXVAR: | |
178 return 0; | |
179 case VARFIX: | |
180 for (i = 0; i < l; i++) | |
181 { | |
182 acc += sbr->bs_rel_bord[ch][i]; | |
183 } | |
184 return acc; | |
185 case VARVAR: | |
186 for (i = 0; i < l; i++) | |
187 { | |
188 acc += sbr->bs_rel_bord_0[ch][i]; | |
189 } | |
190 return acc; | |
191 } | |
192 | |
193 return 0; | |
194 } | |
195 | |
196 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) | |
197 { | |
198 uint8_t i; | |
199 int16_t acc = 0; | |
200 | |
201 switch (sbr->bs_frame_class[ch]) | |
202 { | |
203 case FIXFIX: | |
204 case VARFIX: | |
205 return 0; | |
206 case FIXVAR: | |
207 for (i = 0; i < l; i++) | |
208 { | |
209 acc += sbr->bs_rel_bord[ch][i]; | |
210 } | |
211 return acc; | |
212 case VARVAR: | |
213 for (i = 0; i < l; i++) | |
214 { | |
215 acc += sbr->bs_rel_bord_1[ch][i]; | |
216 } | |
217 return acc; | |
218 } | |
219 | |
220 return 0; | |
221 } | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
222 #endif |
61 | 223 |
224 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) | |
225 { | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
226 int8_t retval = 0; |
61 | 227 |
228 switch (sbr->bs_frame_class[ch]) | |
229 { | |
230 case FIXFIX: | |
231 retval = sbr->L_E[ch]/2; | |
232 break; | |
233 case VARFIX: | |
234 if (sbr->bs_pointer[ch] == 0) | |
235 retval = 1; | |
236 else if (sbr->bs_pointer[ch] == 1) | |
237 retval = sbr->L_E[ch] - 1; | |
238 else | |
239 retval = sbr->bs_pointer[ch] - 1; | |
240 break; | |
241 case FIXVAR: | |
242 case VARVAR: | |
243 if (sbr->bs_pointer[ch] > 1) | |
244 retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; | |
245 else | |
246 retval = sbr->L_E[ch] - 1; | |
247 break; | |
248 } | |
249 | |
250 return (retval > 0) ? retval : 0; | |
251 } | |
252 | |
253 | |
254 #endif |