mirror of https://github.com/SixLabors/ImageSharp
2 changed files with 133 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.WebP |
||||
|
{ |
||||
|
internal ref struct AlphaDecoder |
||||
|
{ |
||||
|
public int Width { get; set; } |
||||
|
|
||||
|
public int Height { get; set; } |
||||
|
|
||||
|
public int Method { get; set; } |
||||
|
|
||||
|
public WebPFilterBase Filter { get; set; } |
||||
|
|
||||
|
public int PreProcessing { get; set; } |
||||
|
|
||||
|
public Vp8LDecoder Vp8LDec { get; set; } |
||||
|
|
||||
|
public Vp8Io Io { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Although Alpha Channel requires only 1 byte per pixel,
|
||||
|
/// sometimes Vp8LDecoder may need to allocate
|
||||
|
/// 4 bytes per pixel internally during decode.
|
||||
|
/// </summary>
|
||||
|
public bool Use8BDecode { get; set; } |
||||
|
|
||||
|
// last output row (or null)
|
||||
|
private Span<byte> PrevLine { get; set; } |
||||
|
|
||||
|
private int PrevLineOffset { get; set; } |
||||
|
|
||||
|
// Taken from vp8l_dec.c AlphaApplyFilter
|
||||
|
public void AlphaApplyFilter( |
||||
|
int firstRow, int lastRow, |
||||
|
Span<byte> output, int outputOffset, |
||||
|
int stride) |
||||
|
{ |
||||
|
if (!(this.Filter is WebPFilterNone)) |
||||
|
{ |
||||
|
Span<byte> prevLine = this.PrevLine; |
||||
|
int prevLineOffset = this.PrevLineOffset; |
||||
|
|
||||
|
for (int y = firstRow; y < lastRow; y++) |
||||
|
{ |
||||
|
this.Filter |
||||
|
.Unfilter( |
||||
|
prevLine, prevLineOffset, |
||||
|
output, outputOffset, |
||||
|
output, outputOffset, |
||||
|
stride); |
||||
|
prevLineOffset = outputOffset; |
||||
|
outputOffset += stride; |
||||
|
} |
||||
|
|
||||
|
this.PrevLine = prevLine; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,70 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.WebP |
||||
|
{ |
||||
|
// from
|
||||
|
public ref struct Vp8Io |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Picture Width in pixels (invariable).
|
||||
|
/// Original, uncropped dimensions.
|
||||
|
/// The actual area passed to put() is stored in <see cref="MbW"/> /> field.
|
||||
|
/// </summary>
|
||||
|
public int Width { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Picture Width in pixels (invariable).
|
||||
|
/// Original, uncropped dimensions.
|
||||
|
/// The actual area passed to put() is stored in <see cref="MbH"/> /> field.
|
||||
|
/// </summary>
|
||||
|
public int Height { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Position of the current Rows (in pixels)
|
||||
|
/// </summary>
|
||||
|
public int MbY { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// number of columns in the sample
|
||||
|
/// </summary>
|
||||
|
public int MbW { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Number of Rows in the sample
|
||||
|
/// </summary>
|
||||
|
public int MbH { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Rows to copy (in YUV format)
|
||||
|
/// </summary>
|
||||
|
private Span<byte> Y { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Rows to copy (in YUV format)
|
||||
|
/// </summary>
|
||||
|
private Span<byte> U { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Rows to copy (in YUV format)
|
||||
|
/// </summary>
|
||||
|
private Span<byte> V { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Row stride for luma
|
||||
|
/// </summary>
|
||||
|
public int YStride { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Row stride for chroma
|
||||
|
/// </summary>
|
||||
|
public int UvStride { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// User data
|
||||
|
/// </summary>
|
||||
|
private object Opaque { get; set; } |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue