Mercurial > mplayer.hg
annotate libfaad2/sbr_tf_grid.c @ 14585:81059277538c
Be less verbose with -v (do not print a line for each demuxed packet)
author | rtognimp |
---|---|
date | Mon, 24 Jan 2005 21:52:24 +0000 |
parents | 6d50ef45a058 |
children | 2ae5ab4331ca |
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 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
26 ** $Id: sbr_tf_grid.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 | 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 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
51 /* function constructs new time border vector */ |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
52 /* first build into temp vector to be able to use previous vector on error */ |
10989 | 53 uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) |
10725 | 54 { |
10989 | 55 uint8_t l, border, temp; |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
56 uint8_t t_E_temp[6] = {0}; |
10725 | 57 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
58 t_E_temp[0] = sbr->rate * sbr->abs_bord_lead[ch]; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
59 t_E_temp[sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch]; |
10725 | 60 |
61 switch (sbr->bs_frame_class[ch]) | |
62 { | |
63 case FIXFIX: | |
64 switch (sbr->L_E[ch]) | |
65 { | |
66 case 4: | |
10989 | 67 temp = (int) (sbr->numTimeSlots / 4); |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
68 t_E_temp[3] = sbr->rate * 3 * temp; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
69 t_E_temp[2] = sbr->rate * 2 * temp; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
70 t_E_temp[1] = sbr->rate * temp; |
10725 | 71 break; |
72 case 2: | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
73 t_E_temp[1] = sbr->rate * (int) (sbr->numTimeSlots / 2); |
10725 | 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 { | |
10989 | 88 if (border < sbr->bs_rel_bord[ch][l]) |
89 return 1; | |
90 | |
10725 | 91 border -= sbr->bs_rel_bord[ch][l]; |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
92 t_E_temp[--i] = sbr->rate * border; |
10725 | 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]; | |
10989 | 106 |
107 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
108 return 1; | |
109 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
110 t_E_temp[i++] = sbr->rate * border; |
10725 | 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]; | |
10989 | 124 |
125 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
126 return 1; | |
127 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
128 t_E_temp[i++] = sbr->rate * border; |
10725 | 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 { | |
10989 | 139 if (border < sbr->bs_rel_bord_1[ch][l]) |
140 return 1; | |
141 | |
10725 | 142 border -= sbr->bs_rel_bord_1[ch][l]; |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
143 t_E_temp[--i] = sbr->rate * border; |
10725 | 144 } |
145 } | |
146 break; | |
147 } | |
10989 | 148 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
149 /* no error occured, we can safely use this t_E vector */ |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
150 for (l = 0; l < 6; l++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
151 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
152 sbr->t_E[ch][l] = t_E_temp[l]; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
153 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
154 |
10989 | 155 return 0; |
10725 | 156 } |
157 | |
158 void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) | |
159 { | |
160 sbr->t_Q[ch][0] = sbr->t_E[ch][0]; | |
161 | |
162 if (sbr->L_E[ch] == 1) | |
163 { | |
164 sbr->t_Q[ch][1] = sbr->t_E[ch][1]; | |
165 sbr->t_Q[ch][2] = 0; | |
166 } else { | |
167 uint8_t index = middleBorder(sbr, ch); | |
168 sbr->t_Q[ch][1] = sbr->t_E[ch][index]; | |
169 sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; | |
170 } | |
171 } | |
172 | |
12527 | 173 #if 0 |
10725 | 174 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) |
175 { | |
176 uint8_t i; | |
177 int16_t acc = 0; | |
178 | |
179 switch (sbr->bs_frame_class[ch]) | |
180 { | |
181 case FIXFIX: | |
10989 | 182 return sbr->numTimeSlots/sbr->L_E[ch]; |
10725 | 183 case FIXVAR: |
184 return 0; | |
185 case VARFIX: | |
186 for (i = 0; i < l; i++) | |
187 { | |
188 acc += sbr->bs_rel_bord[ch][i]; | |
189 } | |
190 return acc; | |
191 case VARVAR: | |
192 for (i = 0; i < l; i++) | |
193 { | |
194 acc += sbr->bs_rel_bord_0[ch][i]; | |
195 } | |
196 return acc; | |
197 } | |
198 | |
199 return 0; | |
200 } | |
201 | |
202 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) | |
203 { | |
204 uint8_t i; | |
205 int16_t acc = 0; | |
206 | |
207 switch (sbr->bs_frame_class[ch]) | |
208 { | |
209 case FIXFIX: | |
210 case VARFIX: | |
211 return 0; | |
212 case FIXVAR: | |
213 for (i = 0; i < l; i++) | |
214 { | |
215 acc += sbr->bs_rel_bord[ch][i]; | |
216 } | |
217 return acc; | |
218 case VARVAR: | |
219 for (i = 0; i < l; i++) | |
220 { | |
221 acc += sbr->bs_rel_bord_1[ch][i]; | |
222 } | |
223 return acc; | |
224 } | |
225 | |
226 return 0; | |
227 } | |
12527 | 228 #endif |
10725 | 229 |
230 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) | |
231 { | |
12527 | 232 int8_t retval = 0; |
10725 | 233 |
234 switch (sbr->bs_frame_class[ch]) | |
235 { | |
236 case FIXFIX: | |
237 retval = sbr->L_E[ch]/2; | |
238 break; | |
239 case VARFIX: | |
240 if (sbr->bs_pointer[ch] == 0) | |
241 retval = 1; | |
242 else if (sbr->bs_pointer[ch] == 1) | |
243 retval = sbr->L_E[ch] - 1; | |
244 else | |
245 retval = sbr->bs_pointer[ch] - 1; | |
246 break; | |
247 case FIXVAR: | |
248 case VARVAR: | |
249 if (sbr->bs_pointer[ch] > 1) | |
250 retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; | |
251 else | |
252 retval = sbr->L_E[ch] - 1; | |
253 break; | |
254 } | |
255 | |
256 return (retval > 0) ? retval : 0; | |
257 } | |
258 | |
259 | |
260 #endif |