lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# Send the block data compressed using the given Huffman trees
Send the block data compressed using the given Huffman trees
Send the block data compressed using the given Huffman trees
def compress_block(s,ltree,dtree)
    lx = 0
    if s.last_lit != 0
      loop do
        dist = s.d_buf[lx]
        lc = s.l_buf[lx]
        lx+=1
        if dist == 0
          send_bits(s, ltree[lc].fc, ltree[lc].dl)
        else
          code = @@_length_code[lc]
          send_bits(s, ltree[code+LITERALS+1].fc, ltree[code+LITERALS+1].dl)
          extra = @@extra_lbits[code]
          if extra != 0
            lc -= @@base_length[code]
            send_bits(s, lc, extra)
          end
          dist-=1
          code = (dist < 256) ? @@_dist_code[dist] : @@_dist_code[256+(dist >> 7)]
          send_bits(s, dtree[code].fc, dtree[code].dl)
          extra = @@extra_dbits[code]
          if extra != 0
            dist-= @@base_dist[code]
            send_bits(s, dist, extra)
          end
        end
        break if (lx >= s.last_lit)
      end
    end
    send_bits(s, ltree[END_BLOCK].fc, ltree[END_BLOCK].dl)
    s.last_eob_len = ltree[END_BLOCK].dl
  end
def compress_block ( s , ltree , dtree ) lx = 0 if s . last_lit != 0 loop do dist = s . d_buf [ lx ] lc = s . l_buf [ lx ] lx += 1 if dist == 0 send_bits ( s , ltree [ lc ] . fc , ltree [ lc ] . dl ) else code = @@_length_code [ lc ] send_bits ( s , ltree [ code + LITERALS + 1 ] . fc , ltree [ code + LITERALS + 1 ] . dl ) extra = @@extra_lbits [ code ] if extra != 0 lc -= @@base_length [ code ] send_bits ( s , lc , extra ) end dist -= 1 code = ( dist < 256 ) ? @@_dist_code [ dist ] : @@_dist_code [ 256 + ( dist >> 7 ) ] send_bits ( s , dtree [ code ] . fc , dtree [ code ] . dl ) extra = @@extra_dbits [ code ] if extra != 0 dist -= @@base_dist [ code ] send_bits ( s , dist , extra ) end end break if ( lx >= s . last_lit ) end end send_bits ( s , ltree [ END_BLOCK ] . fc , ltree [ END_BLOCK ] . dl ) s . last_eob_len = ltree [ END_BLOCK ] . dl end
Send the block data compressed using the given Huffman trees
Send the block data compressed using the given Huffman trees
s
<not_specific>
ltree
<not_specific>
dtree
<not_specific>