Browse Source

Scale alpha and uv alpha by total number of macroblocks

pull/1552/head
Brian Popow 6 years ago
parent
commit
1a005bd97a
  1. 3
      src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs

3
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 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]; var alphas = new int[WebPConstants.MaxAlpha + 1];
this.alpha = this.MacroBlockAnalysis(width, height, it, y, u, v, yStride, uvStride, alphas, out this.uvAlpha); 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. // Analysis is done, proceed to actual encoding.
this.segmentHeader = new Vp8EncSegmentHeader(4); this.segmentHeader = new Vp8EncSegmentHeader(4);

Loading…
Cancel
Save