Ignore:
Timestamp:
Nov 25, 1999, 4:58:46 PM (26 years ago)
Author:
ansari
Message:

4 bit pour bolo on-of/bolo transmis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Poubelle/archediab.old/archediab.sources/c/compress.c

    r637 r657  
    1 #include <manip.h>
     1#include "manip.h"
    22#include "compress.h"
    33
    44
    55/*******************************************************************************************/
    6 /****************                                                                                                               ****************/
    7 /****************                                       compress_3                                                      ****************/
    8 /****************                                                                                                               ****************/
    9 /*******************************************************************************************/
    10 
    11 void  com_3(long val,long* in,long*out,int n,int pasin);
    12 
    13 
    14 #define kmax_   15              /*  valeur maximum de l'exposant        */
    15 #define kmak_   0xf             /*      masque pour l'exposant          */
    16 #define emak_   0x7             /*      masque pour l'ecart             */             
    17 #define sgbi_   0x4             /*      bit de signe de l'ecart         */
    18 #define sign_   0xfffffff8      /*      masque de signe de l'ecart      */
    19 
    20 /*  compress un tableau in de n*9 points disposé avec un pas pasin              */
     6/****************                                                               ************/
     7/****************                                       compress_3              ************/
     8/****************                                                               ************/
     9/*******************************************************************************************/
     10
     11static int filtre[16]={0xfffffff,0xffffffe,0xffffffc,0xffffff8,
     12                0xffffff0,0xfffffe0,0xfffffc0,0xfffff80,
     13                0xfffff00,0xffffe00,0xffffc00,0xffff800,
     14                0xffff000,0xfffe000,0xfffc000,0xfff8000};
     15int test[16]=  {0x00000000,0x00000001,0x00000002,0x00000004,
     16                0x00000008,0x00000010,0x00000020,0x00000040,
     17                0x00000080,0x00000100,0x00000200,0x00000400,
     18                0x00000800,0x00001000,0x00002000,0x00004000};
     19
     20
     21void  com_3(unsigned long val,unsigned long* in,unsigned long*out,int n,int pasin);
     22
     23#define data_mask       0xffff  /* masque pour les données en entree    */
     24#define ecart_(i,n,val)         (( (in[(i*9+n)*pasin]&data_mask) | ecart_bit )-val);
     25
     26#define ecart_mask              0x7     /*      masque pour l'ecart             */             
     27
     28
     29
     30/*  compress un tableau in de n*9 points disposé avec un pas pasin      */
    2131/*  les data compressées sont ecrites dans le tableau out de n points   */
    22 /*  la valeur val est la valeur de reference du point origine                   */
    23 
    24 
    25 /*  comprime    9*n points  : 1er point dans 1er mot, tous les ecarts dans les n mots suivants          */
    26 /*      9*n     ==>     n+1         pour  72 points :   9 mots                  */
    27 
    28 void compress_3_1(long* in,long*out,int n,int pasin)
    29 {
    30 long val;
     32/*  la valeur val est la valeur de reference du point origine           */
     33
     34
     35/*  comprime    9*n points  : 1er point dans 1er mot                    */
     36/*                            tous les ecarts dans les n mots suivants  */
     37/*      9*n     ==>     n+1         pour  72 points :   9 mots          */
     38
     39void compress_3_1(unsigned long* in,unsigned long*out,int n,int pasin)
     40{
     41unsigned long val;
    3142val=in[0]; out[0]=val;
    3243com_3(val,in,out+1,n/9,pasin);
     
    3546
    3647
    37 void  com_3(long val,long* in,long*out,int n,int pasin)
    38 {
    39 int filtre[16]={0xffffffff,0xfffffffe,0xfffffffc,0xfffffff8,
    40                                 0xfffffff0,0xffffffe0,0xffffffc0,0xffffff80,
    41                                 0xffffff00,0xfffffe00,0xfffffc00,0xfffff800,
    42                                 0xfffff000,0xffffe000,0xffffc000,0xffff8000};
    43 int test[16]=  {0x00000000,0x00000001,0x00000002,0x00000004,
    44                                 0x00000008,0x00000010,0x00000020,0x00000040,
    45                                 0x00000080,0x00000100,0x00000200,0x00000400,
    46                                 0x00000800,0x00001000,0x00002000,0x00004000};
    47 
    48 long val1;
    49 long ec1,ec2,ec3,ec4,ec5,ec6,ec7,ec8,ec9;
    50 int i,k,k1;long q;
     48
     49void  com_3(unsigned long val,unsigned long* in,unsigned long*out,int n,int pasin)
     50{
     51unsigned long val1;
     52unsigned long ec1,ec2,ec3,ec4,ec5,ec6,ec7,ec8,ec9;
     53int i,k,k1;unsigned long q;
    5154
    5255
     
    5558        k=0;q=3;        /* 3 bit = 7 = +-3      */
    5659
    57         ec1=in[i*9*pasin]-val;
     60        ec1=ecart_(i,0,val);
    5861        shif(ec1,k,q);
    59         val1=val + arrondi(ec1,k);
     62        val1=new_val(val,ec1,k);
    6063       
    6164        k1=k;
    62         ec2=in[(i*9+1)*pasin]-val1;
     65        ec2=ecart_(i,1,val1);
    6366        shif(ec2,k,q);
    6467       
    65         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k);}
    66         val1+= arrondi(ec2,k);
    67 
    68         ec3=in[(i*9+2)*pasin]-val1;
     68        if(k>k1)        {k1=k;val1=new_val(val,ec1,k);}
     69        val1=new_val(val1,ec2,k);
     70
     71        ec3=ecart_(i,2,val1);
    6972        shif(ec3,k,q);
    7073
    71         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k);}
    72         val1+= arrondi(ec3,k);         
    73 
    74         ec4=in[(i*9+3)*pasin]-val1;
     74        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k))&data_mask;}
     75        val1=new_val(val1,ec3,k);
     76
     77        ec4=ecart_(i,3,val1);
    7578        shif(ec4,k,q);
    7679
    77         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k);}
    78         val1+= arrondi(ec4,k);         
    79 
    80         ec5=in[(i*9+4)*pasin]-val1;
     80        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k))&data_mask;}
     81        val1=new_val(val1,ec4,k);
     82
     83        ec5=ecart_(i,4,val1);
    8184        shif(ec5,k,q);
    8285
    83         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k) + arrondi(ec4,k);}
    84         val1+= arrondi(ec5,k);         
    85        
    86         ec6=in[(i*9+5)*pasin]-val1;
     86        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
     87                                + arrondi(ec4,k))&data_mask;}
     88        val1=new_val(val1,ec5,k);
     89       
     90        ec6=ecart_(i,5,val1);
    8791        shif(ec6,k,q);
    8892
    89         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
    90                                          + arrondi(ec4,k) + arrondi(ec5,k);}
    91         val1+= arrondi(ec6,k);         
    92        
    93         ec7=in[(i*9+6)*pasin]-val1;
     93        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
     94                                        + arrondi(ec4,k) + arrondi(ec5,k))&data_mask;}
     95        val1=new_val(val1,ec6,k);
     96       
     97        ec7=ecart_(i,6,val1);
    9498        shif(ec7,k,q);
    9599
    96         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k)
    97                                 + arrondi(ec3,k) + arrondi(ec4,k) + arrondi(ec5,k) + arrondi(ec6,k);}
    98         val1+= arrondi(ec7,k);         
    99        
    100         ec8=in[(i*9+7)*pasin]-val1;
     100        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k)
     101                                + arrondi(ec3,k) + arrondi(ec4,k) + arrondi(ec5,k) + arrondi(ec6,k))&data_mask;}
     102        val1=new_val(val1,ec7,k);
     103       
     104        ec8=ecart_(i,7,val1);
    101105        shif(ec8,k,q);
    102106
    103         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
    104                                          + arrondi(ec4,k) + arrondi(ec5,k) + arrondi(ec6,k) + arrondi(ec7,k);}
    105         val1+= arrondi(ec8,k);         
    106        
    107         ec9=in[(i*9+8)*pasin]-val1;
     107        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
     108                                         + arrondi(ec4,k) + arrondi(ec5,k) + arrondi(ec6,k) + arrondi(ec7,k))&data_mask;}
     109        val1=new_val(val1,ec8,k);
     110       
     111        ec9=ecart_(i,8,val1);
    108112        shif(ec9,k,q);
    109113       
     
    120124        ec9 =  arrondi(ec9,k) >> k;
    121125
    122         out[i]= ((ec1&emak_)<<29) | ((ec2&emak_)<<26) | ((ec3&emak_)<<23)
    123                                 | ((ec4&emak_)<<20) | ((ec5&emak_)<<17) | ((ec6&emak_)<<14)
    124                                 | ((ec7&emak_)<<11)  | ((ec8&emak_)<<8) | ((ec9&emak_)<<5) | k ;
     126        out[i]= ((ec1&ecart_mask)<<29) | ((ec2&ecart_mask)<<26) | ((ec3&ecart_mask)<<23)
     127                | ((ec4&ecart_mask)<<20) | ((ec5&ecart_mask)<<17) | ((ec6&ecart_mask)<<14)
     128                | ((ec7&ecart_mask)<<11)  | ((ec8&ecart_mask)<<8) | ((ec9&ecart_mask)<<5) | k ;
    125129
    126130
    127131/*      if(i<30)  printf("i=%d  k=%d  ec= %d %d %d \n",i,k,ec1,ec2,ec3,out[(i+8)/7]);*/
    128132
    129         val+= ( (ec1 + ec2 + ec3 + ec4 + ec5 + ec6 + ec7 + ec8 + ec9 ) << k );
     133        val=(val + ( (ec1 + ec2 + ec3 + ec4 + ec5 + ec6 + ec7 + ec8 + ec9 ) << k )) & data_mask;
    130134        }
    131135}
     
    139143/*******************************************************************************************/
    140144
    141 void  com_4(long val,long* in,long*out,int n,int pasin);
    142 void  com_4_paire(long val1,long val2,long* in,long*out,int n,int pasin);
    143 
    144 
    145 #undef kmax_
    146 #undef  kmak_
    147 #undef  emak_           
    148 #undef  sgbi_
    149 #undef  sign_
    150 
    151 
    152 #define kmax_   15              /*  valeur maximum de l'exposant        */
    153 #define kmak_   0xf             /*      masque pour l'exposant          */
    154 #define emak_   0xf             /*      masque pour l'ecart             */             
    155 #define sgbi_   0x8             /*      bit de signe de l'ecart         */
    156 #define sign_   0xfffffff0      /*      masque de signe de l'ecart      */
     145void  com_4(unsigned long val,unsigned long* in,unsigned long*out,int n,int pasin);
     146void  com_4_paire(unsigned long val1,unsigned long val2,unsigned long* in,unsigned long*out,int n,int pasin);
     147
     148
     149#undef  ecart_mask             
     150#define ecart_mask      0xf             /*      masque pour l'ecart             */             
     151
     152#undef  data_mask
     153#define data_mask       0xffff  /* masque pour les données en entree    */
     154#undef  ecart_
     155#define ecart_(i,n,val)         (( (in[(i*7+n)*pasin]&data_mask) | ecart_bit )-val);
     156
    157157
    158158/*  compress un tableau in de n*7 points disposé avec un pas pasin      */
     
    165165/*      7*n + 2 ==>     n+1          ==>   pour  72 points :   11 mots                          */
    166166
    167 void compress_4_1(long* in,long*out,int n,int pasin)
    168 {
    169 long val1,val2;
     167void compress_4_1(unsigned long* in,unsigned long*out,int n,int pasin)
     168{
     169unsigned long val1,val2;
    170170val1=in[0];val2=in[1];
    171171*out=( (val1<<16) & 0xffff0000 )        |       ( ( val2 ) & 0xffff ) ;
     
    176176
    177177
    178 void  com_4(long val,long* in,long*out,int n,int pasin)
    179 {
    180 int filtre[16]={0xffffffff,0xfffffffe,0xfffffffc,0xfffffff8,
    181                                 0xfffffff0,0xffffffe0,0xffffffc0,0xffffff80,
    182                                 0xffffff00,0xfffffe00,0xfffffc00,0xfffff800,
    183                                 0xfffff000,0xffffe000,0xffffc000,0xffff8000};
    184 int test[16]=  {0x00000000,0x00000001,0x00000002,0x00000004,
    185                                 0x00000008,0x00000010,0x00000020,0x00000040,
    186                                 0x00000080,0x00000100,0x00000200,0x00000400,
    187                                 0x00000800,0x00001000,0x00002000,0x00004000};
    188 
    189 long val1;
    190 long ec1,ec2,ec3,ec4,ec5,ec6,ec7;
    191 int i,k,k1;long q;
     178void  com_4(unsigned long val,unsigned long* in,unsigned long*out,int n,int pasin)
     179{
     180unsigned long val1;
     181unsigned long ec1,ec2,ec3,ec4,ec5,ec6,ec7;
     182int i,k,k1;unsigned long q;
    192183
    193184
     
    196187        k=0;q=7;        /* 4 bit = 15 = +-7     */
    197188
    198         ec1=in[i*7*pasin]-val;
     189        ec1=ecart_(i,0,val);
    199190        shif(ec1,k,q);
    200         val1=val + arrondi(ec1,k);
     191        val1=new_val(val,ec1,k);
    201192       
    202193        k1=k;
    203         ec2=in[(i*7+1)*pasin]-val1;
     194        ec2=ecart_(i,1,val1);
    204195        shif(ec2,k,q);
    205196       
    206         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k);}
    207         val1+= arrondi(ec2,k);
    208 
    209         ec3=in[(i*7+2)*pasin]-val1;
     197        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k))&data_mask;}
     198        val1=new_val(val1,ec2,k);
     199
     200        ec3=ecart_(i,2,val1);
    210201        shif(ec3,k,q);
    211202
    212         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k);}
    213         val1+= arrondi(ec3,k);         
    214 
    215         ec4=in[(i*7+3)*pasin]-val1;
     203        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k))&data_mask;}
     204        val1=new_val(val1,ec3,k);
     205
     206        ec4=ecart_(i,3,val1);
    216207        shif(ec4,k,q);
    217208
    218         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k);}
    219         val1+= arrondi(ec4,k);         
    220 
    221         ec5=in[(i*7+4)*pasin]-val1;
     209        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k))&data_mask;}
     210        val1=new_val(val1,ec4,k);
     211
     212        ec5=ecart_(i,4,val1);
    222213        shif(ec5,k,q);
    223214
    224         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k) + arrondi(ec4,k);}
    225         val1+= arrondi(ec5,k);         
    226        
    227         ec6=in[(i*7+5)*pasin]-val1;
     215        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k) + arrondi(ec4,k))&data_mask;}
     216        val1=new_val(val1,ec5,k);
     217       
     218        ec6=ecart_(i,5,val1);
    228219        shif(ec6,k,q);
    229220
    230         if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
    231                                          + arrondi(ec4,k) + arrondi(ec5,k);}
    232         val1+= arrondi(ec6,k);         
    233        
    234         ec7=in[(i*7+6)*pasin]-val1;
     221        if(k>k1)        {k1=k;val1=(val + arrondi(ec1,k) + arrondi(ec2,k) + arrondi(ec3,k)
     222                                         + arrondi(ec4,k) + arrondi(ec5,k))&data_mask;}
     223        val1=new_val(val1,ec6,k);
     224       
     225        ec7=ecart_(i,6,val1);
    235226        shif(ec7,k,q);
    236227       
     
    245236        ec7 =  arrondi(ec7,k) >> k;
    246237
    247         out[i]= ((ec1&emak_)<<28) | ((ec2&emak_)<<24) | ((ec3&emak_)<<20)
    248                                 | ((ec4&emak_)<<16) | ((ec5&emak_)<<12) | ((ec6&emak_)<<8) | ((ec7&emak_)<<4) | k ;
     238        out[i]= ((ec1&ecart_mask)<<28) | ((ec2&ecart_mask)<<24) | ((ec3&ecart_mask)<<20)
     239                                | ((ec4&ecart_mask)<<16) | ((ec5&ecart_mask)<<12) | ((ec6&ecart_mask)<<8) | ((ec7&ecart_mask)<<4) | k ;
    249240
    250241
    251242/*      if(i<30)  printf("i=%d  k=%d  ec= %d %d %d \n",i,k,ec1,ec2,ec3,out[(i+8)/7]);*/
    252243
    253         val+= ( (ec1 + ec2 + ec3 + ec4 + ec5 + ec6 + ec7 ) << k );
     244        val=(val+ ( (ec1 + ec2 + ec3 + ec4 + ec5 + ec6 + ec7 ) << k ))&data_mask;
    254245        }
    255246}
     
    264255/*      7*n+2   ==>     n+2                     ==>  pour 72 points :           12 mots                                                         */
    265256
    266 void compress_4_2(long* in,long*out,int n,int pasin)
    267 {
    268 long val1,val2;
    269 val1=in[0];             val2=in[1];
     257#undef  data_mask
     258#define data_mask       0x1fffff        /* masque pour les données en entree 21 bit     */
     259#undef  ecart_
     260#define ecart_(i,n,val)         (( (in[(i*7+n)*pasin]&data_mask) | ecart_bit )-val);
     261
     262void compress_4_2(unsigned long* in,unsigned long*out,int n,int pasin)
     263{
     264unsigned long val1,val2;
     265val1=in[0]&data_mask;           val2=in[1]&data_mask;
    270266out[0]=val1;    out[1]=val2;
    271267com_4_paire(val1,val2,in+2,out+2,n/7,pasin);
     
    273269
    274270
    275 void  com_4_paire(long val1,long val2,long* in,long*out,int n,int pasin)
    276 {
    277 int filtre[16]={0xffffffff,0xfffffffe,0xfffffffc,0xfffffff8,
    278                                 0xfffffff0,0xffffffe0,0xffffffc0,0xffffff80,
    279                                 0xffffff00,0xfffffe00,0xfffffc00,0xfffff800,
    280                                 0xfffff000,0xffffe000,0xffffc000,0xffff8000};
    281 int test[16]=  {0x00000000,0x00000001,0x00000002,0x00000004,
    282                                 0x00000008,0x00000010,0x00000020,0x00000040,
    283                                 0x00000080,0x00000100,0x00000200,0x00000400,
    284                                 0x00000800,0x00001000,0x00002000,0x00004000};
    285 
    286 long val1p,val2p;
    287 long ec1,ec2,ec3,ec4,ec5,ec6,ec7;
    288 int i,k,k1;long q;
     271void  com_4_paire(unsigned long val1,unsigned long val2,unsigned long* in,unsigned long*out,int n,int pasin)
     272{
     273unsigned long val1p,val2p;
     274unsigned long ec1,ec2,ec3,ec4,ec5,ec6,ec7;
     275int i,k,k1;unsigned long q;
    289276
    290277
     
    293280        k=0;q=7;        /* 4 bit = 15 = +-7     */
    294281
    295         ec1=in[i*7*pasin]-val1;
     282        ec1=ecart_(i,0,val1);
    296283        shif(ec1,k,q);
    297284       
    298         ec2=in[(i*7+1)*pasin]-val2;
     285        ec2=ecart_(i,1,val2);
    299286        shif(ec2,k,q);
    300287       
    301288        k1=k;
    302         val1p=val1 + arrondi(ec1,k);
    303 
    304 
    305         ec3=in[(i*7+2)*pasin]-val1p;
     289        val1p=new_val(val1,ec1,k);
     290
     291
     292        ec3=ecart_(i,2,val1p);
    306293        shif(ec3,k,q);
    307294
    308         val2p=val2 + arrondi(ec2,k);
    309 
    310         ec4=in[(i*7+3)*pasin]-val2p;
     295        val2p=new_val(val2,ec2,k);
     296
     297        ec4=ecart_(i,3,val2p);
    311298        shif(ec4,k,q);
    312299
    313         if(k>k1)        {k1=k;val1p=val1 + arrondi(ec1,k);val2p = val2 + arrondi(ec2,k);}
    314        
    315         val1p+= arrondi(ec3,k);         
    316 
    317         ec5=in[(i*7+4)*pasin]-val1p;
     300        if(k>k1)        {k1=k;val1p=new_val(val1,ec1,k);val2p=new_val(val2,ec2,k);}
     301       
     302        val1p=new_val(val1p,ec3,k);             
     303
     304        ec5=ecart_(i,4,val1p);
    318305        shif(ec5,k,q);
    319306
    320307        if(k>k1)        {       k1=k;
    321                                 val1p=val1 + arrondi(ec1,k) + arrondi(ec3,k);
    322                                 val2p=val2 + arrondi(ec2,k);
     308                                val1p=(val1 + arrondi(ec1,k) + arrondi(ec3,k))&data_mask;
     309                                val2p=(val2 + arrondi(ec2,k))&data_mask;
    323310                                }
    324         val2p+= arrondi(ec4,k);         
    325        
    326         ec6=in[(i*7+5)*pasin]-val2p;
     311        val2p=new_val(val2p,ec4,k);             
     312       
     313        ec6=ecart_(i,5,val2p);
    327314        shif(ec6,k,q);
    328315
    329316        if(k>k1)        {       k1=k;
    330                                 val1p=val1 + arrondi(ec1,k) + arrondi(ec3,k);
    331                                 val2p=val2 + arrondi(ec2,k) + arrondi(ec4,k);
     317                                val1p=(val1 + arrondi(ec1,k) + arrondi(ec3,k))&data_mask;
     318                                val2p=(val2 + arrondi(ec2,k) + arrondi(ec4,k))&data_mask;
    332319                                }
    333         val1p+= arrondi(ec5,k);         
    334        
    335         ec7=in[(i*7+6)*pasin]-val1p;
     320        val1p=new_val(val1p,ec5,k);             
     321       
     322        ec7=ecart_(i,6,val1p);
    336323        shif(ec7,k,q);
    337324       
     
    346333        ec7 =  arrondi(ec7,k) >> k;
    347334
    348         out[i]= ((ec1&emak_)<<28) | ((ec2&emak_)<<24) | ((ec3&emak_)<<20)
    349                                 | ((ec4&emak_)<<16) | ((ec5&emak_)<<12) | ((ec6&emak_)<<8) | ((ec7&emak_)<<4) | k ;
     335        out[i]= ((ec1&ecart_mask)<<28) | ((ec2&ecart_mask)<<24) | ((ec3&ecart_mask)<<20)
     336                                | ((ec4&ecart_mask)<<16) | ((ec5&ecart_mask)<<12) | ((ec6&ecart_mask)<<8) | ((ec7&ecart_mask)<<4) | k ;
    350337
    351338
    352339/*      if(i<30)  printf("i=%d  k=%d  ec= %d %d %d \n",i,k,ec1,ec2,ec3,out[(i+8)/7]);*/
    353340
    354         val1p = val1 + ( (ec1 + ec3 + ec5 + ec7 ) << k );
    355         val1= val2 + ( (ec2 + ec4       + ec6 ) << k );
     341        val1p = (val1 + ( (ec1 + ec3 + ec5 + ec7 ) << k ))&data_mask;
     342        val1= (val2 + ( (ec2 + ec4      + ec6 ) << k ))&data_mask;
    356343        val2 = val1p;
    357344        }
     
    368355/*******************************************************************************************/
    369356
    370 
    371 void  compress_7(long val,long* in,long*out,int n,int pasin);
    372 void  compress_7_paire(long val1,long val2,long* in,long*out,int n,int pasin);
    373 
    374 
    375 #undef kmax_
    376 #undef  kmak_
    377 #undef  emak_           
    378 #undef  sgbi_
    379 #undef  sign_
    380 
    381 
    382 
    383 #define kmax_   15              /*  valeur maximum de l'exposant        */
    384 #define kmak_   0xf             /*      masque pour l'exposant          */
    385 #define emak_   0x7f            /*      masque pour l'ecart             */             
    386 #define sgbi_   0x40            /*      bit de signe de l'ecart         */
    387 #define sign_   0xffffff80      /*      masque de signe de l'ecart      */
    388 
    389 
    390 /*  comprime    4*n points  : 1er point dans 1er mot, tous les ecarts dans les n mots suivants          */
     357/*******************************************************************************************/
     358
     359/*  compresse en 7 bit mais par paire (pour data provenant de la detection synchrone      */
     360
     361/* ne prend que les 21 bit de poid faible dans le mot en entree                 */
     362/*  comprime    4*n points  : 1er et 2eme point dans 1er mot (16 bit chacun),  suite dans n mots                */
     363/*              différences entre valeures paires  et entre valeures impaires uniquement                        */
    391364/*      4*n     ==>     n+1     */
    392365
    393 void compress_7_1(long* in,long*out,int n,int pasin)
    394 {
    395 long val;
    396 val=*in;
    397 *out=val;
    398 compress_7(val,in,out+1,n/4,pasin);
    399 }
    400 
    401 
    402 
    403 /*  compress un tableau in de n*4 points disposé avec un pas pasin      */
    404 /*  les data compressées sont ecrites dans le tableau out de n points   */
    405 /*  la valeur val est la valeur de reference du point origine   */
    406 
    407 void  compress_7(long val,long* in,long*out,int n,int pasin)
    408 {
    409 int filtre[16]={0xffffffff,0xfffffffe,0xfffffffc,0xfffffff8,
    410                                 0xfffffff0,0xffffffe0,0xffffffc0,0xffffff80,
    411                                 0xffffff00,0xfffffe00,0xfffffc00,0xfffff800,
    412                                 0xfffff000,0xffffe000,0xffffc000,0xffff8000};
    413 int test[16]=  {0x00000000,0x00000001,0x00000002,0x00000004,
    414                                 0x00000008,0x00000010,0x00000020,0x00000040,
    415                                 0x00000080,0x00000100,0x00000200,0x00000400,
    416                                 0x00000800,0x00001000,0x00002000,0x00004000};
    417 
    418 long val1;
    419 long ec1,ec2,ec3,ec4;
    420 int i,k,k1;long q;
     366
     367
     368void  compress_7_paire(unsigned long val1,unsigned long val2,unsigned long* in,unsigned long*out,int n,int pasin);
     369
     370#undef  data_mask
     371#define data_mask       0x1fffff        /* masque pour les données en entree 21 bit     */
     372#undef  ecart_mask             
     373#define ecart_mask              0x7f            /*      masque pour l'ecart 7 bits              */             
     374
     375#undef   ecart_
     376#define ecart_(i,n,val)         (( (in[(i*4+n)*pasin]&data_mask) | ecart_bit )-val);
     377
     378
     379void compress_7_2(unsigned long* in,unsigned long*out,int n,int pasin)
     380{
     381unsigned long val1,val2;
     382val1=in[0]&0x1fffe0;val2=in[pasin]&0x1fffe0;
     383*out=( (val1<<11) & 0xffff0000 )        |       ( (val2 >> 5) & 0xffff ) ;
     384
     385/*printf("in[0]=%x  val1=%x        in[1]=%x   val2=%x  \n",in[0],val1,in[1],val2);
     386printf("in[2]=%x    in[3]=%x   \n",in[2],in[3]);*/
     387compress_7_paire(val1,val2,in,out+1,n/4,pasin);
     388}
     389
     390
     391void  compress_7_paire(unsigned long val1,unsigned long val2,unsigned long* in,unsigned long*out,int n,int pasin)
     392{
     393
     394unsigned long val1p,val2p;
     395unsigned long ec1,ec2,ec3,ec4;
     396int i,k;unsigned long q;
    421397
    422398
     
    425401        k=0;q=63;               /* 7 bit ->  127  ->   +-63     */
    426402
    427         ec1=in[i*4*pasin]-val;
    428         shif(ec1,k,q);
    429         val1=val + arrondi(ec1,k);
    430        
    431         k1=k;
    432         ec2=in[(i*4+1)*pasin]-val1;
    433         shif(ec2,k,q);
    434        
    435 /*      if(k>k1)        {k1=k;val1=val + arrondi(ec1,k);}       */
    436         val1+= arrondi(ec2,k);
    437 
    438         ec3=in[(i*4+2)*pasin]-val1;
    439         shif(ec3,k,q);
    440 
    441 /*      if(k>k1)        {k1=k;val1=val + arrondi(ec1,k) + arrondi(ec2,k);}      */
    442         val1+= arrondi(ec3,k);         
    443 
    444         ec4=in[(i*4+3)*pasin]-val1;
    445         shif(ec4,k,q);
    446        
    447 /*printf("i=%d  k=%d  ec= %d %d %d \n",i,k,ec1,ec2,ec3,out[(i+8)/7]);   */
    448 
     403        ec1=ecart_(i,0,val1);   shif(ec1,k,q); 
     404       
     405        ec2=ecart_(i,1,val2);   shif(ec2,k,q);
     406        val1p =new_val(val1,ec1,k);
     407
     408        ec3=ecart_(i,2,val1p);  shif(ec3,k,q);
     409        val2p=new_val(val2,ec2,k);
     410
     411        ec4=ecart_(i,3,val2p);  shif(ec4,k,q);
     412       
    449413        ec1 =  arrondi(ec1,k) >> k;
    450414        ec2 =  arrondi(ec2,k) >> k;
     
    452416        ec4 =  arrondi(ec4,k) >> k;
    453417
    454         out[i]= ((ec1&emak_)<<25) | ((ec2&emak_)<<18) | ((ec3&emak_)<<11) | ((ec4&emak_)<<4) | k ;
    455 
    456 /*      if(i<30)  printf("i=%d  k=%d  ec= %d %d %d \n",i,k,ec1,ec2,ec3,out[(i+8)/7]);   */
    457 
    458         val+= ( (ec1 + ec2 + ec3 + ec4 ) << k );
     418        out[i]= ((ec1&ecart_mask)<<25) | ((ec2&ecart_mask)<<18) | ((ec3&ecart_mask)<<11) | ((ec4&ecart_mask)<<4) | k ;
     419
     420        /*if(i<5)  printf("i=%d  k=%d  ec= %x %x %x %x  out=%x \n",i,k,ec1,ec2,ec3,ec4,out[i]); */
     421
     422        val1=(val1+ ( (ec1 + ec3 ) << k ))&data_mask;
     423        val2=(val2+ ( (ec2 + ec4 ) << k ))&data_mask;
    459424        }
    460425}
    461426
    462427
    463 /*******************************************************************************************/
    464 
    465 /*  compresse en 7 bit mais par paire (pour data provenant de la detection synchrone      */
    466 
    467 /* ne prend que les 21 bit de poid faible dans le mot en entree                 */
    468 /*  comprime    4*n points  : 1er et 2eme point dans 1er mot (16 bit chacun),  suite dans n mots                */
    469 /*              différences entre valeures paires  et entre valeures impaires uniquement                        */
    470 /*      4*n     ==>     n+1     */
    471 
    472 #define  point_in(i,pasin,n)  (in[(i*4+n)*pasin]&0x1fffff)
    473 
    474 
    475 void compress_7_2(long* in,long*out,int n,int pasin)
    476 {
    477 long val1,val2;
    478 val1=in[0]&0x1fffe0;val2=in[1]&0x1fffe0;
    479 *out=( (val1<<11) & 0xffff0000 )        |       ( (val2 >> 5) & 0xffff ) ;
    480 
    481 /*printf("in[0]=%x  val1=%x   //    in[1]=%x   val2=%x  \n",in[0],val1,in[1],val2);
    482 printf("in[2]=%x    in[3]=%x   \n",in[2],in[3]);*/
    483 compress_7_paire(val1,val2,in,out+1,n/4,pasin);
    484 }
    485 
    486 
    487 void  compress_7_paire(long val1,long val2,long* in,long*out,int n,int pasin)
    488 {
    489 int filtre[16]={0xffffffff,0xfffffffe,0xfffffffc,0xfffffff8,
    490                                 0xfffffff0,0xffffffe0,0xffffffc0,0xffffff80,
    491                                 0xffffff00,0xfffffe00,0xfffffc00,0xfffff800,
    492                                 0xfffff000,0xffffe000,0xffffc000,0xffff8000};
    493 int test[16]=  {0x00000000,0x00000001,0x00000002,0x00000004,
    494                                 0x00000008,0x00000010,0x00000020,0x00000040,
    495                                 0x00000080,0x00000100,0x00000200,0x00000400,
    496                                 0x00000800,0x00001000,0x00002000,0x00004000};
    497 
    498 long val1p,val2p;
    499 long ec1,ec2,ec3,ec4;
    500 int i,k;long q;
    501 
    502 
    503 for(i=0;i<n;i++)
    504         {
    505         k=0;q=63;               /* 7 bit ->  127  ->   +-63     */
    506 
    507         ec1=point_in(i,pasin,0)-val1;
    508         shif(ec1,k,q);
    509        
    510        
    511         ec2=point_in(i,pasin,1)-val2;
    512         shif(ec2,k,q);
    513                
    514         val1p =val1 + arrondi(ec1,k);
    515 
    516         ec3=point_in(i,pasin,2)-val1p;
    517         shif(ec3,k,q);
    518 
    519         val2p=val2+ arrondi(ec2,k);
    520 
    521         ec4=point_in(i,pasin,3)-val2p;
    522         shif(ec4,k,q);
    523        
    524 /*printf("i=%d  k=%d  ec= %d %d %d \n",i,k,ec1,ec2,ec3,out[(i+8)/7]);   */
    525 
    526         ec1 =  arrondi(ec1,k) >> k;
    527         ec2 =  arrondi(ec2,k) >> k;
    528         ec3 =  arrondi(ec3,k) >> k;
    529         ec4 =  arrondi(ec4,k) >> k;
    530 
    531         out[i]= ((ec1&emak_)<<25) | ((ec2&emak_)<<18) | ((ec3&emak_)<<11) | ((ec4&emak_)<<4) | k ;
    532 
    533 /*      if(i<5)  printf("i=%d  k=%d  ec= %x %x %x %x  out=%x \n",i,k,ec1,ec2,ec3,ec4,out[i]);*/
    534 
    535         val1+= ( (ec1 + ec3 ) << k );
    536         val2+= ( (ec2 + ec4 ) << k );
    537         }
    538 }
    539 
    540 
    541 
    542 
     428
     429
Note: See TracChangeset for help on using the changeset viewer.