vad1.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. ********************************************************************************
  3. **-------------------------------------------------------------------------**
  4. ** **
  5. ** GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 **
  6. ** R99 Version 3.3.0 **
  7. ** REL-4 Version 4.1.0 **
  8. ** **
  9. **-------------------------------------------------------------------------**
  10. ********************************************************************************
  11. *
  12. * File : vad1.h
  13. * Purpose : Voice Activity Detection (VAD) for AMR (option 1)
  14. *
  15. ********************************************************************************
  16. */
  17. #ifndef vad1_h
  18. #define vad1_h "$Id $"
  19. /*
  20. ********************************************************************************
  21. * INCLUDE FILES
  22. ********************************************************************************
  23. */
  24. #include "typedef.h"
  25. #include "cnst_vad.h"
  26. /*
  27. ********************************************************************************
  28. * LOCAL VARIABLES AND TABLES
  29. ********************************************************************************
  30. */
  31. /*
  32. ********************************************************************************
  33. * DEFINITION OF DATA TYPES
  34. ********************************************************************************
  35. */
  36. /* state variable */
  37. typedef struct {
  38. Word16 bckr_est[COMPLEN]; /* background noise estimate */
  39. Word16 ave_level[COMPLEN]; /* averaged input components for stationary */
  40. /* estimation */
  41. Word16 old_level[COMPLEN]; /* input levels of the previous frame */
  42. Word16 sub_level[COMPLEN]; /* input levels calculated at the end of
  43. a frame (lookahead) */
  44. Word16 a_data5[3][2]; /* memory for the filter bank */
  45. Word16 a_data3[5]; /* memory for the filter bank */
  46. Word16 burst_count; /* counts length of a speech burst */
  47. Word16 hang_count; /* hangover counter */
  48. Word16 stat_count; /* stationary counter */
  49. /* Note that each of the following three variables (vadreg, pitch and tone)
  50. holds 15 flags. Each flag reserves 1 bit of the variable. The newest
  51. flag is in the bit 15 (assuming that LSB is bit 1 and MSB is bit 16). */
  52. Word16 vadreg; /* flags for intermediate VAD decisions */
  53. Word16 pitch; /* flags for pitch detection */
  54. Word16 tone; /* flags for tone detection */
  55. Word16 complex_high; /* flags for complex detection */
  56. Word16 complex_low; /* flags for complex detection */
  57. Word16 oldlag_count, oldlag; /* variables for pitch detection */
  58. Word16 complex_hang_count; /* complex hangover counter, used by VAD */
  59. Word16 complex_hang_timer; /* hangover initiator, used by CAD */
  60. Word16 best_corr_hp; /* FIP filtered value Q15 */
  61. Word16 speech_vad_decision; /* final decision */
  62. Word16 complex_warning; /* complex background warning */
  63. Word16 sp_burst_count; /* counts length of a speech burst incl
  64. HO addition */
  65. Word16 corr_hp_fast; /* filtered value */
  66. } vadState1;
  67. /*
  68. ********************************************************************************
  69. * DECLARATION OF PROTOTYPES
  70. ********************************************************************************
  71. */
  72. int vad1_init (vadState1 **st);
  73. /* initialize one instance of the pre processing state.
  74. Stores pointer to filter status struct in *st. This pointer has to
  75. be passed to vad in each call.
  76. returns 0 on success
  77. */
  78. int vad1_reset (vadState1 *st);
  79. /* reset of pre processing state (i.e. set state memory to zero)
  80. returns 0 on success
  81. */
  82. void vad1_exit (vadState1 **st);
  83. /* de-initialize pre processing state (i.e. free status struct)
  84. stores NULL in *st
  85. */
  86. void vad_complex_detection_update (vadState1 *st, /* i/o : State struct */
  87. Word16 best_corr_hp /* i : best Corr Q15 */
  88. );
  89. void vad_tone_detection (vadState1 *st, /* i/o : State struct */
  90. Word32 t0, /* i : autocorrelation maxima */
  91. Word32 t1 /* i : energy */
  92. );
  93. void vad_tone_detection_update (
  94. vadState1 *st, /* i/o : State struct */
  95. Word16 one_lag_per_frame /* i : 1 if one open-loop lag is
  96. calculated per each frame,
  97. otherwise 0 */
  98. );
  99. void vad_pitch_detection (vadState1 *st, /* i/o : State struct */
  100. Word16 lags[] /* i : speech encoder open loop lags */
  101. );
  102. Word16 vad1 (vadState1 *st, /* i/o : State struct */
  103. Word16 in_buf[] /* i : samples of the input frame
  104. inbuf[159] is the very last sample,
  105. incl lookahead */
  106. );
  107. #endif