Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LFS_MINSUM oddities #147

Open
runewalsh opened this issue Apr 4, 2021 · 0 comments
Open

LFS_MINSUM oddities #147

runewalsh opened this issue Apr 4, 2021 · 0 comments

Comments

@runewalsh
Copy link

runewalsh commented Apr 4, 2021

sum += s < 128 ? s : (255U - s);

Taking abs((int8_t)s) straightly will yield 256 - s, not 255 - s. With 255, the absolute values of the negative numbers become off by one from what they should be. Also, for me, 256 behaves more often better than not: resulting PNGs are consistently smaller by several ppm. Was there any source for 255?

While we at it, it doesn't look like libpng prevents filter 0 (FILTER_NONE) from being analyzed by the minimal-sum-of-absolute-differences heuristic on a general basis, like you do. At least, if you turn a bunch of low-variation samples from [−1; 1] with the mean of 0 into an image by remapping them to [0; 255], it can fit it nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant