int_lsf.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 : int_lsf.c
  11. *
  12. ********************************************************************************
  13. */
  14. /*
  15. ********************************************************************************
  16. * MODULE INCLUDE FILE AND VERSION ID
  17. ********************************************************************************
  18. */
  19. #include "int_lsf.h"
  20. const char int_lsf_id[] = "@(#)$Id $" int_lsf_h;
  21. /*
  22. ********************************************************************************
  23. * INCLUDE FILES
  24. ********************************************************************************
  25. */
  26. #include "typedef.h"
  27. #include "basic_op.h"
  28. #include "count.h"
  29. #include "cnst.h"
  30. /*
  31. ********************************************************************************
  32. * LOCAL VARIABLES AND TABLES
  33. ********************************************************************************
  34. */
  35. /*
  36. *--------------------------------------*
  37. * Constants (defined in cnst.h) *
  38. *--------------------------------------*
  39. * M : LSF order *
  40. *--------------------------------------*
  41. */
  42. /*
  43. ********************************************************************************
  44. * PUBLIC PROGRAM CODE
  45. ********************************************************************************
  46. */
  47. /*
  48. **************************************************************************
  49. *
  50. * Function : Int_lsf
  51. * Purpose : Interpolates the LSFs for selected subframe
  52. * Description : The 20 ms speech frame is divided into 4 subframes.
  53. * The LSFs are interpolated at the 1st, 2nd and 3rd
  54. * subframe and only forwarded at the 4th subframe.
  55. *
  56. * |------|------|------|------|
  57. * sf1 sf2 sf3 sf4
  58. * F0 F1
  59. *
  60. * sf1: 3/4 F0 + 1/4 F1 sf3: 1/4 F0 + 3/4 F1
  61. * sf2: 1/2 F0 + 1/2 F1 sf4: F1
  62. * Returns : void
  63. *
  64. **************************************************************************
  65. */
  66. void Int_lsf(
  67. Word16 lsf_old[], /* i : LSF vector at the 4th SF of past frame */
  68. Word16 lsf_new[], /* i : LSF vector at the 4th SF of present frame */
  69. Word16 i_subfr, /* i : Pointer to current sf (equal to 0,40,80 or 120) */
  70. Word16 lsf_out[] /* o : interpolated LSF parameters for current sf */
  71. )
  72. {
  73. Word16 i;
  74. if ( i_subfr == 0 )
  75. {
  76. test ();
  77. for (i = 0; i < M; i++) {
  78. lsf_out[i] = add_ex(sub_ex(lsf_old[i], shr_ex(lsf_old[i], 2)), shr_ex(lsf_new[i], 2));
  79. move16 ();
  80. }
  81. }
  82. else if ( sub_ex(i_subfr, 40) == 0 )
  83. {
  84. test (); test ();
  85. for (i = 0; i < M; i++) {
  86. lsf_out[i] = add_ex(shr_ex(lsf_old[i],1), shr_ex(lsf_new[i], 1) );
  87. move16 ();
  88. }
  89. }
  90. else if ( sub_ex(i_subfr, 80) == 0 )
  91. {
  92. test (); test (); test ();
  93. for (i = 0; i < M; i++) {
  94. lsf_out[i] = add_ex(shr_ex(lsf_old[i], 2), sub_ex(lsf_new[i], shr_ex(lsf_new[i], 2)));
  95. move16 ();
  96. }
  97. }
  98. else if ( sub_ex(i_subfr, 120) == 0 )
  99. {
  100. test (); test (); test (); test ();
  101. for (i = 0; i < M; i++) {
  102. lsf_out[i] = lsf_new[i]; move16 ();
  103. }
  104. }
  105. return;
  106. }