Mercurial > mplayer.hg
annotate libfaad2/sbr_tf_grid.c @ 32613:e006d3eb4e60
Treat non-ref frames like B-frames even if has_b_frames is not set and
they are indeed not B-frames (no reordering).
This happens with flv files, as in bug #1079, and this change fixes that
corruption.
author | reimar |
---|---|
date | Sun, 12 Dec 2010 10:23:41 +0000 |
parents | e83eef58b30a |
children |
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 |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
18141
diff
changeset
|
4 ** |
10725 | 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. | |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
18141
diff
changeset
|
9 ** |
10725 | 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. | |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
18141
diff
changeset
|
14 ** |
10725 | 15 ** You should have received a copy of the GNU General Public License |
29264
e83eef58b30a
Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents:
18141
diff
changeset
|
16 ** along with this program; if not, write to the Free Software |
10725 | 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 ** | |
18141 | 25 ** $Id: sbr_tf_grid.c,v 1.15 2004/09/04 14:56:28 menno Exp $ |
10725 | 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 | |
12527 | 40 |
41 /* static function declarations */ | |
42 #if 0 | |
43 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l); | |
44 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l); | |
45 #endif | |
46 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch); | |
47 | |
48 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
49 /* 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
|
50 /* first build into temp vector to be able to use previous vector on error */ |
10989 | 51 uint8_t envelope_time_border_vector(sbr_info *sbr, uint8_t ch) |
10725 | 52 { |
10989 | 53 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
|
54 uint8_t t_E_temp[6] = {0}; |
10725 | 55 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
56 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
|
57 t_E_temp[sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch]; |
10725 | 58 |
59 switch (sbr->bs_frame_class[ch]) | |
60 { | |
61 case FIXFIX: | |
62 switch (sbr->L_E[ch]) | |
63 { | |
64 case 4: | |
10989 | 65 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
|
66 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
|
67 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
|
68 t_E_temp[1] = sbr->rate * temp; |
10725 | 69 break; |
70 case 2: | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
71 t_E_temp[1] = sbr->rate * (int) (sbr->numTimeSlots / 2); |
10725 | 72 break; |
73 default: | |
74 break; | |
75 } | |
76 break; | |
77 | |
78 case FIXVAR: | |
79 if (sbr->L_E[ch] > 1) | |
80 { | |
81 int8_t i = sbr->L_E[ch]; | |
82 border = sbr->abs_bord_trail[ch]; | |
83 | |
84 for (l = 0; l < (sbr->L_E[ch] - 1); l++) | |
85 { | |
10989 | 86 if (border < sbr->bs_rel_bord[ch][l]) |
87 return 1; | |
88 | |
10725 | 89 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
|
90 t_E_temp[--i] = sbr->rate * border; |
10725 | 91 } |
92 } | |
93 break; | |
94 | |
95 case VARFIX: | |
96 if (sbr->L_E[ch] > 1) | |
97 { | |
98 int8_t i = 1; | |
99 border = sbr->abs_bord_lead[ch]; | |
100 | |
101 for (l = 0; l < (sbr->L_E[ch] - 1); l++) | |
102 { | |
103 border += sbr->bs_rel_bord[ch][l]; | |
10989 | 104 |
105 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
106 return 1; | |
107 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
108 t_E_temp[i++] = sbr->rate * border; |
10725 | 109 } |
110 } | |
111 break; | |
112 | |
113 case VARVAR: | |
114 if (sbr->bs_num_rel_0[ch]) | |
115 { | |
116 int8_t i = 1; | |
117 border = sbr->abs_bord_lead[ch]; | |
118 | |
119 for (l = 0; l < sbr->bs_num_rel_0[ch]; l++) | |
120 { | |
121 border += sbr->bs_rel_bord_0[ch][l]; | |
10989 | 122 |
123 if (sbr->rate * border + sbr->tHFAdj > sbr->numTimeSlotsRate+sbr->tHFGen) | |
124 return 1; | |
125 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
126 t_E_temp[i++] = sbr->rate * border; |
10725 | 127 } |
128 } | |
129 | |
130 if (sbr->bs_num_rel_1[ch]) | |
131 { | |
132 int8_t i = sbr->L_E[ch]; | |
133 border = sbr->abs_bord_trail[ch]; | |
134 | |
135 for (l = 0; l < sbr->bs_num_rel_1[ch]; l++) | |
136 { | |
10989 | 137 if (border < sbr->bs_rel_bord_1[ch][l]) |
138 return 1; | |
139 | |
10725 | 140 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
|
141 t_E_temp[--i] = sbr->rate * border; |
10725 | 142 } |
143 } | |
144 break; | |
145 } | |
10989 | 146 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
147 /* 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
|
148 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
|
149 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
150 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
|
151 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
152 |
10989 | 153 return 0; |
10725 | 154 } |
155 | |
156 void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch) | |
157 { | |
158 sbr->t_Q[ch][0] = sbr->t_E[ch][0]; | |
159 | |
160 if (sbr->L_E[ch] == 1) | |
161 { | |
162 sbr->t_Q[ch][1] = sbr->t_E[ch][1]; | |
163 sbr->t_Q[ch][2] = 0; | |
164 } else { | |
165 uint8_t index = middleBorder(sbr, ch); | |
166 sbr->t_Q[ch][1] = sbr->t_E[ch][index]; | |
167 sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]]; | |
168 } | |
169 } | |
170 | |
12527 | 171 #if 0 |
10725 | 172 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l) |
173 { | |
174 uint8_t i; | |
175 int16_t acc = 0; | |
176 | |
177 switch (sbr->bs_frame_class[ch]) | |
178 { | |
179 case FIXFIX: | |
10989 | 180 return sbr->numTimeSlots/sbr->L_E[ch]; |
10725 | 181 case FIXVAR: |
182 return 0; | |
183 case VARFIX: | |
184 for (i = 0; i < l; i++) | |
185 { | |
186 acc += sbr->bs_rel_bord[ch][i]; | |
187 } | |
188 return acc; | |
189 case VARVAR: | |
190 for (i = 0; i < l; i++) | |
191 { | |
192 acc += sbr->bs_rel_bord_0[ch][i]; | |
193 } | |
194 return acc; | |
195 } | |
196 | |
197 return 0; | |
198 } | |
199 | |
200 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l) | |
201 { | |
202 uint8_t i; | |
203 int16_t acc = 0; | |
204 | |
205 switch (sbr->bs_frame_class[ch]) | |
206 { | |
207 case FIXFIX: | |
208 case VARFIX: | |
209 return 0; | |
210 case FIXVAR: | |
211 for (i = 0; i < l; i++) | |
212 { | |
213 acc += sbr->bs_rel_bord[ch][i]; | |
214 } | |
215 return acc; | |
216 case VARVAR: | |
217 for (i = 0; i < l; i++) | |
218 { | |
219 acc += sbr->bs_rel_bord_1[ch][i]; | |
220 } | |
221 return acc; | |
222 } | |
223 | |
224 return 0; | |
225 } | |
12527 | 226 #endif |
10725 | 227 |
228 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch) | |
229 { | |
12527 | 230 int8_t retval = 0; |
10725 | 231 |
232 switch (sbr->bs_frame_class[ch]) | |
233 { | |
234 case FIXFIX: | |
235 retval = sbr->L_E[ch]/2; | |
236 break; | |
237 case VARFIX: | |
238 if (sbr->bs_pointer[ch] == 0) | |
239 retval = 1; | |
240 else if (sbr->bs_pointer[ch] == 1) | |
241 retval = sbr->L_E[ch] - 1; | |
242 else | |
243 retval = sbr->bs_pointer[ch] - 1; | |
244 break; | |
245 case FIXVAR: | |
246 case VARVAR: | |
247 if (sbr->bs_pointer[ch] > 1) | |
248 retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; | |
249 else | |
250 retval = sbr->L_E[ch] - 1; | |
251 break; | |
252 } | |
253 | |
254 return (retval > 0) ? retval : 0; | |
255 } | |
256 | |
257 | |
258 #endif |