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

📄 pktencoder.java

📁 jpeg2000算法实现
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * CVS identifier: * * $Id: PktEncoder.java,v 1.23 2001/03/01 17:00:44 grosbois Exp $ * * Class:                   PktEncoder * * Description:             Builds bit stream packets and keeps *                          interpacket dependencies. * * * * 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.writer;import jj2000.j2k.wavelet.analysis.*;import jj2000.j2k.entropy.encoder.*;import jj2000.j2k.codestream.*;import jj2000.j2k.encoder.*;import jj2000.j2k.wavelet.*;import jj2000.j2k.image.*;import jj2000.j2k.util.*;import jj2000.j2k.*;import java.util.Vector;/** * This class builds packets and keeps the state information of packet * interdependencies. It also supports saving the state and reverting * (restoring) to the last saved state, with the save() and restore() methods. * * <P>Each time the encodePacket() method is called a new packet is encoded, * the packet header is returned by the method, and the packet body can be * obtained with the getLastBodyBuf() and getLastBodyLen() methods. * */public class PktEncoder {        /** The prefix for packet encoding options: 'P' */    public final static char OPT_PREFIX = 'P';    /** The list of parameters that is accepted for packet encoding.*/    private final static String [][] pinfo = {        { "Psop", "[<tile idx>] on|off"+         "[ [<tile idx>] on|off ...]",          "Specifies whether start of packet (SOP) markers should be used. "+          "'on' enables, 'off' disables it.","off"},        { "Peph", "[<tile idx>] on|off"+         "[ [<tile  idx>] on|off ...]",          "Specifies whether end of packet header (EPH) markers should be "+          " used. 'on' enables, 'off' disables it.","off"}    };    /** The initial value for the lblock */    private final static int INIT_LBLOCK = 3;        /** The source object */    private CodedCBlkDataSrcEnc infoSrc;        /** The encoder specs */    EncoderSpecs encSpec;    /**     * The tag tree for inclusion information. The indexes are outlined     * below. Note that the layer indexes start at 1, therefore, the layer     * index minus 1 is used. The subband indices are used as they are defined     * in the Subband class. The tile indices start at 0 and follow a     * lexicographical order.     *     * <ul>     * <li>1st index: tile index, in lexicographical order</li>     * <li>2nd index: component index </li>     * <li>3rd index: resolution level </li>     * <li>4th index: subband index </li>     * <li>5th index: precinct index </li>     * </ul>     **/    private TagTreeEncoder ttIncl[][][][][];    /**     * The tag tree for the maximum significant bit-plane. The indexes are     * outlined below. Note that the layer indexes start at 1, therefore, the     * layer index minus 1 is used. The subband indices are used as they are     * defined in the Subband class. The tile indices start at 0 and follow a     * lexicographical order.     *     * <ul>     * <li>1st index: tile index, in lexicographical order</li>     * <li>2nd index: component index </li>     * <li>3rd index: resolution level </li>     * <li>4th index: subband index - subband index offset </li>     * <li>5th index: precinct index </li>     * </ul>     * */    private TagTreeEncoder ttMaxBP[][][][][];    /**     * The base number of bits for sending code-block length information     * (referred as Lblock in the JPEG 2000 standard). The indexes are     * outlined below. Note that the layer indexes start at 1, therefore, the     * layer index minus 1 is used. The subband indices are used as they are     * defined in the Subband class. The tile indices start at 0 and follow a     * lexicographical order.     *     * <ul>     * <li>1st index: tile index, in lexicographical order </li>     * <li>2nd index: component index </li>     * <li>3rd index: resolution level </li>     * <li>4th index: subband index - subband index offset </li>     * <li>5th index: code-block index, in lexicographical order</li>     * </ul>     * */    private int lblock[][][][][];    /**     * The last encoded truncation point for each code-block. A negative value     * means that no information has been included for the block, yet. The     * indexes are outlined below. The subband indices are used as they are     * defined in the Subband class. The tile indices start at 0 and follow a     * lexicographical order. The code-block indices follow a lexicographical     * order within the subband tile.     *     * <P>What is actually stored is the index of the element in     * CBlkRateDistStats.truncIdxs that gives the real truncation point.     *     * <ul>     * <li>1st index: tile index, in lexicographical order </li>     * <li>2nd index: component index </li>     * <li>3rd index: resolution level </li>     * <li>4th index: subband index - subband index offset </li>     * <li>5th index: code-block index, in lexicographical order </li>     * </ul>     *  */    private int prevtIdxs[][][][][];    /**     * The saved base number of bits for sending code-block length     * information. It is used for restoring previous saved state by     * restore(). The indexes are outlined below. Note that the layer indexes     * start at 1, therefore, the layer index minus 1 is used. The subband     * indices are used as they are defined in the Subband class. The tile     * indices start at 0 and follow a lexicographical order.     *      * <ul>      * <li>1st index: tile index, in lexicographical order </li>     * <li>2nd index: component index </li>     * <li>3rd index: resolution level </li>     * <li>4th index: subband index - subband index offset </li>     * <li>5th index: code-block index, in lexicographical order</li>     * </ul>     * */    private int bak_lblock[][][][][];    /**     * The saved last encoded truncation point for each code-block. It is used     * for restoring previous saved state by restore(). A negative value means     * that no information has been included for the block, yet. The indexes     * are outlined below. The subband indices are used as they are defined in     * the Subband class. The tile indices start at 0 and follow a     * lexicographical order. The code-block indices follow a lexicographical     * order within the subband tile.     *     * <ul>     * <li>1st index: tile index, in lexicographical order </li>     * <li>2nd index: component index </li>     * <li>3rd index: resolution level </li>     * <li>4th index: subband index - subband index offset </li>     * <li>5th index: code-block index, in lexicographical order </li>     * </ul>     *  */    private int bak_prevtIdxs[][][][][];    /** The body buffer of the last encoded packet */    private byte[] lbbuf;    /** The body length of the last encoded packet */    private int lblen;    /** The saved state */    private boolean saved;    /** Whether or not there is ROI information in the last encoded Packet */    private boolean roiInPkt = false;        /** Length to read in current packet body to get all the ROI information */    private int roiLen = 0;    /**     *  Array containing the coordinates, width, height, indexes, ... of the     *  precincts     *     * <ul>     * <li> 1st dim: tile index.</li>     * <li> 2nd dim: component index.</li>     * <li> 3nd dim: resolution level index.</li>     * <li> 4th dim: subband index.</li>     * <li> 5th dim: precinct index.</li>     * </ul>      * */    private PrecCoordInfo precArrayI[][][][][];        /**     *  Array containing the coordinates, width, height, indexes, ... of the     *  code-blocks     *     * <ul>     * <li> 1st dim: tile index.</li>     * <li> 2nd dim: component index.</li>     * <li> 3nd dim: resolution level index.</li>     * <li> 4th dim: subband index.</li>     * <li> 5th dim: code-block index.</li>     * </ul> */    private CBlkCoordInfo cbArrayI[][][][][];        /**      * Maximum number of precincts in each resolution level :     *     * <ul>     * <li> 1st dim: tile index.</li>     * <li> 2nd dim: component index.</li>     * <li> 3nd dim: resolution level index.</li>     * </ul>     */    private Coord maxNumPrec[][][];        /**      * Array containing the increment step     *     * <ul>     * <li> 1st dim : tile index</li>     * <li> 2nd dim : component index</li>     * <li> 3rd dim : resolution level</li>     * </ul>     */    private Coord incArray[][][];        /**      * Array containing the maximum increment step     *     * <ul>     * <li> 1st dim : tile index</li>     * <li> 2nd dim : component index</li>     * </ul>     * */    private Coord incArrayMax[][];        /**      * Array used to store the start/end of tile horizontal and vertical     * coordinates at each resolution level     *     * <ul>     * <li> 1st dim : tile index</li>     * <li> 2nd dim : component index</li>     * <li> 3rd dim : resolution level</li>     * <li> 4th dim : 0, start of tile, 1, end of tile</li>     * </ul>     * */    private Coord sot_eotArray[][][][];        /**      * Array used to store the start/end of tile horizontal and vertical     * coordinates at the highest resolution level using the smallest     * increments     *      * <ul>     * <li> 1st dim : tile index</li>     * <li> 2nd dim : component index</li>     * <li> 3rd dim : 0, start of tile, 1, end of tile</li>     * </ul>     * */    private Coord sot_eotArrayMax[][][];         /**      * The maximum number of resolution level for each component and each tile     * */    int mrl[][];            /**      * Keeps the first and the last subband index in the associated resolution     * level for each tile and each component     * */    private int[][][][] subRange;             /** Whether or not the current packet is writable */    private boolean packetWritable;        /**      * Backup of the subband tree for each tile and component as they are used     * quite often.     * */    private SubbandAn savedSbTree[][];        /**     * Creates a new packet header encoder, using the information from the     * 'infoSrc' object. The information used is the number of components,     * number of tiles, subband decomposition, etc.     *     * <P>Note that this constructor visits all the tiles in the 'infoSrc'     * object. The 'infoSrc' object is left at the original tile (i.e. the     * current tile before calling this constructor), but any side effects of     * visiting the tiles is not reverted.     *

⌨️ 快捷键说明

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