• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /*
19 *****************************************************************************
20 *
21 *      GSM AMR-NB speech codec   R98   Version 7.5.0   March 2, 2001
22 *                                R99   Version 3.2.0
23 *                                REL-4 Version 4.0.0
24 *
25 *****************************************************************************
26 *
27 *      File             : d_homing.c
28 *
29 *****************************************************************************
30 */
31 
32 /*
33 *****************************************************************************
34 *                         MODULE INCLUDE FILE AND VERSION ID
35 *****************************************************************************
36 */
37 
38 #include "d_homing.h"
39 //const char d_homing_id[] = "@(#)$Id $" d_homing_h;
40 
41 /*
42 *****************************************************************************
43 *                         INCLUDE FILES
44 *****************************************************************************
45 */
46 
47 #include <stdlib.h>
48 #include "typedef.h"
49 #include "cnst.h"
50 #include "mode.h"
51 #include "bits2prm.h"
52 
53 #include "d_homing.tab"
54 
55 /* get rid of compiler warning "`bitno' defined but never used" */
56 //static void* dummy[] = { (void *) bitno, (void *) dummy };
57 
58 
59 /*
60 *****************************************************************************
61 *                         PRIVATE PROGRAM CODE
62 *****************************************************************************
63 */
64 
65 /*
66 ********************************************************************************
67 *
68 *     Function        : dhf_test
69 *     In              : input_frame[]  one frame of encoded serial bits
70 *                       mode           mode type
71 *                       nparms         number of parameters to check
72 *     Out             : none
73 *     Calls           : Bits2prm
74 *     Tables          : d_homing.tab
75 *     Compile Defines : none
76 *     Return          : 0  input frame does not match the decoder homing
77 *                          frame pattern (up to nparms)
78 *                       1  input frame matches the decoder homing frame pattern
79 *                          (for the first nparms parameters)
80 *     Information     : The encoded serial bits are converted to all parameters
81 *                       of the corresponding mode. These parameters are compared
82 *                       with all parameters of the corresponding decoder homing frame.
83 *
84 ********************************************************************************
85 */
86 
dhf_test(Word16 input_frame[],enum Mode mode,Word16 nparms)87 static Word16 dhf_test(Word16 input_frame[], enum Mode mode, Word16 nparms)
88 {
89     Word16 i, j;
90     Word16 param[MAX_PRM_SIZE];
91 
92 
93     /* retrieve the encoded parameters from the received serial bits */
94     Bits2prm(mode, input_frame, param);
95 
96     j = 0;
97 
98     /* check if the encoded parameters matches the parameters
99        of the corresponding decoder homing frame */
100     for (i = 0; i < nparms; i++)
101     {
102         j = param[i] ^ dhf[mode][i];
103 
104         if (j)
105             break;
106     }
107 
108     return !j;
109 }
110 
111 
112 /*
113 *****************************************************************************
114 *                         PUBLIC PROGRAM CODE
115 *****************************************************************************
116 */
117 
118 
119 /*
120 ********************************************************************************
121 *
122 *     Function        : decoder_homing_frame_test
123 *     In              : input_frame[]  one frame of encoded serial bits
124 *                       mode           mode type
125 *     Out             : none
126 *     Calls           : dhf_test
127 *     Tables          : d_homing.tab
128 *     Compile Defines : none
129 *     Return          : 0  input frame does not match the decoder homing frame
130 *                          pattern
131 *                       1  input frame matches the decoder homing frame pattern
132 *     Information     : The encoded serial bits are converted to all parameters
133 *                       of the corresponding mode. These parameters are compared
134 *                       with all parameters of the corresponding decoder homing frame.
135 *
136 ********************************************************************************
137 */
138 
decoder_homing_frame_test(Word16 input_frame[],enum Mode mode)139 Word16 decoder_homing_frame_test(Word16 input_frame[], enum Mode mode)
140 {
141     /* perform test for COMPLETE parameter frame */
142     return dhf_test(input_frame, mode, prmno[mode]);
143 }
144 
145 
146 /*
147 ********************************************************************************
148 *
149 *     Function        : decoder_homing_frame_test_first
150 *     In              : input_frame[]  one frame of encoded serial bits
151 *                       mode           mode type
152 *     Out             : none
153 *     Calls           : Bits2prm
154 *     Tables          : d_homing.tab
155 *     Compile Defines : none
156 *     Return          : 0  input frame does not match the decoder homing frame
157 *                          pattern (up to and including the first subframe)
158 *                       1  input frame matches the decoder homing frame pattern
159 *                          (up to and including the first subframe)
160 *     Information     : The encoded serial bits are converted to all parameters
161 *                       of the corresponding mode. These parameters are
162 *                       compared with the parameters for LPC and first subframe
163 *                       of the decoder homing frame.
164 *
165 ********************************************************************************
166 */
167 
decoder_homing_frame_test_first(Word16 input_frame[],enum Mode mode)168 Word16 decoder_homing_frame_test_first(Word16 input_frame[], enum Mode mode)
169 {
170     /* perform test for FIRST SUBFRAME of parameter frame ONLY */
171     return dhf_test(input_frame, mode, prmnofsf[mode]);
172 }
173