1 #ifndef VLICODEC_HEADER_
2 #define VLICODEC_HEADER_
4 #include "../headers.h"
5 #include "../fileUtil.h"
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"
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
)
23 /** Indices for settings */
24 enum Settings
{ VLIExponent
};
27 int possib
/// the number of possibilities set by ::setPossibilities
28 , lastSymbol
; ///< the last encoded symbol (::possib/2 at the beginning)
30 /** \name IIntCodec interface
32 void setPossibilities(int possibilities
) {
33 possib
= possibilities
;
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
); }
46 #endif // VLICODEC_HEADER_