double ZopfliCalculateBlockSizeAutoType(const ZopfliLZ77Store* lz77, size_t lstart, size_t lend) { double uncompressedcost = ZopfliCalculateBlockSize(lz77, lstart, lend, 0); /* Don't do the expensive fixed cost calculation for larger blocks that are unlikely to use it. */ double fixedcost = (lz77->size > 1000) ? uncompressedcost : ZopfliCalculateBlockSize(lz77, lstart, lend, 1); double dyncost = ZopfliCalculateBlockSize(lz77, lstart, lend, 2); return (uncompressedcost < fixedcost && uncompressedcost < dyncost) ? uncompressedcost : (fixedcost < dyncost ? fixedcost : dyncost); }
/* Returns estimated cost of a block in bits. It includes the size to encode the tree and the size to encode all literal, length and distance symbols and their extra bits. litlens: lz77 lit/lengths dists: ll77 distances lstart: start of block lend: end of block (not inclusive) */ static double EstimateCost(const unsigned short* litlens, const unsigned short* dists, size_t lstart, size_t lend, int ohh) { return ZopfliCalculateBlockSize(litlens, dists, lstart, lend, 2, ohh); }