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

📄 invwtfull.java

📁 jpeg2000编解码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*  * CVS identifier: *  * $Id: InvWTFull.java,v 1.1.1.1 2002/07/22 09:26:55 grosbois Exp $ *  * Class:                   InvWTFull *  * Description:             This class implements a full page inverse DWT for *                          int and float data. *  *                          the InvWTFullInt and InvWTFullFloat *                          classes by Bertrand Berthelot, Apr-19-1999 *  *  * 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.wavelet.synthesis;import jj2000.j2k.wavelet.*;import jj2000.j2k.decoder.*;import jj2000.j2k.image.*;import jj2000.j2k.util.*;/** * This class implements the InverseWT with the full-page approach for int and * float data. * * <p>The image can be reconstructed at different (image) resolution levels * indexed from the lowest resolution available for each tile-component. This * is controlled by the setImgResLevel() method.</p> * * <p>Note: Image resolution level indexes may differ from tile-component * resolution index. They are indeed indexed starting from the lowest number * of decomposition levels of each component of each tile.</p> * * <p>Example: For an image (1 tile) with 2 components (component 0 having 2 * decomposition levels and component 1 having 3 decomposition levels), the * first (tile-) component has 3 resolution levels and the second one has 4 * resolution levels, whereas the image has only 3 resolution levels * available.</p> * * <p>This implementation does not support progressive data: Data is * considered to be non-progressive (i.e. "final" data) and the 'progressive' * attribute of the 'DataBlk' class is always set to false, see the 'DataBlk' * class.</p> * * @see DataBlk * */public class InvWTFull extends InverseWT {    /** Reference to the ProgressWatch instance if any */    private ProgressWatch pw = null;    /** The total number of code-blocks to decode */    private int cblkToDecode = 0;    /** The number of already decoded code-blocks */    private int nDecCblk = 0;    /** the code-block buffer's source i.e. the quantizer */    private CBlkWTDataSrcDec src;        /** Current data type */    private int dtype;        /** Block storing the reconstructed image for each component */    private DataBlk reconstructedComps[];    /** Number of decomposition levels in each component */    private int[] ndl;    /**     * The reversible flag for each component in each tile. The first index is     * the tile index, the second one is the component index. The     * reversibility of the components for each tile are calculated on a as     * needed basis.     * */    private boolean reversible[][];    /**     * Initializes this object with the given source of wavelet     * coefficients. It initializes the resolution level for full resolutioin     * reconstruction.     *     * @param src from where the wavelet coefficinets should be obtained.     *     * @param decSpec The decoder specifications     * */    public InvWTFull(CBlkWTDataSrcDec src, DecoderSpecs decSpec){        super(src,decSpec);        this.src = src;        int nc = src.getNumComps();        reconstructedComps = new DataBlk[nc];        ndl = new int[nc];	pw = FacilityManager.getProgressWatch();    }   /**     * Returns the reversibility of the current subband. It computes     * iteratively the reversibility of the child subbands. For each subband     * it tests the reversibility of the horizontal and vertical synthesis     * filters used to reconstruct this subband.     *     * @param subband The current subband.     *     * @return true if all the  filters used to reconstruct the current      * subband are reversible     * */    private boolean isSubbandReversible(Subband subband) {        if(subband.isNode) {            // It's reversible if the filters to obtain the 4 subbands are            // reversible and the ones for this one are reversible too.            return                isSubbandReversible(subband.getLL()) &&                isSubbandReversible(subband.getHL()) &&                isSubbandReversible(subband.getLH()) &&                isSubbandReversible(subband.getHH()) &&                ((SubbandSyn)subband).hFilter.isReversible() &&                 ((SubbandSyn)subband).vFilter.isReversible();        } else {            // Leaf subband. Reversibility of data depends on source, so say            // it's true            return true;        }     }    /**     * Returns the reversibility of the wavelet transform for the specified     * component, in the current tile. A wavelet transform is reversible when     * it is suitable for lossless and lossy-to-lossless compression.     *     * @param t The index of the tile.     *     * @param c The index of the component.     *     * @return true is the wavelet transform is reversible, false if not.     * */    public boolean isReversible(int t,int c) {        if (reversible[t] == null) {            // Reversibility not yet calculated for this tile            reversible[t] = new boolean[getNumComps()];            for (int i=reversible.length-1; i>=0 ; i--) {                reversible[t][i] =                    isSubbandReversible(src.getSynSubbandTree(t,i));            }        }        return reversible[t][c];    }        /**     * Returns the number of bits, referred to as the "range bits",     * corresponding to the nominal range of the data in the specified     * component.     *     * <p>The returned value corresponds to the nominal dynamic range of the     * reconstructed image data, as long as the getNomRangeBits() method of     * the source returns a value corresponding to the nominal dynamic range     * of the image data and not not of the wavelet coefficients.</p>     *     * <p>If this number is <i>b</b> then for unsigned data the nominal range     * is between 0 and 2^b-1, and for signed data it is between -2^(b-1) and     * 2^(b-1)-1.</p>     *     * @param c The index of the component.     *     * @return The number of bits corresponding to the nominal range of the     * data.     * */    public int getNomRangeBits(int c) {        return src.getNomRangeBits(c);    }        /**     * Returns the position of the fixed point in the specified     * component. This is the position of the least significant integral     * (i.e. non-fractional) bit, which is equivalent to the number of     * fractional bits. For instance, for fixed-point values with 2 fractional     * bits, 2 is returned. For floating-point data this value does not apply     * and 0 should be returned. Position 0 is the position of the least     * significant bit in the data.     *     * <p>This default implementation assumes that the wavelet transform does     * not modify the fixed point. If that were the case this method should be     * overriden.</p>     *     * @param c The index of the component.     *     * @return The position of the fixed-point, which is the same as the     * number of fractional bits. For floating-point data 0 is returned.     * */    public int getFixedPoint(int c) {        return src.getFixedPoint(c);    }        /**     * Returns a block of image data containing the specifed rectangular area,     * in the specified component, as a reference to the internal buffer (see     * below). The rectangular area is specified by the coordinates and     * dimensions of the 'blk' object.     *     * <p>The area to return is specified by the 'ulx', 'uly', 'w' and 'h'     * members of the 'blk' argument. These members are not modified by this     * method.</p>     *     * <p>The data returned by this method can be the data in the internal     * buffer of this object, if any, and thus can not be modified by the     * caller. The 'offset' and 'scanw' of the returned data can be     * arbitrary. See the 'DataBlk' class.</p>     *     * <p>The returned data has its 'progressive' attribute unset     * (i.e. false).</p>     *     * @param blk Its coordinates and dimensions specify the area to return.     *     * @param c The index of the component from which to get the data.     *     * @return The requested DataBlk     *     * @see #getInternCompData     * */    public final DataBlk getInternCompData(DataBlk blk, int c) {        int tIdx = getTileIdx();	if(src.getSynSubbandTree(tIdx,c).getHorWFilter()==null) {	    dtype = DataBlk.TYPE_INT;	} else {	    dtype =                 src.getSynSubbandTree(tIdx,c).getHorWFilter().getDataType();        }        //If the source image has not been decomposed         if(reconstructedComps[c]==null) {            //Allocate component data buffer            switch (dtype) {            case DataBlk.TYPE_FLOAT:                reconstructedComps[c] =                     new DataBlkFloat(0,0,getTileCompWidth(tIdx,c),                                     getTileCompHeight(tIdx,c));                break;            case DataBlk.TYPE_INT:                reconstructedComps[c] =                     new DataBlkInt(0,0,getTileCompWidth(tIdx,c),                                   getTileCompHeight(tIdx,c));                break;            }            //Reconstruct source image            waveletTreeReconstruction(reconstructedComps[c],                                      src.getSynSubbandTree(tIdx,c),c);	    if(pw!=null && c==src.getNumComps()-1) {		pw.terminateProgressWatch();	    }        }        	if(blk.getDataType()!=dtype) {	    if(dtype==DataBlk.TYPE_INT) {		blk = new DataBlkInt(blk.ulx,blk.uly,blk.w,blk.h);	    } else {		blk = new DataBlkFloat(blk.ulx,blk.uly,blk.w,blk.h);	    }	}        // Set the reference to the internal buffer        blk.setData(reconstructedComps[c].getData());        blk.offset = reconstructedComps[c].w*blk.uly+blk.ulx;        blk.scanw = reconstructedComps[c].w;        blk.progressive = false;	return blk;    }    /**     * Returns a block of image data containing the specifed rectangular area,     * in the specified component, as a copy (see below). The rectangular area     * is specified by the coordinates and dimensions of the 'blk' object.     *     * <p>The area to return is specified by the 'ulx', 'uly', 'w' and 'h'     * members of the 'blk' argument. These members are not modified by this     * method.</p>     *     * <p>The data returned by this method is always a copy of the internal     * data of this object, if any, and it can be modified "in place" without     * any problems after being returned. The 'offset' of the returned data is     * 0, and the 'scanw' is the same as the block's width. See the 'DataBlk'     * class.</p>     *     * <p>If the data array in 'blk' is <tt>null</tt>, then a new one is     * created. If the data array is not <tt>null</tt> then it must be big     * enough to contain the requested area.</p>     *     * <p>The returned data always has its 'progressive' attribute unset (i.e     * false)</p>     *

⌨️ 快捷键说明

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