diff --git a/src/ImageSharp/Formats/WebP/Vp8Decoder.cs b/src/ImageSharp/Formats/WebP/Vp8Decoder.cs
index 303fd1e467..5643b798b5 100644
--- a/src/ImageSharp/Formats/WebP/Vp8Decoder.cs
+++ b/src/ImageSharp/Formats/WebP/Vp8Decoder.cs
@@ -8,14 +8,128 @@ namespace SixLabors.ImageSharp.Formats.WebP
///
internal class Vp8Decoder
{
- public Vp8Decoder()
+ public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp8FilterHeader filterHeader, Vp8SegmentHeader segmentHeader, Vp8Proba probabilities, Vp8Io io)
{
+ this.FrameHeader = frameHeader;
+ this.PictureHeader = pictureHeader;
+ this.FilterHeader = filterHeader;
+ this.SegmentHeader = segmentHeader;
+ this.Probabilities = probabilities;
this.DeQuantMatrices = new Vp8QuantMatrix[WebPConstants.NumMbSegments];
this.FilterStrength = new Vp8FilterInfo[WebPConstants.NumMbSegments, 2];
+ this.IntraL = new byte[4];
+
+ this.Init(io);
}
+ public Vp8FrameHeader FrameHeader { get; }
+
+ public Vp8PictureHeader PictureHeader { get; }
+
+ public Vp8FilterHeader FilterHeader { get; }
+
+ public Vp8SegmentHeader SegmentHeader { get; }
+
+ public bool Dither { get; set; }
+
+ ///
+ /// Gets or sets dequantization matrices (one set of DC/AC dequant factor per segment).
+ ///
+ public Vp8QuantMatrix[] DeQuantMatrices { get; private set; }
+
+ public bool UseSkipProba { get; set; }
+
+ public byte SkipProbability { get; set; }
+
+ public Vp8Proba Probabilities { get; set; }
+
+ // top intra modes values: 4 * MbWidth
+ public byte[] IntraT { get; set; }
+
+ // left intra modes values
+ public byte[] IntraL { get; }
+
+ ///
+ /// Gets or sets the width in macroblock units.
+ ///
+ public int MbWidth { get; set; }
+
+ ///
+ /// Gets or sets the height in macroblock units.
+ ///
+ public int MbHeight { get; set; }
+
+ ///
+ /// Gets or sets the top-left x index of the macroblock that must be in-loop filtered.
+ ///
+ public int TopLeftMbX { get; set; }
+
+ ///
+ /// Gets or sets the top-left y index of the macroblock that must be in-loop filtered.
+ ///
+ public int TopLeftMbY { get; set; }
+
+ ///
+ /// Gets or sets the last bottom-right x index of the macroblock that must be decoded.
+ ///
+ public int BotomRightMbX { get; set; }
+
+ ///
+ /// Gets or sets the last bottom-right y index of the macroblock that must be decoded.
+ ///
+ public int BottomRightMbY { get; set; }
+
+ ///
+ /// Gets or sets the current x position in macroblock units.
+ ///
+ public int MbX { get; set; }
+
+ ///
+ /// Gets or sets the current y position in macroblock units.
+ ///
+ public int MbY { get; set; }
+
+ ///
+ /// Gets or sets the parsed reconstruction data.
+ ///
+ public Vp8MacroBlockData[] MacroBlockData { get; set; }
+
+ ///
+ /// Gets or sets contextual macroblock infos.
+ ///
+ public Vp8MacroBlock[] MacroBlockInfo { get; set; }
+
+ public int MacroBlockIdx { get; set; }
+
+ public LoopFilter Filter { get; set; }
+
+ public Vp8FilterInfo[,] FilterStrength { get; }
+
+ ///
+ /// Gets or sets filter strength info.
+ ///
+ public Vp8FilterInfo FilterInfo { get; set; }
+
public void Init(Vp8Io io)
{
+ this.MbWidth = (int)((this.PictureHeader.Width + 15) >> 4);
+ this.MbHeight = (int)((this.PictureHeader.Height + 15) >> 4);
+ int intraPredModeSize = 4 * this.MbWidth;
+ this.IntraT = new byte[intraPredModeSize];
+
+ io.Width = (int)this.PictureHeader.Width;
+ io.Height = (int)this.PictureHeader.Height;
+ io.UseCropping = false;
+ io.CropTop = 0;
+ io.CropLeft = 0;
+ io.CropRight = io.Width;
+ io.CropBottom = io.Height;
+ io.UseScaling = false;
+ io.ScaledWidth = io.Width;
+ io.ScaledHeight = io.ScaledHeight;
+ io.MbW = io.Width;
+ io.MbH = io.Height;
+
int extraPixels = WebPConstants.FilterExtraRows[(int)this.Filter];
if (this.Filter is LoopFilter.Complex)
{
@@ -128,94 +242,12 @@ namespace SixLabors.ImageSharp.Formats.WebP
}
else
{
- info.Limit = 0; // no filtering
+ info.Limit = 0; // no filtering.
}
info.InnerLevel = (byte)i4x4;
}
}
}
-
- public Vp8FrameHeader FrameHeader { get; set; }
-
- public Vp8PictureHeader PictureHeader { get; set; }
-
- public Vp8FilterHeader FilterHeader { get; set; }
-
- public Vp8SegmentHeader SegmentHeader { get; set; }
-
- public bool Dither { get; set; }
-
- ///
- /// Gets or sets dequantization matrices (one set of DC/AC dequant factor per segment).
- ///
- public Vp8QuantMatrix[] DeQuantMatrices { get; private set; }
-
- public bool UseSkipProba { get; set; }
-
- public byte SkipProbability { get; set; }
-
- public Vp8Proba Probabilities { get; set; }
-
- ///
- /// Gets or sets the width in macroblock units.
- ///
- public int MbWidth { get; set; }
-
- ///
- /// Gets or sets the height in macroblock units.
- ///
- public int MbHeight { get; set; }
-
- ///
- /// Gets or sets the top-left x index of the macroblock that must be in-loop filtered.
- ///
- public int TopLeftMbX { get; set; }
-
- ///
- /// Gets or sets the top-left y index of the macroblock that must be in-loop filtered.
- ///
- public int TopLeftMbY { get; set; }
-
- ///
- /// Gets or sets the last bottom-right x index of the macroblock that must be decoded.
- ///
- public int BotomRightMbX { get; set; }
-
- ///
- /// Gets or sets the last bottom-right y index of the macroblock that must be decoded.
- ///
- public int BottomRightMbY { get; set; }
-
- ///
- /// Gets or sets the current x position in macroblock units.
- ///
- public int MbX { get; set; }
-
- ///
- /// Gets or sets the current y position in macroblock units.
- ///
- public int MbY { get; set; }
-
- ///
- /// Gets or sets the parsed reconstruction data.
- ///
- public Vp8MacroBlockData[] MacroBlockData { get; set; }
-
- ///
- /// Gets or sets contextual macroblock infos.
- ///
- public Vp8MacroBlock[] MacroBlockInfo { get; set; }
-
- public int MacroBlockPos { get; set; }
-
- public LoopFilter Filter { get; set; }
-
- public Vp8FilterInfo[,] FilterStrength { get; }
-
- ///
- /// Gets or sets filter strength info.
- ///
- public Vp8FilterInfo FilterInfo { get; set; }
}
}
diff --git a/src/ImageSharp/Formats/WebP/Vp8Io.cs b/src/ImageSharp/Formats/WebP/Vp8Io.cs
index dfcf73a486..8ede28c085 100644
--- a/src/ImageSharp/Formats/WebP/Vp8Io.cs
+++ b/src/ImageSharp/Formats/WebP/Vp8Io.cs
@@ -62,6 +62,8 @@ namespace SixLabors.ImageSharp.Formats.WebP
///
public int UvStride { get; set; }
+ public bool UseCropping { get; set; }
+
public int CropLeft { get; set; }
public int CropRight { get; set; }
@@ -70,6 +72,12 @@ namespace SixLabors.ImageSharp.Formats.WebP
public int CropBottom { get; set; }
+ public bool UseScaling { get; set; }
+
+ public int ScaledWidth { get; set; }
+
+ public int ScaledHeight { get; set; }
+
///
/// User data
///
diff --git a/src/ImageSharp/Formats/WebP/Vp8MacroBlockData.cs b/src/ImageSharp/Formats/WebP/Vp8MacroBlockData.cs
index 35d8803af9..5dbeb2358b 100644
--- a/src/ImageSharp/Formats/WebP/Vp8MacroBlockData.cs
+++ b/src/ImageSharp/Formats/WebP/Vp8MacroBlockData.cs
@@ -8,6 +8,11 @@ namespace SixLabors.ImageSharp.Formats.WebP
///
internal class Vp8MacroBlockData
{
+ public Vp8MacroBlockData()
+ {
+ this.Modes = new byte[16];
+ }
+
///
/// Gets or sets the coefficient. 384 coeffs = (16+4+4) * 4*4.
///
@@ -21,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
///
/// Gets or sets the modes. One 16x16 mode (#0) or sixteen 4x4 modes.
///
- public byte Modes { get; set; }
+ public byte[] Modes { get; }
///
/// Gets or sets the chroma prediction mode.
diff --git a/src/ImageSharp/Formats/WebP/WebPConstants.cs b/src/ImageSharp/Formats/WebP/WebPConstants.cs
index 5db5a0bbc8..755b387e1e 100644
--- a/src/ImageSharp/Formats/WebP/WebPConstants.cs
+++ b/src/ImageSharp/Formats/WebP/WebPConstants.cs
@@ -121,6 +121,12 @@ namespace SixLabors.ImageSharp.Formats.WebP
public const int NumCtx = 3;
+ // intra prediction modes (TODO: maybe use an enum for this)
+ public const int DcPred = 0;
+ public const int TmPred = 1;
+ public const int VPred = 2;
+ public const int HPred = 3;
+
///
/// How many extra lines are needed on the MB boundary for caching, given a filtering level.
/// Simple filter: up to 2 luma samples are read and 1 is written.
@@ -183,6 +189,124 @@ namespace SixLabors.ImageSharp.Formats.WebP
public static readonly byte[] Cat6 = { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129 };
public static readonly byte[] Zigzag = { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 };
+ public static readonly sbyte[] YModesIntra4 =
+ {
+ -0, 1,
+ -1, 2,
+ -2, 3,
+ 4, 6,
+ -3, 5,
+ -4, -5,
+ -6, 7,
+ -7, 8,
+ -8, -9
+ };
+
+ // Paragraph 11.5
+ public static readonly byte[,,] BModesProba =
+ {
+ { { 231, 120, 48, 89, 115, 113, 120, 152, 112 },
+ { 152, 179, 64, 126, 170, 118, 46, 70, 95 },
+ { 175, 69, 143, 80, 85, 82, 72, 155, 103 },
+ { 56, 58, 10, 171, 218, 189, 17, 13, 152 },
+ { 114, 26, 17, 163, 44, 195, 21, 10, 173 },
+ { 121, 24, 80, 195, 26, 62, 44, 64, 85 },
+ { 144, 71, 10, 38, 171, 213, 144, 34, 26 },
+ { 170, 46, 55, 19, 136, 160, 33, 206, 71 },
+ { 63, 20, 8, 114, 114, 208, 12, 9, 226 },
+ { 81, 40, 11, 96, 182, 84, 29, 16, 36 } },
+ { { 134, 183, 89, 137, 98, 101, 106, 165, 148 },
+ { 72, 187, 100, 130, 157, 111, 32, 75, 80 },
+ { 66, 102, 167, 99, 74, 62, 40, 234, 128 },
+ { 41, 53, 9, 178, 241, 141, 26, 8, 107 },
+ { 74, 43, 26, 146, 73, 166, 49, 23, 157 },
+ { 65, 38, 105, 160, 51, 52, 31, 115, 128 },
+ { 104, 79, 12, 27, 217, 255, 87, 17, 7 },
+ { 87, 68, 71, 44, 114, 51, 15, 186, 23 },
+ { 47, 41, 14, 110, 182, 183, 21, 17, 194 },
+ { 66, 45, 25, 102, 197, 189, 23, 18, 22 } },
+ { { 88, 88, 147, 150, 42, 46, 45, 196, 205 },
+ { 43, 97, 183, 117, 85, 38, 35, 179, 61 },
+ { 39, 53, 200, 87, 26, 21, 43, 232, 171 },
+ { 56, 34, 51, 104, 114, 102, 29, 93, 77 },
+ { 39, 28, 85, 171, 58, 165, 90, 98, 64 },
+ { 34, 22, 116, 206, 23, 34, 43, 166, 73 },
+ { 107, 54, 32, 26, 51, 1, 81, 43, 31 },
+ { 68, 25, 106, 22, 64, 171, 36, 225, 114 },
+ { 34, 19, 21, 102, 132, 188, 16, 76, 124 },
+ { 62, 18, 78, 95, 85, 57, 50, 48, 51 } },
+ { { 193, 101, 35, 159, 215, 111, 89, 46, 111 },
+ { 60, 148, 31, 172, 219, 228, 21, 18, 111 },
+ { 112, 113, 77, 85, 179, 255, 38, 120, 114 },
+ { 40, 42, 1, 196, 245, 209, 10, 25, 109 },
+ { 88, 43, 29, 140, 166, 213, 37, 43, 154 },
+ { 61, 63, 30, 155, 67, 45, 68, 1, 209 },
+ { 100, 80, 8, 43, 154, 1, 51, 26, 71 },
+ { 142, 78, 78, 16, 255, 128, 34, 197, 171 },
+ { 41, 40, 5, 102, 211, 183, 4, 1, 221 },
+ { 51, 50, 17, 168, 209, 192, 23, 25, 82 } },
+ { { 138, 31, 36, 171, 27, 166, 38, 44, 229 },
+ { 67, 87, 58, 169, 82, 115, 26, 59, 179 },
+ { 63, 59, 90, 180, 59, 166, 93, 73, 154 },
+ { 40, 40, 21, 116, 143, 209, 34, 39, 175 },
+ { 47, 15, 16, 183, 34, 223, 49, 45, 183 },
+ { 46, 17, 33, 183, 6, 98, 15, 32, 183 },
+ { 57, 46, 22, 24, 128, 1, 54, 17, 37 },
+ { 65, 32, 73, 115, 28, 128, 23, 128, 205 },
+ { 40, 3, 9, 115, 51, 192, 18, 6, 223 },
+ { 87, 37, 9, 115, 59, 77, 64, 21, 47 } },
+ { { 104, 55, 44, 218, 9, 54, 53, 130, 226 },
+ { 64, 90, 70, 205, 40, 41, 23, 26, 57 },
+ { 54, 57, 112, 184, 5, 41, 38, 166, 213 },
+ { 30, 34, 26, 133, 152, 116, 10, 32, 134 },
+ { 39, 19, 53, 221, 26, 114, 32, 73, 255 },
+ { 31, 9, 65, 234, 2, 15, 1, 118, 73 },
+ { 75, 32, 12, 51, 192, 255, 160, 43, 51 },
+ { 88, 31, 35, 67, 102, 85, 55, 186, 85 },
+ { 56, 21, 23, 111, 59, 205, 45, 37, 192 },
+ { 55, 38, 70, 124, 73, 102, 1, 34, 98 } },
+ { { 125, 98, 42, 88, 104, 85, 117, 175, 82 },
+ { 95, 84, 53, 89, 128, 100, 113, 101, 45 },
+ { 75, 79, 123, 47, 51, 128, 81, 171, 1 },
+ { 57, 17, 5, 71, 102, 57, 53, 41, 49 },
+ { 38, 33, 13, 121, 57, 73, 26, 1, 85 },
+ { 41, 10, 67, 138, 77, 110, 90, 47, 114 },
+ { 115, 21, 2, 10, 102, 255, 166, 23, 6 },
+ { 101, 29, 16, 10, 85, 128, 101, 196, 26 },
+ { 57, 18, 10, 102, 102, 213, 34, 20, 43 },
+ { 117, 20, 15, 36, 163, 128, 68, 1, 26 } },
+ { { 102, 61, 71, 37, 34, 53, 31, 243, 192 },
+ { 69, 60, 71, 38, 73, 119, 28, 222, 37 },
+ { 68, 45, 128, 34, 1, 47, 11, 245, 171 },
+ { 62, 17, 19, 70, 146, 85, 55, 62, 70 },
+ { 37, 43, 37, 154, 100, 163, 85, 160, 1 },
+ { 63, 9, 92, 136, 28, 64, 32, 201, 85 },
+ { 75, 15, 9, 9, 64, 255, 184, 119, 16 },
+ { 86, 6, 28, 5, 64, 255, 25, 248, 1 },
+ { 56, 8, 17, 132, 137, 255, 55, 116, 128 },
+ { 58, 15, 20, 82, 135, 57, 26, 121, 40 } },
+ { { 164, 50, 31, 137, 154, 133, 25, 35, 218 },
+ { 51, 103, 44, 131, 131, 123, 31, 6, 158 },
+ { 86, 40, 64, 135, 148, 224, 45, 183, 128 },
+ { 22, 26, 17, 131, 240, 154, 14, 1, 209 },
+ { 45, 16, 21, 91, 64, 222, 7, 1, 197 },
+ { 56, 21, 39, 155, 60, 138, 23, 102, 213 },
+ { 83, 12, 13, 54, 192, 255, 68, 47, 28 },
+ { 85, 26, 85, 85, 128, 128, 32, 146, 171 },
+ { 18, 11, 7, 63, 144, 171, 4, 4, 246 },
+ { 35, 27, 10, 146, 174, 171, 12, 26, 128 } },
+ { { 190, 80, 35, 99, 180, 80, 126, 54, 45 },
+ { 85, 126, 47, 87, 176, 51, 41, 20, 32 },
+ { 101, 75, 128, 139, 118, 146, 116, 128, 85 },
+ { 56, 41, 15, 176, 236, 85, 37, 9, 62 },
+ { 71, 30, 17, 119, 118, 255, 17, 18, 138 },
+ { 101, 38, 60, 138, 55, 70, 43, 26, 142 },
+ { 146, 36, 19, 30, 171, 255, 97, 27, 20 },
+ { 138, 45, 61, 62, 219, 1, 81, 188, 64 },
+ { 32, 41, 20, 117, 151, 142, 20, 21, 163 },
+ { 112, 19, 12, 61, 195, 128, 48, 4, 24 } }
+ };
+
// Paragraph 13
public static readonly byte[,,,] CoeffsUpdateProba =
{
diff --git a/src/ImageSharp/Formats/WebP/WebPDecoderCore.cs b/src/ImageSharp/Formats/WebP/WebPDecoderCore.cs
index 060ec0f0f9..22a370592f 100644
--- a/src/ImageSharp/Formats/WebP/WebPDecoderCore.cs
+++ b/src/ImageSharp/Formats/WebP/WebPDecoderCore.cs
@@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
else
{
var lossyDecoder = new WebPLossyDecoder(imageInfo.Vp8BitReader, this.memoryAllocator);
- lossyDecoder.Decode(pixels, image.Width, image.Height, imageInfo.Vp8Profile);
+ lossyDecoder.Decode(pixels, image.Width, image.Height, imageInfo);
}
// There can be optional chunks after the image data, like EXIF and XMP.
diff --git a/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs b/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs
index 364b4b3be1..1c102a06b7 100644
--- a/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs
+++ b/src/ImageSharp/Formats/WebP/WebPLossyDecoder.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
this.bitReader = bitReader;
}
- public void Decode(Buffer2D pixels, int width, int height, int vp8Version)
+ public void Decode(Buffer2D pixels, int width, int height, WebPImageInfo info)
where TPixel : struct, IPixel
{
// we need buffers for Y U and V in size of the image
@@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
// those prediction values are the base, the values from DCT processing are added to that
// TODO residue signal from DCT: 4x4 blocks of DCT transforms, 16Y, 4U, 4V
- Vp8Profile vp8Profile = this.DecodeProfile(vp8Version);
+ Vp8Profile vp8Profile = this.DecodeProfile(info.Vp8Profile);
// Paragraph 9.3: Parse the segment header.
var proba = new Vp8Proba();
@@ -57,6 +57,115 @@ namespace SixLabors.ImageSharp.Formats.WebP
// Paragraph 13.4: Parse probabilities.
this.ParseProbabilities(proba);
+
+ var vp8Io = default(Vp8Io);
+ var decoder = new Vp8Decoder(info.Vp8FrameHeader, info.Vp8PictureHeader, vp8FilterHeader, vp8SegmentHeader, proba, vp8Io);
+ this.ParseFrame(decoder, vp8Io);
+ }
+
+ private void ParseFrame(Vp8Decoder dec, Vp8Io io)
+ {
+ for (dec.MbY = 0; dec.MbY < dec.BottomRightMbY; ++dec.MbY)
+ {
+ // Parse intra mode mode row.
+ for (int mbX = 0; mbX < dec.MbWidth; ++mbX)
+ {
+ this.ParseIntraMode(dec, mbX);
+ }
+
+ for (; dec.MbX < dec.MbWidth; ++dec.MbX)
+ {
+ this.DecodeMacroBlock(dec);
+ }
+
+ // Prepare for next scanline.
+ this.InitScanline(dec);
+
+ // TODO: Reconstruct, filter and emit the row.
+ }
+ }
+
+ private void InitScanline(Vp8Decoder dec)
+ {
+ Vp8MacroBlock left = dec.MacroBlockInfo[dec.MacroBlockIdx - 1];
+ left.NoneZeroAcDcCoeffs = 0;
+ left.NoneZeroDcCoeffs = 0;
+ for (int i = 0; i < dec.IntraL.Length; i++)
+ {
+ dec.IntraL[i] = 0;
+ }
+
+ dec.MbX = 0;
+ }
+
+ private void ParseIntraMode(Vp8Decoder dec, int mbX)
+ {
+ Vp8MacroBlockData block = dec.MacroBlockData[mbX];
+ byte[] left = dec.IntraL;
+ byte[] top = dec.IntraT;
+
+ if (dec.SegmentHeader.UpdateMap)
+ {
+ // Hardcoded tree parsing.
+ block.Segment = this.bitReader.GetBit((int)dec.Probabilities.Segments[0]) != 0
+ ? (byte)this.bitReader.GetBit((int)dec.Probabilities.Segments[1])
+ : (byte)this.bitReader.GetBit((int)dec.Probabilities.Segments[2]);
+ }
+ else
+ {
+ // default for intra
+ block.Segment = 0;
+ }
+
+ if (dec.UseSkipProba)
+ {
+ block.Skip = (byte)this.bitReader.GetBit(dec.SkipProbability);
+ }
+
+ block.IsI4x4 = this.bitReader.GetBit(145) != 0;
+ if (!block.IsI4x4)
+ {
+ // Hardcoded 16x16 intra-mode decision tree.
+ int yMode = this.bitReader.GetBit(156) > 0 ?
+ this.bitReader.GetBit(128) > 0 ? WebPConstants.TmPred : WebPConstants.HPred :
+ this.bitReader.GetBit(163) > 0 ? WebPConstants.VPred : WebPConstants.DcPred;
+ block.Modes[0] = (byte)yMode;
+ for (int i = 0; i < left.Length; i++)
+ {
+ left[i] = (byte)yMode;
+ top[i] = (byte)yMode;
+ }
+ }
+ else
+ {
+ byte[] modes = block.Modes;
+ for (int y = 0; y < 4; ++y)
+ {
+ int yMode = left[y];
+ for (int x = 0; x < 4; ++x)
+ {
+ byte[] prob = null; //= WebPConstants.BModesProba[top[x], yMode];
+ int i = WebPConstants.YModesIntra4[this.bitReader.GetBit(prob[0])];
+ while (i > 0)
+ {
+ i = WebPConstants.YModesIntra4[(2 * i) + this.bitReader.GetBit(prob[i])];
+ }
+
+ yMode = -i;
+ top[x] = (byte)yMode;
+ }
+
+ // memcpy(modes, top, 4 * sizeof(*top));
+ // modes += 4;
+ left[y] = (byte)yMode;
+ }
+ }
+
+ // Hardcoded UVMode decision tree.
+ block.UvMode = (byte)(this.bitReader.GetBit(142) is 0 ? 0 :
+ this.bitReader.GetBit(114) is 0 ? 2 :
+ this.bitReader.GetBit(183) > 0 ? 1 : 3);
+
}
private Vp8Profile DecodeProfile(int version)
@@ -81,9 +190,9 @@ namespace SixLabors.ImageSharp.Formats.WebP
private void DecodeMacroBlock(Vp8Decoder dec)
{
- Vp8MacroBlock left = dec.MacroBlockInfo[dec.MacroBlockPos - 1]; // TODO: not sure if this - 1 is correct here
- Vp8MacroBlock macroBlock = dec.MacroBlockInfo[dec.MacroBlockPos + dec.MbX];
- Vp8MacroBlockData blockData = dec.MacroBlockData[dec.MacroBlockPos + dec.MbX];
+ Vp8MacroBlock left = dec.MacroBlockInfo[dec.MacroBlockIdx - 1]; // TODO: not sure if this - 1 is correct here
+ Vp8MacroBlock macroBlock = dec.MacroBlockInfo[dec.MacroBlockIdx + dec.MbX];
+ Vp8MacroBlockData blockData = dec.MacroBlockData[dec.MacroBlockIdx + dec.MbX];
int skip = dec.UseSkipProba ? blockData.Skip : 0;
if (skip is 0)