Mercurial > mplayer.hg
comparison libfaad2/tns.c @ 13453:6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
patch by adland <adland123 at yahoo dot com>
author | diego |
---|---|
date | Fri, 24 Sep 2004 17:31:36 +0000 |
parents | d81145997036 |
children | 2ae5ab4331ca |
comparison
equal
deleted
inserted
replaced
13452:c364b7c13dd8 | 13453:6d50ef45a058 |
---|---|
21 ** | 21 ** |
22 ** Commercial non-GPL licensing of this software is possible. | 22 ** Commercial non-GPL licensing of this software is possible. |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
24 ** | 24 ** |
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 | 25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 |
26 ** $Id: tns.c,v 1.3 2004/06/02 22:59:04 diego Exp $ | 26 ** $Id: tns.c,v 1.4 2004/06/23 13:50:53 diego Exp $ |
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ | 27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
28 **/ | 28 **/ |
29 | 29 |
30 #include "common.h" | 30 #include "common.h" |
31 #include "structs.h" | 31 #include "structs.h" |
239 to the next data sample is given by "inc" | 239 to the next data sample is given by "inc" |
240 */ | 240 */ |
241 | 241 |
242 uint8_t j; | 242 uint8_t j; |
243 uint16_t i; | 243 uint16_t i; |
244 real_t y, state[TNS_MAX_ORDER]; | 244 real_t y; |
245 | 245 /* state is stored as a double ringbuffer */ |
246 for (i = 0; i < order; i++) | 246 real_t state[2*TNS_MAX_ORDER] = {0}; |
247 state[i] = 0; | 247 int8_t state_index = 0; |
248 | 248 |
249 for (i = 0; i < size; i++) | 249 for (i = 0; i < size; i++) |
250 { | 250 { |
251 y = *spectrum; | 251 y = *spectrum; |
252 | 252 |
253 for (j = 0; j < order; j++) | 253 for (j = 0; j < order; j++) |
254 y -= MUL_C(state[j], lpc[j+1]); | 254 y -= MUL_C(state[state_index+j], lpc[j+1]); |
255 | 255 |
256 for (j = order-1; j > 0; j--) | 256 /* double ringbuffer state */ |
257 state[j] = state[j-1]; | 257 state_index--; |
258 | 258 if (state_index < 0) |
259 state[0] = y; | 259 state_index = order-1; |
260 state[state_index] = state[state_index + order] = y; | |
261 | |
260 *spectrum = y; | 262 *spectrum = y; |
261 spectrum += inc; | 263 spectrum += inc; |
264 | |
265 //#define TNS_PRINT | |
266 #ifdef TNS_PRINT | |
267 //printf("%d\n", y); | |
268 printf("0x%.8X\n", y); | |
269 #endif | |
262 } | 270 } |
263 } | 271 } |
264 | 272 |
265 static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, | 273 static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, |
266 uint8_t order) | 274 uint8_t order) |
274 to the next data sample is given by "inc" | 282 to the next data sample is given by "inc" |
275 */ | 283 */ |
276 | 284 |
277 uint8_t j; | 285 uint8_t j; |
278 uint16_t i; | 286 uint16_t i; |
279 real_t y, state[TNS_MAX_ORDER]; | 287 real_t y; |
280 | 288 /* state is stored as a double ringbuffer */ |
281 for (i = 0; i < order; i++) | 289 real_t state[2*TNS_MAX_ORDER] = {0}; |
282 state[i] = REAL_CONST(0.0); | 290 int8_t state_index = 0; |
283 | 291 |
284 for (i = 0; i < size; i++) | 292 for (i = 0; i < size; i++) |
285 { | 293 { |
286 y = *spectrum; | 294 y = *spectrum; |
287 | 295 |
288 for (j = 0; j < order; j++) | 296 for (j = 0; j < order; j++) |
289 y += MUL_C(state[j], lpc[j+1]); | 297 y += MUL_C(state[j], lpc[j+1]); |
290 | 298 |
291 for (j = order-1; j > 0; j--) | 299 /* double ringbuffer state */ |
292 state[j] = state[j-1]; | 300 state_index--; |
293 | 301 if (state_index < 0) |
294 state[0] = *spectrum; | 302 state_index = order-1; |
303 state[state_index] = state[state_index + order] = *spectrum; | |
304 | |
295 *spectrum = y; | 305 *spectrum = y; |
296 spectrum += inc; | 306 spectrum += inc; |
297 } | 307 } |
298 } | 308 } |