lflg_upd.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 : lflg_upd.c
  11. * Purpose : LTP_flag update for AMR VAD option 2
  12. *
  13. *****************************************************************************
  14. */
  15. const char lflg_upd_id[] = "@(#)$Id $";
  16. #include "typedef.h"
  17. #include "cnst.h"
  18. #include "basic_op.h"
  19. #include "oper_32b.h"
  20. #include "count.h"
  21. #include "vad2.h"
  22. #include "mode.h"
  23. /***************************************************************************
  24. *
  25. * FUNCTION NAME: LTP_flag_update
  26. *
  27. * PURPOSE:
  28. * Set LTP_flag if the LTP gain > LTP_THRESHOLD, where the value of
  29. * LTP_THRESHOLD depends on the LTP analysis window length.
  30. *
  31. * INPUTS:
  32. *
  33. * mode
  34. * AMR mode
  35. * vadState->L_R0
  36. * LTP energy
  37. * vadState->L_Rmax
  38. * LTP maximum autocorrelation
  39. * OUTPUTS:
  40. *
  41. * vadState->LTP_flag
  42. * Set if LTP gain > LTP_THRESHOLD
  43. *
  44. * RETURN VALUE:
  45. *
  46. * none
  47. *
  48. *************************************************************************/
  49. void LTP_flag_update (vadState2 * st, Word16 mode)
  50. {
  51. Word16 thresh;
  52. Word16 hi1;
  53. Word16 lo1;
  54. Word32 Ltmp;
  55. test(); test();
  56. if ((sub_ex(mode, MR475) == 0) || (sub_ex(mode, MR515) == 0))
  57. {
  58. thresh = (Word16)(32768.0*0.55); move16();
  59. }
  60. else if (sub_ex(mode, MR102) == 0)
  61. {
  62. thresh = (Word16)(32768.0*0.60); move16();
  63. }
  64. else
  65. {
  66. thresh = (Word16)(32768.0*0.65); move16();
  67. }
  68. L_Extract (st->L_R0, &hi1, &lo1);
  69. Ltmp = Mpy_32_16(hi1, lo1, thresh); test();
  70. if (L_sub_ex(st->L_Rmax, Ltmp) > 0)
  71. {
  72. st->LTP_flag = TRUE; move16();
  73. }
  74. else
  75. {
  76. st->LTP_flag = FALSE; move16();
  77. }
  78. return;
  79. }