agc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 : agc.h
  11. * Purpose : Scales the postfilter output on a subframe basis
  12. * : by automatic control of the subframe gain.
  13. *
  14. *****************************************************************************
  15. */
  16. #ifndef agc_h
  17. #define agc_h "$Id $"
  18. /*
  19. *****************************************************************************
  20. * INCLUDE FILES
  21. *****************************************************************************
  22. */
  23. #include "typedef.h"
  24. /*
  25. *****************************************************************************
  26. * DEFINITION OF DATA TYPES
  27. *****************************************************************************
  28. */
  29. typedef struct {
  30. Word16 past_gain;
  31. } agcState;
  32. /*
  33. *****************************************************************************
  34. * DECLARATION OF PROTOTYPES
  35. *****************************************************************************
  36. */
  37. /*
  38. **************************************************************************
  39. *
  40. * Function : agc_init
  41. * Purpose : Allocates memory for agc state and initializes
  42. * state memory
  43. * Description : Stores pointer to agc status struct in *st. This pointer
  44. * has to be passed to agc in each call.
  45. * Returns : 0 on success
  46. *
  47. **************************************************************************
  48. */
  49. int agc_init(agcState **st);
  50. /*
  51. **************************************************************************
  52. *
  53. * Function : agc_reset
  54. * Purpose : Reset of agc (i.e. set state memory to 1.0)
  55. * Returns : 0 on success
  56. *
  57. **************************************************************************
  58. */
  59. int agc_reset (agcState *st);
  60. /*
  61. **************************************************************************
  62. *
  63. * Function : agc_exit
  64. * Purpose : The memory used for state memory is freed,
  65. * de-initialize agc
  66. *
  67. **************************************************************************
  68. */
  69. void agc_exit (agcState **st);
  70. /*
  71. **************************************************************************
  72. *
  73. * Function : agc
  74. * Purpose : Scales the postfilter output on a subframe basis
  75. * Description : sig_out[n] = sig_out[n] * gain[n];
  76. * where gain[n] is the gain at the nth sample given by
  77. * gain[n] = agc_fac * gain[n-1] + (1 - agc_fac) g_in/g_out
  78. * g_in/g_out is the square root of the ratio of energy at
  79. * the input and output of the postfilter.
  80. *
  81. **************************************************************************
  82. */
  83. int agc (
  84. agcState *st, /* i/o : agc state */
  85. Word16 *sig_in, /* i : postfilter input signal, (l_trm) */
  86. Word16 *sig_out, /* i/o : postfilter output signal, (l_trm) */
  87. Word16 agc_fac, /* i : AGC factor */
  88. Word16 l_trm /* i : subframe size */
  89. );
  90. /*
  91. **************************************************************************
  92. *
  93. * Function: agc2
  94. * Purpose: Scales the excitation on a subframe basis
  95. *
  96. **************************************************************************
  97. */
  98. void agc2 (
  99. Word16 *sig_in, /* i : postfilter input signal */
  100. Word16 *sig_out, /* i/o : postfilter output signal */
  101. Word16 l_trm /* i : subframe size */
  102. );
  103. #endif