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

📄 cbzip2inputstream.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            } else {                if (++lastShadow >= limitLast) {                    throw new IOException("block overrun");                }                final char tmp = yy[nextSym - 1];                unzftab[seqToUnseq[tmp] & 0xff]++;                ll8[lastShadow] = seqToUnseq[tmp];                /*                  This loop is hammered during decompression,                  hence avoid native method call overhead of                  System.arraycopy for very small ranges to copy.                */                if (nextSym <= 16) {                    for (int j = nextSym - 1; j > 0;) {                        yy[j] = yy[--j];                    }                } else {                    System.arraycopy(yy, 0, yy, 1, nextSym - 1);                }                yy[0] = tmp;                if (groupPos == 0) {                    groupPos    = G_SIZE - 1;                    zt          = selector[++groupNo] & 0xff;                    base_zt     = base[zt];                    limit_zt    = limit[zt];                    perm_zt     = perm[zt];                    minLens_zt  = minLens[zt];                } else {                    groupPos--;                }                int zn = minLens_zt;                // Inlined:                // int zvec = bsR(zn);                while (bsLiveShadow < zn) {                    final int thech = inShadow.read();                    if (thech >= 0) {                        bsBuffShadow = (bsBuffShadow << 8) | thech;                        bsLiveShadow += 8;                        continue;                    } else {                        throw new IOException("unexpected end of stream");                    }                }                int zvec = (bsBuffShadow >> (bsLiveShadow - zn)) & ((1 << zn) - 1);                bsLiveShadow -= zn;                while (zvec > limit_zt[zn]) {                    zn++;                    while (bsLiveShadow < 1) {                        final int thech = inShadow.read();                        if (thech >= 0) {                            bsBuffShadow = (bsBuffShadow << 8) | thech;                            bsLiveShadow += 8;                            continue;                        } else {                            throw new IOException("unexpected end of stream");                        }                    }                    bsLiveShadow--;                    zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) & 1);                }                nextSym = perm_zt[zvec - base_zt[zn]];            }        }        this.last = lastShadow;        this.bsLive = bsLiveShadow;        this.bsBuff = bsBuffShadow;    }    private int getAndMoveToFrontDecode0(final int groupNo)        throws IOException {        final InputStream inShadow  = this.in;        final Data dataShadow  = this.data;        final int zt          = dataShadow.selector[groupNo] & 0xff;        final int[] limit_zt  = dataShadow.limit[zt];        int zn = dataShadow.minLens[zt];        int zvec = bsR(zn);        int bsLiveShadow = this.bsLive;        int bsBuffShadow = this.bsBuff;        while (zvec > limit_zt[zn]) {            zn++;            while (bsLiveShadow < 1) {                final int thech = inShadow.read();                if (thech >= 0) {                    bsBuffShadow = (bsBuffShadow << 8) | thech;                    bsLiveShadow += 8;                    continue;                } else {                    throw new IOException("unexpected end of stream");                }            }            bsLiveShadow--;            zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) & 1);        }        this.bsLive = bsLiveShadow;        this.bsBuff = bsBuffShadow;        return dataShadow.perm[zt][zvec - dataShadow.base[zt][zn]];    }    private void setupBlock() throws IOException {        if (this.data == null) {            return;        }        final int[] cftab = this.data.cftab;        final int[] tt    = this.data.initTT(this.last + 1);        final byte[] ll8  = this.data.ll8;        cftab[0] = 0;        System.arraycopy(this.data.unzftab, 0, cftab, 1, 256);        for (int i = 1, c = cftab[0]; i <= 256; i++) {            c += cftab[i];            cftab[i] = c;        }        for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) {            tt[cftab[ll8[i] & 0xff]++] = i;        }        if ((this.origPtr < 0) || (this.origPtr >= tt.length)) {            throw new IOException("stream corrupted");        }        this.su_tPos = tt[this.origPtr];        this.su_count = 0;        this.su_i2 = 0;        this.su_ch2 = 256;   /* not a char and not EOF */        if (this.blockRandomised) {            this.su_rNToGo = 0;            this.su_rTPos = 0;            setupRandPartA();        } else {            setupNoRandPartA();        }    }    private void setupRandPartA() throws IOException {        if (this.su_i2 <= this.last) {            this.su_chPrev = this.su_ch2;            int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;            this.su_tPos = this.data.tt[this.su_tPos];            if (this.su_rNToGo == 0) {                this.su_rNToGo = BZip2Constants.rNums[this.su_rTPos] - 1;                if (++this.su_rTPos == 512) {                    this.su_rTPos = 0;                }            } else {                this.su_rNToGo--;            }            this.su_ch2 = su_ch2Shadow ^= (this.su_rNToGo == 1) ? 1 : 0;            this.su_i2++;            this.currentChar = su_ch2Shadow;            this.currentState = RAND_PART_B_STATE;            this.crc.updateCRC(su_ch2Shadow);        } else {            endBlock();            initBlock();            setupBlock();        }    }    private void setupNoRandPartA() throws IOException {        if (this.su_i2 <= this.last) {            this.su_chPrev = this.su_ch2;            int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff;            this.su_ch2 = su_ch2Shadow;            this.su_tPos = this.data.tt[this.su_tPos];            this.su_i2++;            this.currentChar = su_ch2Shadow;            this.currentState = NO_RAND_PART_B_STATE;            this.crc.updateCRC(su_ch2Shadow);        } else {            this.currentState = NO_RAND_PART_A_STATE;            endBlock();            initBlock();            setupBlock();        }    }    private void setupRandPartB() throws IOException {        if (this.su_ch2 != this.su_chPrev) {            this.currentState = RAND_PART_A_STATE;            this.su_count = 1;            setupRandPartA();        } else if (++this.su_count >= 4) {            this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff);            this.su_tPos = this.data.tt[this.su_tPos];            if (this.su_rNToGo == 0) {                this.su_rNToGo = BZip2Constants.rNums[this.su_rTPos] - 1;                if (++this.su_rTPos == 512) {                    this.su_rTPos = 0;                }            } else {                this.su_rNToGo--;            }            this.su_j2 = 0;            this.currentState = RAND_PART_C_STATE;            if (this.su_rNToGo == 1) {                this.su_z ^= 1;            }            setupRandPartC();        } else {            this.currentState = RAND_PART_A_STATE;            setupRandPartA();        }    }    private void setupRandPartC() throws IOException {        if (this.su_j2 < this.su_z) {            this.currentChar = this.su_ch2;            this.crc.updateCRC(this.su_ch2);            this.su_j2++;        } else {            this.currentState = RAND_PART_A_STATE;            this.su_i2++;            this.su_count = 0;            setupRandPartA();        }    }    private void setupNoRandPartB() throws IOException {        if (this.su_ch2 != this.su_chPrev) {            this.su_count = 1;            setupNoRandPartA();        } else if (++this.su_count >= 4) {            this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff);            this.su_tPos = this.data.tt[this.su_tPos];            this.su_j2 = 0;            setupNoRandPartC();        } else {            setupNoRandPartA();        }    }    private void setupNoRandPartC() throws IOException {        if (this.su_j2 < this.su_z) {            int su_ch2Shadow = this.su_ch2;            this.currentChar = su_ch2Shadow;            this.crc.updateCRC(su_ch2Shadow);            this.su_j2++;            this.currentState = NO_RAND_PART_C_STATE;        } else {            this.su_i2++;            this.su_count = 0;            setupNoRandPartA();        }    }    private static final class Data extends Object {        // (with blockSize 900k)        final boolean[] inUse   = new boolean[256];                                   //      256 byte        final byte[] seqToUnseq   = new byte[256];                                    //      256 byte        final byte[] selector     = new byte[MAX_SELECTORS];                          //    18002 byte        final byte[] selectorMtf  = new byte[MAX_SELECTORS];                          //    18002 byte        /**         * Freq table collected to save a pass over the data during         * decompression.         */        final int[] unzftab = new int[256];                                           //     1024 byte        final int[][] limit = new int[N_GROUPS][MAX_ALPHA_SIZE];                      //     6192 byte        final int[][] base  = new int[N_GROUPS][MAX_ALPHA_SIZE];                      //     6192 byte        final int[][] perm  = new int[N_GROUPS][MAX_ALPHA_SIZE];                      //     6192 byte        final int[] minLens = new int[N_GROUPS];                                      //       24 byte        final int[]     cftab     = new int[257];                                     //     1028 byte        final char[]    getAndMoveToFrontDecode_yy = new char[256];                   //      512 byte        final char[][]  temp_charArray2d  = new char[N_GROUPS][MAX_ALPHA_SIZE];       //     3096 byte        final byte[] recvDecodingTables_pos = new byte[N_GROUPS];                     //        6 byte        //---------------        //    60798 byte        int[] tt;                                                                     //  3600000 byte        byte[] ll8;                                                                   //   900000 byte        //---------------        //  4560782 byte        //===============        Data(int blockSize100k) {            super();            this.ll8 = new byte[blockSize100k * BZip2Constants.baseBlockSize];        }        /**         * Initializes the {@link #tt} array.         *         * This method is called when the required length of the array         * is known.  I don't initialize it at construction time to         * avoid unneccessary memory allocation when compressing small         * files.         */        final int[] initTT(int length) {            int[] ttShadow = this.tt;            // tt.length should always be >= length, but theoretically            // it can happen, if the compressor mixed small and large            // blocks.  Normally only the last block will be smaller            // than others.            if ((ttShadow == null) || (ttShadow.length < length)) {                this.tt = ttShadow = new int[length];            }            return ttShadow;        }    }}

⌨️ 快捷键说明

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