📄 headerinfo.java
字号:
/* * CVS identifier: * * $Id: HeaderInfo.java,v 1.1.1.1 2002/07/22 09:26:46 grosbois Exp $ * * Class: HeaderInfo * * Description: Holds information found in main and tile-part * headers * * * * COPYRIGHT: * * This software module was originally developed by Rapha雔 Grosbois and * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel * Askel鰂 (Ericsson Radio Systems AB); and Bertrand Berthelot, David * Bouchard, F閘ix 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 jj2000.j2k.wavelet.*;import java.util.*;/** * 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; cc<csiz; cc++) { compWidth[cc] = (int)(Math.ceil((xsiz)/(double)xrsiz[cc]) - Math.ceil(x0siz/(double)xrsiz[cc])); } } return compWidth[c]; } public int getMaxCompWidth() { if (compWidth==null) { compWidth = new int[csiz]; for(int cc=0; cc<csiz; cc++) { compWidth[cc] = (int)(Math.ceil((xsiz)/(double)xrsiz[cc]) - Math.ceil(x0siz/(double)xrsiz[cc])); } } if (maxCompWidth==-1) { for(int c=0; c<csiz; c++) { if(compWidth[c]>maxCompWidth) { maxCompWidth = compWidth[c]; } } } return maxCompWidth; } public int getCompImgHeight(int c) { if (compHeight==null) { compHeight = new int[csiz]; for(int cc=0; cc<csiz; cc++) { compHeight[cc] = (int)(Math.ceil((ysiz)/(double)yrsiz[cc]) - Math.ceil(y0siz/(double)yrsiz[cc])); } } return compHeight[c]; } public int getMaxCompHeight() { if (compHeight==null) { compHeight = new int[csiz]; for(int cc=0; cc<csiz; cc++) { compHeight[cc] = (int)(Math.ceil((ysiz)/(double)yrsiz[cc]) - Math.ceil(y0siz/(double)yrsiz[cc])); } } if (maxCompHeight==-1) { for(int c=0; c<csiz; c++) { if(compHeight[c]!=maxCompHeight) { maxCompHeight = compHeight[c]; } } } return maxCompHeight; } private int numTiles = -1; public int getNumTiles() { if(numTiles==-1) { numTiles = ((xsiz-xt0siz+xtsiz-1) / xtsiz) * ((ysiz-yt0siz+ytsiz-1) / ytsiz); } return numTiles; } private boolean[] origSigned = null; public boolean isOrigSigned(int c) { if(origSigned==null) { origSigned = new boolean[csiz]; for(int cc=0; cc<csiz; cc++) { origSigned[cc] = ((ssiz[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<csiz; cc++) { origBitDepth[cc] = (ssiz[cc] & ((1<<SSIZ_DEPTH_BITS)-1))+1; } } return origBitDepth[c]; } public SIZ getCopy() { SIZ ms = null; try { ms = (SIZ)this.clone(); } catch (CloneNotSupportedException e) { throw new Error("Cannot clone SIZ marker segment"); } return ms; } /** Display information found in SIZ marker segment */ public String toString() { String str = "\n --- SIZ ("+lsiz+" bytes) ---\n"; str += " Capabilities : "+rsiz+"\n"; str += " Image dim. : "+(xsiz-x0siz)+"x"+(ysiz-y0siz)+", (off="+ x0siz+","+y0siz+")\n"; str += " Tile dim. : "+xtsiz+"x"+ytsiz+", (off="+xt0siz+","+ yt0siz+")\n"; str += " Component(s) : "+csiz+"\n"; str += " Orig. depth : "; for (int i=0; i<csiz; i++) { str += getOrigBitDepth(i)+" "; } str += "\n"; str += " Orig. signed : "; for (int i=0; i<csiz; i++) { str += isOrigSigned(i)+" "; } str += "\n"; str += " Subs. factor : "; for (int i=0; i<csiz; i++) { str += xrsiz[i]+","+yrsiz[i]+" "; } str += "\n"; return str; } } /** Returns a new instance of SIZ */ public SIZ getNewSIZ() { return new SIZ(); } /** Internal class holding information found in the SOt marker segments */ public class SOT { public int lsot; public int isot; public int psot; public int tpsot; public int tnsot; /** Display information found in this SOT marker segment */ public String toString() { String str = "\n --- SOT ("+lsot+" bytes) ---\n"; str += "Tile index : "+isot+"\n"; str += "Tile-part length : "+psot+" bytes\n"; str += "Tile-part index : "+tpsot+"\n"; str += "Num. of tile-parts : "+tnsot+"\n"; str += "\n"; return str; } } /** Returns a new instance of SOT */ public SOT getNewSOT() { return new SOT(); } /** Internal class holding information found in the COD marker segments */ public class COD implements Cloneable { public int lcod; public int scod; public int sgcod_po; // Progression order public int sgcod_nl; // Number of layers public int sgcod_mct; // Multiple component transformation public int spcod_ndl; // Number of decomposition levels public int spcod_cw; // Code-blocks width public int spcod_ch; // Code-blocks height public int spcod_cs; // Code-blocks style public int[] spcod_t = new int[1]; // Transformation public int[] spcod_ps; // Precinct size public COD getCopy() { COD ms = null; try { ms = (COD)this.clone(); } catch (CloneNotSupportedException e) { throw new Error("Cannot clone SIZ marker segment"); } return ms; } /** Display information found in this COD marker segment */ public String toString() { String str = "\n --- COD ("+lcod+" bytes) ---\n"; str += " Coding style : "; if(scod==0) { str += "Default"; } else { if((scod&SCOX_PRECINCT_PARTITION)!=0) str += "Precints "; if((scod&SCOX_USE_SOP)!=0) str += "SOP "; if((scod&SCOX_USE_EPH)!=0) str += "EPH "; int cb0x = ((scod&SCOX_HOR_CB_PART)!=0) ? 1 : 0; int cb0y = ((scod&SCOX_VER_CB_PART)!=0) ? 1 : 0; if (cb0x!=0 || cb0y!=0) { str += "Code-blocks offset"; str += "\n Cblk partition : "+cb0x+","+cb0y; } } str += "\n"; str += " Cblk style : "; if(spcod_cs==0) { str += "Default"; } else { if((spcod_cs&0x1)!=0) str += "Bypass "; if((spcod_cs&0x2)!=0) str += "Reset "; if((spcod_cs&0x4)!=0) str += "Terminate "; if((spcod_cs&0x8)!=0) str += "Vert_causal "; if((spcod_cs&0x10)!=0) str += "Predict "; if((spcod_cs&0x20)!=0) str += "Seg_symb "; } str += "\n"; str += " Num. of levels : "+spcod_ndl+"\n"; switch(sgcod_po) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -