int deflateParams(int _level, int _strategy){ int err=Z_OK; if(_level == Z_DEFAULT_COMPRESSION){ _level = 6; } if(_level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) { return Z_STREAM_ERROR; } if(config_table[level].func!=config_table[_level].func && strm.total_in != 0) { // Flush the last buffer: err = strm.deflate(Z_PARTIAL_FLUSH); } if(level != _level) { level = _level; max_lazy_match = config_table[level].max_lazy; good_match = config_table[level].good_length; nice_match = config_table[level].nice_length; max_chain_length = config_table[level].max_chain; } strategy = _strategy; return err; }
public void init(int type, int level){ if(type==DEFLATER){ stream.deflateInit(level); this.type=DEFLATER; } else if(type==INFLATER){ stream.inflateInit(); inflated_buf=new byte[BUF_SIZE]; this.type=INFLATER; } }
@Override public void init(Mode mode) { stream = new ZStream(); switch (mode) { case DEFLATE: stream.deflateInit(JZlib.Z_DEFAULT_COMPRESSION); break; case INFLATE: stream.inflateInit(); break; default: assert false; } }
public void end() { if(z==null) return; if(compress){ z.deflateEnd(); } else{ z.inflateEnd(); } z.free(); z=null; } public void close() throws IOException {
public RpcGZIPOutputStream(OutputStream out) throws IOException { super(out); this.jzOutputSream = new ZStream(); this.jzOutputSream.deflateInit(JZlib.Z_DEFAULT_COMPRESSION, ZBITS, true); this.jzBytes = new byte[ZBUF_SIZE]; this.jzOutputSream.next_out = this.jzBytes; this.jzOutputSream.next_out_index = 0; this.jzOutputSream.avail_out = this.jzBytes.length; }
public void write(byte b[], int off, int len) throws IOException { if(len==0) return; int err; z.next_in=b; z.next_in_index=off; z.avail_in=len; do{ z.next_out=buf; z.next_out_index=0; z.avail_out=bufsize; if(compress) err=z.deflate(flush); else err=z.inflate(flush); if(err!=JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); out.write(buf, 0, bufsize-z.avail_out); } while(z.avail_in>0 || z.avail_out==0); }
public ZOutputStream(OutputStream out, int level, boolean nowrap) { super(); this.out=out; z.deflateInit(level, nowrap); compress=true; }
public ZOutputStream(OutputStream out) { super(); this.out=out; z.inflateInit(); compress=false; }
public byte[] uncompress(byte[] buffer, int start, int length) throws IOException { // int inflated_end = 0; uncompressOut.reset(); stream.next_in = buffer; stream.next_in_index = start; stream.avail_in = length; while(true) { stream.next_out = inflated_buf; stream.next_out_index = 0; stream.avail_out = BUF_SIZE; int status = stream.inflate(JZlib.Z_PARTIAL_FLUSH); switch(status) { case JZlib.Z_OK: uncompressOut.write(inflated_buf, 0, BUF_SIZE - stream.avail_out); break; case JZlib.Z_BUF_ERROR: return uncompressOut.toByteArray(); default: throw new IOException("uncompress: inflate returnd " + status); } } }
/** * Creates a new instance of {@code Compression}. */ public CompressionImpl() { _zstream = new ZStream(); }
void flush_block_only(boolean eof){ _tr_flush_block(block_start>=0 ? block_start : -1, strstart-block_start, eof); block_start=strstart; strm.flush_pending(); }
n = strm.read_buf(window, strstart + lookahead, more); lookahead += n;
/** * Cleanly close the stream and finalize deflation (compression). No one dies * if you don't call this properly, but it certainly helps to close the * stream cleanly. * * @see java.io.FilterOutputStream#close() */ @Override public void close() throws IOException { this.jzOutputSream.deflateEnd(); }
/** * Cleans up the resources used by the compression library. */ public void cleanUp() { if (zStream != null) { zStream.free(); } } }
public void write(byte b[], int off, int len) throws IOException { if(len==0) return; int err; z.next_in=b; z.next_in_index=off; z.avail_in=len; do{ z.next_out=buf; z.next_out_index=0; z.avail_out=bufsize; if(compress) err=z.deflate(flush); else err=z.inflate(flush); if(err!=JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); out.write(buf, 0, bufsize-z.avail_out); } while(z.avail_in>0 || z.avail_out==0); }
public ZInputStream(InputStream in, int level) { super(in); this.in=in; z.deflateInit(level); compress=true; z.next_in=buf; z.next_in_index=0; z.avail_in=0; }
public ZInputStream(InputStream in, boolean nowrap) { super(in); this.in=in; z.inflateInit(nowrap); compress=false; z.next_in=buf; z.next_in_index=0; z.avail_in=0; }
public RpcGZIPOutputStream(OutputStream out) throws IOException { super(out); this.jzOutputSream = new ZStream(); this.jzOutputSream.deflateInit(JZlib.Z_DEFAULT_COMPRESSION, ZBITS, true); this.jzBytes = new byte[ZBUF_SIZE]; this.jzOutputSream.next_out = this.jzBytes; this.jzOutputSream.next_out_index = 0; this.jzOutputSream.avail_out = this.jzBytes.length; }
_zstream.next_out_index = 0; _zstream.avail_out = BUF_SIZE; status = _zstream.inflate(JZlib.Z_PARTIAL_FLUSH); switch( status ) { case JZlib.Z_OK:
public Compression(){ stream=new ZStream(); }