|
|
@ -16,42 +16,36 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|
|
internal struct ResizeKernel |
|
|
internal struct ResizeKernel |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The left index for the destination row
|
|
|
/// Initializes a new instance of the <see cref="ResizeKernel"/> struct.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public int Left; |
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
|
|
internal ResizeKernel(int left, Memory<float> bufferSlice) |
|
|
|
|
|
{ |
|
|
|
|
|
this.Left = left; |
|
|
|
|
|
this.BufferSlice = bufferSlice; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The length of the kernel
|
|
|
/// Gets the left index for the destination row
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public int Length; |
|
|
public int Left { get; } |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The buffer containing the weights values.
|
|
|
/// Gets the slice of the buffer containing the weights values.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly Memory<float> buffer; |
|
|
public Memory<float> BufferSlice { get; } |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="ResizeKernel"/> struct.
|
|
|
/// Gets the the length of the kernel
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="index">The destination index in the buffer</param>
|
|
|
public int Length => this.BufferSlice.Length; |
|
|
/// <param name="left">The local left index</param>
|
|
|
|
|
|
/// <param name="buffer">The span</param>
|
|
|
|
|
|
/// <param name="length">The length of the window</param>
|
|
|
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
|
|
internal ResizeKernel(int index, int left, Buffer2D<float> buffer, int length) |
|
|
|
|
|
{ |
|
|
|
|
|
int flatStartIndex = index * buffer.Width; |
|
|
|
|
|
this.Left = left; |
|
|
|
|
|
this.buffer = buffer.MemorySource.Memory.Slice(flatStartIndex, length); |
|
|
|
|
|
this.Length = length; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the span representing the portion of the <see cref="KernelMap"/> that this window covers
|
|
|
/// Gets the span representing the portion of the <see cref="KernelMap"/> that this window covers
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <returns>The <see cref="Span{T}"/></returns>
|
|
|
/// <returns>The <see cref="Span{T}"/></returns>
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
public Span<float> GetValues() => this.buffer.Span; |
|
|
public Span<float> GetValues() => this.BufferSlice.Span; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Computes the sum of vectors in 'rowSpan' weighted by weight values, pointed by this <see cref="ResizeKernel"/> instance.
|
|
|
/// Computes the sum of vectors in 'rowSpan' weighted by weight values, pointed by this <see cref="ResizeKernel"/> instance.
|
|
|
|