anaFilter.c 1.7 KB

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