jj2000.j2k.codestream.HeaderInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jai-imageio-jpeg2000 Show documentation
Show all versions of jai-imageio-jpeg2000 Show documentation
JPEG2000 support for Java Advanced Imaging Image I/O Tools API core.
This module is licensed under the [JJ2000 license](LICENSE.txt) and
is therefore NOT compatible with the GPL 3 license. It should be
compatible with the LGPL 2.1 license.
/*
* $RCSfile: HeaderInfo.java,v $
* $Revision: 1.1 $
* $Date: 2005/02/11 05:02:00 $
* $State: Exp $
*
* Class: HeaderInfo
*
* Description: Holds information found in main and tile-part
* headers
*
*
*
* COPYRIGHT:
*
* This software module was originally developed by Raphaël Grosbois and
* Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
* Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
* Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
* Centre France S.A) in the course of development of the JPEG2000
* standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
* software module is an implementation of a part of the JPEG 2000
* Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
* Systems AB and Canon Research Centre France S.A (collectively JJ2000
* Partners) agree not to assert against ISO/IEC and users of the JPEG
* 2000 Standard (Users) any of their rights under the copyright, not
* including other intellectual property rights, for this software module
* with respect to the usage by ISO/IEC and Users of this software module
* or modifications thereof for use in hardware or software products
* claiming conformance to the JPEG 2000 Standard. Those intending to use
* this software module in hardware or software products are advised that
* their use may infringe existing patents. The original developers of
* this software module, JJ2000 Partners and ISO/IEC assume no liability
* for use of this software module or modifications thereof. No license
* or right to this software module is granted for non JPEG 2000 Standard
* conforming products. JJ2000 Partners have full right to use this
* software module for his/her own purpose, assign or donate this
* software module to any third party and to inhibit third parties from
* using this software module for non JPEG 2000 Standard conforming
* products. This copyright notice must be included in all copies or
* derivative works of this software module.
*
* Copyright (c) 1999/2000 JJ2000 Partners.
* */
package jj2000.j2k.codestream;
import java.util.Hashtable;
import jj2000.j2k.wavelet.FilterTypes;
/**
* Classe that holds information found in the marker segments of the main and
* tile-part headers. There is one inner-class per marker segment type found
* in these headers.
* */
public class HeaderInfo implements Markers,ProgressionType,FilterTypes,
Cloneable {
/** Internal class holding information found in the SIZ marker segment */
public class SIZ implements Cloneable {
public int lsiz;
public int rsiz;
public int xsiz;
public int ysiz;
public int x0siz;
public int y0siz;
public int xtsiz;
public int ytsiz;
public int xt0siz;
public int yt0siz;
public int csiz;
public int[] ssiz;
public int[] xrsiz;
public int[] yrsiz;
/** Component widths */
private int[] compWidth = null;
/** Maximum width among all components */
private int maxCompWidth = -1;
/** Component heights */
private int[] compHeight = null;
/** Maximum height among all components */
private int maxCompHeight = -1;
/**
* Width of the specified tile-component
*
* @param t Tile index
*
* @param c Component index
* */
public int getCompImgWidth(int c) {
if (compWidth==null) {
compWidth = new int[csiz];
for(int cc=0; ccmaxCompWidth) {
maxCompWidth = compWidth[c];
}
}
}
return maxCompWidth;
}
public int getCompImgHeight(int c) {
if (compHeight==null) {
compHeight = new int[csiz];
for(int cc=0; cc>>SSIZ_DEPTH_BITS)==1);
}
}
return origSigned[c];
}
private int[] origBitDepth = null;
public int getOrigBitDepth(int c) {
if(origBitDepth==null) {
origBitDepth = new int[csiz];
for (int cc=0; cc>4)))+" ";
}
}
str += "\n";
return str;
}
}
/** Returns a new instance of COD */
public COD getNewCOD() { return new COD(); }
/** Internal class holding information found in the COC marker segments */
public class COC {
public int lcoc;
public int ccoc;
public int scoc;
public int spcoc_ndl; // Number of decomposition levels
public int spcoc_cw;
public int spcoc_ch;
public int spcoc_cs;
public int[] spcoc_t = new int[1];
public int[] spcoc_ps;
/** Display information found in this COC marker segment */
public String toString() {
String str = "\n --- COC ("+lcoc+" bytes) ---\n";
str += " Component : "+ccoc+"\n";
str += " Coding style : ";
if(scoc==0) {
str += "Default";
} else {
if((scoc&0x1)!=0) str += "Precints ";
if((scoc&0x2)!=0) str += "SOP ";
if((scoc&0x4)!=0) str += "EPH ";
}
str += "\n";
str += " Cblk style : ";
if(spcoc_cs==0) {
str += "Default";
} else {
if((spcoc_cs&0x1)!=0) str += "Bypass ";
if((spcoc_cs&0x2)!=0) str += "Reset ";
if((spcoc_cs&0x4)!=0) str += "Terminate ";
if((spcoc_cs&0x8)!=0) str += "Vert_causal ";
if((spcoc_cs&0x10)!=0) str += "Predict ";
if((spcoc_cs&0x20)!=0) str += "Seg_symb ";
}
str += "\n";
str += " Num. of levels : "+spcoc_ndl+"\n";
str += " Cblk dimension : "+(1<<(spcoc_cw+2))+"x"+
(1<<(spcoc_ch+2))+"\n";
switch (spcoc_t[0]) {
case W9X7:
str += " Filter : 9-7 irreversible\n";
break;
case W5X3:
str += " Filter : 5-3 reversible\n";
break;
}
if(spcoc_ps!=null) {
str += " Precincts : ";
for(int i=0; i>4)))+" ";
}
}
str += "\n";
return str;
}
}
/** Returns a new instance of COC */
public COC getNewCOC() { return new COC(); }
/** Internal class holding information found in the RGN marker segments */
public class RGN {
public int lrgn;
public int crgn;
public int srgn;
public int sprgn;
/** Display information found in this RGN marker segment */
public String toString() {
String str = "\n --- RGN ("+lrgn+" bytes) ---\n";
str += " Component : "+crgn+"\n";
if(srgn==0) {
str += " ROI style : Implicit\n";
} else {
str += " ROI style : Unsupported\n";
}
str += " ROI shift : "+sprgn+"\n";
str += "\n";
return str;
}
}
/** Returns a new instance of RGN */
public RGN getNewRGN() { return new RGN(); }
/** Internal class holding information found in the QCD marker segments */
public class QCD {
public int lqcd;
public int sqcd;
public int[][] spqcd;
private int qType = -1;
public int getQuantType() {
if(qType==-1) {
qType = sqcd & ~(SQCX_GB_MSK<>SQCX_GB_SHIFT)&SQCX_GB_MSK;
}
return gb;
}
/** Display information found in this QCD marker segment */
public String toString() {
String str = "\n --- QCD ("+lqcd+" bytes) ---\n";
str += " Quant. type : ";
int qt = getQuantType();
if(qt==SQCX_NO_QUANTIZATION) str += "No quantization \n";
else if(qt==SQCX_SCALAR_DERIVED) str += "Scalar derived\n";
else if(qt==SQCX_SCALAR_EXPOUNDED) str += "Scalar expounded\n";
str += " Guard bits : "+getNumGuardBits()+"\n";
if(qt==SQCX_NO_QUANTIZATION) {
str += " Exponents :\n";
int exp;
for (int i=0; i>SQCX_EXP_SHIFT)&SQCX_EXP_MASK;
str += "\tr=0 : "+exp+"\n";
} else if (i!=0 && j>0) {
exp = (spqcd[i][j]>>SQCX_EXP_SHIFT)&SQCX_EXP_MASK;
str += "\tr="+i+",s="+j+" : "+exp+"\n";
}
}
}
} else {
str += " Exp / Mantissa : \n";
int exp;
double mantissa;
for (int i=0; i>11)&0x1f;
mantissa = (-1f-((float)(spqcd[0][0]&0x07ff))/
(1<<11))/(-1<0) {
exp = (spqcd[i][j]>>11)&0x1f;
mantissa = (-1f-((float)(spqcd[i][j]&0x07ff))/
(1<<11))/(-1<>SQCX_GB_SHIFT)&SQCX_GB_MSK;
}
return gb;
}
/** Display information found in this QCC marker segment */
public String toString() {
String str = "\n --- QCC ("+lqcc+" bytes) ---\n";
str += " Component : "+cqcc+"\n";
str += " Quant. type : ";
int qt = getQuantType();
if(qt==SQCX_NO_QUANTIZATION) str += "No quantization \n";
else if(qt==SQCX_SCALAR_DERIVED) str += "Scalar derived\n";
else if(qt==SQCX_SCALAR_EXPOUNDED) str += "Scalar expounded\n";
str += " Guard bits : "+getNumGuardBits()+"\n";
if(qt==SQCX_NO_QUANTIZATION) {
str += " Exponents :\n";
int exp;
for (int i=0; i>SQCX_EXP_SHIFT)&SQCX_EXP_MASK;
str += "\tr=0 : "+exp+"\n";
} else if (i!=0 && j>0) {
exp = (spqcc[i][j]>>SQCX_EXP_SHIFT)&SQCX_EXP_MASK;
str += "\tr="+i+",s="+j+" : "+exp+"\n";
}
}
}
} else {
str += " Exp / Mantissa : \n";
int exp;
double mantissa;
for (int i=0; i>11)&0x1f;
mantissa = (-1f-((float)(spqcc[0][0]&0x07ff))/
(1<<11))/(-1<0) {
exp = (spqcc[i][j]>>11)&0x1f;
mantissa = (-1f-((float)(spqcc[i][j]&0x07ff))/
(1<<11))/(-1<