d4_17pf.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 : d4_17pf.c
  11. * Purpose : Algebraic codebook decoder
  12. *
  13. ********************************************************************************
  14. */
  15. /*
  16. ********************************************************************************
  17. * MODULE INCLUDE FILE AND VERSION ID
  18. ********************************************************************************
  19. */
  20. #include "d4_17pf.h"
  21. const char d4_17pf_c_id[] = "@(#)$Id $" d4_17pf_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. #define NB_PULSE 4
  37. #include "gray.tab"
  38. /*
  39. ********************************************************************************
  40. * PUBLIC PROGRAM CODE
  41. ********************************************************************************
  42. */
  43. /*************************************************************************
  44. *
  45. * FUNCTION: decod_ACELP()
  46. *
  47. * PURPOSE: Algebraic codebook decoder
  48. *
  49. *************************************************************************/
  50. void decode_4i40_17bits(
  51. Word16 sign, /* i : signs of 4 pulses. */
  52. Word16 index, /* i : Positions of the 4 pulses. */
  53. Word16 cod[] /* o : algebraic (fixed) codebook excitation */
  54. )
  55. {
  56. Word16 i, j;
  57. Word16 pos[NB_PULSE];
  58. /* Decode the positions */
  59. i = index & 7; logic16 ();
  60. i = dgray[i]; move16 ();
  61. pos[0] = add_ex(i, shl_ex(i, 2)); /* pos0 =i*5 */ move16 ();
  62. index = shr_ex(index, 3);
  63. i = index & 7; logic16 ();
  64. i = dgray[i]; move16 ();
  65. i = add_ex(i, shl_ex(i, 2)); /* pos1 =i*5+1 */
  66. pos[1] = add_ex(i, 1); move16 ();
  67. index = shr_ex(index, 3);
  68. i = index & 7; logic16 ();
  69. i = dgray[i]; move16 ();
  70. i = add_ex(i, shl_ex(i, 2)); /* pos2 =i*5+1 */
  71. pos[2] = add_ex(i, 2); move16 ();
  72. index = shr_ex(index, 3);
  73. j = index & 1; logic16 ();
  74. index = shr_ex(index, 1);
  75. i = index & 7; logic16 ();
  76. i = dgray[i]; move16 ();
  77. i = add_ex(i, shl_ex(i, 2)); /* pos3 =i*5+3+j */
  78. i = add_ex(i, 3);
  79. pos[3] = add_ex(i, j); move16 ();
  80. /* decode the signs and build the codeword */
  81. for (i = 0; i < L_SUBFR; i++) {
  82. cod[i] = 0; move16 ();
  83. }
  84. for (j = 0; j < NB_PULSE; j++) {
  85. i = sign & 1; logic16 ();
  86. sign = shr_ex(sign, 1);
  87. test ();
  88. if (i != 0) {
  89. cod[pos[j]] = 8191; move16 ();
  90. } else {
  91. cod[pos[j]] = -8192; move16 ();
  92. }
  93. }
  94. return;
  95. }