Browse Source
Merge branch 'main' into js/format-conversion
pull/2751/head
James Jackson-South
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
25 additions and
2 deletions
-
src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs
-
tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Webp/issues/Issue2763.png
|
|
|
@ -696,6 +696,8 @@ internal class Vp8LEncoder : IDisposable |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
histogramImageSize = maxIndex; |
|
|
|
|
|
|
|
this.bitWriter.PutBits((uint)(this.HistoBits - 2), 3); |
|
|
|
this.EncodeImageNoHuffman( |
|
|
|
histogramBgra, |
|
|
|
@ -711,7 +713,7 @@ internal class Vp8LEncoder : IDisposable |
|
|
|
// Store Huffman codes.
|
|
|
|
// Find maximum number of symbols for the huffman tree-set.
|
|
|
|
int maxTokens = 0; |
|
|
|
for (int i = 0; i < 5 * histogramImage.Count; i++) |
|
|
|
for (int i = 0; i < 5 * histogramImageSize; i++) |
|
|
|
{ |
|
|
|
HuffmanTreeCode codes = huffmanCodes[i]; |
|
|
|
if (maxTokens < codes.NumSymbols) |
|
|
|
@ -726,7 +728,7 @@ internal class Vp8LEncoder : IDisposable |
|
|
|
tokens[i] = new HuffmanTreeToken(); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 5 * histogramImage.Count; i++) |
|
|
|
for (int i = 0; i < 5 * histogramImageSize; i++) |
|
|
|
{ |
|
|
|
HuffmanTreeCode codes = huffmanCodes[i]; |
|
|
|
this.StoreHuffmanCode(huffTree, tokens, codes); |
|
|
|
|
|
|
|
@ -499,6 +499,23 @@ public class WebpEncoderTests |
|
|
|
image.VerifyEncoder(provider, "webp", string.Empty, encoder, ImageComparer.Tolerant(0.04f)); |
|
|
|
} |
|
|
|
|
|
|
|
// https://github.com/SixLabors/ImageSharp/issues/2763
|
|
|
|
[Theory] |
|
|
|
[WithFile(Lossy.Issue2763, PixelTypes.Rgba32)] |
|
|
|
public void WebpDecoder_CanDecode_Issue2763<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
WebpEncoder encoder = new() |
|
|
|
{ |
|
|
|
Quality = 84, |
|
|
|
FileFormat = WebpFileFormatType.Lossless |
|
|
|
}; |
|
|
|
|
|
|
|
using Image<TPixel> image = provider.GetImage(PngDecoder.Instance); |
|
|
|
image.DebugSave(provider); |
|
|
|
image.VerifyEncoder(provider, "webp", string.Empty, encoder); |
|
|
|
} |
|
|
|
|
|
|
|
public static void RunEncodeLossy_WithPeakImage() |
|
|
|
{ |
|
|
|
TestImageProvider<Rgba32> provider = TestImageProvider<Rgba32>.File(TestImageLossyFullPath); |
|
|
|
|
|
|
|
@ -823,6 +823,7 @@ public static class TestImages |
|
|
|
public const string Issue2243 = "Webp/issues/Issue2243.webp"; |
|
|
|
public const string Issue2257 = "Webp/issues/Issue2257.webp"; |
|
|
|
public const string Issue2670 = "Webp/issues/Issue2670.webp"; |
|
|
|
public const string Issue2763 = "Webp/issues/Issue2763.png"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:eb221c5045e9bcbfdb7f4704aa571d910ca0d382fe4748319fe56f4c8c2aab78 |
|
|
|
size 429101 |