source: Sophya/trunk/Poubelle/archTOI.old/decompress.c@ 310

Last change on this file since 310 was 310, checked in by ansari, 26 years ago

Conversion Archeops raw file -> TOI

File size: 7.3 KB
Line 
1#include "compress.h"
2
3
4//*******************************************************************************************
5//**************** *****************
6//**************** decompress_3 *****************
7//**************** *****************
8//*******************************************************************************************
9
10void decom_3(long val,long* in,long*out,int n);
11
12#define kmax_ 15 /* valeur maximum de l'exposant */
13#define kmak_ 0xf /* masque pour l'exposant */
14#define emak_ 0x7 /* masque pour l'ecart */
15#define sgbi_ 0x4 /* bit de signe de l'ecart */
16#define sign_ 0xfffffff8 /* masque de signe de l'ecart */
17
18// compress un tableau in de n*9 points disposé avec un pas pasin
19// les data compressées sont ecrites dans le tableau out de n points
20// la valeur val est la valeur de reference du point origine
21
22/* comprime 9*n points : 1er point dans 1er mot, tous les ecarts dans les n mots suivants */
23/* 9*n ==> n+1 pour 72 points : 9 mots */
24
25
26void decompress_3_1(long* in,long*out,int n)
27{
28long val;
29val= *in;
30decom_3(val,in+1,out,n/9);
31}
32
33
34
35void decom_3(long val,long* in,long*out,int n)
36{
37register long R;
38long ec1,ec2,ec3,ec4,ec5,ec6,ec7,ec8,ec9;
39int i,k;
40
41for(i=0;i<n;i++)
42 {
43 R=in[i];
44 k=R&kmak_;
45 recup(ec1,29,k);
46 recup(ec2,26,k);
47 recup(ec3,23,k);
48 recup(ec4,20,k);
49 recup(ec5,17,k);
50 recup(ec6,14,k);
51 recup(ec7,11,k);
52 recup(ec8,8,k);
53 recup(ec9,5,k);
54
55 val+=ec1; out[i*9]=val;
56 val+=ec2; out[i*9+1]=val;
57 val+=ec3; out[i*9+2]=val;
58 val+=ec4; out[i*9+3]=val;
59 val+=ec5; out[i*9+4]=val;
60 val+=ec6; out[i*9+5]=val;
61 val+=ec7; out[i*9+6]=val;
62 val+=ec8; out[i*9+7]=val;
63 val+=ec9; out[i*9+8]=val;
64 }
65}
66
67
68
69//*******************************************************************************************
70//**************** *****************
71//**************** decompress_4 *****************
72//**************** *****************
73//*******************************************************************************************
74
75void decom_4(long val,long* in,long*out,int n);
76void decom_4_paire(long val1,long val2,long* in,long*out,int n);
77
78#undef kmax_
79#undef kmak_
80#undef emak_
81#undef sgbi_
82#undef sign_
83
84
85
86#define kmax_ 15 /* valeur maximum de l'exposant */
87#define kmak_ 0xf /* masque pour l'exposant */
88#define emak_ 0xf /* masque pour l'ecart */
89#define sgbi_ 0x8 /* bit de signe de l'ecart */
90#define sign_ 0xfffffff0 /* masque de signe de l'ecart */
91
92
93/* comprime 7*n + 2 points (de 16 bit chacun) */
94/* 1er et 2 eme point dans 1er mot, les ecarts dans les n mots suivants */
95/* 7*n + 2 ==> n+1 ==> pour 72 points : 11 mots */
96
97
98void decompress_4_1(long* in,long*out,int n)
99{
100long val1,val2;
101val1= ( (*in & 0xffff0000)>>16 ) & 0x0000ffff;
102val2= ( (*in & 0x0000ffff) ) & 0x0000ffff;
103out[0]=val1;
104out[1]=val2;
105decom_4(val2,in+1,out+2,n/7);
106}
107
108
109
110void decom_4(long val,long* in,long*out,int n)
111{
112register long R;
113long ec1,ec2,ec3,ec4,ec5,ec6,ec7;
114int i,k;
115
116for(i=0;i<n;i++)
117 {
118 R=in[i];
119 k=R&kmak_;
120 recup(ec1,28,k);
121 recup(ec2,24,k);
122 recup(ec3,20,k);
123 recup(ec4,16,k);
124 recup(ec5,12,k);
125 recup(ec6,8,k);
126 recup(ec7,4,k);
127
128 val+=ec1; out[7*i]=val;
129 val+=ec2; out[7*i+1]=val;
130 val+=ec3; out[7*i+2]=val;
131 val+=ec4; out[7*i+3]=val;
132 val+=ec5; out[7*i+4]=val;
133 val+=ec6; out[7*i+5]=val;
134 val+=ec7; out[7*i+6]=val;
135 }
136}
137
138/********************************************************************************************/
139
140/* compresse en 4 bit mais par paire (pour data provenant de la detection synchrone) */
141
142/* 21 bit maleur maximum */
143/* comprime 7*n+2 points : 1er et 2eme point dans 1er et 2eme mot, suite dans n mots */
144/* différences entre valeures paires et entre valeures impaires uniquement */
145/* 7*n+2 ==> n+2 ==> pour 72 points : 12 mots */
146
147
148void decompress_4_2(long* in,long*out,int n)
149{
150long val1,val2;
151val1=in[0]; val2=in[1];
152out[0]=val1; out[1]=val2;
153decom_4_paire(val1,val2,in+2,out+2,n/7);
154}
155
156
157void decom_4_paire(long val1,long val2,long* in,long*out,int n)
158{
159register long R;
160long ec1,ec2,ec3,ec4,ec5,ec6,ec7;
161int i,k;
162
163for(i=0;i<n;i++)
164 {
165 R=in[i];
166 k=R&kmak_;
167 recup(ec1,28,k);
168 recup(ec2,24,k);
169 recup(ec3,20,k);
170 recup(ec4,16,k);
171 recup(ec5,12,k);
172 recup(ec6,8,k);
173 recup(ec7,4,k);
174
175// printf("i=%d k=%d ec= %d %d %d \n",i,k,ec1,ec2,ec3);
176
177
178 val1+=ec1; out[7*i]=val1;
179 val2+=ec2; out[7*i+1]=val2;
180 val1+=ec3; out[7*i+2]=val1;
181 val2+=ec4; out[7*i+3]=val2;
182 val1+=ec5; out[7*i+4]=val1;
183 val2+=ec6; out[7*i+5]=val2;
184 val1+=ec7; out[7*i+6]=val1;
185 R=val1;val1=val2;val2=R;
186 }
187}
188
189
190//*******************************************************************************************
191//**************** *****************
192//**************** compress_7 *****************
193//**************** *****************
194//*******************************************************************************************
195
196
197#undef kmax_
198#undef kmak_
199#undef emak_
200#undef sgbi_
201#undef sign_
202
203
204
205#define kmax_ 15 /* valeur maximum de l'exposant */
206#define kmak_ 0xf /* masque pour l'exposant */
207#define emak_ 0x7f /* masque pour l'ecart */
208#define sgbi_ 0x40 /* bit de signe de l'ecart */
209#define sign_ 0xffffff80 /* masque de signe de l'ecart */
210
211
212/* comprime 4*n points : 1er point dans 1er mot, tous les ecarts dans les n mots suivants */
213/* 4*n ==> n+1 */
214
215void decom_7(long val,long* in,long*out,int n);
216
217void decompress_7_1(long* in,long*out,int n)
218{
219long val;
220val=*in;
221*out=val;
222decom_7(val,in+1,out,n/4);
223}
224
225
226
227/* compress un tableau in de n*4 points disposé avec un pas pasin */
228/* les data compressées sont ecrites dans le tableau out de n points */
229/* la valeur val est la valeur de reference du point origine */
230
231void decom_7(long val,long* in,long*out,int n)
232{
233register long R;
234long ec1,ec2,ec3,ec4;
235int i,k;
236
237for(i=0;i<n;i++)
238 {
239 R=in[i];
240 k=R&kmak_;
241 recup(ec1,25,k);
242 recup(ec2,18,k);
243 recup(ec3,11,k);
244 recup(ec4,4,k);
245
246 val+=ec1; out[4*i]=val;
247 val+=ec2; out[4*i+1]=val;
248 val+=ec3; out[4*i+2]=val;
249 val+=ec4; out[4*i+3]=val;
250 }
251}
252
253/********************************************************************************/
254/* compresse en 7 bit mais par paire (pour data de la detection synchrone */
255/* 21 bit maleur maximum */
256/* comprime 4*n points : 1er et 2eme point dans 1er mot (16 bit chacun), */
257/* suite dans n mots */
258/* différences entre valeures paires et entre valeures impaires uniquement*/
259/* 4*n ==> n+1 */
260/********************************************************************************/
261
262void decom_7_paire(long val1,long val2,long* in,long*out,int n);
263
264void decompress_7_2(long* in,long*out,int n)
265{
266long val1,val2;
267val1= ( (*in & 0xffff0000)>>11 ) & 0x001fffe0;
268val2= ( (*in & 0x0000ffff)<<5 ) & 0x001fffe0;
269/*printf("val1=%x val2=%x \n",val1,val2);*/
270decom_7_paire(val1,val2,in+1,out,n/4);
271}
272
273
274void decom_7_paire(long val1,long val2,long* in,long*out,int n)
275{
276register long R;
277long ec1,ec2,ec3,ec4;
278int i,k;
279
280for(i=0;i<n;i++)
281 {
282 R=in[i];
283 k=R&kmak_;
284 recup(ec1,25,k);
285 recup(ec2,18,k);
286 recup(ec3,11,k);
287 recup(ec4,4,k);
288
289 val1+=ec1; out[4*i]=val1;
290 val2+=ec2; out[4*i+1]=val2;
291 val1+=ec3; out[4*i+2]=val1;
292 val2+=ec4; out[4*i+3]=val2;
293
294/*if(i<5) printf("in=%x i=%d k=%d ec= %x %x %x %x \n",R,i,k,ec1,ec2,ec3,ec4); */
295
296 }
297}
298
299
Note: See TracBrowser for help on using the repository browser.