⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 headerdecoder.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * CVS identifier: * * $Id: HeaderDecoder.java,v 1.2 2002/08/02 09:33:04 grosbois Exp $ * * Class:                   HeaderDecoder * * Description:             Reads 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.reader;import jj2000.j2k.quantization.dequantizer.*;import jj2000.j2k.wavelet.synthesis.*;import jj2000.j2k.entropy.decoder.*;import jj2000.j2k.quantization.*;import jj2000.j2k.codestream.*;import jj2000.j2k.wavelet.*;import jj2000.j2k.entropy.*;import jj2000.j2k.decoder.*;import jj2000.j2k.image.*;import jj2000.j2k.util.*;import jj2000.j2k.roi.*;import jj2000.j2k.io.*;import jj2000.j2k.*;import colorspace.*;import icc.*;import java.io.*;import java.util.*;/** * This class reads main and tile-part headers from the codestream given a * RandomAccessIO instance located at the beginning of the codestream (i.e * just before the SOC marker) or at the beginning of a tile-part (i.e. just * before a SOT marker segment) respectively. * * <p>A marker segment includes a marker and eventually marker segment * parameters. It is designed by the three letters code of the marker * associated with the marker segment. JPEG 2000 part 1 defines 6 types of * markers segments: * * <ul>  * <li> Delimiting : SOC, SOT, SOD, EOC</li>  * * <li> Fixed information: SIZ.</li> * * <li> Functional: COD, COC, RGN, QCD, QCC,POC.</li>  * * <li> In bit-stream: SOP, EPH.</li> * * <li> Pointer: TLM, PLM, PLT, PPM, PPT.</li> * * <li> Informational: CRG, COM.</li> * </ul></p> * * <p>The main header is read when the constructor is called whereas tile-part * headers are read when the FileBitstreamReaderAgent instance is created. The * reading is done in 2 passes: *  * <ol>  * <li>All marker segments are buffered and their corresponding flag is * activated (extractMainMarkSeg and extractTilePartMarkSeg methods).</li> * * <li>Buffered marker segment are analyzed in a logical way and * specifications are stored in appropriate member of DecoderSpecs instance * (readFoundMainMarkSeg and readFoundTilePartMarkSeg methods).</li> * </ol></p> * * <p>Whenever a marker segment is not recognized a warning message is * displayed and its length parameter is used to skip it.</p> * * <p>The information found in this header is stored in HeaderInfo and * DecoderSpecs instances.</p> * * @see DecoderSpecs * @see HeaderInfo * @see Decoder * @see FileBitstreamReaderAgent * */public class HeaderDecoder implements ProgressionType, Markers,                                      StdEntropyCoderOptions {    /** The prefix for header decoder options: 'H' */    public final static char OPT_PREFIX = 'H';    /** The list of parameters that is accepted for quantization. Options      * for quantization start with 'Q'. */    private final static String [][] pinfo = null;    /** The reference to the HeaderInfo instance holding the information found     * in headers */    private HeaderInfo hi;    /** Whether or not to display general information */    private boolean verbose;    /** Current header information in a string */    private String hdStr = "";    /** The number of tiles within the image */    private int nTiles;    /** The number of tile parts in each tile */    public int[] nTileParts;    /** Used to store which markers have been already read, by using flag     * bits. The different markers are marked with XXX_FOUND flags, such as     * SIZ_FOUND */    private int nfMarkSeg = 0;    /** Counts number of COC markers found in the header */    private int nCOCMarkSeg = 0;    /** Counts number of QCC markers found in the header */    private int nQCCMarkSeg = 0;    /** Counts number of COM markers found in the header */    private int nCOMMarkSeg = 0;    /** Counts number of RGN markers found in the header */    private int nRGNMarkSeg = 0;        /** Counts number of PPM markers found in the header */    private int nPPMMarkSeg = 0;        /** Counts number of PPT markers found in the header */    private int[][] nPPTMarkSeg = null;    /** Flag bit for SIZ marker segment found */    private static final int SIZ_FOUND = 1;    /** Flag bit for COD marker segment found */    private static final int COD_FOUND = 1<<1;    /** Flag bit for COC marker segment found */    private static final int COC_FOUND = 1<<2;    /** Flag bit for QCD marker segment found */    private static final int QCD_FOUND = 1<<3;    /** Flag bit for TLM marker segment found */    private static final int TLM_FOUND = 1<<4;    /** Flag bit for PLM marker segment found */    private static final int PLM_FOUND = 1<<5;    /** Flag bit for SOT marker segment found */    private static final int SOT_FOUND = 1<<6;    /** Flag bit for PLT marker segment found */    private static final int PLT_FOUND = 1<<7;    /** Flag bit for QCC marker segment found */    private static final int QCC_FOUND = 1<<8;    /** Flag bit for RGN marker segment found */    private static final int RGN_FOUND = 1<<9;    /** Flag bit for POC marker segment found */    private static final int POC_FOUND = 1<<10;    /** Flag bit for COM marker segment found */    private static final int COM_FOUND = 1<<11;    /** Flag bit for SOD marker segment found */    public static final int SOD_FOUND = 1<<13;    /** Flag bit for SOD marker segment found */    public static final int PPM_FOUND = 1<<14;    /** Flag bit for SOD marker segment found */    public static final int PPT_FOUND = 1<<15;    /** Flag bit for CRG marker segment found */    public static final int CRG_FOUND = 1<<16;    /** The reset mask for new tiles */    private static final int TILE_RESET = ~(PLM_FOUND|SIZ_FOUND|RGN_FOUND);    /** HashTable used to store temporary marker segment byte buffers */    private Hashtable ht = null;    /** The number of components in the image */    private int nComp;    /** The horizontal code-block partition origin */    private int cb0x = -1;    /** The vertical code-block partition origin */    private int cb0y = -1;    /** The decoder specifications */    private DecoderSpecs decSpec;    /** Is the precinct partition used */    boolean precinctPartitionIsUsed;        /** The offset of the main header in the input stream */    public int mainHeadOff;    /** Vector containing info as to which tile each tilepart belong */    public Vector tileOfTileParts;    /** Array containing the Nppm and Ippm fields of the PPM marker segments*/    private byte[][] pPMMarkerData;        /** Array containing the Ippm fields of the PPT marker segments */    private byte[][][][] tilePartPkdPktHeaders;        /** The packed packet headers if the PPM or PPT markers are used */    private ByteArrayOutputStream[] pkdPktHeaders;    /**      * Return the maximum height among all components      *     * @return Maximum component height     * */    public int getMaxCompImgHeight() { return hi.siz.getMaxCompHeight(); }    /**      * Return the maximum width among all components      *     * @return Maximum component width     * */    public int getMaxCompImgWidth() { return hi.siz.getMaxCompWidth(); }        /**     * Returns the image width in the reference grid.     *     * @return The image width in the reference grid     * */    public final int getImgWidth() { return hi.siz.xsiz-hi.siz.x0siz; }    /**     * Returns the image height in the reference grid.     *     * @return The image height in the reference grid     * */    public final int getImgHeight() { return hi.siz.ysiz-hi.siz.y0siz; }    /**     * Return the horizontal upper-left coordinate of the image in the     * reference grid.     *     * @return The horizontal coordinate of the image origin.     * */    public final int getImgULX() { return hi.siz.x0siz; }    /**     * Return the vertical upper-left coordinate of the image in the reference     * grid.     *     * @return The vertical coordinate of the image origin.     * */    public final int getImgULY() { return hi.siz.y0siz; }    /**     * Returns the nominal width of the tiles in the reference grid.     *     * @return The nominal tile width, in the reference grid.     * */    public final int getNomTileWidth() { return hi.siz.xtsiz; }    /**     * Returns the nominal width of the tiles in the reference grid.     *     * @return The nominal tile width, in the reference grid.     * */    public final int getNomTileHeight() { return hi.siz.ytsiz; }    /**     * Returns the tiling origin, referred to as '(Px,Py)' in the 'ImgData'     * interface.     *     * @param co If not null this object is used to return the information. If     * null a new one is created and returned.     *     * @return The coordinate of the tiling origin, in the canvas system, on     * the reference grid.     *     * @see jj2000.j2k.image.ImgData     * */    public final Coord getTilingOrigin(Coord co) {        if (co != null) {            co.x = hi.siz.xt0siz;            co.y = hi.siz.yt0siz;            return co;        }        else {            return new Coord(hi.siz.xt0siz,hi.siz.yt0siz);        }    }    /**     * Returns true if the original data of the specified component was     * signed. If the data was not signed a level shift has to be applied at     * the end of the decompression chain.     *     * @param c The index of the component     *     * @return True if the original image component was signed.     * */    public final boolean isOriginalSigned(int c) {         return hi.siz.isOrigSigned(c);    }    /**     * Returns the original bitdepth of the specified component.     *     * @param c The index of the component     *     * @return The bitdepth of the component     * */    public final int getOriginalBitDepth(int c) {        return hi.siz.getOrigBitDepth(c);    }    /**     * Returns the number of components in the image.     *     * @return The number of components in the image.     * */    public final int getNumComps() {        return nComp;    }    /**     * Returns the component sub-sampling factor, with respect to the     * reference grid, along the horizontal direction for the specified     * component.     *     * @param c The index of the component     *     * @return The component sub-sampling factor X-wise.     * */    public final int getCompSubsX(int c) { return hi.siz.xrsiz[c]; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -