Mercurial > mplayer.hg
annotate libfaad2/sbr_tf_grid.c @ 12681:6d815f12e3e5
rtc-device cmd option by James Noble
author | alex |
---|---|
date | Sat, 26 Jun 2004 10:51:44 +0000 |
parents | d81145997036 |
children | 6d50ef45a058 |
rev | line source |
---|---|
10725 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
12527 | 3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
10725 | 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 ** | |
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 |
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
26 ** $Id: sbr_tf_grid.c,v 1.3 2004/06/02 22:59:03 diego Exp $ |
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 | 28 **/ |
29 | |
30 /* Time/Frequency grid */ | |
31 | |
32 #include "common.h" | |
33 #include "structs.h" | |
34 | |
35 #ifdef SBR_DEC | |
36 | |
37 #include <stdlib.h> | |
38 | |
39 #include "sbr_syntax.h" | |
40 #include "sbr_tf_grid.h" | |
41 | |
12527 | 42 |
43 /* static function declarations */ | |
44 #if 0 | |
45 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l); | |
46 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l); | |
47 #endif | |
48 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch); | |
49 | |
50 | |
10989 | 51 uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) |
10725 | 52 { |
10989 | 53 uint8_t l, border, temp; |
10725 | 54 |
55 for (l = 0; l <= sbr->L_E[ch]; l++) | |
56 { | |
57 sbr->t_E[ch][l] = 0; | |
58 } | |
59 | |
60 sbr->t_E[ch][0] = sbr->rate * sbr->abs_bord_lead[ch]; | |
61 sbr->t_E[ch][sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch]; | |
62 | |
63 switch (sbr->bs_frame_class[ch]) | |
64 { | |
65 case FIXFIX: | |
66 switch (sbr->L_E[ch]) | |
67 { | |
68 case 4: | |
10989 | 69 temp = (int) (sbr->numTimeSlots / 4); |
70 sbr->t_E[ch][3] = sbr->rate * 3 * temp; | |
71 sbr->t_E[ch][2] = sbr->rate * 2 * temp; | |
72 sbr->t_E[ch][1] = sbr->rate * temp; | |
10725 | 73 break; |
74 case 2: | |
10989 | 75 sbr->t_E[ch][1] = sbr->rate * (int) (sbr->numTimeSlots / 2); |
10725 | 76 break; |
77 default: | |
78 break; | |
79 } | |
80 break; | |
81 | |
82 case FIXVAR: | |
83 if (sbr->L_E[ch] > 1) | |
84 { | |
85 int8_t i = sbr->L_E[ch]; | |
86 border = sbr->abs_bord_trail[ch]; | |
87 | |
88 for (l = 0; l < (sbr->L_E[ch] - 1); l++) | |
89 { | |
10989 | 90 if (border < sbr->bs_rel_bord[ch][l]) |
91 return 1; | |
92 | |
10725 | 93 border -= sbr->bs_rel_bord[ch][l]; |
94 sbr->t_E[ch][--i] = sbr->rate * border; | |
95 } | |
96 } | |
97 break; | |
98 | |
99 case VARFIX: | |
100 if (sbr->L_E[ch] > 1) | |
101 { | |
102 int8_t i = 1; | |
103 border = sbr->abs_bord_lead[ch]; | |
104 | |
105 for (l = 0; l < (sbr->L_E[ch] - 1); l++) | |
106 { | |
107 border += sbr->bs_rel_bord[ch][l]; | |
10989 | 108 |
109 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
110 return 1; | |
111 | |
10725 | 112 sbr->t_E[ch][i++] = sbr->rate * border; |
113 } | |
114 } | |
115 break; | |
116 | |
117 case VARVAR: | |
118 if (sbr->bs_num_rel_0[ch]) | |
119 { | |
120 int8_t i = 1; | |
121 border = sbr->abs_bord_lead[ch]; | |
122 | |
123 for (l = 0; l < sbr->bs_num_rel_0[ch]; l++) | |
124 { | |
125 border += sbr->bs_rel_bord_0[ch][l]; | |
10989 | 126 |
127 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
128 return 1; | |
129 | |
10725 | 130 sbr->t_E[ch][i++] = sbr->rate * border; |
131 } | |
132 } | |
133 | |
134 if (sbr->bs_num_rel_1[ch]) | |
135 { | |
136 int8_t i = sbr->L_E[ch]; | |
137 border = sbr->abs_bord_trail[ch]; | |
138 | |
139 for (l = 0; l < sbr->bs_num_rel_1[ch]; l++) | |
140 { | |
10989 | 141 if (border < sbr->bs_rel_bord_1[ch][l]) |
142 return 1; | |
143 | |
10725 | 144 border -= sbr->bs_rel_bord_1[ch][l]; |
145 sbr->t_E[ch][--i] = sbr->rate * border; | |
146 } | |
147 } | |
148 break; | |
149 } | |
10989 | 150 |
151 return 0; | |
10725 | 152 } |
153 | |
154 void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) | |
155 { | |
156 sbr->t_Q[ch][0] = sbr->t_E[ch][0]; | |
157 | |
158 if (sbr->L_E[ch] == 1) | |
159 { | |
160 sbr->t_Q[ch][1] = sbr->t_E[ch][1]; | |
161 sbr->t_Q[ch][2] = 0; | |
162 } else { | |
163 uint8_t index = middleBorder(sbr, ch); | |
164 sbr->t_Q[ch][1] = sbr->t_E[ch][index]; | |
165 sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; | |
166 } | |
167 } | |
168 | |
12527 | 169 #if 0 |
10725 | 170 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) |
171 { | |
172 uint8_t i; | |
173 int16_t acc = 0; | |
174 | |
175 switch (sbr->bs_frame_class[ch]) | |
176 { | |
177 case FIXFIX: | |
10989 | 178 return sbr->numTimeSlots/sbr->L_E[ch]; |
10725 | 179 case FIXVAR: |
180 return 0; | |
181 case VARFIX: | |
182 for (i = 0; i < l; i++) | |
183 { | |
184 acc += sbr->bs_rel_bord[ch][i]; | |
185 } | |
186 return acc; | |
187 case VARVAR: | |
188 for (i = 0; i < l; i++) | |
189 { | |
190 acc += sbr->bs_rel_bord_0[ch][i]; | |
191 } | |
192 return acc; | |
193 } | |
194 | |
195 return 0; | |
196 } | |
197 | |
198 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) | |
199 { | |
200 uint8_t i; | |
201 int16_t acc = 0; | |
202 | |
203 switch (sbr->bs_frame_class[ch]) | |
204 { | |
205 case FIXFIX: | |
206 case VARFIX: | |
207 return 0; | |
208 case FIXVAR: | |
209 for (i = 0; i < l; i++) | |
210 { | |
211 acc += sbr->bs_rel_bord[ch][i]; | |
212 } | |
213 return acc; | |
214 case VARVAR: | |
215 for (i = 0; i < l; i++) | |
216 { | |
217 acc += sbr->bs_rel_bord_1[ch][i]; | |
218 } | |
219 return acc; | |
220 } | |
221 | |
222 return 0; | |
223 } | |
12527 | 224 #endif |
10725 | 225 |
226 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) | |
227 { | |
12527 | 228 int8_t retval = 0; |
10725 | 229 |
230 switch (sbr->bs_frame_class[ch]) | |
231 { | |
232 case FIXFIX: | |
233 retval = sbr->L_E[ch]/2; | |
234 break; | |
235 case VARFIX: | |
236 if (sbr->bs_pointer[ch] == 0) | |
237 retval = 1; | |
238 else if (sbr->bs_pointer[ch] == 1) | |
239 retval = sbr->L_E[ch] - 1; | |
240 else | |
241 retval = sbr->bs_pointer[ch] - 1; | |
242 break; | |
243 case FIXVAR: | |
244 case VARVAR: | |
245 if (sbr->bs_pointer[ch] > 1) | |
246 retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; | |
247 else | |
248 retval = sbr->L_E[ch] - 1; | |
249 break; | |
250 } | |
251 | |
252 return (retval > 0) ? retval : 0; | |
253 } | |
254 | |
255 | |
256 #endif |