www.pudn.com > g729_audio_encode.rar > filter.c
/*
ITU-T G.729 Speech Coder ANSI-C Source Code
Version 3.3 Last modified: December 26, 1995
Copyright (c) 1996,
AT&T, France Telecom, NTT, Universite de Sherbrooke, Lucent Technologies
All rights reserved.
*/
/*-------------------------------------------------------------------*
* Function Convolve: *
* ~~~~~~~~~ *
*-------------------------------------------------------------------*
* Perform the convolution between two vectors x[] and h[] and *
* write the result in the vector y[]. *
* All vectors are of length N. *
*-------------------------------------------------------------------*/
#include "typedef.h"
#include "basic_op.h"
#include "ld8k.h"
void Convolve(
Word16 x[], /* (i) : input vector */
Word16 h[], /* (i) Q12 : impulse response */
Word16 y[], /* (o) : output vector */
Word16 L /* (i) : vector size */
)
{
Word16 i, n;
Word32 s;
for (n = 0; n < L; n++)
{
s = 0;
for (i = 0; i <= n; i++)
s = L_mac(s, x[i], h[n-i]);
s = L_shl(s, 3); /* h is in Q12 and saturation */
y[n] = extract_h(s);
}
return;
}
/*-----------------------------------------------------*
* procedure Syn_filt: *
* ~~~~~~~~ *
* Do the synthesis filtering 1/A(z). *
*-----------------------------------------------------*/
void Syn_filt(
Word16 a[], /* (i) Q12 : a[m+1] prediction coefficients (m=10) */
Word16 x[], /* (i) : input signal */
Word16 y[], /* (o) : output signal */
Word16 lg, /* (i) : size of filtering */
Word16 mem[], /* (i/o) : memory associated with this filtering. */
Word16 update /* (i) : 0=no update, 1=update of memory. */
)
{
Word16 i, j;
Word32 s;
Word16 tmp[80]; /* This is usually done by memory allocation (lg+M) */
Word16 *yy;
/* Copy mem[] to yy[] */
yy = tmp;
for(i=0; i