class ZPCodec

Performs ZP-Coder encoding and decoding.

Public Fields

[more]int bitcount
Counter for code bits (requires -DZPCODEC_BITCOUNT).

Public Methods

[more] ZPCodec(ByteStream &bs, bool encoding, bool djvucompat=false)
Constructs a ZP-Coder.
[more]void encoder(int bit, BitContext &ctx)
Encodes bit bit using context variable ctx.
[more]int decoder(BitContext &ctx)
Decodes a bit using context variable ctx.
[more]void encoder(int bit)
Encodes bit bit without compression (pass-thru encoder).
[more]int decoder(void)
Decodes a bit without compression (pass-thru decoder).


Documentation

Performs ZP-Coder encoding and decoding. A ZPCodec object must either constructed for encoding or for decoding. The ZPCodec object is connected with a ByteStream object specified at construction time. A ZPCodec object constructed for decoding reads code bits from the ByteStream and returns a message bit whenever function decoder is called. A ZPCodec constructed for encoding processes the message bits provided by function encoder and writes the corresponding code bits to ByteStream bs.

You should never directly access a ByteStream object connected to a valid ZPCodec object. The most direct way to access the ByteStream object consists of using the "pass-thru" versions of functions encoder and decoder.

The ByteStream object can be accessed again after the destruction of the ZPCodec object. Note that the encoder always flushes its internal buffers and writes a few final code bytes when the ZPCodec object is destroyed. Note also that the decoder often reads a few bytes beyond the last code byte written by the encoder. This lag means that you must reposition the ByteStream after the destruction of the ZPCodec object and before re-using the ByteStream object (see IFFByteStream.)

Please note also that the decoder has no way to reliably indicate the end of the message bit sequence. The content of the message must be designed in a way which indicates when to stop decoding. Simple ways to achieve this consists of announcing the message length at the beginning (like a pascal style string), or of defining a termination code (like a null terminated string).

o ZPCodec(ByteStream &bs, bool encoding, bool djvucompat=false)
Constructs a ZP-Coder. If argument object will read code bits from the ByteStream bs and return a message bit whenever function decoder is called. If flag the ZP-Coder object will process the message bits provided by function

djvucompat selects a slightly less efficient adaptation table which is used by the DjVu project. This is required in order to ensure the bitstream compatibility. You should not use this flag unless you want to decode JB2, IW44 or BZZ encoded data.

ovoid encoder(int bit, BitContext &ctx)
Encodes bit bit using context variable ctx. Argument bit must be 0 or 1. This function should only be used with ZP-Coder objects created for encoding. It may modify the contents of variable ctx in order to perform context adaptation.

oint decoder(BitContext &ctx)
Decodes a bit using context variable ctx. This function should only be used with ZP-Coder objects created for decoding. It may modify the contents of variable ctx in order to perform context adaptation.

ovoid encoder(int bit)
Encodes bit bit without compression (pass-thru encoder). Argument bit must be 0 or 1. No compression will be applied. Calling this function always increases the length of the code bit sequence by one bit.

oint decoder(void)
Decodes a bit without compression (pass-thru decoder). This function retrieves bits encoded with the pass-thru encoder.

oint bitcount
Counter for code bits (requires -DZPCODEC_BITCOUNT). This member variable is available when the ZP-Coder is compiled with option -DZPCODEC_BITCOUNT. Variable bitcount counts the number of code bits processed by the coder since the construction of the object. This variable can be used to evaluate how many code bits are spent on various components of the message.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.