residu.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. ********************************************************************************
  3. *
  4. * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
  5. * R99 Version 3.3.0
  6. * REL-4 Version 4.1.0
  7. *
  8. ********************************************************************************
  9. *
  10. * File : residu.c
  11. * Purpose : Computes the LP residual.
  12. * Description : The LP residual is computed by filtering the input
  13. * : speech through the LP inverse filter A(z).
  14. *
  15. ********************************************************************************
  16. */
  17. /*
  18. ********************************************************************************
  19. * MODULE INCLUDE FILE AND VERSION ID
  20. ********************************************************************************
  21. */
  22. #include "residu.h"
  23. const char residu_id[] = "@(#)$Id $" residu_h;
  24. /*
  25. ********************************************************************************
  26. * INCLUDE FILES
  27. ********************************************************************************
  28. */
  29. #include "typedef.h"
  30. #include "basic_op.h"
  31. #include "count.h"
  32. #include "cnst.h"
  33. /*
  34. ********************************************************************************
  35. * LOCAL VARIABLES AND TABLES
  36. ********************************************************************************
  37. */
  38. /*
  39. *--------------------------------------*
  40. * Constants (defined in cnst.h *
  41. *--------------------------------------*
  42. * M : LPC order *
  43. *--------------------------------------*
  44. */
  45. /*
  46. ********************************************************************************
  47. * PUBLIC PROGRAM CODE
  48. ********************************************************************************
  49. */
  50. void Residu (
  51. Word16 a[], /* (i) : prediction coefficients */
  52. Word16 x[], /* (i) : speech signal */
  53. Word16 y[], /* (o) : residual signal */
  54. Word16 lg /* (i) : size of filtering */
  55. )
  56. {
  57. Word16 i, j;
  58. Word32 s;
  59. for (i = 0; i < lg; i++)
  60. {
  61. s = L_mult_ex (x[i], a[0]);
  62. for (j = 1; j <= M; j++)
  63. {
  64. s = L_mac_ex (s, a[j], x[i - j]);
  65. }
  66. s = L_shl_ex (s, 3);
  67. y[i] = round_ex (s); move16 ();
  68. }
  69. return;
  70. }