source: Sophya/trunk/Poubelle/archediab.old/prog_compression_unsigned/decompress.c@ 647

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

compression

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