Add support for encoding lossy webp images with alpha channels#1971
Merged
JimBobSquarePants merged 9 commits intomasterfrom Feb 2, 2022
Merged
Add support for encoding lossy webp images with alpha channels#1971JimBobSquarePants merged 9 commits intomasterfrom
JimBobSquarePants merged 9 commits intomasterfrom
Conversation
| { | ||
| int width = image.Width; | ||
| int height = image.Height; | ||
| IMemoryOwner<byte> alphaData = ExtractAlphaChannel(image, configuration, memoryAllocator); |
Member
There was a problem hiding this comment.
I can't see where this is getting disposed?
Collaborator
Author
There was a problem hiding this comment.
Its done in the Dispose of the Vp8Encoder
Collaborator
Author
There was a problem hiding this comment.
Maybe it would be better to keep the responsibility of disposing to the AlphaEncoder instead?
Member
There was a problem hiding this comment.
Yeah, I think that's wise. Difficult to keep track of otherwise.
gfoidl
reviewed
Feb 1, 2022
| private readonly int[] scratch = new int[16]; | ||
| private readonly bool alphaCompression; | ||
|
|
||
| private readonly byte[] averageBytesPerMb = { 50, 24, 16, 9, 7, 5, 3, 2 }; |
Contributor
There was a problem hiding this comment.
Suggested change
| private readonly byte[] averageBytesPerMb = { 50, 24, 16, 9, 7, 5, 3, 2 }; | |
| // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. | |
| private static ReadOnlySpan<byte> AverageBytesPerMb => new byte[] { 50, 24, 16, 9, 7, 5, 3, 2 }; |
While you're on it.
Need to update
to new name too.
JimBobSquarePants
approved these changes
Feb 2, 2022
Member
JimBobSquarePants
left a comment
There was a problem hiding this comment.
LGTM. Thanks for pushing this through so quickly!
Closed
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.
Prerequisites
Description
This PR adds support for encoding lossy webp images with alpha channels.
The alpha data can be either compressed (with webp lossless compression) or uncompressed.
Related to #1802