예제 #1
0
    void deflate_start(int level)
    {
        if(level==0)
            level=DEFAULT_LEVEL;
        else if(level<1)
            level=1;
        else if(level>9)
            level=9;

        this.compr_level=level;
        this.initflag=false;
        this.eofile=false;
        if(outbuf!=null)return;

        this.free_queue=this.qhead=this.qtail=null;
        this.outbuf=new byte[OUTBUFSIZ];
        this.win=new byte[window_size];
        this.d_buf=new int[DIST_BUFSIZE];
        this.l_buf=new int[INBUFSIZ+INBUF_EXTRA];
        this.prev=new int[1<<BITS];

        this.dyn_ltree=new_ctarray(HEAP_SIZE);
        this.dyn_dtree=new_ctarray(2*D_CODES+1);
        this.static_ltree=new_ctarray(L_CODES+2);
        this.static_dtree=new_ctarray(D_CODES);
        this.bl_tree=new_ctarray(2*BL_CODES+1);

        this.l_desc=new DeflateTreeDesc();
        this.d_desc=new DeflateTreeDesc();
        this.bl_desc=new DeflateTreeDesc();
        this.bl_count=new int[MAX_BITS+1];
        this.heap=new int[2*L_CODES+1];
        this.depth=new int[2*L_CODES+1];
        this.length_code=new int[MAX_MATCH-MIN_MATCH+1];
        this.dist_code=new int[512];
        this.base_length=new int[LENGTH_CODES];
        this.base_dist=new int[D_CODES];
        this.flag_buf=new int[LIT_BUFSIZE/8];
    }
예제 #2
0
 /*
 function deflate_end(){
     free_queue=qhead=qtail=null;
     outbuf=null;
     win=null;
     d_buf=null;
     l_buf=null;
     prev=null;
     dyn_ltree=null;
     dyn_dtree=null;
     static_ltree=null;
     static_dtree=null;
     bl_tree=null;
     l_desc=null;
     d_desc=null;
     bl_desc=null;
     bl_count=null;
     heap=null;
     depth=null;
     length_code=null;
     dist_code=null;
     base_length=null;
     base_dist=null;
     flag_buf=null;
 }
 //*/
 void reuse_queue(DeflateBuffer p)
 {
     p.next=free_queue;
     free_queue=p;
 }
예제 #3
0
 void qoutbuf()
 {
     if(outcnt!=0){
         DeflateBuffer q=new_queue();
         if(qhead==null)
             qhead=qtail=q;
         else{
             qtail=qtail.next=q;
         }
         q.len=outcnt-outoff;
     //      System.arraycopy(outbuf,outoff,q.ptr,0,q.len);
         for(int i=0;i<q.len;i++)
             q.ptr[i]=outbuf[outoff+i];
         outcnt=outoff=0;
     }
 }
예제 #4
0
    int qcopy(byte[] buff,int off,int buff_size)
    {
        int n,i,j;

        n=0;
        while(qhead!=null&&n<buff_size){
            i=buff_size-n;
            if(i>qhead.len)i=qhead.len;
        //      System.arraycopy(qhead.ptr,qhead.off,buff,off+n,i);
            for(j=0;j<i;j++)buff[off+n+j]=qhead.ptr[qhead.off+j];

            qhead.off+=i;
            qhead.len-=i;
            n+=i;
            if(qhead.len==0){
                DeflateBuffer p=qhead;
                qhead=qhead.next;
                reuse_queue(p);
            }
        }

        if(n==buff_size)return n;

        if(outoff<outcnt){
            i=buff_size-n;
            if(i>outcnt-outoff)i=outcnt-outoff;
            // System.arraycopy(outbuf,outoff,buff,off+n,i);
            for(j=0;j<i;j++)buff[off+n+j]=outbuf[outoff+j];
            outoff+=i;
            n+=i;
            if(outcnt==outoff)outcnt=outoff=0;
        }
        return n;
    }
예제 #5
0
    DeflateBuffer new_queue()
    {
        DeflateBuffer p;

        if(free_queue!=null){
            p=this.free_queue;
            this.free_queue=free_queue.next;
        }else{
            p=new DeflateBuffer();
        }
        p.next=null;
        p.len=p.off=0;

        return p;
    }
예제 #6
0
    void init_deflate()
    {
        if(eofile)return;
        bi_buf=0;
        bi_valid=0;
        ct_init();
        lm_init();

        qhead=null;
        outcnt=0;
        outoff=0;

        if(compr_level<=3){
            prev_length=MIN_MATCH-1;
            match_length=0;
        }else{
            match_length=MIN_MATCH-1;
            match_available=0;
        }

        complete=false;
    }