12 if(
sizeof(
unsigned long long)!=8 ||
sizeof(
unsigned short)!=2 )
13 throw std::runtime_error(
std::string(
"Wrong platform: sizeof(unsigned long long)!=8 || sizeof(unsigned short)!=2"));
16 unsigned long coruptions=0;
19 unsigned long long *dduWord = (
unsigned long long*) buf, word_1=0, word_2=0;
21 length /=
sizeof(
unsigned long long)/
sizeof(
unsigned short);
23 bool spHeader=
false, spTrailer=
false;
24 unsigned long spWordCount=0, spWordCountExpected=0;
28 while( index<length ){
30 word_2 = dduWord[
index];
32 if( spHeader && !spTrailer ) spWordCount++;
34 if( (word_1&0xF000F000F000F000LL)==0x9000900090009000LL &&
35 (word_2&0xF000F000F000F000LL)==0xA000A000A000A000LL ){
37 coruptions |= MISSING_TRAILER;
44 spWordCountExpected=0;
47 const unsigned short *spWord = (
unsigned short*) &dduWord[index-1];
53 if( length > index+1 ){ spWord += 4; }
else { coruptions |= OUT_OF_BUFFER;
break; }
57 for(
unsigned short tbin=0,
shift=0; tbin<header.
nTBINs() && !header.
empty(); tbin++){
59 if( length <= index+spWordCountExpected+2 ){
60 coruptions |= OUT_OF_BUFFER;
66 if( ((spWord[
shift+7]>>8) & 0x7) != tbin+1 )
continue;
68 if( (spWord[
shift+0]&0xF000)==0xF000 && (spWord[
shift+1]&0xF000)==0xF000 && (spWord[
shift+2]&0xF000)==0xF000 && (spWord[
shift+3]&0xF000)==0xF000 &&
69 (spWord[
shift+4]&0xF000)==0xE000 && (spWord[
shift+5]&0xF000)==0xE000 && (spWord[
shift+6]&0xF000)==0xE000 && (spWord[
shift+7]&0xF000)==0xE000 )
break;
73 spWordCountExpected += 2;
75 for(
unsigned int me_block=0; me_block<15; me_block++)
77 spWordCountExpected += 1;
79 for(
unsigned int mb_block=0; mb_block<2; mb_block++)
81 spWordCountExpected += 1;
83 for(
unsigned int sp_block=0; sp_block<3; sp_block++)
85 spWordCountExpected += 1;
87 shift = spWordCountExpected*4;
94 if( coruptions&OUT_OF_BUFFER )
break;
99 if( (word_1&0xF000F000F000F000LL)==0xF000F000F000F000LL &&
100 (word_2&0xF000F000F000F000LL)==0xE000E000E000E000LL ){
102 coruptions |= MISSING_HEADER;
108 if( spWordCount!=spWordCountExpected+2 ){
109 coruptions |= WORD_COUNT;
113 const unsigned short *spWord = (
unsigned short*) &dduWord[index-spWordCount-1];
117 coruptions |= CONFIGURATION;
unsigned int unpack(const unsigned short *buf, unsigned int length)
static unsigned int const shift