![]() |
Project
|
#include <HuffmanCodec.h>
Inherits _BASE.
Classes | |
class | isless |
class | isless< std::shared_ptr< T > > |
specialization for shared pointer More... | |
class | isless< T * > |
specialization for pointer types More... | |
Public Types | |
using | base_type = _BASE |
using | code_type = Rep |
using | node_type = HuffmanNode< code_type > |
using | value_type = typename _BASE::value_type |
Public Member Functions | |
HuffmanModel () | |
~HuffmanModel ()=default | |
int | init (double v=1.) |
code_type | Encode (typename _BASE::value_type symbol, uint16_t &codeLength) const |
value_type | Decode (code_type code, uint16_t &codeLength) const |
bool | GenerateHuffmanTree () |
int | assignCode (node_type *node) |
int | write (const char *filename, std::string method="zlib") const |
Write Huffman table to file. | |
int | write (std::ostream &out) const |
Write Huffman table in self-consistent format to an output stream. | |
int | read (const char *filename, std::string method="zlib") |
Read configuration from file. | |
int | read (std::istream &in) |
Read configuration from stream The previous configuration is discarded. | |
void | print () const |
Static Public Attributes | |
static constexpr bool | OrderMSB = orderMSB |
Definition at line 240 of file HuffmanCodec.h.
using o2::data_compression::HuffmanModel< _BASE, Rep, orderMSB >::base_type = _BASE |
Definition at line 246 of file HuffmanCodec.h.
using o2::data_compression::HuffmanModel< _BASE, Rep, orderMSB >::code_type = Rep |
Definition at line 247 of file HuffmanCodec.h.
using o2::data_compression::HuffmanModel< _BASE, Rep, orderMSB >::node_type = HuffmanNode<code_type> |
Definition at line 248 of file HuffmanCodec.h.
using o2::data_compression::HuffmanModel< _BASE, Rep, orderMSB >::value_type = typename _BASE::value_type |
Definition at line 249 of file HuffmanCodec.h.
|
inline |
Definition at line 243 of file HuffmanCodec.h.
|
default |
|
inline |
assign code to this node loop to right and left nodes
Code direction is determined by template parameter orderMSB being either true or false. Code can be built up in two directions, either with the bit of the parent node in the MSB or LSB. In the latter case, the bit of the parent node has to be right of the bit of child nodes, i.e. bits correspond to the current code length. A bit stream storing bits from MSB to LSB and then overwrapping to the MSBs of the next byte, requires to code to start with MSB.
TODO: implement iterator concept
Definition at line 423 of file HuffmanCodec.h.
|
inline |
Decode bit pattern
The caller provides a bit field determined by the class' template parameter, The number of decoded bits is indicated in the codeLength parameter after decoding.
Definition at line 290 of file HuffmanCodec.h.
|
inline |
Encode value
Definition at line 261 of file HuffmanCodec.h.
|
inline |
Combine and sort nodes to build a binary tree TODO: separate data structures for tree and leaf nodes to optimize storage
Definition at line 376 of file HuffmanCodec.h.
|
inline |
Definition at line 252 of file HuffmanCodec.h.
|
inline |
Definition at line 615 of file HuffmanCodec.h.
|
inline |
Read configuration from file.
Read configuration text file, can be in compressed format, supported methods: gzip, zlib, bzip2, and lzma
Definition at line 492 of file HuffmanCodec.h.
|
inline |
Read configuration from stream The previous configuration is discarded.
The text file contains a self-consistent representatio of the Huffman tree, one node definition per line. Each node has an index (corresponding to the line number). The tree nodes hold the indices of their child nodes. Leave node format: index value weight codelen code Tree node format: index left_index right_index
Definition at line 508 of file HuffmanCodec.h.
|
inline |
Write Huffman table to file.
The file can be compressed on-the-fly, supported methods: gzip, zlib, bzip2, and lzma
Configuration is written in self-consistent text file format.
Definition at line 469 of file HuffmanCodec.h.
|
inline |
Write Huffman table in self-consistent format to an output stream.
Definition at line 478 of file HuffmanCodec.h.
|
staticconstexpr |
Definition at line 250 of file HuffmanCodec.h.