syntFilter.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /******************************************************************
  2. iLBC Speech Coder ANSI-C Source Code
  3. syntFilter.c
  4. Copyright (C) The Internet Society (2004).
  5. All Rights Reserved.
  6. ******************************************************************/
  7. #include "iLBC_define.h"
  8. /*----------------------------------------------------------------*
  9. * LP synthesis filter.
  10. *---------------------------------------------------------------*/
  11. void syntFilter(
  12. float *Out, /* (i/o) Signal to be filtered */
  13. float *a, /* (i) LP parameters */
  14. int len, /* (i) Length of signal */
  15. float *mem /* (i/o) Filter state */
  16. ){
  17. int i, j;
  18. float *po, *pi, *pa, *pm;
  19. po=Out;
  20. /* Filter first part using memory from past */
  21. for (i=0; i<LPC_FILTERORDER; i++) {
  22. pi=&Out[i-1];
  23. pa=&a[1];
  24. pm=&mem[LPC_FILTERORDER-1];
  25. for (j=1; j<=i; j++) {
  26. *po-=(*pa++)*(*pi--);
  27. }
  28. for (j=i+1; j<LPC_FILTERORDER+1; j++) {
  29. *po-=(*pa++)*(*pm--);
  30. }
  31. po++;
  32. }
  33. /* Filter last part where the state is entirely in
  34. the output vector */
  35. for (i=LPC_FILTERORDER; i<len; i++) {
  36. pi=&Out[i-1];
  37. pa=&a[1];
  38. for (j=1; j<LPC_FILTERORDER+1; j++) {
  39. *po-=(*pa++)*(*pi--);
  40. }
  41. po++;
  42. }
  43. /* Update state vector */
  44. memcpy(mem, &Out[len-LPC_FILTERORDER],
  45. LPC_FILTERORDER*sizeof(float));
  46. }