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;
28 unsigned int index = 0;
29 while (index < length) {
31 word_2 = dduWord[
index];
33 if (spHeader && !spTrailer)
36 if ((word_1 & 0xF000F000F000F000LL) == 0x9000900090009000LL &&
37 (word_2 & 0xF000F000F000F000LL) == 0xA000A000A000A000LL) {
46 spWordCountExpected = 0;
49 const unsigned short *spWord =
reinterpret_cast<const unsigned short *
>(&dduWord[index - 1]);
55 if (length > index + 1) {
64 for (
unsigned short tbin = 0,
shift = 0; tbin < header.
nTBINs() && !header.
empty(); tbin++) {
66 if (length <= index + spWordCountExpected + 2) {
73 if (((spWord[
shift + 7] >> 8) & 0x7) != tbin + 1)
76 if ((spWord[
shift + 0] & 0xF000) == 0xF000 && (spWord[
shift + 1] & 0xF000) == 0xF000 &&
77 (spWord[
shift + 2] & 0xF000) == 0xF000 && (spWord[
shift + 3] & 0xF000) == 0xF000 &&
78 (spWord[
shift + 4] & 0xF000) == 0xE000 && (spWord[
shift + 5] & 0xF000) == 0xE000 &&
79 (spWord[
shift + 6] & 0xF000) == 0xE000 && (spWord[
shift + 7] & 0xF000) == 0xE000)
84 spWordCountExpected += 2;
86 for (
unsigned int me_block = 0; me_block < 15; me_block++)
87 if (header.
active() & (1 << (me_block / 3)) &&
89 spWordCountExpected += 1;
91 for (
unsigned int mb_block = 0; mb_block < 2; mb_block++)
93 spWordCountExpected += 1;
95 for (
unsigned int sp_block = 0; sp_block < 3; sp_block++)
97 spWordCountExpected += 1;
100 shift = spWordCountExpected * 4;
106 spWordCountExpected += 1;
114 if ((word_1 & 0xF000F000F000F000LL) == 0xF000F000F000F000LL &&
115 (word_2 & 0xF000F000F000F000LL) == 0xE000E000E000E000LL) {
123 if (spWordCount != spWordCountExpected + 2) {
128 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