FreeCalypso > hg > fc-magnetite
comparison src/gpf3/ccd/gsm1_v.c @ 2:c41a534f33c6
src/gpf3: preened GPF goo from TCS3.2
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Sep 2016 23:52:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:864b8cc0cf63 | 2:c41a534f33c6 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : | |
4 | Modul : gsm1_v.c | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : Definition of encoding and decoding functions for GSM1_V elements | |
18 +----------------------------------------------------------------------------- | |
19 */ | |
20 | |
21 | |
22 /* | |
23 * standard definitions like GLOBAL, UCHAR, ERROR etc. | |
24 */ | |
25 #include "typedefs.h" | |
26 #include "header.h" | |
27 | |
28 /* | |
29 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only | |
30 * look at ccdapi.h | |
31 */ | |
32 #undef USE_DRIVER | |
33 #include "ccdapi.h" | |
34 | |
35 /* | |
36 * Types and functions for bit access and manipulation | |
37 */ | |
38 #include "ccd_globs.h" | |
39 #include "bitfun.h" | |
40 | |
41 /* | |
42 * Prototypes of ccd internal functions | |
43 */ | |
44 #include "ccd.h" | |
45 | |
46 | |
47 /* | |
48 * Declaration of coder/decoder tables | |
49 */ | |
50 #include "ccdtable.h" | |
51 #include "ccddata.h" | |
52 | |
53 #ifndef RUN_FLASH | |
54 /* | |
55 +--------------------------------------------------------------------+ | |
56 | PROJECT : CCD (6144) MODULE : CDC_GSM | | |
57 | STATE : code ROUTINE : cdc_gsm1v_decode | | |
58 +--------------------------------------------------------------------+ | |
59 | |
60 PURPOSE : Decoding of the GSM Type 1V element. This element | |
61 consists of a V component with max. 4 Bit length. | |
62 */ | |
63 | |
64 SHORT cdc_gsm1v_decode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
65 { | |
66 SHORT ret; | |
67 ULONG cix_ref, num_prolog_steps, prolog_step_ref; | |
68 | |
69 #ifdef DEBUG_CCD | |
70 #ifndef CCD_SYMBOLS | |
71 TRACE_CCD (globs, "cdc_gsm1v_decode()"); | |
72 #else | |
73 TRACE_CCD (globs, "cdc_gsm1v_decode() %s", ccddata_get_alias((USHORT) e_ref, 1)); | |
74 #endif | |
75 #endif | |
76 | |
77 cix_ref = melem[e_ref].calcIdxRef; | |
78 num_prolog_steps = calcidx[cix_ref].numPrologSteps; | |
79 prolog_step_ref = calcidx[cix_ref].prologStepRef; | |
80 | |
81 /* | |
82 * if this element have a defined Prolog | |
83 * we have to process it before decoding the bitstream | |
84 */ | |
85 if (num_prolog_steps) | |
86 { | |
87 ccd_performOperations (num_prolog_steps, prolog_step_ref, globs); | |
88 } | |
89 | |
90 if (!globs->Swap1V_inProgress) | |
91 { | |
92 /* | |
93 * check if the next element is a GSM1V too | |
94 */ | |
95 if ((ULONG)(mcomp[c_ref].componentRef | |
96 +mcomp[c_ref].numOfComponents) > e_ref | |
97 AND (melem[e_ref].codingType EQ melem[e_ref+1].codingType | |
98 OR melem[e_ref+1].elemType EQ 'S')) | |
99 { | |
100 if (melem[e_ref+1].elemType EQ 'S') | |
101 { | |
102 /* | |
103 * if the next element is a spare then skip the next 4 bits | |
104 * do not decode the spare bits. | |
105 */ | |
106 bf_setBitpos ((globs->bitpos+4), globs); | |
107 | |
108 ret = cdc_std_decode (c_ref, e_ref, globs); | |
109 | |
110 if (ret EQ 1) | |
111 ret++; | |
112 | |
113 return ret; | |
114 } | |
115 else | |
116 { | |
117 /* | |
118 * another 1V-element follow. We have to swap the nibbles. | |
119 */ | |
120 globs->Swap1V_inProgress = TRUE; | |
121 /* | |
122 * store the akt position | |
123 */ | |
124 globs->akt1VPos = (USHORT)(globs->bitpos+4); | |
125 globs->next1VPos = globs->bitpos; | |
126 | |
127 bf_setBitpos (globs->akt1VPos, globs); | |
128 ret = cdc_std_decode (c_ref, e_ref, globs); | |
129 /* | |
130 * increment the globs->maxBitpos by 1 so the bf_endOfBitstream | |
131 * will return FALSE | |
132 */ | |
133 globs->maxBitpos++; | |
134 | |
135 return ret; | |
136 } | |
137 } | |
138 ret = cdc_std_decode (c_ref, e_ref, globs); | |
139 | |
140 } | |
141 else | |
142 { | |
143 globs->akt1VPos = globs->next1VPos; | |
144 globs->next1VPos = globs->bitpos; | |
145 | |
146 bf_setBitpos (globs->akt1VPos, globs); | |
147 | |
148 /* | |
149 * decrement the globs->maxBitpos by 1 so the bf_endOfBitstream | |
150 * will return TRUE if the bitstream ended | |
151 */ | |
152 globs->maxBitpos--; | |
153 | |
154 ret = cdc_std_decode (c_ref, e_ref, globs); | |
155 | |
156 bf_setBitpos (globs->next1VPos, globs); | |
157 | |
158 globs->Swap1V_inProgress = FALSE; | |
159 | |
160 } | |
161 return ret; | |
162 } | |
163 #endif /* !RUN_FLASH */ | |
164 | |
165 #ifndef RUN_FLASH | |
166 /* | |
167 +--------------------------------------------------------------------+ | |
168 | PROJECT : CCD (6144) MODULE : CDC_GSM | | |
169 | STATE : code ROUTINE : cdc_gsm1v_encode | | |
170 +--------------------------------------------------------------------+ | |
171 | |
172 PURPOSE : encoding of the GSM Type 1V element. This element | |
173 consists of a V component with max. 4 Bit length. | |
174 */ | |
175 | |
176 SHORT cdc_gsm1v_encode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
177 { | |
178 #ifdef DEBUG_CCD | |
179 #ifndef CCD_SYMBOLS | |
180 TRACE_CCD (globs, "cdc_gsm1v_encode()"); | |
181 #else | |
182 TRACE_CCD (globs, "cdc_gsm1v_encode() %s", ccddata_get_alias((USHORT) e_ref, 1)); | |
183 #endif | |
184 #endif | |
185 | |
186 if (!globs->Swap1V_inProgress) | |
187 { | |
188 /* | |
189 * check if the next element is a GSM1V too | |
190 */ | |
191 if ((ULONG)(mcomp[c_ref].componentRef | |
192 +mcomp[c_ref].numOfComponents) > e_ref | |
193 AND (melem[e_ref].codingType EQ melem[e_ref+1].codingType | |
194 OR melem[e_ref+1].elemType EQ 'S')) | |
195 { | |
196 if (melem[e_ref+1].elemType EQ 'S') | |
197 { | |
198 SHORT ret; | |
199 /* | |
200 * if the next element is a spare then skip the next 4 bits | |
201 * do not code the spare bits because the bitstream is cleared. | |
202 */ | |
203 bf_setBitpos (globs->bitpos+4, globs); | |
204 | |
205 ret = cdc_std_encode (c_ref, e_ref, globs); | |
206 | |
207 if (ret EQ 1) | |
208 ret++; | |
209 | |
210 return ret; | |
211 } | |
212 else | |
213 { | |
214 /* | |
215 * another 1V-element follow. We have to swap the nibbles. | |
216 */ | |
217 globs->Swap1V_inProgress = TRUE; | |
218 /* | |
219 * store the akt position | |
220 */ | |
221 globs->akt1VPos = (USHORT)(globs->bitpos+4); | |
222 globs->next1VPos = globs->bitpos; | |
223 | |
224 bf_setBitpos (globs->akt1VPos, globs); | |
225 } | |
226 } | |
227 return cdc_std_encode (c_ref, e_ref, globs); | |
228 } | |
229 else | |
230 { | |
231 SHORT ret; | |
232 | |
233 globs->akt1VPos = globs->next1VPos; | |
234 globs->next1VPos = globs->bitpos; | |
235 | |
236 bf_setBitpos (globs->akt1VPos, globs); | |
237 | |
238 ret = cdc_std_encode (c_ref, e_ref, globs); | |
239 | |
240 bf_setBitpos (globs->next1VPos, globs); | |
241 | |
242 globs->Swap1V_inProgress = FALSE; | |
243 | |
244 return ret; | |
245 } | |
246 } | |
247 #endif /* !RUN_FLASH */ |