]>
Commit | Line | Data |
---|---|---|
2e9f335b | 1 | /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * |
2 | * See cxx source for full Copyright notice */ | |
3 | ||
4 | ////////////////////////////////////////////////////// | |
a79660fb | 5 | // Class for Compression and Decompression // |
2e9f335b | 6 | ////////////////////////////////////////////////////// |
7 | ||
8 | ||
9 | #ifndef AliTPCCOMPRESSION_H | |
10 | #define AliTPCCOMPRESSION_H | |
11 | ||
f8aae377 | 12 | #ifdef __CINT__ |
13 | class fstream; | |
14 | #else | |
15 | #include "Riostream.h" | |
16 | #endif | |
17 | ||
2e9f335b | 18 | class AliTPCHNode; |
19 | class AliTPCHTable; | |
20 | ||
21 | class AliTPCCompression:public TObject{ | |
22 | public: | |
23 | AliTPCCompression(); | |
24 | virtual ~AliTPCCompression(){;} | |
25 | AliTPCCompression(const AliTPCCompression &source); // copy constructor | |
26 | AliTPCCompression& operator=(const AliTPCCompression &source); // ass. op. | |
2e9f335b | 27 | Int_t CompressDataOptTables(Int_t NumTable,const char* fSource,const char* fDest); |
a79660fb | 28 | //This method is used to compress an Altro file using a set of general table previously calculated and |
c9bd9d3d | 29 | //stored as a sequence of txt file. |
5fe3851e | 30 | Int_t DecompressDataOptTables(Int_t NumTables,const char* fname,const char* fDest="SourceDecompressed.dat"); |
a79660fb | 31 | //This method is used to decompress a file compressed using the CompressDataOptTable method |
32 | //It expects a set of table used for compressing the file in the same directory of the compressed file | |
09f6432c | 33 | Int_t Decompress(AliTPCHNode *RootNode[],Int_t NumTables,char* PointBuffer,UInt_t BufferSize,UShort_t out[],UInt_t &dim); |
c9bd9d3d | 34 | //This method is used to decompress data stored in a char* buffer |
95e50ecd | 35 | Int_t DecompressWithLUTs(AliTPCHNode *RootNode[],UInt_t *LUTDimension[],AliTPCHNode **LUTNode[],Int_t /*NumTables*/,char* PointBuffer,UInt_t BufferSize,UShort_t out[],UInt_t &dim); |
09f6432c | 36 | Int_t FillTables(const char* fSource,AliTPCHTable* table[],Int_t NumTables); |
a79660fb | 37 | //This method is used to compute the frequencies of the symbols in the source file |
09f6432c | 38 | Int_t CreateTables(const char* fSource,Int_t NumTables); |
a79660fb | 39 | //This method is used to create and store the tables |
0b3c7dfc | 40 | Int_t CreateTableFormula(Double_t beta,UInt_t M,Int_t dim,Int_t Type); |
9f992f70 | 41 | //This method is used to create and store the Bunch length or Time Gap Table using a formula |
a79660fb | 42 | void SetVerbose(Int_t val){fVerbose=val;} |
2e9f335b | 43 | //This method is used to set up the verbose level |
44 | // 0 ==> No output messages are displayed | |
45 | // 1 ==> Some output messages are displayed during the running | |
46 | // 2 ==> A complete output is displayed | |
a79660fb | 47 | void ReadAltroFormat(char* fileOut,char* fileIn)const; |
2e9f335b | 48 | //This method is used to read an Altro file and generate a text file containing the same information |
49 | //It's is useful for debugging | |
9f992f70 | 50 | Int_t CreateTablesFromTxtFiles(Int_t NumTable); |
51 | //This method creates a set of binary tables starting from a set of txt tables | |
09f6432c | 52 | Int_t DestroyTables(AliTPCHNode *RootNode[],Int_t NumTables); |
c9bd9d3d | 53 | //This methods is use to deallocate the memory used by Huffman trees |
1d98347a | 54 | Int_t CreateTreesFromFile(AliTPCHNode *RootNode[],Int_t NumTables); |
c9bd9d3d | 55 | //This method is like the previous one but the tables are stored in binary files |
56 | //It is used in the decompression phase (DecompressDataOptTables()) | |
95e50ecd | 57 | Int_t CreateLUTsFromTrees(AliTPCHNode *RootNode[],Int_t NumTables,UInt_t *LUTDimension[],AliTPCHNode **LUTNode[]); |
2e9f335b | 58 | private: |
a79660fb | 59 | Int_t StoreTables(AliTPCHTable* table[],const Int_t NumTable); |
2e9f335b | 60 | //This method is used to store an array of tables in a sequence of binary files |
a79660fb | 61 | //Each file contains the Size of the table (number of words) and for each word contains the correspondent |
2e9f335b | 62 | //codeword and codelength |
2e9f335b | 63 | Int_t RetrieveTables(AliTPCHTable* table[],Int_t NumTable); |
a79660fb | 64 | //This method is used to retrieve an array of tables from a sequence of binary files created using |
65 | //the previous method | |
2e9f335b | 66 | void DeleteHuffmanTree(AliTPCHNode* node); |
a79660fb | 67 | //This method is used to delete an Huffman tree |
2e9f335b | 68 | void VisitHuffmanTree(AliTPCHNode* node); |
a79660fb | 69 | //This method realizes an in order visit of a binary tree |
a79660fb | 70 | void NextTable(Int_t Val,Int_t &NextTableType,Int_t &BunchLen,Int_t &Count)const; |
2e9f335b | 71 | //This method is used to deduce which is the next table that as to be used to interpret the next value |
72 | //reading the Altro format | |
0b3c7dfc | 73 | void StoreValue(UInt_t val,UChar_t len); |
a79660fb | 74 | //This method is used to store a value in the compressed file |
0b3c7dfc | 75 | UInt_t Mirror(UInt_t val,UChar_t len)const; |
a79660fb | 76 | //This method is used to get the specular value of a given value |
77 | //for instance the specular value of 12345 is 54321 | |
2e9f335b | 78 | void Flush(); |
a79660fb | 79 | //This method is used to complete and store the buffer in the output file when it isn't completely full |
95e50ecd | 80 | UInt_t ReadWord(UInt_t NumberOfBit); |
a79660fb | 81 | //this method is used to read a specified number of bits from the compressed file |
95e50ecd | 82 | UInt_t ReadWordBuffer(UInt_t NumberOfBit); |
c9bd9d3d | 83 | //this method is used to read a specified number of bits from the compressed memory buffer |
95e50ecd | 84 | inline void AdjustWordBuffer(UInt_t NumberOfBit); |
85 | inline UInt_t ReadWordBufferWithLUTs(); | |
a8ffd46b | 86 | inline UInt_t ReadBitFromWordBuffer(); |
95e50ecd | 87 | inline UInt_t ReadBitFromLUTBuffer(UInt_t *buffer); |
c9bd9d3d | 88 | void ReadTrailer(Int_t &WordsNumber,Int_t &PadNumber,Int_t &RowNumber,Int_t &SecNumberr,Bool_t Memory); |
a79660fb | 89 | //This method is used to read the trailer |
a8ffd46b | 90 | inline UInt_t GetDecodedWordBuffer(AliTPCHNode* root); |
91 | //This method is used to get a decoded word from the compressed file | |
92 | inline UInt_t GetDecodedWord(AliTPCHNode* root); | |
a79660fb | 93 | //This method is used to get a decoded word from the compressed file |
95e50ecd | 94 | inline UInt_t GetDecodedWordBufferWithLUTs(UInt_t* LUTDimension,AliTPCHNode** LUTNode); |
95 | inline UInt_t GetDecodedLUTBuffer(AliTPCHNode** node,UInt_t *buffer); | |
a79660fb | 96 | |
2e9f335b | 97 | fstream f; // f is the logical name for the compressed and uncompressed file |
a79660fb | 98 | ofstream fStat; // Logical name for the Statistics file |
0b3c7dfc | 99 | UInt_t fBuffer; // buffer |
2e9f335b | 100 | Int_t fDimBuffer; // buffer dimension (32 bit) |
101 | Int_t fFreeBitsBuffer; // number of free bits inside the buffer | |
95e50ecd | 102 | UInt_t fBitsToRead; // number of bits to be read |
0b3c7dfc | 103 | UInt_t fPos; // current file position |
a79660fb | 104 | Int_t fVerbose; // verbose level (0 silent, !=0 output messages) |
0b3c7dfc | 105 | UInt_t fFillWords; // Number of hexadecimally words (2AA pattern) inside a pad data block |
a8ffd46b | 106 | UInt_t* fPointBuffer; //pointer to the compressed raw data |
95e50ecd | 107 | static const UInt_t fgkTableDimension = 7; // size of LUTs for fast decompression |
108 | ||
2e9f335b | 109 | ClassDef(AliTPCCompression,1) |
110 | }; | |
111 | #endif |