CADI.Common.LogicalTarget.JPEG2000.Codestream
Class TagTreeDecoder

java.lang.Object
  extended by CADI.Common.LogicalTarget.JPEG2000.Codestream.TagTreeDecoder

public class TagTreeDecoder
extends java.lang.Object

This class implements a tag tree decoder. A tag tree is an efficient way to code a 2D matrix.

Usage: example:
  constructor
  decoder
  getValue
  [reset]
  decoder
  getValue
  [reset]
  .....

Version:
1.0.2 2008/11/07
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  int cols
          Number of columns
Negative values are not allowed
private  int levels
          Number of levels
Negative values are not allowed
private  PacketHeaderDataInputStream PHDataInputStream
          Is an input stream where the bit will be read from.
private  int rows
          Number of rows
Negative values are not allowed
private  int[][][] states
          Tag Tree States.
private  int[][][] tagTree
          Tag Tree values.
 
Constructor Summary
TagTreeDecoder(int rows, int cols)
          Constructor
 
Method Summary
 int Decoder(int t, int m, int n, PacketHeaderDataInputStream PHDataInputStream)
          Decode a value of the matrix
private  int getBit()
          Returns the bit readed from the file.
 int getValue(int m, int n)
           
 void list(java.io.PrintStream out)
          Prints this Tag Tree out to the specified output stream.
 void reset()
          Sets the state and tagTree internal attributes to its initial values.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rows

private int rows
Number of rows
Negative values are not allowed


cols

private int cols
Number of columns
Negative values are not allowed


PHDataInputStream

private PacketHeaderDataInputStream PHDataInputStream
Is an input stream where the bit will be read from.


levels

private int levels
Number of levels
Negative values are not allowed


tagTree

private int[][][] tagTree
Tag Tree values. The first index value indicates the level of the tree, where the value 0 is the matrix to encoder, and value levels-1 is the root. The second index is the rows, and the third is the columns
Negative values are not allowed


states

private int[][][] states
Tag Tree States. The first index value indicates the level of the tree, where the value 0 is the matrix to encoder, and value levels-1 is the root. The second index is the rows, and the third is the columns
Negative values are not allowed

Constructor Detail

TagTreeDecoder

TagTreeDecoder(int rows,
               int cols)
Constructor

Parameters:
rows - matrix rows
cols - matrix columns
Throws:
ErrorException - when a codeblock row or column values are wrong
Method Detail

Decoder

public int Decoder(int t,
                   int m,
                   int n,
                   PacketHeaderDataInputStream PHDataInputStream)
            throws java.io.EOFException,
                   java.io.IOException
Decode a value of the matrix

Parameters:
t - threshold
m - coordintes of the value to codify
n - coordintes of the value to codify
PHDataInputStream - data input stream with the packet header.
Returns:
tag tree value at [m,n] position for theshold t
Throws:
ErrorException - when codeblock coordinates are wrong or the bitstream is insuficient for decoding the tag tree information
java.io.EOFException
java.io.IOException

reset

public void reset()
Sets the state and tagTree internal attributes to its initial values.


getValue

public int getValue(int m,
                    int n)
             throws ErrorException
Parameters:
m - coordinates of the value to codify
n - coordinates of the value to codify
Throws:
ErrorException - when the codeblock coordinates are wrong

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

list

public void list(java.io.PrintStream out)
Prints this Tag Tree out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

getBit

private int getBit()
            throws java.io.EOFException,
                   java.io.IOException
Returns the bit readed from the file.

Returns:
an integer that represents the bit readed from the file
Throws:
java.io.EOFException
java.io.IOException


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)