/*************************************************************************
 *
 *  FUNCTION:  Residu
 *
 *  PURPOSE:  Computes the LP residual.
 *
 *  DESCRIPTION:
 *     The LP residual is computed by filtering the input speech through
 *     the LP inverse filter A(z).
 *
 *************************************************************************/

#include "typedef.h"
#include "cnst.h"

/* m = LPC order == 10 */
#define m 10

void Residu (
    Word16 a[], /* (i)     : prediction coefficients                      */
    Word16 x[], /* (i)     : speech signal                                */
    Word16 y[]  /* (o)     : residual signal                              */
)
{
    Word16 i, j;
    Word32 s;

    for (i = 0; i < L_SUBFR; i++)
    {
				s = 0;
        for (j = 0; j <= m; j++)
        {
            s += (Word32)(a[j] * x[i - j]);
        }
        y[i] = (Word16)((s + (1 << 11)) >> 12);
    }
}
