diff --git a/src/ImageSharp/Formats/WebP/LoopFilter.cs b/src/ImageSharp/Formats/WebP/LoopFilter.cs
index e48d89cea2..8330ca593f 100644
--- a/src/ImageSharp/Formats/WebP/LoopFilter.cs
+++ b/src/ImageSharp/Formats/WebP/LoopFilter.cs
@@ -3,12 +3,24 @@
namespace SixLabors.ImageSharp.Formats.WebP
{
+ ///
+ /// Enum for the different loop filters used. VP8 supports two types of loop filters.
+ ///
internal enum LoopFilter
{
+ ///
+ /// No filter is used.
+ ///
None = 0,
+ ///
+ /// Simple loop filter.
+ ///
Simple = 1,
+ ///
+ /// Complex loop filter.
+ ///
Complex = 2,
}
}
diff --git a/src/ImageSharp/Formats/WebP/Vp8Decoder.cs b/src/ImageSharp/Formats/WebP/Vp8Decoder.cs
index 8de3144f6e..91a508b960 100644
--- a/src/ImageSharp/Formats/WebP/Vp8Decoder.cs
+++ b/src/ImageSharp/Formats/WebP/Vp8Decoder.cs
@@ -10,6 +10,13 @@ namespace SixLabors.ImageSharp.Formats.WebP
{
private Vp8MacroBlock leftMacroBlock;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The frame header.
+ /// The picture header.
+ /// The segment header.
+ /// The probabilities.
public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp8SegmentHeader segmentHeader, Vp8Proba probabilities)
{
this.FilterHeader = new Vp8FilterHeader();
@@ -18,7 +25,6 @@ namespace SixLabors.ImageSharp.Formats.WebP
this.SegmentHeader = segmentHeader;
this.Probabilities = probabilities;
this.IntraL = new byte[4];
- this.YuvBuffer = new byte[2000]; // new byte[(WebPConstants.Bps * 17) + (WebPConstants.Bps * 9)];
this.MbWidth = (int)((this.PictureHeader.Width + 15) >> 4);
this.MbHeight = (int)((this.PictureHeader.Height + 15) >> 4);
this.CacheYStride = 16 * this.MbWidth;
@@ -52,15 +58,16 @@ namespace SixLabors.ImageSharp.Formats.WebP
uint height = pictureHeader.Height;
// TODO: use memory allocator
- int extraRows = WebPConstants.FilterExtraRows[2]; // TODO: assuming worst case: complex filter
+ int extraRows = WebPConstants.FilterExtraRows[(int)LoopFilter.Complex]; // assuming worst case: complex filter
int extraY = extraRows * this.CacheYStride;
int extraUv = (extraRows / 2) * this.CacheUvStride;
- this.CacheY = new byte[(width * height) + extraY + 256]; // TODO: this is way too much mem, figure out what the min req is.
- this.CacheU = new byte[(width * height) + extraUv + 256];
- this.CacheV = new byte[(width * height) + extraUv + 256];
- this.TmpYBuffer = new byte[(width * height) + extraY]; // TODO: figure out min buffer length
- this.TmpUBuffer = new byte[(width * height) + extraUv]; // TODO: figure out min buffer length
- this.TmpVBuffer = new byte[(width * height) + extraUv]; // TODO: figure out min buffer length
+ this.YuvBuffer = new byte[(WebPConstants.Bps * 17) + (WebPConstants.Bps * 9) + extraY];
+ this.CacheY = new byte[(16 * this.CacheYStride) + extraY];
+ this.CacheU = new byte[(16 * this.CacheUvStride) + extraUv];
+ this.CacheV = new byte[(16 * this.CacheUvStride) + extraUv];
+ this.TmpYBuffer = new byte[width];
+ this.TmpUBuffer = new byte[width];
+ this.TmpVBuffer = new byte[width];
this.Pixels = new byte[width * height * 4];
for (int i = 0; i < this.YuvBuffer.Length; i++)
@@ -82,12 +89,24 @@ namespace SixLabors.ImageSharp.Formats.WebP
this.Vp8BitReaders = new Vp8BitReader[WebPConstants.MaxNumPartitions];
}
+ ///
+ /// Gets the frame header.
+ ///
public Vp8FrameHeader FrameHeader { get; }
+ ///
+ /// Gets the picture header.
+ ///
public Vp8PictureHeader PictureHeader { get; }
+ ///
+ /// Gets the filter header.
+ ///
public Vp8FilterHeader FilterHeader { get; }
+ ///
+ /// Gets the segment header.
+ ///
public Vp8SegmentHeader SegmentHeader { get; }
///
@@ -110,8 +129,14 @@ namespace SixLabors.ImageSharp.Formats.WebP
///
public bool UseSkipProbability { get; set; }
+ ///
+ /// Gets or sets the skip probability.
+ ///
public byte SkipProbability { get; set; }
+ ///
+ /// Gets or sets the Probabilities.
+ ///
public Vp8Proba Probabilities { get; set; }
///
@@ -174,8 +199,15 @@ namespace SixLabors.ImageSharp.Formats.WebP
///
public Vp8MacroBlock[] MacroBlockInfo { get; }
+ ///
+ /// Gets or sets the loop filter used. The purpose of the loop filter is to eliminate (or at least reduce)
+ /// visually objectionable artifacts.
+ ///
public LoopFilter Filter { get; set; }
+ ///
+ /// Gets or sets the filter strengths.
+ ///
public Vp8FilterInfo[,] FilterStrength { get; }
public byte[] YuvBuffer { get; }
diff --git a/src/ImageSharp/Formats/WebP/Vp8Io.cs b/src/ImageSharp/Formats/WebP/Vp8Io.cs
index 36b561847b..feb763129f 100644
--- a/src/ImageSharp/Formats/WebP/Vp8Io.cs
+++ b/src/ImageSharp/Formats/WebP/Vp8Io.cs
@@ -27,12 +27,12 @@ namespace SixLabors.ImageSharp.Formats.WebP
public int MbY { get; set; }
///
- /// Gets or sets the macroblock width.
+ /// Gets or sets number of columns in the sample.
///
public int MbW { get; set; }
///
- /// Gets or sets the macroblock height.
+ /// Gets or sets number of rows in the sample.
///
public int MbH { get; set; }