Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code always tends to get messy over time. I've found the `optimize_raw` function increasingly harder to read, particularly after the addition of fast mode, so I've taken some time to refactor and simplify it. One change of note here is the main compression trials now use the Evaluator. This means verbose output is a little different which is shown below. There is no change to performance or output size. `-vvo2`: master ``` Processing: tests/files/rgba_8_should_be_palette_4.png 500x400 pixels, PNG format 8-bit RGB + Alpha, non-interlaced IDAT size = 2757 bytes File size = 18109 bytes Eval: 4-bit Indexed (5 colors) None 1837 bytes Eval: 8-bit Indexed (5 colors) None 1988 bytes Eval: 4-bit Indexed (5 colors) Bigrams >1837 bytes Eval: 8-bit Indexed (5 colors) Bigrams >1837 bytes Transformed image to 4-bit Indexed (5 colors), non-interlaced Evaluating: 2 filters Eval: 4-bit Indexed (5 colors) Sub >1810 bytes Eval: 4-bit Indexed (5 colors) Entropy >1810 bytes Trying: None zc = 11 f = None 1583 bytes Found better combination: zc = 11 f = None 1583 bytes IDAT size = 1583 bytes (1174 bytes decrease) file size = 16962 bytes (1147 bytes = 6.33% decrease) 16962 bytes (6.33% smaller): Running in pretend mode, no output ``` `-vvo2`: PR ``` Processing: tests/files/rgba_8_should_be_palette_4.png 500x400 pixels, PNG format 8-bit RGB + Alpha, non-interlaced IDAT size = 2757 bytes File size = 18109 bytes Eval: 4-bit Indexed (5 colors) None 1837 bytes Eval: 8-bit Indexed (5 colors) None 1988 bytes Eval: 4-bit Indexed (5 colors) Bigrams >1837 bytes Eval: 8-bit Indexed (5 colors) Bigrams >1837 bytes Transformed image to 4-bit Indexed (5 colors), non-interlaced Evaluating 2 filters Eval: 4-bit Indexed (5 colors) Sub >1810 bytes Eval: 4-bit Indexed (5 colors) Entropy >1810 bytes Trying filter None with zc = 11 1610 bytes Found better result: zc = 11, f = None IDAT size = 1583 bytes (1174 bytes decrease) file size = 16962 bytes (1147 bytes = 6.33% decrease) 16962 bytes (6.33% smaller): Running in pretend mode, no output ``` `-vvZo5`: master ``` Processing: tests/files/rgba_8_should_be_palette_4.png 500x400 pixels, PNG format 8-bit RGB + Alpha, non-interlaced IDAT size = 2757 bytes File size = 18109 bytes Eval: 8-bit Indexed (battiato sort) None 1821 bytes Eval: 4-bit Indexed (5 colors) None 1657 bytes Eval: 8-bit Indexed (mzeng sort) None 1821 bytes Eval: 8-bit Indexed (5 colors) None 1821 bytes Eval: 8-bit Indexed (battiato sort) Bigrams >1821 bytes Eval: 4-bit Indexed (5 colors) Bigrams >1657 bytes Eval: 8-bit Indexed (mzeng sort) Bigrams >1657 bytes Eval: 8-bit Indexed (5 colors) Bigrams >1657 bytes Transformed image to 4-bit Indexed (5 colors), non-interlaced Trying: 8 filters zc = zopfli f = Brute 1562 bytes zc = zopfli f = Sub >1562 bytes zc = zopfli f = Bigrams >1562 bytes zc = zopfli f = None 1407 bytes zc = zopfli f = Up >1407 bytes zc = zopfli f = MinSum >1407 bytes zc = zopfli f = BigEnt >1407 bytes zc = zopfli f = Entropy >1407 bytes Found better combination: zc = zopfli f = None 1407 bytes IDAT size = 1407 bytes (1350 bytes decrease) file size = 16786 bytes (1323 bytes = 7.31% decrease) 16786 bytes (7.31% smaller): Running in pretend mode, no output ``` `-vvZo5`: PR ``` Processing: tests/files/rgba_8_should_be_palette_4.png 500x400 pixels, PNG format 8-bit RGB + Alpha, non-interlaced IDAT size = 2757 bytes File size = 18109 bytes Eval: 8-bit Indexed (battiato sort) None 1821 bytes Eval: 4-bit Indexed (5 colors) None 1657 bytes Eval: 8-bit Indexed (mzeng sort) None 1821 bytes Eval: 8-bit Indexed (5 colors) None 1821 bytes Eval: 8-bit Indexed (battiato sort) Bigrams >1657 bytes Eval: 4-bit Indexed (5 colors) Bigrams >1657 bytes Eval: 8-bit Indexed (mzeng sort) Bigrams >1657 bytes Eval: 8-bit Indexed (5 colors) Bigrams >1657 bytes Transformed image to 4-bit Indexed (5 colors), non-interlaced Trying 8 filters with zopfli, zi = 15 Eval: 4-bit Indexed (5 colors) Brute 1589 bytes Eval: 4-bit Indexed (5 colors) Bigrams 1641 bytes Eval: 4-bit Indexed (5 colors) Sub 1711 bytes Eval: 4-bit Indexed (5 colors) None 1434 bytes Eval: 4-bit Indexed (5 colors) Up 1764 bytes Eval: 4-bit Indexed (5 colors) MinSum 1760 bytes Eval: 4-bit Indexed (5 colors) BigEnt 1742 bytes Eval: 4-bit Indexed (5 colors) Entropy 1748 bytes Found better result: zopfli, zi = 15, f = None IDAT size = 1407 bytes (1350 bytes decrease) file size = 16786 bytes (1323 bytes = 7.31% decrease) 16786 bytes (7.31% smaller): Running in pretend mode, no output ```
- Loading branch information