Class CX
Represents a context in the arithmetic decoder that selects probability estimates and statistics used during decoding procedures, as defined in ITU-T Rec. T.88 (2000 E), ISO/IEC 14492:2001.
Context State:
cxarray: Stores the probability estimate index (0-127) for each context statempsarray: Stores the most probable symbol (0 or 1) for each context stateindex: Current context index, selected based on the neighborhood pattern (template-specific arrangement of previously decoded pixels)
Usage: The index is set before each decision to select which context state to use. After decoding, the arithmetic decoder updates the selected context's probability estimate and MPS based on the decoded symbol (see Annex A, T.88).
Reuse:
When arithmetic coding contexts are retained and reused across segments (§7.4.2.2),
a copy() must be created to avoid sharing mutable probability state
between decoders.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCX(int size, int index) Creates a new context with the specified number of context states. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates and returns a deep copy of thisCXobject.(package private) intcx()(package private) intgetIndex()(package private) bytemps()(package private) voidsetCx(int value) voidsetIndex(int index) Sets the context index used for subsequent decoding decisions.(package private) voidFlips the bit in actual "more predictable symbol" array element.
-
Field Details
-
index
private int index -
cx
private final byte[] cx -
mps
private final byte[] mps
-
-
Constructor Details
-
CX
public CX(int size, int index) Creates a new context with the specified number of context states. All probability estimates are initialized to 0, and all MPS values are initialized to 0.- Parameters:
size- the number of context statesindex- the initial context index
-
-
Method Details
-
cx
int cx() -
setCx
void setCx(int value) -
mps
byte mps()- Returns:
- The decision. Possible values are
0or1.
-
toggleMps
void toggleMps()Flips the bit in actual "more predictable symbol" array element. -
getIndex
int getIndex() -
setIndex
public void setIndex(int index) Sets the context index used for subsequent decoding decisions. The index selects which context state's probability estimate and MPS will be used.The index value is typically computed from the neighboring pixels in the template (§6.2.5.1 for generic regions, §6.4.7.1 for text regions).
- Parameters:
index- the context index (0 to size-1)
-
copy
Creates and returns a deep copy of thisCXobject. The new instance will have the same context values, probability estimates, and current index as this object, but will be a separate instance. Changes to the copied object will not affect the original, and vice versa.This is required when reusing arithmetic coding contexts across segments, to avoid sharing mutable probability state between decoders.
- Returns:
- A new
CXobject with the same internal state as this object.
-