Browse Source

Add data classes for decoding VP8 images

pull/1552/head
Brian Popow 6 years ago
parent
commit
87c4a7af05
  1. 31
      src/ImageSharp/Formats/WebP/Vp8FilterInfo.cs
  2. 26
      src/ImageSharp/Formats/WebP/Vp8FrameHeader.cs
  3. 15
      src/ImageSharp/Formats/WebP/Vp8LDecoder.cs
  4. 21
      src/ImageSharp/Formats/WebP/Vp8MacroBlock.cs
  5. 44
      src/ImageSharp/Formats/WebP/Vp8MacroBlockData.cs
  6. 38
      src/ImageSharp/Formats/WebP/Vp8PictureHeader.cs
  7. 24
      src/ImageSharp/Formats/WebP/Vp8QuantMatrix.cs
  8. 33
      src/ImageSharp/Formats/WebP/Vp8SegmentHeader.cs

31
src/ImageSharp/Formats/WebP/Vp8FilterInfo.cs

@ -0,0 +1,31 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Filter information.
/// </summary>
internal class Vp8FilterInfo
{
/// <summary>
/// Gets or sets the filter limit in [3..189], or 0 if no filtering.
/// </summary>
public sbyte Limit { get; set; }
/// <summary>
/// Gets or sets the inner limit in [1..63].
/// </summary>
public sbyte InnerLevel { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to do inner filtering.
/// </summary>
public bool InnerFiltering { get; set; }
/// <summary>
/// Gets or sets the high edge variance threshold in [0..2].
/// </summary>
public sbyte HighEdgeVarianceThreshold { get; set; }
}
}

26
src/ImageSharp/Formats/WebP/Vp8FrameHeader.cs

@ -0,0 +1,26 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Vp8 frame header information.
/// </summary>
internal class Vp8FrameHeader
{
/// <summary>
/// Gets or sets a value indicating whether this is a key frame.
/// </summary>
public bool KeyFrame { get; set; }
/// <summary>
/// Gets or sets Vp8 profile [0..3].
/// </summary>
public sbyte Profile { get; set; }
/// <summary>
/// Gets or sets the partition length.
/// </summary>
public uint PartitionLength { get; set; }
}
}

15
src/ImageSharp/Formats/WebP/Vp8LDecoder.cs

@ -5,6 +5,9 @@ using System.Collections.Generic;
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Holds information for decoding a lossless image.
/// </summary>
internal class Vp8LDecoder
{
public Vp8LDecoder(int width, int height)
@ -14,12 +17,24 @@ namespace SixLabors.ImageSharp.Formats.WebP
this.Metadata = new Vp8LMetadata();
}
/// <summary>
/// Gets or sets the width of the image to decode.
/// </summary>
public int Width { get; set; }
/// <summary>
/// Gets or sets the height of the image to decode.
/// </summary>
public int Height { get; set; }
/// <summary>
/// Gets or sets the necessary VP8L metadata (like huffman tables) to decode the image.
/// </summary>
public Vp8LMetadata Metadata { get; set; }
/// <summary>
/// Gets or sets the transformations which needs to be reversed.
/// </summary>
public List<Vp8LTransform> Transforms { get; set; }
}
}

21
src/ImageSharp/Formats/WebP/Vp8MacroBlock.cs

@ -0,0 +1,21 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Info about a macro block.
/// </summary>
internal class Vp8MacroBlock
{
/// <summary>
/// Gets or sets non-zero AC/DC coeffs (4bit for luma + 4bit for chroma).
/// </summary>
public uint NoneZeroAcDcCoeffs { get; set; }
/// <summary>
/// Gets or sets non-zero DC coeff (1bit).
/// </summary>
public uint NoneZeroDcCoeffs { get; set; }
}
}

44
src/ImageSharp/Formats/WebP/Vp8MacroBlockData.cs

@ -0,0 +1,44 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Data needed to reconstruct a macroblock.
/// </summary>
internal class Vp8MacroBlockData
{
/// <summary>
/// Gets or sets the coefficient. 384 coeffs = (16+4+4) * 4*4.
/// </summary>
public short Coeffs { get; set; }
/// <summary>
/// Gets or sets a value indicating whether its intra4x4.
/// </summary>
public bool IsI4x4 { get; set; }
/// <summary>
/// Gets or sets the modes. One 16x16 mode (#0) or sixteen 4x4 modes.
/// </summary>
public byte Modes { get; set; }
/// <summary>
/// Gets or sets the chroma prediction mode.
/// </summary>
public byte UvMode { get; set; }
public uint NonZeroY { get; set; }
public uint NonZeroUv { get; set; }
/// <summary>
/// Gets or sets the local dithering strength (deduced from NonZero_*).
/// </summary>
public byte Dither { get; set; }
public byte Skip { get; set; }
public byte Segment { get; set; }
}
}

38
src/ImageSharp/Formats/WebP/Vp8PictureHeader.cs

@ -0,0 +1,38 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
internal class Vp8PictureHeader
{
/// <summary>
/// Gets or sets the width of the image.
/// </summary>
public uint Width { get; set; }
/// <summary>
/// Gets or sets the Height of the image.
/// </summary>
public uint Height { get; set; }
/// <summary>
/// Gets or sets the horizontal scale.
/// </summary>
public sbyte XScale { get; set; }
/// <summary>
/// Gets or sets the vertical scale.
/// </summary>
public sbyte YScale { get; set; }
/// <summary>
/// Gets or sets the colorspace. 0 = YCbCr.
/// </summary>
public sbyte ColorSpace { get; set; }
/// <summary>
/// Gets or sets the clamp type.
/// </summary>
public sbyte ClampType { get; set; }
}
}

24
src/ImageSharp/Formats/WebP/Vp8QuantMatrix.cs

@ -0,0 +1,24 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
internal class Vp8QuantMatrix
{
public int[] Y1Mat { get; set; }
public int[] Y2Mat { get; set; }
public int[] UVMat { get; set; }
/// <summary>
/// Gets or sets the U/V quantizer value.
/// </summary>
public int UvQuant { get; set; }
/// <summary>
/// Gets or sets the dithering amplitude (0 = off, max=255).
/// </summary>
public int Dither { get; set; }
}
}

33
src/ImageSharp/Formats/WebP/Vp8SegmentHeader.cs

@ -0,0 +1,33 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Segment features.
/// </summary>
internal class Vp8SegmentHeader
{
public bool UseSegment { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to update the segment map or not.
/// </summary>
public bool UpdateMap { get; set; }
/// <summary>
/// Gets or sets the absolute or delta values for quantizer and filter.
/// </summary>
public int AbsoluteOrDelta { get; set; }
/// <summary>
/// Gets or sets quantization changes.
/// </summary>
public byte[] Quantizer { get; set; }
/// <summary>
/// Gets or sets the filter strength for segments.
/// </summary>
public byte[] FilterStrength { get; set; }
}
}
Loading…
Cancel
Save