Reduce the number of memory allocations in lossless WebP encoder#2940
Merged
JimBobSquarePants merged 8 commits intoSixLabors:mainfrom Jun 13, 2025
Merged
Reduce the number of memory allocations in lossless WebP encoder#2940JimBobSquarePants merged 8 commits intoSixLabors:mainfrom
JimBobSquarePants merged 8 commits intoSixLabors:mainfrom
Conversation
Member
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Just a quick read so far but looking good. I'll have to pull it down to review properly.
| { | ||
| PixOrCopy v = backwardRefsEnumerator.Current; | ||
| int ix = ((y >> histoBits) * histoXSize) + (x >> histoBits); | ||
| histograms[ix].AddSinglePixOrCopy(v, false); |
Member
There was a problem hiding this comment.
This method could be updated to take the struct via in to avoid the copy.
Contributor
Author
There was a problem hiding this comment.
I've made the change. But if there is any performance difference, it's hard to notice. The structure is not that big.
antonfirsov
approved these changes
Jun 11, 2025
Member
antonfirsov
left a comment
There was a problem hiding this comment.
Looks good after skimming through all changes.
Member
|
I'm thinking of backporting this to V3. @antonfirsov what do you think? |
Member
|
The change looks simple and safe enough to backport. |
Member
|
Thanks for this @SladeThe it's very much appreciated!! |
JimBobSquarePants
added a commit
that referenced
this pull request
Jun 13, 2025
4 tasks
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.
This PR closes #2934
The results of benchmark
#55 EncodeWebp:Before
After
Pin the refs (without the capacity guard)