Avoid stack-heavy Huffman optimization for fixed deflate blocks - #310
Closed
xiaobai050 wants to merge 1 commit into
Closed
xiaobai050 wants to merge 1 commit into
xiaobai050 wants to merge 1 commit into
Conversation
Contributor
|
Thank you for this. The fixed codes match RFC 1951, and on the host the compressor gives byte-identical output before and after the change (static and dynamic blocks, 168 inputs). The files under One note on the effect: the peak stack of the built-in |
lovyan03
pushed a commit
that referenced
this pull request
Sep 28, 2026
From lovyan03/LovyanGFX#943 (originally #310 by xiaobai050).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Construct RFC 1951 fixed literal/length and distance Huffman codes directly when starting a static deflate block. The generic optimizer is still used for dynamic blocks.
The fixed codes are predetermined by the format, but
tdefl_start_static_block()currently callstdefl_optimize_huffman_table()twice. In an ESP-IDF build this call path had a 5,584-byte stack frame, even withstatic_table=true, which made PNG snapshot compression expensive on a small UI task stack. The code tables already live intdefl_compressor; this change fills them using scalar locals and reverses each code for the deflate bit order.Validation