diff options
author | diego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-09-24 17:31:36 +0000 |
---|---|---|
committer | diego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-09-24 17:31:36 +0000 |
commit | e1ece5e2eb68c81b1645c9ff989c833c4d67dfd8 (patch) | |
tree | 8553b3a4ef8164d14ff1b4a3f67e57cfa1d8908a /libfaad2/tns.c | |
parent | 2887bacbdb6bd320e4840fd230e92a59cc74b9ae (diff) | |
download | mpv-e1ece5e2eb68c81b1645c9ff989c833c4d67dfd8.tar.bz2 mpv-e1ece5e2eb68c81b1645c9ff989c833c4d67dfd8.tar.xz |
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
patch by adland <adland123 at yahoo dot com>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13454 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libfaad2/tns.c')
-rw-r--r-- | libfaad2/tns.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/libfaad2/tns.c b/libfaad2/tns.c index 9766bc703b..87902d7647 100644 --- a/libfaad2/tns.c +++ b/libfaad2/tns.c @@ -23,7 +23,7 @@ ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 -** $Id: tns.c,v 1.3 2004/06/02 22:59:04 diego Exp $ +** $Id: tns.c,v 1.4 2004/06/23 13:50:53 diego Exp $ ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ **/ @@ -241,24 +241,32 @@ static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l uint8_t j; uint16_t i; - real_t y, state[TNS_MAX_ORDER]; - - for (i = 0; i < order; i++) - state[i] = 0; + real_t y; + /* state is stored as a double ringbuffer */ + real_t state[2*TNS_MAX_ORDER] = {0}; + int8_t state_index = 0; for (i = 0; i < size; i++) { y = *spectrum; for (j = 0; j < order; j++) - y -= MUL_C(state[j], lpc[j+1]); + y -= MUL_C(state[state_index+j], lpc[j+1]); - for (j = order-1; j > 0; j--) - state[j] = state[j-1]; + /* double ringbuffer state */ + state_index--; + if (state_index < 0) + state_index = order-1; + state[state_index] = state[state_index + order] = y; - state[0] = y; *spectrum = y; spectrum += inc; + +//#define TNS_PRINT +#ifdef TNS_PRINT + //printf("%d\n", y); + printf("0x%.8X\n", y); +#endif } } @@ -276,10 +284,10 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l uint8_t j; uint16_t i; - real_t y, state[TNS_MAX_ORDER]; - - for (i = 0; i < order; i++) - state[i] = REAL_CONST(0.0); + real_t y; + /* state is stored as a double ringbuffer */ + real_t state[2*TNS_MAX_ORDER] = {0}; + int8_t state_index = 0; for (i = 0; i < size; i++) { @@ -288,10 +296,12 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l for (j = 0; j < order; j++) y += MUL_C(state[j], lpc[j+1]); - for (j = order-1; j > 0; j--) - state[j] = state[j-1]; + /* double ringbuffer state */ + state_index--; + if (state_index < 0) + state_index = order-1; + state[state_index] = state[state_index + order] = *spectrum; - state[0] = *spectrum; *spectrum = y; spectrum += inc; } |