reorder.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 : reorder.c
  11. * Purpose : To make sure that the LSFs are properly ordered
  12. * : and to keep a certain minimum distance between
  13. * : adjacent LSFs.
  14. *
  15. ********************************************************************************
  16. */
  17. /*
  18. ********************************************************************************
  19. * MODULE INCLUDE FILE AND VERSION ID
  20. ********************************************************************************
  21. */
  22. #include "reorder.h"
  23. const char reorder_id[] = "@(#)$Id $" reorder_h;
  24. /*
  25. ********************************************************************************
  26. * INCLUDE FILES
  27. ********************************************************************************
  28. */
  29. #include "typedef.h"
  30. #include "basic_op.h"
  31. #include "count.h"
  32. /*
  33. ********************************************************************************
  34. * LOCAL VARIABLES AND TABLES
  35. ********************************************************************************
  36. */
  37. /*
  38. ********************************************************************************
  39. * PUBLIC PROGRAM CODE
  40. ********************************************************************************
  41. */
  42. /*************************************************************************
  43. *
  44. * FUNCTION: Reorder_lsf()
  45. *
  46. * PURPOSE: To make sure that the LSFs are properly ordered and to keep a
  47. * certain minimum distance between adjacent LSFs.
  48. *
  49. * The LSFs are in the frequency range 0-0.5 and represented in Q15
  50. *
  51. *************************************************************************/
  52. void Reorder_lsf (
  53. Word16 *lsf, /* (i/o) : vector of LSFs (range: 0<=val<=0.5) */
  54. Word16 min_dist, /* (i) : minimum required distance */
  55. Word16 n /* (i) : LPC order */
  56. )
  57. {
  58. Word16 i;
  59. Word16 lsf_min;
  60. lsf_min = min_dist; move16 ();
  61. for (i = 0; i < n; i++)
  62. {
  63. test ();
  64. if (sub_ex (lsf[i], lsf_min) < 0)
  65. {
  66. lsf[i] = lsf_min; move16 ();
  67. }
  68. lsf_min = add_ex (lsf[i], min_dist);
  69. }
  70. }