calc_cor.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 : calc_cor.c
  11. * Purpose : Calculate all correlations for prior the OL LTP
  12. *
  13. ********************************************************************************
  14. */
  15. /*
  16. ********************************************************************************
  17. * MODULE INCLUDE FILE AND VERSION ID
  18. ********************************************************************************
  19. */
  20. #include "calc_cor.h"
  21. const char calc_cor_id[] = "@(#)$Id $" calc_cor_h;
  22. /*
  23. ********************************************************************************
  24. * INCLUDE FILES
  25. ********************************************************************************
  26. */
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include "typedef.h"
  30. #include "basic_op.h"
  31. #include "oper_32b.h"
  32. #include "count.h"
  33. #include "cnst.h"
  34. /*
  35. ********************************************************************************
  36. * PUBLIC PROGRAM CODE
  37. ********************************************************************************
  38. */
  39. /*************************************************************************
  40. *
  41. * FUNCTION: comp_corr
  42. *
  43. * PURPOSE: Calculate all correlations of scal_sig[] in a given delay
  44. * range.
  45. *
  46. * DESCRIPTION:
  47. * The correlation is given by
  48. * cor[t] = <scal_sig[n],scal_sig[n-t]>, t=lag_min,...,lag_max
  49. * The functions outputs the all correlations
  50. *
  51. *************************************************************************/
  52. void comp_corr (
  53. Word16 scal_sig[], /* i : scaled signal. */
  54. Word16 L_frame, /* i : length of frame to compute pitch */
  55. Word16 lag_max, /* i : maximum lag */
  56. Word16 lag_min, /* i : minimum lag */
  57. Word32 corr[]) /* o : correlation of selected lag */
  58. {
  59. Word16 i, j;
  60. Word16 *p, *p1;
  61. Word32 t0;
  62. for (i = lag_max; i >= lag_min; i--)
  63. {
  64. p = scal_sig; move16 ();
  65. p1 = &scal_sig[-i]; move16 ();
  66. t0 = 0; move32 ();
  67. for (j = 0; j < L_frame; j++, p++, p1++)
  68. {
  69. t0 = L_mac_ex (t0, *p, *p1);
  70. }
  71. corr[-i] = t0; move32 ();
  72. }
  73. return;
  74. }