syn_filt.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 : syn_filt.c
  11. * Purpose : Perform synthesis filtering through 1/A(z).
  12. *
  13. ********************************************************************************
  14. */
  15. /*
  16. ********************************************************************************
  17. * MODULE INCLUDE FILE AND VERSION ID
  18. ********************************************************************************
  19. */
  20. #include "syn_filt.h"
  21. const char syn_filt_id[] = "@(#)$Id $" syn_filt_h;
  22. /*
  23. ********************************************************************************
  24. * INCLUDE FILES
  25. ********************************************************************************
  26. */
  27. #include "typedef.h"
  28. #include "basic_op.h"
  29. #include "count.h"
  30. #include "cnst.h"
  31. /*
  32. ********************************************************************************
  33. * LOCAL VARIABLES AND TABLES
  34. ********************************************************************************
  35. */
  36. /*
  37. *--------------------------------------*
  38. * Constants (defined in cnst.h *
  39. *--------------------------------------*
  40. * M : LPC order *
  41. *--------------------------------------*
  42. */
  43. /*
  44. ********************************************************************************
  45. * PUBLIC PROGRAM CODE
  46. ********************************************************************************
  47. */
  48. void Syn_filt (
  49. Word16 a[], /* (i) : a[M+1] prediction coefficients (M=10) */
  50. Word16 x[], /* (i) : input signal */
  51. Word16 y[], /* (o) : output signal */
  52. Word16 lg, /* (i) : size of filtering */
  53. Word16 mem[], /* (i/o) : memory associated with this filtering. */
  54. Word16 update /* (i) : 0=no update, 1=update of memory. */
  55. )
  56. {
  57. Word16 i, j;
  58. Word32 s;
  59. Word16 tmp[80]; /* This is usually done by memory allocation (lg+M) */
  60. Word16 *yy;
  61. /* Copy mem[] to yy[] */
  62. yy = tmp; move16 ();
  63. for (i = 0; i < M; i++)
  64. {
  65. *yy++ = mem[i]; move16 ();
  66. }
  67. /* Do the filtering. */
  68. for (i = 0; i < lg; i++)
  69. {
  70. s = L_mult_ex (x[i], a[0]);
  71. for (j = 1; j <= M; j++)
  72. {
  73. s = L_msu_ex (s, a[j], yy[-j]);
  74. }
  75. s = L_shl_ex (s, 3);
  76. *yy++ = round_ex (s); move16 ();
  77. }
  78. for (i = 0; i < lg; i++)
  79. {
  80. y[i] = tmp[i + M]; move16 ();
  81. }
  82. /* Update of memory if update==1 */
  83. test ();
  84. if (update != 0)
  85. {
  86. for (i = 0; i < M; i++)
  87. {
  88. mem[i] = y[lg - M + i]; move16 ();
  89. }
  90. }
  91. return;
  92. }