mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
Change the logic adjusting the Histogram bits.
Updated the logic to limit the Histogram size to a constant, instead of computing the same based on the Histogram size (that's variable size based on the cache bits) for the maximum possible cache bits. The actual cache bits may be lower than the maximum. Note: The constant 2600 is 16MB/Sizeof(HistogramSize(MAX_COLOR_CACHE_BITS)). The compression density remains the same with this change, with little faster compression speed. Change-Id: I3149894962852e9dad2501b9aa16bb847a20fd86
This commit is contained in:
parent
53b096c0d7
commit
919220c7e6
@ -25,7 +25,8 @@
|
||||
#include "../webp/format_constants.h"
|
||||
|
||||
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer.
|
||||
#define MAX_HUFF_IMAGE_SIZE (16 * 1024 * 1024)
|
||||
// Maximum number of histogram images (sub-blocks).
|
||||
#define MAX_HUFF_IMAGE_SIZE 2600
|
||||
#define MAX_COLORS_FOR_GRAPH 64
|
||||
|
||||
#define OPTIMIZE_MIN_NUM_COLORS 8
|
||||
@ -263,13 +264,12 @@ static int AnalyzeSubtractGreen(const uint32_t* const argb,
|
||||
}
|
||||
|
||||
static int GetHistoBits(int method, int use_palette, int width, int height) {
|
||||
const int hist_size = VP8LGetHistogramSize(MAX_COLOR_CACHE_BITS);
|
||||
// Make tile size a function of encoding method (Range: 0 to 6).
|
||||
int histo_bits = (use_palette ? 9 : 7) - method;
|
||||
while (1) {
|
||||
const int huff_image_size = VP8LSubSampleSize(width, histo_bits) *
|
||||
VP8LSubSampleSize(height, histo_bits);
|
||||
if ((uint64_t)huff_image_size * hist_size <= MAX_HUFF_IMAGE_SIZE) break;
|
||||
if (huff_image_size <= MAX_HUFF_IMAGE_SIZE) break;
|
||||
++histo_bits;
|
||||
}
|
||||
return (histo_bits < MIN_HUFFMAN_BITS) ? MIN_HUFFMAN_BITS :
|
||||
|
Loading…
Reference in New Issue
Block a user