d_homing.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 : d_homing.c
  11. *
  12. *****************************************************************************
  13. */
  14. /*
  15. *****************************************************************************
  16. * MODULE INCLUDE FILE AND VERSION ID
  17. *****************************************************************************
  18. */
  19. #include "d_homing.h"
  20. const char d_homing_id[] = "@(#)$Id $" d_homing_h;
  21. /*
  22. *****************************************************************************
  23. * INCLUDE FILES
  24. *****************************************************************************
  25. */
  26. #include <stdlib.h>
  27. #include "typedef.h"
  28. #include "mode.h"
  29. #include "bits2prm.h"
  30. #include "d_homing.tab"
  31. /* get rid of compiler warning "`bitno' defined but never used" */
  32. static void* dummy[] = { (void *) bitno, (void *) dummy };
  33. /*
  34. *****************************************************************************
  35. * PRIVATE PROGRAM CODE
  36. *****************************************************************************
  37. */
  38. /*
  39. ********************************************************************************
  40. *
  41. * Function : dhf_test
  42. * In : input_frame[] one frame of encoded serial bits
  43. * mode mode type
  44. * nparms number of parameters to check
  45. * Out : none
  46. * Calls : Bits2prm
  47. * Tables : d_homing.tab
  48. * Compile Defines : none
  49. * Return : 0 input frame does not match the decoder homing
  50. * frame pattern (up to nparms)
  51. * 1 input frame matches the decoder homing frame pattern
  52. * (for the first nparms parameters)
  53. * Information : The encoded serial bits are converted to all parameters
  54. * of the corresponding mode. These parameters are compared
  55. * with all parameters of the corresponding decoder homing frame.
  56. *
  57. ********************************************************************************
  58. */
  59. static Word16 dhf_test (Word16 input_frame[], enum Mode mode, Word16 nparms)
  60. {
  61. Word16 i, j;
  62. Word16 param[MAX_PRM_SIZE];
  63. /* retrieve the encoded parameters from the received serial bits */
  64. Bits2prm(mode, input_frame, param);
  65. j = 0;
  66. /* check if the encoded parameters matches the parameters
  67. of the corresponding decoder homing frame */
  68. for (i = 0; i < nparms; i++)
  69. {
  70. j = param[i] ^ dhf[mode][i];
  71. if (j)
  72. break;
  73. }
  74. return !j;
  75. }
  76. /*
  77. *****************************************************************************
  78. * PUBLIC PROGRAM CODE
  79. *****************************************************************************
  80. */
  81. /*
  82. ********************************************************************************
  83. *
  84. * Function : decoder_homing_frame_test
  85. * In : input_frame[] one frame of encoded serial bits
  86. * mode mode type
  87. * Out : none
  88. * Calls : dhf_test
  89. * Tables : d_homing.tab
  90. * Compile Defines : none
  91. * Return : 0 input frame does not match the decoder homing frame
  92. * pattern
  93. * 1 input frame matches the decoder homing frame pattern
  94. * Information : The encoded serial bits are converted to all parameters
  95. * of the corresponding mode. These parameters are compared
  96. * with all parameters of the corresponding decoder homing frame.
  97. *
  98. ********************************************************************************
  99. */
  100. Word16 decoder_homing_frame_test (Word16 input_frame[], enum Mode mode)
  101. {
  102. /* perform test for COMPLETE parameter frame */
  103. return dhf_test(input_frame, mode, prmno[mode]);
  104. }
  105. /*
  106. ********************************************************************************
  107. *
  108. * Function : decoder_homing_frame_test_first
  109. * In : input_frame[] one frame of encoded serial bits
  110. * mode mode type
  111. * Out : none
  112. * Calls : Bits2prm
  113. * Tables : d_homing.tab
  114. * Compile Defines : none
  115. * Return : 0 input frame does not match the decoder homing frame
  116. * pattern (up to and including the first subframe)
  117. * 1 input frame matches the decoder homing frame pattern
  118. * (up to and including the first subframe)
  119. * Information : The encoded serial bits are converted to all parameters
  120. * of the corresponding mode. These parameters are
  121. * compared with the parameters for LPC and first subframe
  122. * of the decoder homing frame.
  123. *
  124. ********************************************************************************
  125. */
  126. Word16 decoder_homing_frame_test_first (Word16 input_frame[], enum Mode mode)
  127. {
  128. /* perform test for FIRST SUBFRAME of parameter frame ONLY */
  129. return dhf_test(input_frame, mode, prmnofsf[mode]);
  130. }