CADI.Server.LogicalTarget.JPEG2000.Codestream
Class JPCMainHeaderEncoder

java.lang.Object
  extended by CADI.Server.LogicalTarget.JPEG2000.Codestream.JPCMainHeaderEncoder
All Implemented Interfaces:
JPCMarkers

public class JPCMainHeaderEncoder
extends java.lang.Object
implements JPCMarkers

This class generates the JPC headers from the JPEG2000 parameters. Usage example:
  construct
  run

Version:
2.0.1 2008/12/04
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  CODParameters codParameters
          Definition in CODParameters.
private  boolean[] definedPrecincts
          Tells if precincts are defined within the headers or not.
private  BufferedDataOutputStream headerStream
          Contains headers of the JPC file.
private  QCDParameters qcdParameters
          Definition in QCDParameters.
private  SIZParameters sizParameters
          Definition in SIZParameters.
private  int[] tileParts
          Number of tile-parts in each tile.
 
Fields inherited from interface CADI.Common.LogicalTarget.JPEG2000.Codestream.JPCMarkers
COC, COD, COM, CRG, EOC, EPH, PLM, PLT, POC, PPM, PPT, QCC, QCD, RGN, SIZ, SOC, SOD, SOP, SOT, TLM
 
Constructor Summary
JPCMainHeaderEncoder(SIZParameters sizParameters, CODParameters codParameters, QCDParameters qcdParameters)
          Constructor of JPCMainHeaderEncoder.
 
Method Summary
 byte[] getMainHeader()
          Returns the headerStream attribute as a byte array.
 void list(java.io.PrintStream out)
          Prints this JPC Main Header Encoder out to the specified output stream.
private  boolean neddedCOC(int component)
          To know if a COC marker segment is needed for a specific component.
private  boolean neddedQCC(int component)
          To know if a QCC marker segment is needed for a specific component.
 byte[] run()
          Generates the JPC file headers.
 java.lang.String toString()
           
private  void writeCOC(int z)
          Generates the COC marker segment, COC has the coding style for a specific component.
private  void writeCOD()
          Generates the COD marker segment COD has the default coding style for all components; first component is considered to have the default values.
private  void writePrecinctSizes(int z)
          Recives the COD or COC BitStream marker and fill it with the precinct Sizes
private  void writeQCC(int z)
          Generates the QCC marker segment, QCC has the quantization parameters for a specific component.
private  void writeQCD()
          Generates the QCD marker segment, QCD has the default quantization parameters for all components.
private  void writeQuantization(int z)
          Recives the COD or COC BitStream marker and fill it with the precinct Sizes
private  void writeSIZ()
          Generates the SIZ marker segment.
 
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.


qcdParameters

private QCDParameters qcdParameters
Definition in QCDParameters.


headerStream

private BufferedDataOutputStream headerStream
Contains headers of the JPC file.


definedPrecincts

private boolean[] definedPrecincts
Tells if precincts are defined within the headers or not. Index in the array is component index


tileParts

private int[] tileParts
Number of tile-parts in each tile. Index of array means tile index (0...65534).

Values must be between 0 - 254.

Constructor Detail

JPCMainHeaderEncoder

public JPCMainHeaderEncoder(SIZParameters sizParameters,
                            CODParameters codParameters,
                            QCDParameters qcdParameters)
Constructor of JPCMainHeaderEncoder. It receives the information about the compressed image needed to build the JPC main headers.

Parameters:
sizParameters - definition in SIZParameters.
codParameters - definition in CODParameters.
qcdParameters - definition in QCDParameters.
Method Detail

run

public byte[] run()
           throws WarningException,
                  java.io.IOException
Generates the JPC file headers.

Returns:
a bytestream with the JPC markers
Throws:
WarningException - when the header cannot be generated
java.io.IOException

getMainHeader

public byte[] getMainHeader()
Returns the headerStream attribute as a byte array.

Returns:
the headerStream as a byte array.

toString

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

list

public void list(java.io.PrintStream out)
Prints this JPC Main Header Encoder out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

writeSIZ

private void writeSIZ()
               throws WarningException,
                      java.io.IOException
Generates the SIZ marker segment.

Throws:
WarningException - when the header cannot be generated
java.io.IOException - when an I/O error has occurred.

writeCOD

private void writeCOD()
               throws WarningException,
                      java.io.IOException
Generates the COD marker segment COD has the default coding style for all components; first component is considered to have the default values.

Throws:
WarningException - when COD marker segment cannot be generated due to CADI options
java.io.IOException - when an I/O error has occurred.

writeCOC

private void writeCOC(int z)
               throws WarningException,
                      java.io.IOException
Generates the COC marker segment, COC has the coding style for a specific component.

Parameters:
z - image component
Throws:
WarningException - when COC marker segment cannot be generated due to BOI options
java.io.IOException - when an I/O error has occurred.

writePrecinctSizes

private void writePrecinctSizes(int z)
                         throws WarningException,
                                java.io.IOException
Recives the COD or COC BitStream marker and fill it with the precinct Sizes

Parameters:
z - image component
Throws:
WarningException - when COD or COC marker segment cannot be generated due to CADI options
java.io.IOException - when an I/O error has occurred.

writeQCD

private void writeQCD()
               throws WarningException,
                      java.io.IOException
Generates the QCD marker segment, QCD has the default quantization parameters for all components.

Throws:
WarningException - when QCD marker segment cannot be generated due to CADI options
java.io.IOException - when an I/O error has occurred.

writeQCC

private void writeQCC(int z)
               throws WarningException,
                      java.io.IOException
Generates the QCC marker segment, QCC has the quantization parameters for a specific component.

Parameters:
z - image component
Throws:
WarningException - when QCC marker segment cannot be generated due to CADI options
java.io.IOException - when an I/O error has occurred.

writeQuantization

private void writeQuantization(int z)
                        throws WarningException,
                               java.io.IOException
Recives the COD or COC BitStream marker and fill it with the precinct Sizes

Parameters:
z - image component
Throws:
WarningException - when COD or COC marker segment cannot be generated due to CADI options
java.io.IOException - when an I/O error has occurred.

neddedCOC

private boolean neddedCOC(int component)
To know if a COC marker segment is needed for a specific component.

Parameters:
component - image component
Returns:
true or false

neddedQCC

private boolean neddedQCC(int component)
To know if a QCC marker segment is needed for a specific component.

Parameters:
component - image component
Returns:
true or false


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)