Some documentation changes.
[fic.git] / modules / vliCodec.h
blobe0ea483b80f56191f3e848d19df7ed5e0a8ae2fe
1 #ifndef VLICODEC_HEADER_
2 #define VLICODEC_HEADER_
4 #include "../headers.h"
5 #include "../fileUtil.h"
7 class VLI;
9 /** Variable-length-integer codec optimized for encoding little-changing sequences.
10 * It lets user choose the number of first-level symbols. */
11 class MDifferentialVLICodec: public IIntCodec {
13 DECLARE_TypeInfo( MDifferentialVLICodec, "Differential VLI"
14 , "Variable-length-integer differential encoder with adjustable distribution"
15 , {
16 label: "First level symbols",
17 desc: "The number of possibilities\n"
18 "that will occupy least space",
19 type: settingInt(0,1,8,IntLog2)
20 } )
22 private:
23 /** Indices for settings */
24 enum Settings { VLIExponent };
26 private:
27 int possib /// the number of possibilities set by ::setPossibilities
28 , lastSymbol; ///< the last encoded symbol (::possib/2 at the beginning)
29 public:
30 /** \name IIntCodec interface
31 * @{ */
32 void setPossibilities(int possibilities) {
33 possib= possibilities;
34 lastSymbol= possib/2;
36 void encode(std::vector<int> &data,std::ostream &file);
37 void decode(std::istream &file,int count,std::vector<int> &data);
39 void writeSettings(std::ostream &file)
40 { put<Uchar>( file, settingsInt(VLIExponent) ); }
41 void readSettings(std::istream &file)
42 { settingsInt(VLIExponent)= get<Uchar>(file); }
43 /// @}
46 #endif // VLICODEC_HEADER_