@Override public BZip2CompressorInputStream create(InputStream in) throws IOException { return new BZip2CompressorInputStream(in); }
private int setupRandPartC() throws IOException { if (this.su_j2 < this.su_z) { this.crc.updateCRC(this.su_ch2); this.su_j2++; return this.su_ch2; } this.currentState = RAND_PART_A_STATE; this.su_i2++; this.su_count = 0; return setupRandPartA(); }
private int setupNoRandPartC() throws IOException { if (this.su_j2 < this.su_z) { final int su_ch2Shadow = this.su_ch2; this.crc.updateCRC(su_ch2Shadow); this.su_j2++; this.currentState = NO_RAND_PART_C_STATE; return su_ch2Shadow; } this.su_i2++; this.su_count = 0; return setupNoRandPartA(); }
@Override protected OutputStream createOutputStream(OutputStream out) throws IOException { return new BZip2CompressorOutputStream(out); } };
private int setupNoRandPartA() throws IOException { if (this.su_i2 <= this.last) { this.su_chPrev = this.su_ch2; final int su_ch2Shadow = this.data.ll8[this.su_tPos] & 0xff; this.su_ch2 = su_ch2Shadow; checkBounds(this.su_tPos, this.data.tt.length, "su_tPos"); this.su_tPos = this.data.tt[this.su_tPos]; this.su_i2++; this.currentState = NO_RAND_PART_B_STATE; this.crc.updateCRC(su_ch2Shadow); return su_ch2Shadow; } this.currentState = NO_RAND_PART_A_STATE; endBlock(); initBlock(); return setupBlock(); }
/** * Writes magic bytes like BZ on the first position of the stream * and bytes indiciating the file-format, which is * huffmanised, followed by a digit indicating blockSize100k. * @throws IOException if the magic bytes could not been written */ private void init() throws IOException { bsPutUByte('B'); bsPutUByte('Z'); this.data = new Data(this.blockSize100k); this.blockSorter = new BlockSort(this.data); // huffmanised magic bytes bsPutUByte('h'); bsPutUByte('0' + this.blockSize100k); this.combinedCRC = 0; initBlock(); }
private void moveToFrontCodeAndSend() throws IOException { bsW(24, this.data.origPtr); generateMTFValues(); sendMTFValues(); }
private int setupNoRandPartB() throws IOException { if (this.su_ch2 != this.su_chPrev) { this.su_count = 1; return setupNoRandPartA(); } else if (++this.su_count >= 4) { checkBounds(this.su_tPos, this.data.ll8.length, "su_tPos"); this.su_z = (char) (this.data.ll8[this.su_tPos] & 0xff); this.su_tPos = this.data.tt[this.su_tPos]; this.su_j2 = 0; return setupNoRandPartC(); } else { return setupNoRandPartA(); } }
private static int bsGetInt(BitInputStream bin) throws IOException { return bsR(bin, 32); }
private void initBlock() { // blockNo++; this.crc.initialiseCRC(); this.last = -1; // ch = 0; final boolean[] inUse = this.data.inUse; for (int i = 256; --i >= 0;) { inUse[i] = false; } }
/** * swaps two intervals starting at yyp1 and yyp2 of length yyn inside fmap. */ private void fvswap(final int[] fmap, int yyp1, int yyp2, int yyn) { while (yyn > 0) { fswap(fmap, yyp1, yyp2); yyp1++; yyp2++; yyn--; } }
private void blockSort() { blockSorter.blockSort(data, last); }
@Override protected InputStream createInputStream(InputStream in) throws IOException { return new BZip2CompressorInputStream(in); } };
@Override public OutputStream wrapOutputStream(OutputStream out) throws IOException { return new BZip2CompressorOutputStream(out); } };
private static char bsGetUByte(BitInputStream bin) throws IOException { return (char) bsR(bin, 8); }
private void bsPutUByte(final int c) throws IOException { bsW(8, c); }
@Override InputStream decode(final String archiveName, final InputStream in, final long uncompressedLength, final Coder coder, final byte[] password) throws IOException { return new BZip2CompressorInputStream(in); } @Override
private static boolean bsGetBit(BitInputStream bin) throws IOException { return bsR(bin, 1) != 0; }