summaryrefslogtreecommitdiff
path: root/src/libfaad/tns.c
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2005-10-29 23:57:06 +0000
committerMike Melanson <mike@multimedia.cx>2005-10-29 23:57:06 +0000
commit03ac29c63fd3d5019c67b3662669b1c443896f0b (patch)
tree00db769b2943fce16b9967591652d2c0724be168 /src/libfaad/tns.c
parentc7976c4d0d8d02fa18bc9fd82bafe99e333e2a53 (diff)
downloadxine-lib-03ac29c63fd3d5019c67b3662669b1c443896f0b.tar.gz
xine-lib-03ac29c63fd3d5019c67b3662669b1c443896f0b.tar.bz2
update libfaad2 to CVS snapshot 2004-09-15
CVS patchset: 7777 CVS date: 2005/10/29 23:57:06
Diffstat (limited to 'src/libfaad/tns.c')
-rw-r--r--src/libfaad/tns.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/libfaad/tns.c b/src/libfaad/tns.c
index 2252e02d2..bb4db731a 100644
--- a/src/libfaad/tns.c
+++ b/src/libfaad/tns.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: tns.c,v 1.7 2004/12/03 01:15:31 tmattern Exp $
+** $Id: tns.c,v 1.8 2005/10/29 23:57:07 tmmm Exp $
**/
#include "common.h"
@@ -239,24 +239,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
}
}
@@ -274,10 +282,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++)
{
@@ -286,10 +294,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;
}