d_gain_p.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 : d_gain_p.c
  11. *
  12. ********************************************************************************
  13. */
  14. /*
  15. ********************************************************************************
  16. * MODULE INCLUDE FILE AND VERSION ID
  17. ********************************************************************************
  18. */
  19. #include "d_gain_p.h"
  20. const char d_gain_p_id[] = "@(#)$Id $" d_gain_p_h;
  21. /*
  22. ********************************************************************************
  23. * INCLUDE FILES
  24. ********************************************************************************
  25. */
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include "typedef.h"
  29. #include "mode.h"
  30. #include "basic_op.h"
  31. #include "oper_32b.h"
  32. #include "count.h"
  33. #include "cnst.h"
  34. /*
  35. ********************************************************************************
  36. * LOCAL VARIABLES AND TABLES
  37. ********************************************************************************
  38. */
  39. #include "gains.tab"
  40. /*
  41. ********************************************************************************
  42. * PUBLIC PROGRAM CODE
  43. ********************************************************************************
  44. */
  45. /*
  46. **************************************************************************
  47. *
  48. * Function : d_gain_pitch
  49. * Purpose : Decodes the pitch gain using the received index.
  50. * output is in Q14
  51. *
  52. **************************************************************************
  53. */
  54. Word16 d_gain_pitch ( /* return value: gain (Q14) */
  55. enum Mode mode, /* i : AMR mode */
  56. Word16 index /* i : index of quantization */
  57. )
  58. {
  59. Word16 gain;
  60. test ();
  61. if (sub_ex(mode, MR122) == 0)
  62. {
  63. /* clear 2 LSBits */
  64. gain = shl_ex (shr_ex (qua_gain_pitch[index], 2), 2); move16 ();
  65. }
  66. else
  67. {
  68. gain = qua_gain_pitch[index]; move16 ();
  69. }
  70. return gain;
  71. }