Method | Description | |
---|---|---|
MQCoder ( CSJ2K.j2k.entropy.encoder.ByteOutputBuffer oStream, int nrOfContexts, int init ) : System |
Instantiates a new MQ-coder, with the specified number of contexts and initial states. The compressed bytestream is written to the 'oStream' object.
|
|
codeSymbol ( int bit, int context ) : void |
This function performs the arithmetic encoding of one symbol. The function receives a bit that is to be encoded and a context with which to encode it. Each context has a current MPS and an index describing what the current probability is for the LPS. Each bit is encoded and if the probability of the LPS exceeds .5, the MPS and LPS are switched.
|
|
codeSymbols ( int bits, int cX, int n ) : void |
This function performs the arithmetic encoding of several symbols together. The function receives an array of symbols that are to be encoded and an array containing the contexts with which to encode them. The advantage of using this function is that the cost of the method call is amortized by the number of coded symbols per method call. Each context has a current MPS and an index describing what the current probability is for the LPS. Each bit is encoded and if the probability of the LPS exceeds .5, the MPS and LPS are switched.
|
|
fastCodeSymbols ( int bit, int ctxt, int n ) : void |
This method performs the coding of the symbol 'bit', using context 'ctxt', 'n' times, using the MQ-coder speedup mode if possible. If the symbol 'bit' is the current more probable symbol (MPS) and qe[ctxt]<=0x4000, and (A-0x8000)>=qe[ctxt], speedup mode will be used. Otherwise the normal mode will be used. The speedup mode can significantly improve the speed of arithmetic coding when several MPS symbols, with a high probability distribution, must be coded with the same context. The generated bit stream is the same as if the normal mode was used. This method is also faster than the 'codeSymbols()' and 'codeSymbol()' ones, for coding the same symbols with the same context several times, when speedup mode can not be used, although not significantly.
|
|
finishLengthCalculation ( int rates, int n ) : void |
Terminates the calculation of the required length for each coding pass. This method must be called just after the 'terminate()' one has been called for each terminated MQ segment. The values in 'rates' must have been compensated for any offset due to previous terminated segments, so that the correct index to the stored coded data is used.
|
|
reset ( ) : void |
Reinitializes the MQ coder and the underlying 'ByteOutputBuffer' buffer as if a new object was instantaited. All the data in the 'ByteOutputBuffer' buffer is erased and the state and contexts of the MQ coder are reinitialized). Additionally any saved MQ states are discarded.
|
|
resetCtxt ( int c ) : void |
Resets a context to the original probability distribution, and sets its more probable symbol to 0.
|
|
resetCtxts ( ) : void |
Resets all contexts to their original probability distribution and sets all more probable symbols to 0.
|
|
terminate ( ) : int |
This function flushes the remaining encoded bits and makes sure that enough information is written to the bit stream to be able to finish decoding, and then it reinitializes the internal state of the MQ coder but without modifying the context states. After calling this method the 'finishLengthCalculation()' method should be called, after compensating the returned length for the length of previous coded segments, so that the length calculation is finalized. The type of termination used depends on the one specified at the constructor.
|
Method | Description | |
---|---|---|
byteOut ( ) : void |
This function puts one byte of compressed bits in the output stream. The highest 8 bits of c are then put in b to be the next byte to write. This method delays the output of any 0xFF bytes until a non 0xFF byte has to be written to the output bit stream (the 'delFF' variable signals if there is a delayed 0xff byte).
|
|
saveState ( ) : void |
Saves the current state of the MQ coder (just the registers, not the contexts) so that a near optimal length calculation can be performed later.
|
public MQCoder ( CSJ2K.j2k.entropy.encoder.ByteOutputBuffer oStream, int nrOfContexts, int init ) : System | ||
oStream | CSJ2K.j2k.entropy.encoder.ByteOutputBuffer | where to output the compressed data. /// /// |
nrOfContexts | int | The number of contexts used by the MQ coder. /// /// |
init | int | The initial state for each context. A reference is kept to /// this array to reinitialize the contexts whenever 'reset()' or /// 'resetCtxts()' is called. /// /// |
return | System |
public codeSymbol ( int bit, int context ) : void | ||
bit | int | The symbol to be encoded, must be 0 or 1. /// /// |
context | int | the context with which to encode the symbol. /// /// |
return | void |
public codeSymbols ( int bits, int cX, int n ) : void | ||
bits | int | An array containing the symbols to be encoded. Valid /// symbols are 0 and 1. /// /// |
cX | int | The context for each of the symbols to be encoded. /// /// |
n | int | The number of symbols to encode. /// /// |
return | void |
public fastCodeSymbols ( int bit, int ctxt, int n ) : void | ||
bit | int | The symbol do code, 0 or 1. /// /// |
ctxt | int | The context to us in coding the symbol. /// /// |
n | int | The number of times that the symbol must be coded. /// /// |
return | void |
public finishLengthCalculation ( int rates, int n ) : void | ||
rates | int | The array containing the values returned by /// 'getNumCodedBytes()' for each coding pass. /// /// |
n | int | The index in the 'rates' array of the last terminated length. /// /// |
return | void |
public resetCtxt ( int c ) : void | ||
c | int | The number of the context (it starts at 0). /// /// |
return | void |