| 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 |
|
|---|
| 55 |
|
|---|
| 56 | /*
|
|---|
| 57 | printf("comprime : ");
|
|---|
| 58 | t=TickCount();
|
|---|
| 59 | for(i=0;i<1000;i++) compress_4_1((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
|---|
| 60 | decompress_4_1(comp,rec,lg);
|
|---|
| 61 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
|---|
| 62 | printf("fin de comprime 4_1 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
|---|
| 63 | */
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | printf("comprime : ");
|
|---|
| 67 | t=TickCount();
|
|---|
| 68 | for(i=0;i<1000;i++) compress_4_2((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
|---|
| 69 | decompress_4_2(comp,rec,lg);
|
|---|
| 70 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
|---|
| 71 | printf("fin de comprime 4_2 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | /*
|
|---|
| 75 | printf("comprime : ");
|
|---|
| 76 | t=TickCount();
|
|---|
| 77 | for(i=0;i<1000;i++) compress_7_1((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
|---|
| 78 | decompress_7_1(comp,rec,lg);
|
|---|
| 79 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
|---|
| 80 | printf("fin de comprime 7_1 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | printf("comprime : ");
|
|---|
| 85 | t=TickCount();
|
|---|
| 86 | for(i=0;i<1;i++) compress_7_2((unsigned long*)entree,(unsigned long*)comp,lg,1);
|
|---|
| 87 | decompress_7_2(comp,rec,lg);
|
|---|
| 88 | y=0;for(i=0;i<lg;i++) {x=entree[i]-rec[i];y+=x*x;} y=sqrt(y/(double)lg);
|
|---|
| 89 | printf("fin de comprime 7_2 : t=%d ecart total = %g \n\n",TickCount()-t,y);
|
|---|
| 90 | */
|
|---|
| 91 |
|
|---|
| 92 | for(i=0;i<lg;i++) trace(1,i,rec[i]);
|
|---|
| 93 | graph->couleur_trace=vert;
|
|---|
| 94 | style(1);
|
|---|
| 95 | for(i=0;i<lg;i++) trace(1,i,entree[i]-rec[i]);
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | break;
|
|---|
| 99 | case fermeture :
|
|---|
| 100 | break;
|
|---|
| 101 | default : break;
|
|---|
| 102 | }
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|