Skip to content

Replace ColorTree with a more performant ColorMap.#197

Open
runewalsh wants to merge 1 commit into
lvandeve:masterfrom
runewalsh:master
Open

Replace ColorTree with a more performant ColorMap.#197
runewalsh wants to merge 1 commit into
lvandeve:masterfrom
runewalsh:master

Conversation

@runewalsh

Copy link
Copy Markdown

5 years ago I tried translating LodePNG to Pascal for easier use in my projects and during that found a few ways to significantly speed up certain scenarios, so maybe over the next 5 years I’ll translate them back if you like it and your specific solutions didn’t have non-obvious reasons that I might have missed. :D

This MR changes ColorTree to a static 512-cell hash table. I don't think ColorTree makes any sense; even if you intended to find the nearest colors or so, you’d need something else.

My effect on this image (RGB8):

Yangyang

is just reducing the amount of lodepng_(m|re)alloc calls during lodepng_encode from 1952 to 587.

Effect on (re-)encoding this image, however (8-bit palette):

Ef

is speeding up lodepng_encode by 30% (16 to 21.3 MP/s), in addition to reducing the number of allocations from 3497 to 547. IIRC using an actual zlib makes lodepng_compute_color_stats dominate the compression itself and leads to much larger relative savings, but I’m lazy to check exactly.

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

Successfully merging this pull request may close these issues.

1 participant