Table of Contents
QccENTHuffmanEncodeChannel, QccENTHuffmanDecodeChannel - Huffman
encoding and decoding of channels
#include "libQccPack.h"
int
QccENTHuffmanEncodeChannel(const QccChannel *channel, QccBitBuffer *output_buffer,
QccENTHuffmanTable *table);
int QccENTHuffmanDecodeChannel(QccBitBuffer
*input_buffer, const QccChannel *channel, const QccENTHuffmanTable *table);
QccENTHuffmanEncodeChannel() performs Huffman coding of the
symbol stream in channel, outputting the binary codewords to output_buffer.
channel should not contain any null symbols (see QccChannel(3)
); use
QccChannelRemoveNullSymbols(3)
to remove null symbols if needed. QccENTHuffmanEncodeChannel()
designs a Huffman code table, via a call to QccENTHuffmanDesign(3)
, specifically
for the symbols in channel by estimating symbol probabilities from the
number of times each symbol occurs in channel. QccENTHuffmanEncode(3)
is then called to produce the binary coding of the channel symbols with
the newly designed Huffman code table. Finally, the Huffman table used
is returned as huffman_table table->table_type = QCCENTHUFFMAN_ENCODETABLE).
QccENTHuffmanDecodeChannel() performs Huffman decoding of the bits in
the bitstream input_buffer, producing a output stream of channel symbols
that are stored in channel . channel must be allocated prior to calling
QccENTHuffmanDecodeChannel(); QccChannelGetBlockSize(3)
is called to find
out how many channel symbols are to be decoded from input_buffer. QccENTHuffmanDecodeChannel()
calls QccENTHuffmanDecode(3)
to actually do the Huffman decoding.
Multiple successive calls to QccENTHuffmanEncodeChannel() are possible;
in this case, the individual bitstreams produced by each encoding appear
concatenated in the final output bitstream. QccBitBufferFlush(3)
must be
called after the final call to QccENTHuffmanEncodeChannel() (but not after
any of the preceeding calls to QccENTHuffmanEncodeChannel()) to ensure
that the last few bits of the concatenated bitstream are actually written
to the output file. Multiple calls to QccENTHuffmanDecodeChannel() can
be used to decode the concatenated bitstream produced in this fashion,
or a single call will work too.
These routines return 0 on
success, and 1 on failure.
QccENTHuffmanEncode(3)
, QccENTHuffmanDecode(3)
,
QccENTHuffmanDesign(3)
, QccENTHuffmanTable(3)
, QccChannel(3)
, QccPackENT(3)
,
QccPack(3)
D. A. Huffman, "A Method for the Construction of Minimum-Redundancy
Codes," Proceedings of the IRE, vol. 40, pp. 1098-1101, September 1952.
Copyright (C) 1997-2021 James E. Fowler
Table of Contents