gc_pred.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 : gc_pred.h
  11. * Purpose : codebook gain MA prediction
  12. *
  13. ********************************************************************************
  14. */
  15. #ifndef gc_pred_h
  16. #define gc_pred_h "$Id $"
  17. /*
  18. ********************************************************************************
  19. * INCLUDE FILES
  20. ********************************************************************************
  21. */
  22. #include "typedef.h"
  23. #include "mode.h"
  24. /*
  25. ********************************************************************************
  26. * LOCAL VARIABLES AND TABLES
  27. ********************************************************************************
  28. */
  29. /*
  30. ********************************************************************************
  31. * DEFINITION OF DATA TYPES
  32. ********************************************************************************
  33. */
  34. typedef struct {
  35. Word16 past_qua_en[4]; /* normal MA predictor memory, Q10 */
  36. /* (contains 20*log10(qua_err)) */
  37. Word16 past_qua_en_MR122[4]; /* MA predictor memory for MR122 mode, Q10 */
  38. /* (contains log2(qua_err)) */
  39. } gc_predState;
  40. /*
  41. ********************************************************************************
  42. * DECLARATION OF PROTOTYPES
  43. ********************************************************************************
  44. */
  45. int gc_pred_init (gc_predState **st);
  46. /* initialize one instance of codebook gain MA predictor
  47. Stores pointer to state struct in *st. This pointer has to
  48. be passed to gc_pred in each call.
  49. returns 0 on success
  50. */
  51. int gc_pred_reset (gc_predState *st);
  52. /* reset of codebook gain MA predictor state (i.e. set state memory to zero)
  53. returns 0 on success
  54. */
  55. void gc_pred_exit (gc_predState **st);
  56. /* de-initialize codebook gain MA predictor state (i.e. free state struct)
  57. stores NULL in *st
  58. */
  59. void
  60. gc_pred_copy(
  61. gc_predState *st_src, /* i : State struct */
  62. gc_predState *st_dest /* o : State struct */
  63. );
  64. /*************************************************************************
  65. *
  66. * FUNCTION: gc_pred()
  67. *
  68. * PURPOSE: MA prediction of the innovation energy
  69. * (in dB/(20*log10(2))) with mean removed).
  70. *
  71. *************************************************************************/
  72. void gc_pred(
  73. gc_predState *st, /* i/o: State struct */
  74. enum Mode mode, /* i : AMR mode */
  75. Word16 *code, /* i : innovative codebook vector (L_SUBFR) */
  76. /* MR122: Q12, other modes: Q13 */
  77. Word16 *exp_gcode0, /* o : exponent of predicted gain factor, Q0 */
  78. Word16 *frac_gcode0,/* o : fraction of predicted gain factor Q15 */
  79. Word16 *exp_en, /* o : exponent of innovation energy, Q0 */
  80. /* (only calculated for MR795) */
  81. Word16 *frac_en /* o : fraction of innovation energy, Q15 */
  82. /* (only calculated for MR795) */
  83. );
  84. /*************************************************************************
  85. *
  86. * FUNCTION: gc_pred_update()
  87. *
  88. * PURPOSE: update MA predictor with last quantized energy
  89. *
  90. *************************************************************************/
  91. void gc_pred_update(
  92. gc_predState *st, /* i/o: State struct */
  93. Word16 qua_ener_MR122, /* i : quantized energy for update, Q10 */
  94. /* (log2(qua_err)) */
  95. Word16 qua_ener /* i : quantized energy for update, Q10 */
  96. /* (20*log10(qua_err)) */
  97. );
  98. /*************************************************************************
  99. *
  100. * FUNCTION: gc_pred_average_limited()
  101. *
  102. * PURPOSE: get average of MA predictor state values (with a lower limit)
  103. * [used in error concealment]
  104. *
  105. *************************************************************************/
  106. void gc_pred_average_limited(
  107. gc_predState *st, /* i: State struct */
  108. Word16 *ener_avg_MR122, /* o: averaged quantized energy, Q10 */
  109. /* (log2(qua_err)) */
  110. Word16 *ener_avg /* o: averaged quantized energy, Q10 */
  111. /* (20*log10(qua_err)) */
  112. );
  113. #endif