public int init(int level, int bits, int memlevel){ finished = false; dstate=new Deflate(this); return dstate.deflateInit(level, bits, memlevel); } public int init(int level, int bits, boolean nowrap){
void _tr_align(){ send_bits(STATIC_TREES<<1, 3); send_code(END_BLOCK, StaticTree.static_ltree); bi_flush(); // Of the 10 bits for the empty block, we have already sent // (10 - bi_valid) bits. The lookahead for the last real code (before // the EOB of the previous block) was thus at least one plus the length // of the EOB plus what we have just sent of the empty static block. if (1 + last_eob_len + 10 - bi_valid < 9) { send_bits(STATIC_TREES<<1, 3); send_code(END_BLOCK, StaticTree.static_ltree); bi_flush(); } last_eob_len = 7; }
void copy_block(int buf, // the input data int len, // its length boolean header // true if block header must be written ){ int index=0; bi_windup(); // align on byte boundary last_eob_len = 8; // enough lookahead for inflate if (header) { put_short((short)len); put_short((short)~len); } // while(len--!=0) { // put_byte(window[buf+index]); // index++; // } put_byte(window, buf, len); }
void _tr_stored_block(int buf, // input block int stored_len, // length of input block boolean eof // true if this is the last block for a file ){ send_bits((STORED_BLOCK<<1)+(eof?1:0), 3); // send block type copy_block(buf, stored_len, true); // with header }
if(data_type == Z_UNKNOWN) set_data_type(); max_blindex=build_bl_tree(); _tr_stored_block(buf, stored_len, eof); send_bits((STATIC_TREES<<1)+(eof?1:0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); send_bits((DYN_TREES<<1)+(eof?1:0), 3); send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1); compress_block(dyn_ltree, dyn_dtree); init_block(); bi_windup();
fill_window(); if(lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH){ return NeedMore; match_length=longest_match (hash_head); bflush=_tr_tally(strstart-match_start, match_length-MIN_MATCH); bflush=_tr_tally(0, window[strstart]&0xff); lookahead--; strstart++; flush_block_only(false); if(strm.avail_out==0) return NeedMore; flush_block_only(flush == Z_FINISH); if(strm.avail_out==0){ if(flush == Z_FINISH) return FinishStarted;
getGZIPHeader().put(this); status=BUSY_STATE; strm.adler.reset(); putShortMSB(header); putShortMSB((int)(adler>>>16)); putShortMSB((int)(adler&0xffff)); switch(config_table[level].func){ case STORED: bstate = deflate_stored(flush); break; case FAST: bstate = deflate_fast(flush); break; case SLOW: bstate = deflate_slow(flush); break; default: _tr_align(); _tr_stored_block(0, 0, false); put_byte((byte)(adler&0xff)); put_byte((byte)((adler>>8)&0xff)); put_byte((byte)((adler>>16)&0xff)); put_byte((byte)((adler>>24)&0xff));
putShortMSB(header); putShortMSB((int)(strm.adler>>>16)); putShortMSB((int)(strm.adler&0xffff)); switch(config_table[level].func){ case STORED: bstate = deflate_stored(flush); break; case FAST: bstate = deflate_fast(flush); break; case SLOW: bstate = deflate_slow(flush); break; default: _tr_align(); _tr_stored_block(0, 0, false); putShortMSB((int)(strm.adler>>>16)); putShortMSB((int)(strm.adler&0xffff)); strm.flush_pending();
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(); }
if(data_type == Z_UNKNOWN) set_data_type(); max_blindex=build_bl_tree(); _tr_stored_block(buf, stored_len, eof); send_bits((STATIC_TREES<<1)+(eof?1:0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); send_bits((DYN_TREES<<1)+(eof?1:0), 3); send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1); compress_block(dyn_ltree, dyn_dtree); init_block(); bi_windup();
fill_window(); if(lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH){ return NeedMore; match_length=longest_match (hash_head); bflush=_tr_tally(strstart-match_start, match_length-MIN_MATCH); bflush=_tr_tally(0, window[strstart]&0xff); lookahead--; strstart++; flush_block_only(false); if(strm.avail_out==0) return NeedMore; flush_block_only(flush == Z_FINISH); if(strm.avail_out==0){ if(flush == Z_FINISH) return FinishStarted;
getGZIPHeader().put(this); status=BUSY_STATE; strm.adler.reset(); putShortMSB(header); putShortMSB((int)(adler>>>16)); putShortMSB((int)(adler&0xffff)); switch(config_table[level].func){ case STORED: bstate = deflate_stored(flush); break; case FAST: bstate = deflate_fast(flush); break; case SLOW: bstate = deflate_slow(flush); break; default: _tr_align(); _tr_stored_block(0, 0, false); put_byte((byte)(adler&0xff)); put_byte((byte)((adler>>8)&0xff)); put_byte((byte)((adler>>16)&0xff)); put_byte((byte)((adler>>24)&0xff));
putShortMSB(header); putShortMSB((int)(strm.adler>>>16)); putShortMSB((int)(strm.adler&0xffff)); switch(config_table[level].func){ case STORED: bstate = deflate_stored(flush); break; case FAST: bstate = deflate_fast(flush); break; case SLOW: bstate = deflate_slow(flush); break; default: _tr_align(); _tr_stored_block(0, 0, false); putShortMSB((int)(strm.adler>>>16)); putShortMSB((int)(strm.adler&0xffff)); strm.flush_pending();
void _tr_stored_block(int buf, // input block int stored_len, // length of input block boolean eof // true if this is the last block for a file ){ send_bits((STORED_BLOCK<<1)+(eof?1:0), 3); // send block type copy_block(buf, stored_len, true); // with header }
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(); }
if(data_type == Z_UNKNOWN) set_data_type(); max_blindex=build_bl_tree(); _tr_stored_block(buf, stored_len, eof); send_bits((STATIC_TREES<<1)+(eof?1:0), 3); compress_block(StaticTree.static_ltree, StaticTree.static_dtree); send_bits((DYN_TREES<<1)+(eof?1:0), 3); send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1); compress_block(dyn_ltree, dyn_dtree); init_block(); bi_windup();
fill_window(); if(lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH){ return NeedMore; match_length=longest_match (hash_head); bflush=_tr_tally(strstart-match_start, match_length-MIN_MATCH); bflush=_tr_tally(0, window[strstart]&0xff); lookahead--; strstart++; flush_block_only(false); if(strm.avail_out==0) return NeedMore; flush_block_only(flush == Z_FINISH); if(strm.avail_out==0){ if(flush == Z_FINISH) return FinishStarted;
getGZIPHeader().put(this); status=BUSY_STATE; strm.adler.reset(); putShortMSB(header); putShortMSB((int)(adler>>>16)); putShortMSB((int)(adler&0xffff)); switch(config_table[level].func){ case STORED: bstate = deflate_stored(flush); break; case FAST: bstate = deflate_fast(flush); break; case SLOW: bstate = deflate_slow(flush); break; default: _tr_align(); _tr_stored_block(0, 0, false); put_byte((byte)(adler&0xff)); put_byte((byte)((adler>>8)&0xff)); put_byte((byte)((adler>>16)&0xff)); put_byte((byte)((adler>>24)&0xff));
putShortMSB(header); putShortMSB((int)(strm.adler>>>16)); putShortMSB((int)(strm.adler&0xffff)); switch(config_table[level].func){ case STORED: bstate = deflate_stored(flush); break; case FAST: bstate = deflate_fast(flush); break; case SLOW: bstate = deflate_slow(flush); break; default: _tr_align(); _tr_stored_block(0, 0, false); putShortMSB((int)(strm.adler>>>16)); putShortMSB((int)(strm.adler&0xffff)); strm.flush_pending();
public int deflateInit(int level, int bits, boolean nowrap){ dstate=new Deflate(); return dstate.deflateInit(this, level, nowrap?-bits:bits); } public int deflate(int flush){