Line data Source code
1 : //-*- Mode: C++ -*-
2 : #ifndef ALIHLTDATAINFLATERHUFFMAN_H
3 : #define ALIHLTDATAINFLATERHUFFMAN_H
4 : //* This file is property of and copyright by the ALICE HLT Project *
5 : //* ALICE Experiment at CERN, All rights reserved. *
6 : //* See cxx source for full Copyright notice *
7 :
8 : /// @file AliHLTDataInflaterHuffman.h
9 : /// @author Matthias Richter
10 : /// @date 2011-09-01
11 : /// @brief Data inflater implementation for huffman encoded data
12 : /// @note
13 :
14 : #include "AliHLTDataInflater.h"
15 :
16 : class AliHLTHuffman;
17 : class TList;
18 :
19 : class AliHLTDataInflaterHuffman : public AliHLTDataInflater
20 : {
21 : public:
22 : /// standard constructor
23 : AliHLTDataInflaterHuffman();
24 : /// destructor
25 : ~AliHLTDataInflaterHuffman();
26 :
27 : /// add a parameter definition to the configuration, return reference id
28 : int AddParameterDefinition(const char* name, unsigned bitLength);
29 :
30 : /// init list of decoders
31 : int InitDecoders(TList* decoderlist);
32 :
33 : /**
34 : * Retrieve next value from data stream
35 : * The next variable-length code is read from the stream and decoded
36 : * using the initialized Huffman instance. The maximum number of input
37 : * bits is always required for the Huffman decoder. Internal buffering
38 : * is implemented to avoid repetitive backward seek in the input stream
39 : * after decoding of a symbol when the length is known.
40 : *
41 : * overloaded from AliHLTDataInflater
42 : */
43 : virtual bool NextValue(AliHLTUInt64_t& value, AliHLTUInt32_t& length);
44 :
45 : /// switch to next parameter
46 : virtual int NextParameter() {
47 0 : if (fHuffmanCoders.size()==0) return -1;
48 0 : if (fLegacyMode>0) return fCurrentParameter;
49 0 : fLegacyMode=0;
50 0 : if ((++fCurrentParameter)>=(int)fHuffmanCoders.size()) fCurrentParameter=0;
51 0 : return fCurrentParameter;
52 0 : }
53 :
54 : /**
55 : * Read next bit from the input.
56 : * This overload of AliHLTDataInflater::InputBit handles the internal
57 : * buffer and forwards to the base class method if the buffer is empty.
58 : */
59 : bool InputBit( AliHLTUInt8_t & value );
60 :
61 : /**
62 : * Pad read pointer to next 8 bit boundary
63 : * This overload first clears the internal register and rewinds the read
64 : * pointer appropriately, then calls Pad8Bits of the base class
65 : */
66 : void Pad8Bits();
67 :
68 : void RewindCache();
69 :
70 : /// Print info
71 : void Print(Option_t* option = "") const;
72 : /// clear the object and reset pointer references
73 : virtual void Clear(Option_t * option ="");
74 :
75 : protected:
76 : private:
77 : /** copy constructor prohibited */
78 : AliHLTDataInflaterHuffman(const AliHLTDataInflaterHuffman&);
79 : /** assignment operator prohibited */
80 : AliHLTDataInflaterHuffman& operator=(const AliHLTDataInflaterHuffman&);
81 :
82 : /// index of the decoders in the decoder list
83 : vector<AliHLTHuffman*> fHuffmanCoders; //! index of decoders
84 :
85 : /// list of huffman coders identified by parameter name
86 : TList* fHuffmanCoderList; //! list of huffman coders
87 :
88 : /// current parameter during reading
89 : int fCurrentParameter; //!
90 : /// legacy mode to handle code not using NextParameter()
91 : int fLegacyMode;
92 : /// buffered input
93 : AliHLTUInt64_t fInput; //!
94 : /// valid MSBs in the buffered input
95 : AliHLTUInt32_t fInputLength; //!
96 :
97 126 : ClassDef(AliHLTDataInflaterHuffman, 0)
98 : };
99 :
100 : #endif //ALIHLTDATAINFLATERHUFFMAN_H
|