d3_14pf.c 3.6 KB

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