ec_gains.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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 : ec_gains.h
  11. * Purpose: : Error concealment for pitch and codebook gains
  12. *
  13. ********************************************************************************
  14. */
  15. #ifndef ec_gains_h
  16. #define ec_gains_h "$Id $"
  17. /*
  18. ********************************************************************************
  19. * INCLUDE FILES
  20. ********************************************************************************
  21. */
  22. #include "typedef.h"
  23. #include "gc_pred.h"
  24. /*
  25. ********************************************************************************
  26. * LOCAL VARIABLES AND TABLES
  27. ********************************************************************************
  28. */
  29. /*
  30. ********************************************************************************
  31. * DEFINITION OF DATA TYPES
  32. ********************************************************************************
  33. */
  34. typedef struct {
  35. Word16 pbuf[5];
  36. Word16 past_gain_pit;
  37. Word16 prev_gp;
  38. } ec_gain_pitchState;
  39. typedef struct {
  40. Word16 gbuf[5];
  41. Word16 past_gain_code;
  42. Word16 prev_gc;
  43. } ec_gain_codeState;
  44. /*
  45. ********************************************************************************
  46. * DECLARATION OF PROTOTYPES
  47. ********************************************************************************
  48. */
  49. /*
  50. **************************************************************************
  51. *
  52. * Function : ec_gain_code_init
  53. * Purpose : Allocates memory and initializes state variables
  54. *
  55. **************************************************************************
  56. */
  57. int ec_gain_code_init (
  58. ec_gain_codeState **state
  59. );
  60. /*
  61. **************************************************************************
  62. *
  63. * Function : ec_gain_code_reset
  64. * Purpose : Resets state memory
  65. *
  66. **************************************************************************
  67. */
  68. int ec_gain_code_reset (
  69. ec_gain_codeState *state
  70. );
  71. /*
  72. **************************************************************************
  73. *
  74. * Function : ec_gain_code_exit
  75. * Purpose : The memory used for state memory is freed
  76. *
  77. **************************************************************************
  78. */
  79. void ec_gain_code_exit (
  80. ec_gain_codeState **state
  81. );
  82. /*
  83. **************************************************************************
  84. *
  85. * Function : ec_gain_code
  86. * Purpose : conceal the codebook gain
  87. * Call this function only in BFI (instead of normal gain
  88. * decoding function)
  89. *
  90. **************************************************************************
  91. */
  92. void ec_gain_code (
  93. ec_gain_codeState *st, /* i/o : State struct */
  94. gc_predState *pred_state, /* i/o : MA predictor state */
  95. Word16 state, /* i : state of the state machine */
  96. Word16 *gain_code /* o : decoded innovation gain */
  97. );
  98. /*
  99. **************************************************************************
  100. *
  101. * Function : ec_gain_code_update
  102. * Purpose : update the codebook gain concealment state;
  103. * limit gain_code if the previous frame was bad
  104. * Call this function always after decoding (or concealing)
  105. * the gain
  106. *
  107. **************************************************************************
  108. */
  109. void ec_gain_code_update (
  110. ec_gain_codeState *st, /* i/o : State struct */
  111. Word16 bfi, /* i : flag: frame is bad */
  112. Word16 prev_bf, /* i : flag: previous frame was bad */
  113. Word16 *gain_code /* i/o : decoded innovation gain */
  114. );
  115. /*
  116. **************************************************************************
  117. *
  118. * Function : ec_gain_pitch_init
  119. * Purpose : Allocates memory and initializes state memory.
  120. *
  121. **************************************************************************
  122. */
  123. int ec_gain_pitch_init (
  124. ec_gain_pitchState **state
  125. );
  126. /*
  127. **************************************************************************
  128. *
  129. * Function: ec_gain_pitch_reset
  130. * Purpose: Resets state memory
  131. *
  132. **************************************************************************
  133. */
  134. int ec_gain_pitch_reset (
  135. ec_gain_pitchState *state
  136. );
  137. /*************************************************************************
  138. *
  139. * Function : ec_gain_pitch_exit
  140. * Purpose : The memory used for state memory is freed
  141. *
  142. **************************************************************************
  143. */
  144. void ec_gain_pitch_exit (
  145. ec_gain_pitchState **state
  146. );
  147. /*
  148. **************************************************************************
  149. *
  150. * Function : ec_gain_pitch
  151. * Purpose : conceal the pitch gain
  152. * Call this function only in BFI (instead of normal gain
  153. * decoding function)
  154. *
  155. **************************************************************************
  156. */
  157. void ec_gain_pitch (
  158. ec_gain_pitchState *st, /* i/o : state variables */
  159. Word16 state, /* i : state of the state machine */
  160. Word16 *gain_pitch /* o : pitch gain (Q14) */
  161. );
  162. /*
  163. **************************************************************************
  164. *
  165. * Function : ec_gain_pitch_update
  166. * Purpose : update the pitch gain concealment state;
  167. * limit gain_pitch if the previous frame was bad
  168. * Call this function always after decoding (or concealing)
  169. * the gain
  170. *
  171. **************************************************************************
  172. */
  173. void ec_gain_pitch_update (
  174. ec_gain_pitchState *st, /* i/o : state variables */
  175. Word16 bfi, /* i : flag: frame is bad */
  176. Word16 prev_bf, /* i : flag: previous frame was bad */
  177. Word16 *gain_pitch /* i/o : pitch gain */
  178. );
  179. #endif