3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /// @file AliHLTDataInflater.cxx
20 /// @author Matthias Richter, Timm Steinbeck
22 /// @brief Data inflater reading the bitstream from the AliHLTDataDeflater
23 /// @note Code original from AliHLTTPCCompModelInflater
25 #include "AliHLTDataInflater.h"
26 #include "AliHLTErrorGuard.h"
31 /** ROOT macro for the implementation of ROOT specific class methods */
32 ClassImp(AliHLTDataInflater)
34 AliHLTDataInflater::AliHLTDataInflater()
36 , fBitDataCurrentWord(0)
37 , fBitDataCurrentPosInWord(0)
38 , fBitDataCurrentInput(NULL)
39 , fBitDataCurrentInputStart(NULL)
40 , fBitDataCurrentInputEnd(NULL)
42 // see header file for class documentation
44 // refer to README to build package
46 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49 AliHLTDataInflater::~AliHLTDataInflater()
55 int AliHLTDataInflater::InitBitDataInput(const AliHLTUInt8_t* input, UInt_t inputSize )
57 // init inflater for reading
58 fBitDataCurrentWord = 0;
59 fBitDataCurrentPosInWord = 7;
60 fBitDataCurrentInput = fBitDataCurrentInputStart = input;
61 fBitDataCurrentInputEnd = input+inputSize;
62 fBitDataCurrentWord = *fBitDataCurrentInput;
66 void AliHLTDataInflater::CloseBitDataInput()
68 // close inflater for reading
69 fBitDataCurrentWord=0;
70 fBitDataCurrentPosInWord=0;
71 fBitDataCurrentInput=NULL;
72 fBitDataCurrentInputStart=NULL;
73 fBitDataCurrentInputEnd=NULL;
76 bool AliHLTDataInflater::InputBit( AliHLTUInt8_t & value )
78 // see header file for class documenation
79 if ( fBitDataCurrentInput>=fBitDataCurrentInputEnd )
81 value = (fBitDataCurrentWord >> fBitDataCurrentPosInWord) & 1;
82 if ( fBitDataCurrentPosInWord )
83 fBitDataCurrentPosInWord--;
85 fBitDataCurrentInput++;
86 if ( fBitDataCurrentInput<fBitDataCurrentInputEnd ) {
87 fBitDataCurrentWord = *fBitDataCurrentInput;
88 fBitDataCurrentPosInWord = 7;
94 void AliHLTDataInflater::Pad8Bits()
96 // see header file for class documenation
97 if ( fBitDataCurrentPosInWord == 7 )
99 fBitDataCurrentInput++;
100 if ( fBitDataCurrentInput<fBitDataCurrentInputEnd ) {
101 fBitDataCurrentWord = *fBitDataCurrentInput;
102 fBitDataCurrentPosInWord = 7;
106 bool AliHLTDataInflater::InputBytes( AliHLTUInt8_t* data, UInt_t const & byteCount )
108 // see header file for class documenation
110 if ( fBitDataCurrentInput+byteCount>fBitDataCurrentInputEnd )
112 memcpy( data, fBitDataCurrentInput, byteCount );
113 fBitDataCurrentInput += byteCount;
114 if ( fBitDataCurrentInput<fBitDataCurrentInputEnd ) {
115 fBitDataCurrentWord = *fBitDataCurrentInput;
116 fBitDataCurrentPosInWord = 7;
121 void AliHLTDataInflater::Clear(Option_t * /*option*/)
126 void AliHLTDataInflater::Print(Option_t *option) const
132 void AliHLTDataInflater::Print(ostream& out, Option_t */*option*/) const
135 out << "AliHLTDataInflater: " << endl;
138 ostream& operator<<(ostream &out, const AliHLTDataInflater& me)