From 1a005bd97a755db6dc13bce6d0b87a473c570098 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 11 Nov 2020 16:50:53 +0100 Subject: [PATCH] Scale alpha and uv alpha by total number of macroblocks --- src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs index 3853e56e46..ed18bc6700 100644 --- a/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs @@ -379,6 +379,9 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossy var it = new Vp8EncIterator(this.YTop, this.UvTop, this.Nz, this.mbInfo, this.Preds, this.TopDerr, this.mbw, this.mbh); var alphas = new int[WebPConstants.MaxAlpha + 1]; this.alpha = this.MacroBlockAnalysis(width, height, it, y, u, v, yStride, uvStride, alphas, out this.uvAlpha); + int totalMb = this.mbw * this.mbw; + this.alpha = this.alpha / totalMb; + this.uvAlpha = this.uvAlpha / totalMb; // Analysis is done, proceed to actual encoding. this.segmentHeader = new Vp8EncSegmentHeader(4);