}
// _________________________________________________________________________
-UInt_t AliRawReaderRoot::SwapWord(UInt_t x) const
-{
- // Swap the endianess of the integer value 'x'
-
- return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) |
- ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24));
-}
-
void AliRawReaderRoot::SwapData(const void* inbuf, const void* outbuf, UInt_t size) {
// The method swaps the contents of the
// raw-data event header
- UInt_t intCount = size/sizeof(UInt_t);
+ UInt_t intCount = (size+3)/sizeof(UInt_t);
UInt_t* buf = (UInt_t*) inbuf; // temporary integers buffer
for (UInt_t i=0; i<intCount; i++, buf++) {
UInt_t value = SwapWord(*buf);
- memcpy((UInt_t*)outbuf+i, &value, sizeof(UInt_t));
+ if (i==(intCount-1))
+ memcpy((UInt_t*)outbuf+i, &value, size%sizeof(UInt_t));
+ else
+ memcpy((UInt_t*)outbuf+i, &value, sizeof(UInt_t));
}
}
// _________________________________________________________________________
fHeader=fHeaderSwapped;
#endif
if ((fPosition + fHeader->fSize) != fEnd) {
- Warning("ReadHeader",
- "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
- fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
+ if (fHeader->fSize != 0xFFFFFFFF)
+ Warning("ReadHeader",
+ "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+ fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
fHeader->fSize = fEnd - fPosition;
}
fPosition += sizeof(AliRawDataHeader);
return kFALSE;
}
memcpy(data, fPosition, size);
+
fPosition += size;
fCount -= size;
return kTRUE;
// check consistency of data size in the header and in the equipment
AliRawDataHeader* header = (AliRawDataHeader*) position;
if ((position + header->fSize) != end) {
- Warning("ReadHeader",
- "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
- equipment->GetEquipmentHeader()->GetId(),header->fSize, end - position);
+ if (header->fSize != 0xFFFFFFFF)
+ Warning("ReadHeader",
+ "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+ equipment->GetEquipmentHeader()->GetId(),header->fSize, end - position);
header->fSize = end - position;
result |= kErrSize;
}