anaFilter.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /******************************************************************
  2. iLBC Speech Coder ANSI-C Source Code
  3. anaFilter.c
  4. Copyright (c) 2001,
  5. Global IP Sound AB.
  6. All rights reserved.
  7. ******************************************************************/
  8. #include <string.h>
  9. #include "iLBC_define.h"
  10. #include "anaFilter.h"
  11. /*----------------------------------------------------------------*
  12. * LP analysis filter.
  13. *---------------------------------------------------------------*/
  14. void anaFilter(
  15. float *In, /* (i) Signal to be filtered */
  16. float *a, /* (i) LP parameters */
  17. int len,/* (i) Length of signal */
  18. float *Out, /* (o) Filtered signal */
  19. float *mem /* (i/o) Filter state */
  20. ){
  21. int i, j;
  22. float *po, *pi, *pm, *pa;
  23. po = Out;
  24. /* Filter first part using memory from past */
  25. for (i=0;i<LPC_FILTERORDER;i++) {
  26. pi = &In[i];
  27. pm = &mem[LPC_FILTERORDER-1];
  28. pa = a;
  29. *po=0.0;
  30. for (j=0;j<=i;j++) {
  31. *po+=(*pa++)*(*pi--);
  32. }
  33. for (j=i+1;j<LPC_FILTERORDER+1;j++) {
  34. *po+=(*pa++)*(*pm--);
  35. }
  36. po++;
  37. }
  38. /* Filter last part where the state is entierly
  39. in the input vector */
  40. for (i=LPC_FILTERORDER;i<len;i++) {
  41. pi = &In[i];
  42. pa = a;
  43. *po=0.0;
  44. for (j=0;j<LPC_FILTERORDER+1;j++) {
  45. *po+=(*pa++)*(*pi--);
  46. }
  47. po++;
  48. }
  49. /* Update state vector */
  50. memcpy(mem, &In[len-LPC_FILTERORDER],
  51. LPC_FILTERORDER*sizeof(float));
  52. }