g_adapt.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 : g_adapt.h
  11. * Purpose : gain adaptation for MR795 gain quantization
  12. *
  13. ********************************************************************************
  14. */
  15. /*
  16. ********************************************************************************
  17. * MODULE INCLUDE FILE AND VERSION ID
  18. ********************************************************************************
  19. */
  20. #ifndef g_adapt_h
  21. #define g_adapt_h "$Id $"
  22. /*
  23. ********************************************************************************
  24. * INCLUDE FILES
  25. ********************************************************************************
  26. */
  27. #include "typedef.h"
  28. #define LTPG_MEM_SIZE 5 /* number of stored past LTP coding gains + 1 */
  29. /*
  30. ********************************************************************************
  31. * DEFINITION OF DATA TYPES
  32. ********************************************************************************
  33. */
  34. typedef struct {
  35. Word16 onset; /* onset state, Q0 */
  36. Word16 prev_alpha; /* previous adaptor output, Q15 */
  37. Word16 prev_gc; /* previous code gain, Q1 */
  38. Word16 ltpg_mem[LTPG_MEM_SIZE]; /* LTP coding gain history, Q13 */
  39. /* (ltpg_mem[0] not used for history) */
  40. } GainAdaptState;
  41. /*
  42. ********************************************************************************
  43. * DECLARATION OF PROTOTYPES
  44. ********************************************************************************
  45. */
  46. int gain_adapt_init (GainAdaptState **st);
  47. /* initialize one instance of the gain adaptor
  48. Stores pointer to state struct in *st. This pointer has to
  49. be passed to gain_adapt and gain_adapt_update in each call.
  50. returns 0 on success
  51. */
  52. int gain_adapt_reset (GainAdaptState *st);
  53. /* reset of gain adaptor state (i.e. set state memory to zero)
  54. returns 0 on success
  55. */
  56. void gain_adapt_exit (GainAdaptState **st);
  57. /* de-initialize gain adaptor state (i.e. free state struct)
  58. stores NULL in *st
  59. */
  60. /*************************************************************************
  61. *
  62. * Function: gain_adapt()
  63. * Purpose: calculate pitch/codebook gain adaptation factor alpha
  64. * (and update the adaptor state)
  65. *
  66. **************************************************************************
  67. */
  68. void gain_adapt(
  69. GainAdaptState *st, /* i : state struct */
  70. Word16 ltpg, /* i : ltp coding gain (log2()), Q */
  71. Word16 gain_cod, /* i : code gain, Q13 */
  72. Word16 *alpha /* o : gain adaptation factor, Q15 */
  73. );
  74. #endif