public class MQDecoder extends Object
Constructor and Description 

MQDecoder(ByteInputBuffer iStream,
int nrOfContexts,
int[] initStates)
Instantiates a new MQdecoder, with the specified number of contexts and
initial states.

Modifier and Type  Method and Description 

boolean 
checkPredTerm()
Checks for past errors in the decoding process using the predictable
error resilient termination.

int 
decodeSymbol(int context)
Arithmetically decodes one symbol from the bit stream with the given
context and returns its decoded value.

void 
decodeSymbols(int[] bits,
int[] cX,
int n)
This function performs the arithmetic decoding.

boolean 
fastDecodeSymbols(int[] bits,
int ctxt,
int n)
Decodes 'n' symbols from the bit stream using the same context
'ctxt'.

ByteInputBuffer 
getByteInputBuffer()
Returns the underlying 'ByteInputBuffer' from where the MQ
coded input bytes are read.

int 
getNumCtxts()
Returns the number of contexts in the arithmetic coder.

void 
nextSegment(byte[] buf,
int off,
int len)
Resets the MQ decoder to start a new segment.

void 
resetCtxt(int c)
Resets a context to the original probability distribution.

void 
resetCtxts()
Resets a context to the original probability distribution.

public MQDecoder(ByteInputBuffer iStream, int nrOfContexts, int[] initStates)
iStream
 the stream that contains the coded bitsnrOfContexts
 The number of contexts usedinitStates
 The initial state for each context. A reference is
kept to this array to reinitialize the contexts whenever 'reset()' or
'resetCtxts()' is called.public final boolean fastDecodeSymbols(int[] bits, int ctxt, int n)
Speedup mode should be used when decoding long runs of MPS with high probability with the same context.
This methiod will return the decoded symbols differently if speedup mode was used or not. If true is returned, then speedup mode was used and the 'n' decoded symbols are all the same and it is returned ain bits[0] only. If false is returned then speedup mode was not used, the decoded symbols are probably not all the same and they are returned in bits[0], bits[1], ... bits[n1].
bits
 The array where to put the decoded symbols. Must be of
length 'n' or more.ctxt
 The context to use in decoding the symbols.n
 The number of symbols to decode.public final void decodeSymbols(int[] bits, int[] cX, int n)
Each context has a current MPS and an index describing what the current probability is for the LPS. Each bit is decoded and if the probability of the LPS exceeds .5, the MPS and LPS are switched.
bits
 The array where to place the decoded symbols. It should be
long enough to contain 'n' elements.cX
 The context to use in decoding each symbol.n
 The number of symbols to decodepublic final int decodeSymbol(int context)
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.
context
 The context to use in decoding the symbolpublic boolean checkPredTerm()
public final int getNumCtxts()
public final void resetCtxt(int c)
c
 The number of the context (it starts at 0).public final void resetCtxts()
c
 The index of the context (it starts at 0).public final void nextSegment(byte[] buf, int off, int len)
buf
 The byte array containing the MQ encoded data. If null the
current byte array is assumed.off
 The index of the first element in 'buf' to be decoded. If
negative the byte just after the previous segment is assumed, only
valid if 'buf' is null.len
 The number of bytes in 'buf' to be decoded. Any subsequent
bytes are taken to be 0xFF.public ByteInputBuffer getByteInputBuffer()
Copyright © 2015–2017 SCIFIO. All rights reserved.