/************************************************************ * 11/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 */ /* looks for a DSP header beginning (a word beginning with 1110) */ /************************************************************ * 11/9/2005 modified by david fedele * void findstart_(int *error, int *fd)*/ void getbytes_(int *nbytes, char *buffer, int *p, unsigned int *value); void findstart_(int *error,char *buffer, int *len, int *curpos) { char *buff=buffer; int nbytes2=2; /* int nread */ /* unsigned short word; */ /* unsigned short temp; */ unsigned int word; /***********************************************************/ *error=0; do { /************************************************************/ /* 11/9/2005 modified by david fedele */ /* nread=read(*fd, &word, 2); //reads 16 bits */ /* if(nread == 0) { */ /* // printf("findstart: Unexpected end of file %d at %d \n",*fd,nread); */ /* *error=1; */ /* return ; */ /* } */ /* if(nread != 2) { */ /* // printf("findstart: Error on reading: bytes read -> nread = %d \n",nread); */ /* *error=-1; */ /* return ; */ /* } */ /* /\*** corrects byte ***\/ //endianess... */ /* temp = word; */ /* word = ( (temp&0x00ff) << 8 ) | ( (temp&0xff00) >> 8 ); */ /* // printf("word %x , temp: %x: \n", word, temp);//??? */ /* /\*** goes back 8 bits ***\/ */ /* lseek(*fd, -1, SEEK_CUR); //SEEK_CUR ---> from current position */ /* // unsigned short num=lseek(*fd, -1, SEEK_CUR); //SEEK_CUR ---> from current position */ /* // printf("%i \n",num); */ getbytes_(&nbytes2,buff,curpos,&word); *curpos=*curpos-1; if(*curpos-1 > *len) { // printf("findstart: Unexpected end of file \n"); *error=1; return ; } /***********************************************************/ } while ((word&0xf000) != 0xe000); /************************************************************/ /* 11/9/2005 modified by david fedele */ /* /\*** goes back 8 bits ***\/ */ /* lseek(*fd, -1, SEEK_CUR); */ *curpos=*curpos-1; /************************************************************/ return; }