-
-//_____________________________________________________________________________
-Int_t AliAltroBuffer::GetNext()
-{
-//It reads a 10 bits word in forward dicection from the Buffer.
-//A new Buffer is read from the file only when Buffer is empty.
-//If there aren't elements anymore -1 is returned otherwise
-//the next element is returned
-
- UInt_t mask = 0xFFC00000;
- UInt_t temp;
- UInt_t value;
- if (!fShift) {
- if (fFile->tellg() >= (Int_t)fFileEnd) return -1;
- if (fFile->read((char*)fBuffer, sizeof(UInt_t)*5)) {
- fCurrentCell = 0;
- fShift = 22;
- value = fBuffer[fCurrentCell] & mask;
- value = value >> 22;
- fBuffer[fCurrentCell] = fBuffer[fCurrentCell] << 10;
- return value;
- } else {
- return -1;
- }
- } else {
- if (fShift >= 10) {
- value = fBuffer[fCurrentCell] & mask;
- value = value >> 22;
- fShift -= 10;
- fBuffer[fCurrentCell] = fBuffer[fCurrentCell] << 10;
- } else {
- value = fBuffer[fCurrentCell] & mask;
- fCurrentCell++;
- temp = fBuffer[fCurrentCell];
- temp = temp >> fShift;
- temp = temp & mask;
- value = value | temp;
- value = value >> 22;
- fBuffer[fCurrentCell] = fBuffer[fCurrentCell] << (10-fShift);
- fShift += 22;
- }
- return value;
- }//end else
-}
-
-//_____________________________________________________________________________
-Int_t AliAltroBuffer::GetNextBackWord()
-{
-//It reads a 10 bits word in backward dicection from the Buffer.
-//A new Buffer is read from the file only when Buffer is empty.
-//If there aren't elements anymore -1 is returned otherwise
-//the next element is returned
-
- UInt_t mask = 0x3FF;
- UInt_t temp;
- UInt_t value;
- if (!fShift) {
- if (fFilePosition > fDataHeaderPos){
- fFilePosition -= sizeof(UInt_t)*5;
- fFile->seekg(fFilePosition);
- fFile->read((char*)fBuffer, sizeof(UInt_t)*5);
-
- fCurrentCell = 4;
- fShift = 22;
- fMaskBackward = 0xFF;
- value = fBuffer[fCurrentCell] & mask;
- fBuffer[fCurrentCell] = fBuffer[fCurrentCell] >> 10;
- return value;
- } else {
- fFile->seekg(fDataHeaderPos);
- return -1;
- }
- } else {
- if (fShift >= 10) {
- value = fBuffer[fCurrentCell] & mask;
- fShift -= 10;
- fBuffer[fCurrentCell] = fBuffer[fCurrentCell] >> 10;
- } else {
- value = fBuffer[fCurrentCell];
- fCurrentCell--;
- temp = fBuffer[fCurrentCell] & mask;
- temp = temp & fMaskBackward;
- fMaskBackward = fMaskBackward >> 2;
- temp = temp << fShift;
- value = value | temp;
- fBuffer[fCurrentCell] = fBuffer[fCurrentCell] >> (10-fShift);
- fShift = 22 + fShift;
- }
- return value;
- }//end else
-}
-