CADI.Common.LogicalTarget.JPEG2000.Codestream
Class CodestreamIndexing

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

public class CodestreamIndexing
extends java.lang.Object

This class reads the image a store it in a concret structure to decompress. Usage example:
  construct
  run   get functions

Version:
1.0.4 2009/02/16
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  int[][] blocksPerPrecinctHeights
          Definition in GenerateImageStructure.blocksPerPrecinctHeights
private  int[][] blocksPerPrecinctWidths
          Definition in GenerateImageStructure.blocksPerPrecinctWidths
private  CODParameters codParameters
          Definition in CODParameters.
private  java.util.Hashtable<java.lang.Long,DataBinInfo> dataBins
          This attribute is used to store information about the data-bins of the codestream.
private  int[][][][][][] imageStructure
          Definition in GenerateImageStructure.imageStructure
private  BufferedDataInputStream in
          Is an input stream from where data will be read.
private  PacketHeadersDecoder PkDeheading
          Definition in PacketHeadersDecoder
private  boolean[][][] precinctRead
          Indicates if a precinct has been writen in the file.
private  boolean readCodingPasses
          Indicates whether the coding passes structure must be read.
private  SIZParameters sizParameters
          Definition in SIZParameters.
private  int[][][] xNumBlocks
          Number of blocks X for each component and resolution level and subband (needed to calculate the number of precincts widht and heights)
private  int[][][] yNumBlocks
          number of blocks Y for each component and resolution level and subband (needed to calculate the number of precincts widht and heights)
 
Constructor Summary
CodestreamIndexing(BufferedDataInputStream in, JPCParameters jpcParameters, int[][][][][][] imageStructure, int[][] blocksPerPrecinctWidths, int[][] blocksPerPrecinctHeights)
          Constructor
 
Method Summary
private  void calculateNumBlocksPerPrecinct()
          Calculate the number of blocks that there are per precinct
private  void CPRL()
          Reads file using CPRL progression.
 java.util.Hashtable<java.lang.Long,DataBinInfo> getDataBins()
          Returns the dataBins attribute.
 void list(java.io.PrintStream out)
          Prints this Codestream Indexing fields out to the specified output stream.
private  void LRCP()
          Reads file using LRCP progression.
private  int maxPrecinct()
          Find the maximum precincts of all ressolution levels and all components
private  int maxRlevel()
          Find the biggest ressolution level within all the components
private  int numPrecinctHighRlevel(int z, int rLevel)
          Find the hight precinct in function of one ressolution level
private  int numPrecinctWitdhRlevel(int z, int rLevel)
          Find the width precinct in function of one ressolution level
private  void PCRL()
          Reads file using PCRL progression.
private  double precinctCorrespondenceX(int z, int precinct, int rLevel, int maxRlevel)
          Find the correspondence in width of a precinct
private  double precinctCorrespondenceY(int z, int precinct, int rLevel, int maxRlevel)
          Find the correspondence in hight of a precinct
private  int readByte()
          Reads a byte from the file and returns its value.
private  void readCodingPassesStructure(long inClassIdentifier, int rLevel, int precinct, int z, int layerBegin, int layerToWrite)
          Read a precinct in a file up to the coding pass level.
private  void readPacketStructure(long inClassIdentifier, int rLevel, int precinct, int z, int layerBegin, int layerToRead)
          Read a precinct in a file up to the precinct level.
private  void readPrecinct(int rLevel, int precinct, int z, int layerBegin, int layerToRead)
          Read a precinct in a file.
private  void readSOD()
          Reads the SOD marker.
private  void readSOT()
          Reads the SOT marker segment.
private  void RLCP()
          Reads file using RLCP progression.
private  void RPCL()
          Reads file using RPCL progression.
 void run()
          Reads file with selected progression order.
 void setReadingCodingPasses(boolean readCodingPasses)
          Sets the readCodingPasses attribute.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sizParameters

private SIZParameters sizParameters
Definition in SIZParameters.


codParameters

private CODParameters codParameters
Definition in CODParameters.


blocksPerPrecinctWidths

private int[][] blocksPerPrecinctWidths
Definition in GenerateImageStructure.blocksPerPrecinctWidths


blocksPerPrecinctHeights

private int[][] blocksPerPrecinctHeights
Definition in GenerateImageStructure.blocksPerPrecinctHeights


imageStructure

private int[][][][][][] imageStructure
Definition in GenerateImageStructure.imageStructure


PkDeheading

private PacketHeadersDecoder PkDeheading
Definition in PacketHeadersDecoder


in

private BufferedDataInputStream in
Is an input stream from where data will be read.


dataBins

private java.util.Hashtable<java.lang.Long,DataBinInfo> dataBins
This attribute is used to store information about the data-bins of the codestream. It is implemented with a hash to increase the access, and the key is the unique in-class identifier for each data-bin, and the value is the information.


readCodingPasses

private boolean readCodingPasses
Indicates whether the coding passes structure must be read. Otherwise, codestream is only indexed at packet structure.


precinctRead

private boolean[][][] precinctRead
Indicates if a precinct has been writen in the file. False is not written yet, True has been written.

True or False


xNumBlocks

private int[][][] xNumBlocks
Number of blocks X for each component and resolution level and subband (needed to calculate the number of precincts widht and heights)


yNumBlocks

private int[][][] yNumBlocks
number of blocks Y for each component and resolution level and subband (needed to calculate the number of precincts widht and heights)

Constructor Detail

CodestreamIndexing

public CodestreamIndexing(BufferedDataInputStream in,
                          JPCParameters jpcParameters,
                          int[][][][][][] imageStructure,
                          int[][] blocksPerPrecinctWidths,
                          int[][] blocksPerPrecinctHeights)
                   throws ErrorException
