/************************************************************ * 20/9/2005 modified by david fedele to read buffer-data * instead raw-data-file ************************************************************** * include needed system headers */ #include /* include standard i/o library */ #include /* include standard library */ #include /* include string library */ #include /* include unix standard library */ #include /* */ #include /* */ #include /* */ #include /* error simbol definitions */ #include /* system time definitions */ #include /* math library */ void unpacking(int ndata, unsigned short *output); /************************************************************ * 20/9/2005 modified by david fedele */ /* void dunpacker_(int *l_buffer, unsigned short *buffer, int *error, int *fd) */ void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value); void dunpacker_(int *l_buffer, unsigned short *buff, int *error,char *buffer, int *len,int *curpos) /**************************************************************/ { int i; int nhead; nhead = 13; /* packed */ *error=0; /************************************************************ * 20/9/2005 modified by david fedele */ /* int nread; */ /* unsigned int word; */ /* nread=read(*fd, buffer, 2**l_buffer); */ /* if( nread==0 ) { */ /* printf("dunpacker: Unexpected end of file %d at %d \n",*fd,nread); */ /* *error=1; */ /* return ; */ /* } */ /* if ( nread != 2**l_buffer) { */ /* printf("dunpacker: Error on reading: nread = %d \n",nread); */ /* *error=-1; */ /* return ; */ /* } */ /* /\*** correct byte ***\/ */ /* for(i=0; i<*l_buffer; i++) { */ /* word = buffer[i]; */ /* buffer[i] = ( (word&0x00ff) << 8 ) | ( (word&0xff00) >> 8 ); */ /* } */ int nbytes2=2; unsigned int word_temp; unsigned short word[*l_buffer]; if( *curpos+*l_buffer>*len ) { printf("dunpacker: Unexpected end of file\n"); *error=1; return ; } for(i=0;i<*l_buffer;i++){ getbytes_(&nbytes2,buffer,curpos,&word_temp); word[i]=word_temp; buff[i]=word[i]; } /*** unpacking buffer data ***/ /************************************************************ * 20/9/2005 modified by david fedele */ /* if( nhead == 13) unpacking(*l_buffer, buffer); */ if( nhead == 13) unpacking(*l_buffer, buff); /**************************************************************/ /* int num = (*l_buffer-13-1)/13*16+3;//??? */ /* for( i=0; i> 3; *oo++ = ( (*o1 & 0x0007) << 10 ) | ( (*oi & 0xffc0) >> 6); o1 = oi++; *oo++ = ( (*o1 & 0x003f) << 7 ) | ( (*oi & 0xfe00) >> 9); o1 = oi++; *oo++ = ( (*o1 & 0x01ff) << 4 ) | ( (*oi & 0xf000) >> 12); o1 = oi++; *oo++ = ( (*o1 & 0x0fff) << 1 ) | ( (*oi & 0x8000) >> 15); *oo++ = (*oi & 0x7ffc) >> 2; o1 = oi++; *oo++ = ( (*o1 & 0x0003) << 11 ) | ( (*oi & 0xffe0) >> 5); o1 = oi++; *oo++ = ( (*o1 & 0x001f) << 8 ) | ( (*oi & 0xff00) >> 8); o1 = oi++; *oo++ = ( (*o1 & 0x00ff) << 5 ) | ( (*oi & 0xf800) >> 11); o1 = oi++; *oo++ = ( (*o1 & 0x07ff) << 2 ) | ( (*oi & 0xc000) >> 14); *oo++ = (*oi & 0x3ffe) >> 1; o1 = oi++; *oo++ = ( (*o1 & 0x0001) << 12 ) | ( (*oi & 0xfff0) >> 4); o1 = oi++; *oo++ = ( (*o1 & 0x000f) << 9 ) | ( (*oi & 0xff80) >> 7); o1 = oi++; *oo++ = ( (*o1 & 0x007f) << 6 ) | ( (*oi & 0xfc00) >> 10); o1 = oi++; *oo++ = ( (*o1 & 0x03ff) << 3 ) | ( (*oi & 0xe000) >> 13); *oo++ = *oi++ & 0x1fff; } return; }