Table of Contents

NAME

QccENTAdaptiveGolombEncode, QccENTAdaptiveGolombDecode - adaptive Golomb (Langdon) encoding and decoding

SYNOPSIS

#include "libQccPack.h"

int QccENTAdaptiveGolombEncode(QccBitBuffer *output_buffer, const int *symbols, int num_symbols);
int QccENTAdaptiveGolombDecode(QccBitBuffer *input_buffer, int *symbols, int num_symbols);

DESCRIPTION

QccENTAdaptiveGolombEncode() performs adaptive Golomb (Langdon) coding of the symbol stream in symbols, outputting the binary codewords to output_buffer. num_symbols indicates how many symbols are in the symbol stream (which can be as short as one symbol). Since adaptive Golomb coding is a binary entropy coder, the symbol stream, symbols, can consist of only zeros and ones. output_buffer must be a QccBitBuffer that has been opened for writing prior to calling QccENTAdaptiveGolombEncode(). After calling QccENTAdaptiveGolombEncode(), QccBitBufferFlush(3) must be called to ensure that the last few bits of the bitstream are actually written to the output file.

QccENTAdaptiveGolombDecode() performs adaptive Golomb (Langdon) decoding of the bits in the bitstream input_buffer, producing an output stream of symbols that are stored in symbols. The symbols array must be allocated with space sufficient for holding num_symbols integers; this allocation must be done prior to calling QccENTAdaptiveGolombDecode(). Additionally, input_buffer must be opened for reading prior to calling QccENTAdaptiveGolombDecode().

NOTES

QccBitBufferFlush(3) must be called after the call to QccENTAdaptiveGolombEncode() to ensure that the last few bits of the concatenated bitstream are actually written to the output file.

QccENTAdaptiveGolombEncode() will fail if it encounters an invalid symbol (i.e., a symbol that is neither 0 or 1).

Golomb coding originated in the 1966 paper by Golomb; the adaptive variant described here is due to Langdon. Apparently, this adaptive Golomb coding is also known as runlength/Rice coding.

RETURN VALUE

These routines return 0 on success, and 1 on failure.

SEE ALSO

QccENTAdaptiveGolombEncodeChannel(3) , QccENTAdaptiveGolombDecodeChannel(3) , QccPackENT(3) , QccPack(3)

G. G. Langdon, Jr., "An adaptive run-length coding algorithm," IBM Technical Disclosure Bulletin, vol. 26, no. 7B, pp. 3783-3785, December 1983.

S. W. Golomb, "Run-Length Encodings," IEEE Transactions on Information Theory, vol. 12, pp. 399-401, July 1966.

AUTHOR

Written by Yufei Yuan <yuanyufei@hotmail.com>

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads