public class MQDecoder extends java.lang.Object implements Decoder
Modifier and Type | Field and Description |
---|---|
private int |
A
Interval range.
|
private int |
C
Lower down interval.
|
private CPByteStream |
inputByteStream
Bytestream from which the MQ decoder reads data.
|
private int |
L
Number of bytes transferred to the outputByteStream.
|
private int |
numContexts
Number of contexts (defined by JPEG2000).
|
private int[][] |
statesMPS
State and Most Probable Symbol of each context.
|
private int[][] |
stateSymbolInit
MQ context state initialization (defined by JPEG2000 standard).
|
private int[][] |
stateTrans
MQ probability state transition (defined by JPEG2000 standard).
|
private int |
t
Number of bits to transfer (down counter).
|
private int |
Tr
Byte to transfer.
|
Constructor and Description |
---|
MQDecoder()
Constructor that initializes internal registers of the MQ decoder but does not initialize the inputByteStream.
|
MQDecoder(CPByteStream inputByteStream)
Constructor that initializes internal registers of the MQ decoder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
decodeBit()
Decode a bit using the context 18 (equivalent probabilities).
|
boolean |
decodeBit(int context)
Decode a bit.
|
private void |
fillLSB()
Fill the C register with a new byte of inputByteStream.
|
void |
reset()
Reset the context probabilities of the decoder, if any.
|
void |
restart()
Start the value of the internal variables A, C, ... of the MQ decoder filling them with the values of the inputByteStream.
|
void |
swapInputByteStream(CPByteStream inputByteStream)
Swaps the current inputByteStream.
|
private CPByteStream inputByteStream
The content must be understood as a ByteStream.
private final int numContexts
Positive number.
private final int[][] stateSymbolInit
First array index represents the context and second is: (p.e. [2][0] is the initial state of context 2)
private final int[][] stateTrans
First array index represents the current state and second is: (i.e. [1][0] is the transition to do when code a MPS symbol and the state of the context is 1)
private int A
From right to left: 8 register bits, 3 spacer bits, 8 partial code byte, 1 carry bit.
private int C
From right to left: 8 register bits, 3 spacer bits, 8 partial code byte, 1 carry bit.
private int t
Usually it is initialized to 8, unless carry situations that it initilized to 7. Then count down until 0.
private int Tr
Byte flushed to the outputByteStream.
private int L
Byte flushed to the output ByteStream.
private int[][] statesMPS
Array index is the context and the State [context][0] or MPS [context][1]. It must correspond to some stateTrans.
public MQDecoder()
public MQDecoder(CPByteStream inputByteStream) throws ErrorException
inputByteStream
- the input stream of bytesErrorException
- when end of ByteStream is reachedpublic boolean decodeBit() throws ErrorException
public boolean decodeBit(int context) throws ErrorException
private void fillLSB() throws ErrorException
ErrorException
- when trying to read after the end of the inputByteStreampublic void swapInputByteStream(CPByteStream inputByteStream)
swapInputByteStream
in interface Decoder
inputByteStream
- the input stream of bytespublic void reset()
Decoder
public void restart() throws ErrorException
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)