rEFIt_UEFI/libeg/lodepng.cpp
/*
write the lz77-encoded data, which has lit, len and dist codes, to compressed stream using huffman trees.
tree_ll: the tree for lit and len codes.
tree_d: the tree for distance codes.
*/
write the lz77-encoded data, which has lit, len and dist codes, to compressed stream using huffman trees.
tree_ll: the tree for lit and len codes.
tree_d: the tree for distance codes.
write the lz77 - encoded data which has lit len and dist codes to compressed stream using huffman trees . tree_ll : the tree for lit and len codes . tree_d : the tree for distance codes .
static void writeLZ77data(LodePNGBitWriter* writer, const uivector* lz77_encoded,
                          const HuffmanTree* tree_ll, const HuffmanTree* tree_d) {
  size_t i = 0;
  for(i = 0; i != lz77_encoded->size; ++i) {
    unsigned val = lz77_encoded->data[i];
    writeBitsReversed(writer, tree_ll->codes[val], tree_ll->lengths[val]);
    if(val > 256)  {
      unsigned length_index = val - FIRST_LENGTH_CODE_INDEX;
      unsigned n_length_extra_bits = LENGTHEXTRA[length_index];
      unsigned length_extra_bits = lz77_encoded->data[++i];
      unsigned distance_code = lz77_encoded->data[++i];
      unsigned distance_index = distance_code;
      unsigned n_distance_extra_bits = DISTANCEEXTRA[distance_index];
      unsigned distance_extra_bits = lz77_encoded->data[++i];
      writeBits(writer, length_extra_bits, n_length_extra_bits);
      writeBitsReversed(writer, tree_d->codes[distance_code], tree_d->lengths[distance_code]);
      writeBits(writer, distance_extra_bits, n_distance_extra_bits);
    }
  }
}
static void writeLZ77data ( LodePNGBitWriter * writer , const uivector * lz77_encoded , const HuffmanTree * tree_ll , const HuffmanTree * tree_d ) { size_t i = 0 ; for ( i = 0 ; i != lz77_encoded -> size ; ++ i ) { unsigned val = lz77_encoded -> data [ i ] ; writeBitsReversed ( writer , tree_ll -> codes [ val ] , tree_ll -> lengths [ val ] ) ; if ( val > 256 ) { unsigned length_index = val - FIRST_LENGTH_CODE_INDEX ; unsigned n_length_extra_bits = LENGTHEXTRA [ length_index ] ; unsigned length_extra_bits = lz77_encoded -> data [ ++ i ] ; unsigned distance_code = lz77_encoded -> data [ ++ i ] ; unsigned distance_index = distance_code ; unsigned n_distance_extra_bits = DISTANCEEXTRA [ distance_index ] ; unsigned distance_extra_bits = lz77_encoded -> data [ ++ i ] ; writeBits ( writer , length_extra_bits , n_length_extra_bits ) ; writeBitsReversed ( writer , tree_d -> codes [ distance_code ] , tree_d -> lengths [ distance_code ] ) ; writeBits ( writer , distance_extra_bits , n_distance_extra_bits ) ; } } }
write the lz77-encoded data, which has lit, len and dist codes, to compressed stream using huffman trees.
write the lz77 - encoded data which has lit len and dist codes to compressed stream using huffman trees .
/*for a length code, 3 more things have to be added*/