ol_ltp.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 : ol_ltp.c
  11. * Purpose : Compute the open loop pitch lag.
  12. *
  13. ********************************************************************************
  14. */
  15. /*
  16. ********************************************************************************
  17. * MODULE INCLUDE FILE AND VERSION ID
  18. ********************************************************************************
  19. */
  20. #include "ol_ltp.h"
  21. const char ol_ltp_id[] = "@(#)$Id $" ol_ltp_h;
  22. /*
  23. ********************************************************************************
  24. * INCLUDE FILES
  25. ********************************************************************************
  26. */
  27. #include <stdio.h>
  28. #include "typedef.h"
  29. #include "cnst.h"
  30. #include "pitch_ol.h"
  31. #include "p_ol_wgh.h"
  32. #include "count.h"
  33. #include "basic_op.h"
  34. /*
  35. ********************************************************************************
  36. * LOCAL VARIABLES AND TABLES
  37. ********************************************************************************
  38. */
  39. /*
  40. ********************************************************************************
  41. * PUBLIC PROGRAM CODE
  42. ********************************************************************************
  43. */
  44. int ol_ltp(
  45. pitchOLWghtState *st, /* i/o : State struct */
  46. vadState *vadSt, /* i/o : VAD state struct */
  47. enum Mode mode, /* i : coder mode */
  48. Word16 wsp[], /* i : signal used to compute the OL pitch, Q0 */
  49. /* uses signal[-pit_max] to signal[-1] */
  50. Word16 *T_op, /* o : open loop pitch lag, Q0 */
  51. Word16 old_lags[], /* i : history with old stored Cl lags */
  52. Word16 ol_gain_flg[], /* i : OL gain flag */
  53. Word16 idx, /* i : index */
  54. Flag dtx /* i : dtx flag; use dtx=1, do not use dtx=0 */
  55. )
  56. {
  57. test ();
  58. if (sub_ex (mode, MR102) != 0 )
  59. {
  60. ol_gain_flg[0] = 0; move16 ();
  61. ol_gain_flg[1] = 0; move16 ();
  62. }
  63. test (); test ();
  64. if (sub_ex (mode, MR475) == 0 || sub_ex (mode, MR515) == 0 )
  65. {
  66. *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME, idx, dtx);
  67. move16 ();
  68. }
  69. else
  70. {
  71. if ( sub_ex (mode, MR795) <= 0 )
  72. {
  73. test();
  74. *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
  75. idx, dtx);
  76. move16 ();
  77. }
  78. else if ( sub_ex (mode, MR102) == 0 )
  79. {
  80. test(); test();
  81. *T_op = Pitch_ol_wgh(st, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
  82. old_lags, ol_gain_flg, idx, dtx);
  83. move16 ();
  84. }
  85. else
  86. {
  87. test(); test();
  88. *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN_MR122, PIT_MAX,
  89. L_FRAME_BY2, idx, dtx);
  90. move16 ();
  91. }
  92. }
  93. return 0;
  94. }