📄 forwwtfull.java
字号:
/* * CVS identifier: * * $Id: ForwWTFull.java,v 1.1.1.1 2002/07/22 09:26:54 grosbois Exp $ * * Class: ForwWTFull * * Description: This class implements the full page * forward wavelet transform for both integer * and floating point implementations. * * * * 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.analysis;import jj2000.j2k.codestream.*;import jj2000.j2k.entropy.*;import jj2000.j2k.wavelet.*;import jj2000.j2k.encoder.*;import jj2000.j2k.image.*;import jj2000.j2k.util.*;import jj2000.j2k.*;/** * This class implements the ForwardWT abstract class with the full-page * approach to be used either with integer or floating-point filters * * @see ForwardWT * */public class ForwWTFull extends ForwardWT { /** Boolean to know if one are currently dealing with int or float data.*/ private boolean intData; /** * The subband trees of each tile-component. The array is allocated by the * constructor of this class and updated by the getAnSubbandTree() method * when needed. The first index is the tile index (in lexicographical * order) and the second index is the component index. * * <p>The subband tree for a component in the current tile is created on * the first call to getAnSubbandTree() for that component, in the current * tile. Before that, the element in 'subbTrees' is null.</p> * */ private SubbandAn subbTrees[][]; /** The source of image data */ private BlkImgDataSrc src; /** The horizontal coordinate of the code-block partition origin on the reference grid */ private int cb0x; /** The vertical coordinate of the code-block partition on the reference grid */ private int cb0y; /** The number of decomposition levels specification */ private IntegerSpec dls; /** Wavelet filters for all components and tiles */ private AnWTFilterSpec filters; /** The code-block size specifications */ private CBlkSizeSpec cblks; /** The precinct partition specifications */ private PrecinctSizeSpec pss; /** Block storing the full band decomposition for each component. */ private DataBlk decomposedComps[]; /** The horizontal index of the last "sent" code-block in the current * subband in each component. It should be -1 if none have been sent yet. * */ private int lastn[]; /** The vertical index of the last "sent" code-block in the current * subband in each component. It should be 0 if none have been sent yet. * */ private int lastm[]; /** The subband being dealt with in each component */ SubbandAn currentSubband[]; /** Cache object to avoid excessive allocation/desallocation. This * variable makes the class inheritently thread unsafe. */ Coord ncblks; /** * Initializes this object with the given source of image data and with * all the decompositon parameters * * @param src From where the image data should be obtained. * * @param encSpec The encoder specifications * * @param cb0x The horizontal coordinate of the code-block partition * origin on the reference grid. * * @param cb0y The vertical coordinate of the code-block partition origin * on the reference grid. * * @see ForwardWT * */ public ForwWTFull(BlkImgDataSrc src,EncoderSpecs encSpec, int cb0x,int cb0y) { super(src); this.src = src; this.cb0x = cb0x; this.cb0y = cb0y; this.dls = encSpec.dls; this.filters = encSpec.wfs; this.cblks = encSpec.cblks; this.pss = encSpec.pss; int ncomp = src.getNumComps(); int ntiles = src.getNumTiles(); currentSubband = new SubbandAn[ncomp]; decomposedComps = new DataBlk[ncomp]; subbTrees = new SubbandAn[ntiles][ncomp]; lastn = new int[ncomp]; lastm = new int[ncomp]; } /** * Returns the implementation type of this wavelet transform, WT_IMPL_FULL * (full-page based transform). All components return the same. * * @param c The index of the component. * * @return WT_IMPL_FULL * */ public int getImplementationType(int c) { return WaveletTransform.WT_IMPL_FULL; } /** * Returns the number of decomposition levels that are applied to the LL * band, in the specified tile-component. A value of 0 means that no * wavelet transform is applied. * * @param t The tile index * * @param c The index of the component. * * @return The number of decompositions applied to the LL band (0 for no * wavelet transform). * */ public int getDecompLevels(int t,int c) { return ((Integer)dls.getTileCompVal(t,c)).intValue(); } /** * Returns the wavelet tree decomposition. Actually JPEG 2000 part 1 only * supports WT_DECOMP_DYADIC decomposition. * * @param t The tile-index * * @param c The index of the component. * * @return The wavelet decomposition. * */ public int getDecomp(int t,int c) { return WT_DECOMP_DYADIC; } /** * Returns the horizontal analysis wavelet filters used in each level, for * the specified component and tile. The first element in the array is the * filter used to obtain the lowest resolution (resolution level 0) * subbands (i.e. lowest frequency LL subband), the second element is the * one used to generate the resolution level 1 subbands, and so on. If * there are less elements in the array than the number of resolution * levels, then the last one is assumed to repeat itself. * * <p>The returned filters are applicable only to the specified component * and in the current tile.</p> * * <p>The resolution level of a subband is the resolution level to which a * subband contributes, which is different from its decomposition * level.</p> * * @param t The index of the tile for which to return the filters. * * @param c The index of the component for which to return the filters. * * @return The horizontal analysis wavelet filters used in each level. * */ public AnWTFilter[] getHorAnWaveletFilters(int t,int c) { return filters.getHFilters(t,c); } /** * Returns the vertical analysis wavelet filters used in each level, for * the specified component and tile. The first element in the array is the * filter used to obtain the lowest resolution (resolution level 0) * subbands (i.e. lowest frequency LL subband), the second element is the * one used to generate the resolution level 1 subbands, and so on. If * there are less elements in the array than the number of resolution * levels, then the last one is assumed to repeat itself. * * <p>The returned filters are applicable only to the specified component * and in the current tile.</p> * * <p>The resolution level of a subband is the resolution level to which a * subband contributes, which is different from its decomposition * level.</p> * * @param t The index of the tile for which to return the filters. * * @param c The index of the component for which to return the filters. * * @return The vertical analysis wavelet filters used in each level. * */ public AnWTFilter[] getVertAnWaveletFilters(int t,int c) { return filters.getVFilters(t,c); } /** * Returns the reversibility of the wavelet transform for the specified * component and 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) { return filters.isReversible(t,c); } /** * Returns the horizontal offset of the code-block partition. Allowable * values are 0 and 1, nothing else. * */ public int getCbULX() { return cb0x; } /** * Returns the vertical offset of the code-block partition. Allowable * values are 0 and 1, nothing else. * */ public int getCbULY() { return cb0y; } /** * 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. * * @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 the next code-block in the current tile for the specified * component. The order in which code-blocks are returned is not * specified. However each code-block is returned only once and all * code-blocks will be returned if the method is called 'N' times, where * 'N' is the number of code-blocks in the tile. After all the code-blocks * have been returned for the current tile calls to this method will * return 'null'. * * <p>When changing the current tile (through 'setTile()' or 'nextTile()') * this method will always return the first code-block, as if this method * was never called before for the new current tile.</p> * * <p>The data returned by this method is the data in the internal buffer * of this object, and thus can not be modified by the caller. The * 'offset' and 'scanw' of the returned data have, in general, some * non-zero value. The 'magbits' of the returned data is not set by this * method and should be ignored. See the 'CBlkWTData' class.</p> * * <p>The 'ulx' and 'uly' members of the returned 'CBlkWTData' object * contain the coordinates of the top-left corner of the block, with * respect to the tile, not the subband.</p> * * @param c The component for which to return the next code-block. * * @param cblk If non-null this object will be used to return the new * code-block. If null a new one will be allocated and returned. * * @return The next code-block in the current tile for component 'n', or * null if all code-blocks for the current tile have been returned. * * @see CBlkWTData * */ public CBlkWTData getNextInternCodeBlock(int c, CBlkWTData cblk) { int cbm,cbn,cn,cm; int acb0x, acb0y; SubbandAn sb; intData = (filters.getWTDataType(tIdx,c)==DataBlk.TYPE_INT); //If the source image has not been decomposed if(decomposedComps[c]==null) { int k,w,h; DataBlk bufblk; Object dst_data; w = getTileCompWidth(tIdx,c); h = getTileCompHeight(tIdx,c); //Get the source image data if(intData) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -