1 | #include <manip.h>
|
---|
2 | #include "compress.h"
|
---|
3 |
|
---|
4 |
|
---|
5 | #define lg 72
|
---|
6 |
|
---|
7 | void exec_fen(int fen,int item,double valeur,...);
|
---|
8 |
|
---|
9 | long *entree,*comp,*rec;
|
---|
10 |
|
---|
11 |
|
---|
12 | main()
|
---|
13 | {
|
---|
14 | nouveauD(1,0,"compress",exec_fen);
|
---|
15 | return(1);
|
---|
16 | }
|
---|
17 |
|
---|
18 |
|
---|
19 | //-------------------- fonction exec de la fenetre : copie -------------------------------
|
---|
20 |
|
---|
21 |
|
---|
22 | void exec_fen(int fen,int item,double valeur,...)
|
---|
23 | {
|
---|
24 | int i;
|
---|
25 | long t;
|
---|
26 | double x,y;
|
---|
27 | double bruit=0;
|
---|
28 |
|
---|
29 | switch(item)
|
---|
30 | {
|
---|
31 | case ouverture :
|
---|
32 |
|
---|
33 |
|
---|
34 | random(0.2);
|
---|
35 | entree=malloc(lg*4);
|
---|
36 | comp=malloc(lg*4);
|
---|
37 | rec=malloc(lg*4);
|
---|
38 |
|
---|
39 | for(i=0;i<lg;i++)
|
---|
40 | {
|
---|
41 | bruit=bruit*0.8 + 0.2*random(0);
|
---|
42 | entree[i]=200000.*cos(i*0.005) + 100000.*bruit;
|
---|
43 | // entree[i]=200000.*cos(i*0.005) + 100000.*bruit + (i%2)*80000;
|
---|
44 | if(i>40) entree[i]+=500000.*exp(- 0.05*(i-40));
|
---|
45 | // if(i>40) entree[i]+=200000.*exp(- 0.05*(i-40));
|
---|
46 | entree[i]/=16; // entre 0 et 50 000 soit 16 bits
|
---|
47 | // entree[i]*=2; // de 0 a 15 e6 soit 21 bits
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | for(i=0;i<lg;i++) trace(1,i,entree[i]);
|
---|
52 | graph->couleur_trace=bleu;
|
---|
53 | style(1);
|
---|
54 | retrace(1);
|
---|
55 |
|
---|
56 | alerte(1,"");
|
---|
57 |
|
---|
58 | printf("comprime 4.1 avec lg=%d : ",lg);
|
---|
59 | t=TickCount();
|
---|
60 | for(i=0;i<1000;i++) compress_4_1((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
---|
61 | decompress_4_1(comp,rec,lg);
|
---|
62 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
---|
63 | printf("fin de comprime 4_1 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
---|
64 |
|
---|
65 |
|
---|
66 | /*
|
---|
67 | printf("comprime : ");
|
---|
68 | t=TickCount();
|
---|
69 | for(i=0;i<1000;i++) compress_4_2((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
---|
70 | decompress_4_2(comp,rec,lg);
|
---|
71 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
---|
72 | printf("fin de comprime 4_2 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
---|
73 |
|
---|
74 | */
|
---|
75 | /*
|
---|
76 | printf("comprime : ");
|
---|
77 | t=TickCount();
|
---|
78 | for(i=0;i<1000;i++) compress_7_1((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
---|
79 | decompress_7_1(comp,rec,lg);
|
---|
80 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
---|
81 | printf("fin de comprime 7_1 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | printf("comprime : ");
|
---|
86 | t=TickCount();
|
---|
87 | for(i=0;i<1;i++) compress_7_2((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
---|
88 | decompress_7_2(comp,rec,lg);
|
---|
89 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
---|
90 | printf("fin de comprime 7_2 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
---|
91 | */
|
---|
92 |
|
---|
93 | for(i=0;i<lg;i++) trace(1,i,rec[i]);
|
---|
94 | graph->couleur_trace=vert;
|
---|
95 | style(1);
|
---|
96 | for(i=0;i<lg;i++) trace(1,i,entree[i]-rec[i]);
|
---|
97 |
|
---|
98 |
|
---|
99 | break;
|
---|
100 | case fermeture :
|
---|
101 | break;
|
---|
102 | default : break;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|