d1035pf.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 : d1035pf.c
  11. * Purpose : Builds the innovative codevector
  12. *
  13. ********************************************************************************
  14. */
  15. /*
  16. ********************************************************************************
  17. * MODULE INCLUDE FILE AND VERSION ID
  18. ********************************************************************************
  19. */
  20. #include "d1035pf.h"
  21. const char d1035pf_id[] = "@(#)$Id $" d1035pf_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 10 /* number of pulses */
  37. #include "gray.tab"
  38. /*
  39. ********************************************************************************
  40. * PUBLIC PROGRAM CODE
  41. ********************************************************************************
  42. */
  43. /*************************************************************************
  44. *
  45. * FUNCTION: dec_10i40_35bits()
  46. *
  47. * PURPOSE: Builds the innovative codevector from the received
  48. * index of algebraic codebook.
  49. *
  50. * See c1035pf.c for more details about the algebraic codebook structure.
  51. *
  52. *************************************************************************/
  53. void dec_10i40_35bits (
  54. Word16 index[], /* (i) : index of 10 pulses (sign+position) */
  55. Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */
  56. )
  57. {
  58. Word16 i, j, pos1, pos2, sign, tmp;
  59. for (i = 0; i < L_CODE; i++)
  60. {
  61. cod[i] = 0; move16 ();
  62. }
  63. /* decode the positions and signs of pulses and build the codeword */
  64. for (j = 0; j < NB_TRACK; j++)
  65. {
  66. /* compute index i */
  67. tmp = index[j]; move16 ();
  68. i = tmp & 7; logic16 ();
  69. i = dgray[i]; move16 ();
  70. i = extract_l_ex (L_shr_ex (L_mult_ex (i, 5), 1));
  71. pos1 = add_ex (i, j); /* position of pulse "j" */
  72. i = shr_ex (tmp, 3) & 1; logic16 ();
  73. test ();
  74. if (i == 0)
  75. {
  76. sign = 4096; move16 (); /* +1.0 */
  77. }
  78. else
  79. {
  80. sign = -4096; move16 (); /* -1.0 */
  81. }
  82. cod[pos1] = sign; move16 ();
  83. /* compute index i */
  84. i = index[add_ex (j, 5)] & 7; logic16 ();
  85. i = dgray[i]; move16 ();
  86. i = extract_l_ex (L_shr_ex (L_mult_ex (i, 5), 1));
  87. pos2 = add_ex (i, j); /* position of pulse "j+5" */
  88. test ();
  89. if (sub_ex (pos2, pos1) < 0)
  90. {
  91. sign = negate_ex (sign);
  92. }
  93. cod[pos2] = add_ex (cod[pos2], sign); move16 ();
  94. }
  95. return;
  96. }