inter_36.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 : inter_36.c
  11. * Purpose : Interpolating the normalized correlation
  12. * : with 1/3 or 1/6 resolution.
  13. *
  14. ********************************************************************************
  15. */
  16. /*
  17. ********************************************************************************
  18. * MODULE INCLUDE FILE AND VERSION ID
  19. ********************************************************************************
  20. */
  21. #include "inter_36.h"
  22. const char inter_36_id[] = "@(#)$Id $" inter_36_h;
  23. /*
  24. ********************************************************************************
  25. * INCLUDE FILES
  26. ********************************************************************************
  27. */
  28. #include "typedef.h"
  29. #include "basic_op.h"
  30. #include "count.h"
  31. #include "cnst.h"
  32. /*
  33. ********************************************************************************
  34. * LOCAL VARIABLES AND TABLES
  35. ********************************************************************************
  36. */
  37. #define UP_SAMP_MAX 6
  38. #include "inter_36.tab"
  39. /*
  40. ********************************************************************************
  41. * PUBLIC PROGRAM CODE
  42. ********************************************************************************
  43. */
  44. /*************************************************************************
  45. *
  46. * FUNCTION: Interpol_3or6()
  47. *
  48. * PURPOSE: Interpolating the normalized correlation with 1/3 or 1/6
  49. * resolution.
  50. *
  51. *************************************************************************/
  52. Word16 Interpol_3or6 ( /* o : interpolated value */
  53. Word16 *x, /* i : input vector */
  54. Word16 frac, /* i : fraction (-2..2 for 3*, -3..3 for 6*) */
  55. Word16 flag3 /* i : if set, upsampling rate = 3 (6 otherwise) */
  56. )
  57. {
  58. Word16 i, k;
  59. Word16 *x1, *x2;
  60. const Word16 *c1, *c2;
  61. Word32 s;
  62. test();
  63. if (flag3 != 0)
  64. {
  65. frac = shl_ex (frac, 1); /* inter_3[k] = inter_6[2*k] -> k' = 2*k */
  66. }
  67. test ();
  68. if (frac < 0)
  69. {
  70. frac = add_ex (frac, UP_SAMP_MAX);
  71. x--;
  72. }
  73. x1 = &x[0]; move16 ();
  74. x2 = &x[1]; move16 ();
  75. c1 = &inter_6[frac]; move16 ();
  76. c2 = &inter_6[sub_ex (UP_SAMP_MAX, frac)]; move16 ();
  77. s = 0; move32 ();
  78. for (i = 0, k = 0; i < L_INTER_SRCH; i++, k += UP_SAMP_MAX)
  79. {
  80. s = L_mac_ex (s, x1[-i], c1[k]);
  81. s = L_mac_ex (s, x2[i], c2[k]);
  82. }
  83. return round_ex (s);
  84. }