Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

OctaneCoder Class Reference
[Coders]

#include <coder.hpp>

Inheritance diagram for OctaneCoder:

OctaneClass HuffmanCoder SampleCoder List of all members.

Detailed Description

During compression, the job of the Coder class is use probability information from the modeler to figure out the optimal bitcodes to use when writing symbols into the output stream.

During decompression, the coder is responsible for reading bitcodes from the input and providing a stream of symbol numbers to the compressor.

Definition at line 50 of file coder.hpp.

Public Member Functions

 OctaneCoder ()
 constructor

virtual ~OctaneCoder ()
 destructor

virtual std::string GetName ()
 provide a unique name for the coder, used in some cases to automatically register the object with a manager

virtual std::string GetDescription ()
 optionally provide a longer (maybe 20-60 characters) description

virtual std::string GetHelpInformation ()
 optionally provide more information about the object on request for help

virtual bool WriteSymbolBits (int symbolnum, bitwriter &bw)=0
 write bits for symbol number

virtual bool DecodeSymbolFromInput (int &symbolnum, bitreader &br)=0
 Decode the next symbol from the input.

virtual void ResetState ()
virtual void SynchronizeStateForNewStream ()
 Synchronize state for a new stream - this *MUST* be called before beginning a new parsing stream.

virtual bool PrepareForCoding (OctaneModeler *modelerp)
 Prepare for coding mode; returns true on success.

virtual bool IsReadyToCode ()
 Are we ready to actually code and decode?

virtual void ReceiveNotification_ModelChange_AllSymbolWeights (OctaneModeler *modelerp)
 Notify coder that all probabilities are being updated.

virtual void ReceiveNotification_ModelChange_SingleSymbolWeight (OctaneModeler *modelerp, int symbolnum)
 notify that a single symbol probability has changed (by default just calls AllSymbolWeights change above)

void AlignOutputStreamToByteBoundry (bitwriter &bw)
 Align output stream - called after writing an End-of-stream symbol This throws away any spare bits in the output which are not aligned on a byte boundary.

void AlignInputStreamToByteBoundry (bitreader &br)
 Align input stream - called after reading an End-of-stream symbol This throws away any spare bits in the output which are not aligned on a byte boundary.


Member Function Documentation

virtual std::string OctaneCoder::GetName  )  [inline, virtual]
 

provide a unique name for the coder, used in some cases to automatically register the object with a manager

Returns:
a short *unique* name

Reimplemented from OctaneClass.

Reimplemented in HuffmanCoder, and SampleCoder.

Definition at line 60 of file coder.hpp.

00060 {return "OctaneCoder";}

virtual std::string OctaneCoder::GetDescription  )  [inline, virtual]
 

optionally provide a longer (maybe 20-60 characters) description

Returns:
a one line description

Reimplemented from OctaneClass.

Reimplemented in HuffmanCoder, and SampleCoder.

Definition at line 61 of file coder.hpp.

00061 {return "Base Coder";}

virtual std::string OctaneCoder::GetHelpInformation  )  [inline, virtual]
 

optionally provide more information about the object on request for help

Returns:
a long string (can be multiple
newlines)

Reimplemented from OctaneClass.

Reimplemented in HuffmanCoder, and SampleCoder.

Definition at line 62 of file coder.hpp.

Referenced by OctaneCompressor_Statistical::GetHelpInformation().

00062 { return ""; }

virtual bool OctaneCoder::WriteSymbolBits int  symbolnum,
bitwriter bw
[pure virtual]
 

write bits for symbol number

Returns:
true on success

Implemented in HuffmanCoder, and SampleCoder.

Referenced by OctaneCompressor_Statistical::DoProtectedCompress().

virtual bool OctaneCoder::DecodeSymbolFromInput int &  symbolnum,
bitreader br
[pure virtual]
 

Decode the next symbol from the input.

Returns:
true on success, false when there are no more symbols to read.

Implemented in HuffmanCoder, and SampleCoder.

Referenced by OctaneCompressor_Statistical::DoProtectedDecompress().

virtual bool OctaneCoder::PrepareForCoding OctaneModeler modelerp  )  [inline, virtual]
 

Prepare for coding mode; returns true on success.

Returns:
true on success

Definition at line 82 of file coder.hpp.

Referenced by OctaneCompressor_Statistical::PrepareForCompression().

00082 {return true;};

virtual bool OctaneCoder::IsReadyToCode  )  [inline, virtual]
 

Are we ready to actually code and decode?

Returns:
true on success

Reimplemented in HuffmanCoder, and SampleCoder.

Definition at line 85 of file coder.hpp.

Referenced by OctaneCompressor_Statistical::IsReadyToCompress().

00085 {return true;};

virtual void OctaneCoder::ReceiveNotification_ModelChange_AllSymbolWeights OctaneModeler modelerp  )  [inline, virtual]
 

Notify coder that all probabilities are being updated.

We can be informed by a model when the underlying probabilities are changing this part of the API exists so that we can flexibly and efficiently handle different kinds of situations where the coder needs to be synchronized with the model probabilities. in some cases, a coder may ignore these messages and simply rebuild its internal datastructure on each coding event in other cases, it will want to incrementally update as model changes. Two kinds of notifications are supported, depending on how the model updates itself during processing, whether it updates one symbol per iteration, or modifies all symbols at once.

See also:
OctaneCoder::ReceiveNotification_ModelChange_SingleSymbolWeight

Reimplemented in HuffmanCoder, and SampleCoder.

Definition at line 101 of file coder.hpp.

Referenced by OctaneCompressor_Statistical::DoProtectedCreateSymbolsAndModelsUsingStream(), OctaneCompressor_Statistical::DoProtectedLoadState(), ReceiveNotification_ModelChange_SingleSymbolWeight(), and OctaneCompressor_Statistical::SetupAnyDefaultParser().

00101 {;};

virtual void OctaneCoder::ReceiveNotification_ModelChange_SingleSymbolWeight OctaneModeler modelerp,
int  symbolnum
[inline, virtual]
 

notify that a single symbol probability has changed (by default just calls AllSymbolWeights change above)

Note:
the SingleSymbolWeight() call will NOT be made when all weights change; see ReceiveNotification_ModelChange_AllSymbolWeights instead.
See also:
OctaneCoder::ReceiveNotification_ModelChange_AllSymbolWeights

Reimplemented in HuffmanCoder.

Definition at line 105 of file coder.hpp.

References ReceiveNotification_ModelChange_AllSymbolWeights().

void OctaneCoder::AlignOutputStreamToByteBoundry bitwriter bw  )  [inline]
 

Align output stream - called after writing an End-of-stream symbol This throws away any spare bits in the output which are not aligned on a byte boundary.

This is required when we hit and end of stream symbol, to avoid treating leftover bits as meaningful symbols.

Returns:
true on success

Definition at line 113 of file coder.hpp.

References bitwriter::align_byte().

Referenced by OctaneCompressor_Statistical::DoProtectedCompress().

00113 {bw.align_byte();};

void OctaneCoder::AlignInputStreamToByteBoundry bitreader br  )  [inline]
 

Align input stream - called after reading an End-of-stream symbol This throws away any spare bits in the output which are not aligned on a byte boundary.

This is required when we hit and end of stream symbol, to avoid treating leftover bits as meaningful symbols.

Returns:
true on success

Definition at line 118 of file coder.hpp.

References bitreader::align_byte().

Referenced by OctaneCompressor_Statistical::DoProtectedDecompress().

00118 {br.align_byte();};


The documentation for this class was generated from the following file:  
Generated on 20 May 2004 by doxygen 1.3.3