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