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 const unsigned long long *dduWord =
reinterpret_cast<const unsigned long long*
>(buf);
20 unsigned long long word_1=0, word_2=0;
22 length /=
sizeof(
unsigned long long)/
sizeof(
unsigned short);
24 bool spHeader=
false, spTrailer=
false;
25 unsigned long spWordCount=0, spWordCountExpected=0;
29 while( index<length ){
31 word_2 = dduWord[
index];
33 if( spHeader && !spTrailer ) spWordCount++;
35 if( (word_1&0xF000F000F000F000LL)==0x9000900090009000LL &&
36 (word_2&0xF000F000F000F000LL)==0xA000A000A000A000LL ){
45 spWordCountExpected=0;
48 const unsigned short *spWord =
reinterpret_cast<const unsigned short*
>(&dduWord[index-1]);
54 if( length > index+1 ){ spWord += 4; }
else { coruptions |=
OUT_OF_BUFFER;
break; }
58 for(
unsigned short tbin=0,
shift=0; tbin<header.
nTBINs() && !header.
empty(); tbin++){
60 if( length <= index+spWordCountExpected+2 ){
67 if( ((spWord[
shift+7]>>8) & 0x7) != tbin+1 )
continue;
69 if( (spWord[
shift+0]&0xF000)==0xF000 && (spWord[
shift+1]&0xF000)==0xF000 && (spWord[
shift+2]&0xF000)==0xF000 && (spWord[
shift+3]&0xF000)==0xF000 &&
70 (spWord[
shift+4]&0xF000)==0xE000 && (spWord[
shift+5]&0xF000)==0xE000 && (spWord[
shift+6]&0xF000)==0xE000 && (spWord[
shift+7]&0xF000)==0xE000 )
break;
74 spWordCountExpected += 2;
76 for(
unsigned int me_block=0; me_block<15; me_block++)
78 spWordCountExpected += 1;
80 for(
unsigned int mb_block=0; mb_block<2; mb_block++)
82 spWordCountExpected += 1;
84 for(
unsigned int sp_block=0; sp_block<3; sp_block++)
86 spWordCountExpected += 1;
88 shift = spWordCountExpected*4;
100 if( (word_1&0xF000F000F000F000LL)==0xF000F000F000F000LL &&
101 (word_2&0xF000F000F000F000LL)==0xE000E000E000E000LL ){
109 if( spWordCount!=spWordCountExpected+2 ){
114 const unsigned short *spWord =
reinterpret_cast<const unsigned short*
>(&dduWord[index-spWordCount-1]);
unsigned int unpack(const unsigned short *buf, unsigned int length)
static unsigned int const shift