Class TagTreeDecoder

java.lang.Object
jj2000.j2k.codestream.reader.TagTreeDecoder

public class TagTreeDecoder extends Object
This class implements the tag tree decoder. A tag tree codes a 2D matrix of integer elements in an efficient way. The decoding procedure 'update()' updates a value of the matrix from a stream of coded data, given a threshold. This procedure decodes enough information to identify whether or not the value is greater than or equal to the threshold, and updates the value accordingly.

In general the decoding procedure must follow the same sequence of elements and thresholds as the encoding one. The encoder is implemented by the TagTreeEncoder class.

Tag trees that have one dimension, or both, as 0 are allowed for convenience. Of course no values can be set or coded in such cases.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The vertical dimensions of the base level
    protected int
    The number of levels in the tag tree
    protected int[][]
    The tag tree state.
    protected int[][]
    The tag tree values.
    protected int
    The horizontal dimension of the base level
  • Constructor Summary

    Constructors
    Constructor
    Description
    TagTreeDecoder(int h, int w)
    Creates a tag tree decoder with 'w' elements along the horizontal dimension and 'h' elements along the vertical direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Returns the number of leafs along the vertical direction.
    int
    getValue(int m, int n)
    Returns the current value of the specified element in the tag tree.
    final int
    Returns the number of leafs along the horizontal direction.
    int
    update(int m, int n, int t, jj2000.j2k.codestream.reader.PktHeaderBitReader in)
    Decodes information for the specified element of the tree, given the threshold, and updates its value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • w

      protected int w
      The horizontal dimension of the base level
    • h

      protected int h
      The vertical dimensions of the base level
    • lvls

      protected int lvls
      The number of levels in the tag tree
    • treeV

      protected int[][] treeV
      The tag tree values. The first index is the level, starting at level 0 (leafs). The second index is the element within the level, in lexicographical order.
    • treeS

      protected int[][] treeS
      The tag tree state. The first index is the level, starting at level 0 (leafs). The second index is the element within the level, in lexicographical order.
  • Constructor Details

    • TagTreeDecoder

      public TagTreeDecoder(int h, int w)
      Creates a tag tree decoder with 'w' elements along the horizontal dimension and 'h' elements along the vertical direction. The total number of elements is thus 'vdim' x 'hdim'.

      The values of all elements are initialized to Integer.MAX_VALUE (i.e. no information decoded so far). The states are initialized all to 0.

      Parameters:
      h - The number of elements along the vertical direction.
      w - The number of elements along the horizontal direction.
  • Method Details

    • getWidth

      public final int getWidth()
      Returns the number of leafs along the horizontal direction.
      Returns:
      The number of leafs along the horizontal direction.
    • getHeight

      public final int getHeight()
      Returns the number of leafs along the vertical direction.
      Returns:
      The number of leafs along the vertical direction.
    • update

      public int update(int m, int n, int t, jj2000.j2k.codestream.reader.PktHeaderBitReader in) throws IOException
      Decodes information for the specified element of the tree, given the threshold, and updates its value. The information that can be decoded is whether or not the value of the element is greater than, or equal to, the value of the threshold.
      Parameters:
      m - The vertical index of the element.
      n - The horizontal index of the element.
      t - The threshold to use in decoding. It must be non-negative.
      in - The stream from where to read the coded information.
      Returns:
      The updated value at position (m,n).
      Throws:
      IOException - If an I/O error occurs while reading from 'in'.
      EOFException - If the ned of the 'in' stream is reached before getting all the necessary data.
    • getValue

      public int getValue(int m, int n)
      Returns the current value of the specified element in the tag tree. This is the value as last updated by the update() method.
      Parameters:
      m - The vertical index of the element.
      n - The horizontal index of the element.
      Returns:
      The current value of the element.
      See Also: