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

📄 stddequantizer.java

📁 jpeg2000算法实现
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *     * @param sb The subband in which the code-block to return is.     *     * @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. If the     * "data" array of the object is non-null it will be reused, if possible,     * to return the data.     *     * @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 DataBlk     * */    public final DataBlk getCodeBlock(int c, int m, int n, SubbandSyn sb,                                        DataBlk cblk) {        return getInternCodeBlock(c,m,n,sb,cblk);    }        /**     * Returns the specified code-block in the current tile for the specified     * component (as a reference or copy).     *     * <P>The returned code-block may be progressive, which is indicated by     * the 'progressive' variable of the returned 'DataBlk'     * object. If a code-block is progressive it means that in a later request     * to this method for the same code-block it is possible to retrieve data     * which is a better approximation, since meanwhile more data to decode     * for the code-block could have been received. If the code-block is not     * progressive then later calls to this method for the same code-block     * will return the exact same data values.     *     * <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.     *     * @param c The component for which to return the next code-block.     *     * @param m The vertical index of the code-block to return, in the     * specified subband.     *     * @param n The horizontal index of the code-block to return, in the     * specified subband.     *     * @param sb The subband in which the code-block to return is.     *     * @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. If the     * "data" array of the object is non-null it will be reused, if possible,     * to return the data.     *     * @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 DataBlk     * */    public final        DataBlk getInternCodeBlock(int c, int m, int n, SubbandSyn sb,                                     DataBlk cblk) {        // This method is declared final since getNextCodeBlock() relies on        // the actual implementation of this method.        int j,jmin,k;        int temp;        float step;        int shiftBits;        int magBits;        int[] outiarr,inarr;        float[] outfarr;        int w,h;	boolean reversible = qts.isReversible(tIdx,c);	boolean derived = qts.isDerived(tIdx,c);	StdDequantizerParams 	    params = (StdDequantizerParams)qsss.getTileCompVal(tIdx,c);        int G = ((Integer)gbs.getTileCompVal(tIdx,c)).intValue();	        outdtype = cblk.getDataType();        if (reversible && outdtype!=DataBlk.TYPE_INT) {            throw new IllegalArgumentException("Reversible quantizations "+                                               "must use int data");        }        // To get compiler happy        outiarr = null;        outfarr = null;        inarr = null;        // Get source data and initialize output DataBlk object.        switch (outdtype) {        case DataBlk.TYPE_INT:            // With int data we can use the same DataBlk object to get the            // data from the source and return the dequantized data, and we            // can also work "in place" (i.e. same buffer).            cblk = src.getCodeBlock(c,m,n,sb,cblk);            // Input and output arrays are the same            outiarr = (int[]) cblk.getData();            break;        case DataBlk.TYPE_FLOAT:            // With float data we must use a different DataBlk objects to get            // the data from the source and to return the dequantized data.            inblk = (DataBlkInt) src.getInternCodeBlock(c,m,n,sb,inblk);            inarr = inblk.getDataInt();            if (cblk == null) {                cblk = new DataBlkFloat();            }            // Copy the attributes of the CodeBlock object            cblk.ulx = inblk.ulx;            cblk.uly = inblk.uly;            cblk.w = inblk.w;            cblk.h = inblk.h;            cblk.offset = 0;            cblk.scanw = cblk.w;            cblk.progressive = inblk.progressive;            // Get output data array and check its size            outfarr = (float[]) cblk.getData();            if (outfarr == null || outfarr.length < cblk.w*cblk.h) {                outfarr = new float[cblk.w*cblk.h];                cblk.setData(outfarr);            }            break;        }        magBits = sb.magbits;        // Calculate quantization step and number of magnitude bits        // depending on reversibility and derivedness and perform        // inverse quantization        if(reversible){            shiftBits=31-magBits;            // For int data Inverse quantization happens "in-place". The input            // array has an offset of 0 and scan width equal to the code-block            // width.            for (j=outiarr.length-1; j>=0; j--) {                temp = outiarr[j]; // input array is same as output one                outiarr[j]=(temp >= 0) ? (temp>>shiftBits) :                    -((temp&0x7FFFFFFF)>>shiftBits);            }        }        else{// Not reversible             if(derived){                // Max resolution level                int mrl = src.getSubbandTree(getTileIdx(),c).resLvl;                step=params.nStep[0][0]*                    (1L<<(rb[c]+sb.anGainExp+mrl-sb.level));            }            else{                step=params.nStep[sb.resLvl][sb.sbandIdx]*                    (1L<<(rb[c]+sb.anGainExp));            }            shiftBits=31-magBits;            // Adjust step to the number of shiftBits            step /= (1<<shiftBits);            switch (outdtype) {            case DataBlk.TYPE_INT:                // For int data Inverse quantization happens "in-place". The                // input array has an offset of 0 and scan width equal to the                // code-block width.                for (j=outiarr.length-1; j>=0; j--) {                    temp = outiarr[j]; // input array is same as output one                    outiarr[j] = (int)(((float)((temp >= 0) ? temp :                                                -(temp&0x7FFFFFFF)))*step);                }                break;            case DataBlk.TYPE_FLOAT:                // For float data the inverse quantization can not happen                // "in-place".                w = cblk.w;                h = cblk.h;                for (j=w*h-1, k=inblk.offset+(h-1)*inblk.scanw+w-1,                         jmin = w*(h-1); j>=0; jmin -= w) {                    for (; j>=jmin; k--, j--) {                        temp = inarr[k];                        outfarr[j] = ((float)((temp >= 0) ? temp :                                              -(temp&0x7FFFFFFF)))*step;                    }                    // Jump to beggining of previous line in input                    k -= inblk.scanw - w;                }                break;            }        }        // Return the output code-block        return cblk;    }}

⌨️ 快捷键说明

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