dtx_dec.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 : dtx_dec.h
  11. * Purpose : Decode comfort noice when in DTX
  12. *
  13. *****************************************************************************
  14. */
  15. #ifndef dtx_dec_h
  16. #define dtx_dec_h "$Id $"
  17. /*
  18. *****************************************************************************
  19. * INCLUDE FILES
  20. *****************************************************************************
  21. */
  22. #include "typedef.h"
  23. #include "dtx_enc.h"
  24. #include "d_plsf.h"
  25. #include "gc_pred.h"
  26. #include "c_g_aver.h"
  27. #include "frame.h"
  28. /*
  29. *****************************************************************************
  30. * LOCAL VARIABLES AND TABLES
  31. *****************************************************************************
  32. */
  33. enum DTXStateType {SPEECH = 0, DTX, DTX_MUTE};
  34. #define DTX_MAX_EMPTY_THRESH 50
  35. /*
  36. *****************************************************************************
  37. * DEFINITION OF DATA TYPES
  38. *****************************************************************************
  39. */
  40. typedef struct {
  41. Word16 since_last_sid;
  42. Word16 true_sid_period_inv;
  43. Word16 log_en;
  44. Word16 old_log_en;
  45. Word32 L_pn_seed_rx;
  46. Word16 lsp[M];
  47. Word16 lsp_old[M];
  48. Word16 lsf_hist[M*DTX_HIST_SIZE];
  49. Word16 lsf_hist_ptr;
  50. Word16 lsf_hist_mean[M*DTX_HIST_SIZE];
  51. Word16 log_pg_mean;
  52. Word16 log_en_hist[DTX_HIST_SIZE];
  53. Word16 log_en_hist_ptr;
  54. Word16 log_en_adjust;
  55. Word16 dtxHangoverCount;
  56. Word16 decAnaElapsedCount;
  57. Word16 sid_frame;
  58. Word16 valid_data;
  59. Word16 dtxHangoverAdded;
  60. enum DTXStateType dtxGlobalState; /* contains previous state */
  61. /* updated in main decoder */
  62. Word16 data_updated; /* marker to know if CNI data is ever renewed */
  63. } dtx_decState;
  64. /*
  65. *****************************************************************************
  66. * DECLARATION OF PROTOTYPES
  67. *****************************************************************************
  68. */
  69. /*
  70. **************************************************************************
  71. * Function : dtx_dec_init
  72. * Purpose : Allocates memory and initializes state variables
  73. * Description : Stores pointer to filter status struct in *st. This
  74. * pointer has to be passed to dtx_dec in each call.
  75. * Returns : 0 on success
  76. *
  77. **************************************************************************
  78. */
  79. int dtx_dec_init (dtx_decState **st);
  80. /*
  81. **************************************************************************
  82. *
  83. * Function : dtx_dec_reset
  84. * Purpose : Resets state memory
  85. * Returns : 0 on success
  86. *
  87. **************************************************************************
  88. */
  89. int dtx_dec_reset (dtx_decState *st);
  90. /*
  91. **************************************************************************
  92. *
  93. * Function : dtx_dec_exit
  94. * Purpose : The memory used for state memory is freed
  95. * Description : Stores NULL in *st
  96. *
  97. **************************************************************************
  98. */
  99. void dtx_dec_exit (dtx_decState **st);
  100. /*
  101. **************************************************************************
  102. *
  103. * Function : dtx_dec
  104. * Purpose :
  105. * Description :
  106. *
  107. **************************************************************************
  108. */
  109. int dtx_dec(
  110. dtx_decState *st, /* i/o : State struct */
  111. Word16 mem_syn[], /* i/o : AMR decoder state */
  112. D_plsfState* lsfState, /* i/o : decoder lsf states */
  113. gc_predState* predState, /* i/o : prediction states */
  114. Cb_gain_averageState* averState, /* i/o : CB gain average states */
  115. enum DTXStateType new_state, /* i : new DTX state */
  116. enum Mode mode, /* i : AMR mode */
  117. Word16 parm[], /* i : Vector of synthesis parameters */
  118. Word16 synth[], /* o : synthesised speech */
  119. Word16 A_t[] /* o : decoded LP filter in 4 subframes*/
  120. );
  121. void dtx_dec_activity_update(dtx_decState *st,
  122. Word16 lsf[],
  123. Word16 frame[]);
  124. /*
  125. **************************************************************************
  126. *
  127. * Function : rx_dtx_handler
  128. * Purpose : reads the frame type and checks history
  129. * Description : to decide what kind of DTX/CNI action to perform
  130. **************************************************************************
  131. */
  132. enum DTXStateType rx_dtx_handler(dtx_decState *st, /* i/o : State struct */
  133. enum RXFrameType frame_type /* i : Frame type */
  134. );
  135. #endif