Constructor

Parameters:
in - definition in in
jpcParameters - definition in JPCParameters.
imageStructure - definition in imageStructure
blocksPerPrecinctWidths - definition in blocksPerPrecinctWidths
blocksPerPrecinctHeights - definition in blocksPerPrecinctHeights
Throws:
ErrorException - when the file cannot be load
Method Detail

setReadingCodingPasses

public void setReadingCodingPasses(boolean readCodingPasses)
Sets the readCodingPasses attribute.

Parameters:
readCodingPasses - definition in readCodingPasses.

run

public void run()
         throws ErrorException
Reads file with selected progression order.

Throws:
ErrorException - when some error occurs

getDataBins

public java.util.Hashtable<java.lang.Long,DataBinInfo> getDataBins()
Returns the dataBins attribute.

Returns:
the dataBins attribute

toString

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

list

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

Parameters:
out - an output stream.

readByte

private int readByte()
              throws ErrorException
Reads a byte from the file and returns its value.

Returns:
the byte readed
Throws:
ErrorException - when some wrong bitstream or I/O operation occurs

LRCP

private void LRCP()
           throws ErrorException
Reads file using LRCP progression.

Throws:
ErrorException - when the file cannot be load

RLCP

private void RLCP()
           throws ErrorException
Reads file using RLCP progression.

Throws:
ErrorException - when the file cannot be load

RPCL

private void RPCL()
           throws ErrorException
Reads file using RPCL progression.

Throws:
ErrorException - when the file cannot be load

PCRL

private void PCRL()
           throws ErrorException
Reads file using PCRL progression.

Throws:
ErrorException - when the file cannot be load

CPRL

private void CPRL()
           throws ErrorException
Reads file using CPRL progression.

Throws:
ErrorException - when the file cannot be load

readPrecinct

private void readPrecinct(int rLevel,
                          int precinct,
                          int z,
                          int layerBegin,
                          int layerToRead)
                   throws ErrorException
Read a precinct in a file.

Parameters:
rLevel - whichs belong the precinct
precinct - that will be written in file
z - it refers to the component that belongs the precinct
layerBegin - it refers to the first layer to write
layerToRead - it refers to the number of layers to read
Throws:
ErrorException - when the file cannot be load

readPacketStructure

private void readPacketStructure(long inClassIdentifier,
                                 int rLevel,
                                 int precinct,
                                 int z,
                                 int layerBegin,
                                 int layerToRead)
                          throws ErrorException,
                                 java.io.IOException
Read a precinct in a file up to the precinct level.

Parameters:
rLevel - whichs belong to the precinct
precinct - that will be written in file
z - it refers to the component that belongs the precinct
layerBegin - it refers to the first layer to write
layerToRead - it refers to the number of layers to write
Throws:
ErrorException - when the file cannot be load
java.io.IOException

readCodingPassesStructure

private void readCodingPassesStructure(long inClassIdentifier,
                                       int rLevel,
                                       int precinct,
                                       int z,
                                       int layerBegin,
                                       int layerToWrite)
                                throws ErrorException,
                                       java.io.IOException
Read a precinct in a file up to the coding pass level.

Parameters:
rLevel - whichs belong the precinct
precinct - that will be written in file
z - it refers to the component that belongs the precinct
layerBegin - it refers to the first layer to write
layerToWrite - it refers to the number of layers to write
Throws:
ErrorException - when the file cannot be load
java.io.IOException

readSOT

private void readSOT()
              throws ErrorException
Reads the SOT marker segment.

Throws:
ErrorException - when SOT marker segment is incorrect or tile options are not supported by BOI

readSOD

private void readSOD()
              throws ErrorException
Reads the SOD marker.

Throws:
ErrorException - when the SOD marker is incorrect

numPrecinctWitdhRlevel

private int numPrecinctWitdhRlevel(int z,
                                   int rLevel)
Find the width precinct in function of one ressolution level

Parameters:
z - component to know the number of precinct width
rLevel - to know the number of precincts in width
Returns:
the number of precinct in width of a rlevel

numPrecinctHighRlevel

private int numPrecinctHighRlevel(int z,
                                  int rLevel)
Find the hight precinct in function of one ressolution level

Parameters:
z - component to know the number of precinct High
rLevel - to know the number of precincts in High
Returns:
the number of precinct in Height of a rlevel

precinctCorrespondenceX

private double precinctCorrespondenceX(int z,
                                       int precinct,
                                       int rLevel,
                                       int maxRlevel)
Find the correspondence in width of a precinct

Parameters:
z - component to know the correspondence
precinct - which to know the correspondence, always the biggest ressolution level
rLevel - to know the correspondence
maxRlevel -
Returns:
the correspondence of a precinct

precinctCorrespondenceY

private double precinctCorrespondenceY(int z,
                                       int precinct,
                                       int rLevel,
                                       int maxRlevel)
Find the correspondence in hight of a precinct

Parameters:
z - component to know the correspondence
precinct - which to knOw the correspondence
rLevel - to know the correspondence
maxRlevel -
Returns:
the correspondence of a precinct always from a greater rlevel

maxPrecinct

private int maxPrecinct()
Find the maximum precincts of all ressolution levels and all components

Returns:
an int which represents the maximum precinct of all resolution levels and all components.

maxRlevel

private int maxRlevel()
Find the biggest ressolution level within all the components

Returns:
an int which represents the maximum number of resolution levels within all the components.

calculateNumBlocksPerPrecinct

private void calculateNumBlocksPerPrecinct()
Calculate the number of blocks that there are per precinct



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)