Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -33,7 +33,7 @@ public int WriteTo(Span<byte> buffer)

// Application Data ----
buffer[12] = 3; // Application block length (always 3)
buffer[13] = 1; // Data sub-block indentity (always 1)
buffer[13] = 1; // Data sub-block identity (always 1)

// 0 means loop indefinitely. Count is set as play n + 1 times.
BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(14, 2), this.RepeatCount);
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Memory/MemoryOwnerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static int Length<T>(this IMemoryOwner<T> buffer)
=> buffer.GetSpan().Length;

/// <summary>
/// Gets a <see cref="Span{T}"/> to an offseted position inside the buffer.
/// Gets a <see cref="Span{T}"/> to an offsetted position inside the buffer.
/// </summary>
/// <param name="buffer">The buffer</param>
/// <param name="start">The start</param>
Expand Down Expand Up @@ -60,4 +60,4 @@ public static ref T GetReference<T>(this IMemoryOwner<T> buffer)
where T : struct =>
ref MemoryMarshal.GetReference(buffer.GetSpan());
}
}
}
4 changes: 2 additions & 2 deletions src/ImageSharp/PixelFormats/PixelAlphaCompositionMode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

namespace SixLabors.ImageSharp.PixelFormats
Expand Down Expand Up @@ -39,7 +39,7 @@ public enum PixelAlphaCompositionMode
Dest,

/// <summary>
/// The source where they don't overlap othersie dest in overlapping parts.
/// The source where they don't overlap otherwise dest in overlapping parts.
/// </summary>
DestAtop,

Expand Down
8 changes: 4 additions & 4 deletions src/ImageSharp/Primitives/Complex64.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -37,7 +37,7 @@ public Complex64(float real, float imaginary)
}

/// <summary>
/// Performs the multiplication operation between a <see cref="Complex64"/> intance and a <see cref="float"/> scalar.
/// Performs the multiplication operation between a <see cref="Complex64"/> instance and a <see cref="float"/> scalar.
/// </summary>
/// <param name="value">The <see cref="Complex64"/> value to multiply.</param>
/// <param name="scalar">The <see cref="float"/> scalar to use to multiply the <see cref="Complex64"/> value.</param>
Expand All @@ -46,7 +46,7 @@ public Complex64(float real, float imaginary)
public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar);

/// <summary>
/// Performs the multiplication operation between a <see cref="Complex64"/> intance and a <see cref="Vector4"/>.
/// Performs the multiplication operation between a <see cref="Complex64"/> instance and a <see cref="Vector4"/>.
/// </summary>
/// <param name="value">The <see cref="Complex64"/> value to multiply.</param>
/// <param name="vector">The <see cref="Vector4"/> instance to use to multiply the <see cref="Complex64"/> value.</param>
Expand All @@ -58,7 +58,7 @@ public Complex64(float real, float imaginary)
}

/// <summary>
/// Performs the multiplication operation between a <see cref="Complex64"/> intance and a <see cref="ComplexVector4"/>.
/// Performs the multiplication operation between a <see cref="Complex64"/> instance and a <see cref="ComplexVector4"/>.
/// </summary>
/// <param name="value">The <see cref="Complex64"/> value to multiply.</param>
/// <param name="vector">The <see cref="ComplexVector4"/> instance to use to multiply the <see cref="Complex64"/> value.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism };
int tileWidth = source.Width / this.Tiles;
int tileHeight = tileWidth;
int pixeInTile = tileWidth * tileHeight;
int pixelInTile = tileWidth * tileHeight;
int halfTileHeight = tileHeight / 2;
int halfTileWidth = halfTileHeight;
var slidingWindowInfos = new SlidingWindowInfos(tileWidth, tileHeight, halfTileWidth, halfTileHeight, pixeInTile);
var slidingWindowInfos = new SlidingWindowInfos(tileWidth, tileHeight, halfTileWidth, halfTileHeight, pixelInTile);

using (Buffer2D<TPixel> targetPixels = configuration.MemoryAllocator.Allocate2D<TPixel>(source.Width, source.Height))
{
Expand Down Expand Up @@ -149,7 +149,7 @@ protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle source
/// <param name="source">The source image.</param>
/// <param name="memoryAllocator">The memory allocator.</param>
/// <param name="targetPixels">The target pixels.</param>
/// <param name="swInfos">Informations about the sliding window dimensions.</param>
/// <param name="swInfos"><see cref="SlidingWindowInfos"/> about the sliding window dimensions.</param>
/// <param name="yStart">The y start position.</param>
/// <param name="yEnd">The y end position.</param>
/// <param name="useFastPath">if set to true the borders of the image will not be checked.</param>
Expand Down Expand Up @@ -204,15 +204,15 @@ private Action<int> ProcessSlidingWindow(
{
// Clipping the histogram, but doing it on a copy to keep the original un-clipped values for the next iteration.
histogram.CopyTo(histogramCopy);
this.ClipHistogram(histogramCopy, this.ClipLimitPercentage, swInfos.PixeInTile);
this.ClipHistogram(histogramCopy, this.ClipLimitPercentage, swInfos.PixelInTile);
}

// Calculate the cumulative distribution function, which will map each input pixel in the current tile to a new value.
int cdfMin = this.ClipHistogramEnabled
? this.CalculateCdf(ref cdfBase, ref histogramCopyBase, histogram.Length - 1)
: this.CalculateCdf(ref cdfBase, ref histogramBase, histogram.Length - 1);

float numberOfPixelsMinusCdfMin = swInfos.PixeInTile - cdfMin;
float numberOfPixelsMinusCdfMin = swInfos.PixelInTile - cdfMin;

// Map the current pixel to the new equalized value.
int luminance = GetLuminance(source[x, y], this.LuminanceLevels);
Expand Down Expand Up @@ -367,24 +367,24 @@ private void RemovePixelsFromHistogram(ref Vector4 greyValuesBase, ref int histo

private class SlidingWindowInfos
{
public SlidingWindowInfos(int tileWidth, int tileHeight, int halfTileWidth, int halfTileHeight, int pixeInTile)
public SlidingWindowInfos(int tileWidth, int tileHeight, int halfTileWidth, int halfTileHeight, int pixelInTile)
{
this.TileWidth = tileWidth;
this.TileHeight = tileHeight;
this.HalfTileWidth = halfTileWidth;
this.HalfTileHeight = halfTileHeight;
this.PixeInTile = pixeInTile;
this.PixelInTile = pixelInTile;
}

public int TileWidth { get; private set; }

public int TileHeight { get; private set; }

public int PixeInTile { get; private set; }
public int PixelInTile { get; private set; }

public int HalfTileWidth { get; private set; }

public int HalfTileHeight { get; private set; }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -111,7 +111,7 @@ public static Matrix4x4 CreateTaperMatrix(Size size, TaperSide side, TaperCorner
Matrix4x4 matrix = Matrix4x4.Identity;

/*
* SkMatrix is layed out in the following manner:
* SkMatrix is laid out in the following manner:
*
* [ ScaleX SkewY Persp0 ]
* [ SkewX ScaleY Persp1 ]
Expand Down Expand Up @@ -329,7 +329,7 @@ private static Size ConstrainSize(Rectangle rectangle)
int width = rectangle.Left < 0 ? rectangle.Right : Math.Max(rectangle.Width, rectangle.Right);

// If location in either direction is translated to a negative value equal to or exceeding the
// dimensions in eith direction we need to reassign the dimension.
// dimensions in either direction we need to reassign the dimension.
if (height <= 0)
{
height = rectangle.Height;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Numerics;
Expand All @@ -25,15 +25,15 @@ public unsafe class Block8x8F_DivideRound
private static readonly Vector4 Half = new Vector4(0.5f);

private Block8x8F inputDividend;
private Block8x8F inputDivisior;
private Block8x8F inputDivisor;

[GlobalSetup]
public void Setup()
{
for (int i = 0; i < Block8x8F.Size; i++)
{
this.inputDividend[i] = i*44.8f;
this.inputDivisior[i] = 100 - i;
this.inputDivisor[i] = 100 - i;
}
}

Expand All @@ -43,7 +43,7 @@ public int ByRationalIntegers()
int sum = 0;

Block8x8F b1 = this.inputDividend;
Block8x8F b2 = this.inputDivisior;
Block8x8F b2 = this.inputDivisor;
float* pDividend = (float*)&b1;
float* pDivisor = (float*)&b2;

Expand Down Expand Up @@ -73,7 +73,7 @@ public int BySystemMathRound()
int sum = 0;

Block8x8F b1 = this.inputDividend;
Block8x8F b2 = this.inputDivisior;
Block8x8F b2 = this.inputDivisor;
float* pDividend = (float*)&b1;
float* pDivisor = (float*)&b2;

Expand All @@ -99,7 +99,7 @@ public int BySimdMagic()
int sum = 0;

Block8x8F bDividend = this.inputDividend;
Block8x8F bDivisor = this.inputDivisior;
Block8x8F bDivisor = this.inputDivisor;
float* pDividend = (float*)&bDividend;

for (int cnt = 0; cnt < ExecutionCount; cnt++)
Expand Down Expand Up @@ -155,4 +155,4 @@ private static int RationalRound(int dividend, int divisor)
return -((-dividend + (divisor >> 1)) / divisor);
}
}
}
}
6 changes: 3 additions & 3 deletions tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using BenchmarkDotNet.Configs;
Expand Down Expand Up @@ -143,7 +143,7 @@ protected virtual void ReadFilesImpl()
}

/// <summary>
/// Execute code for each image stream. If the returned object of the opearation <see cref="Func{T, TResult}"/> is <see cref="IDisposable"/> it will be disposed.
/// Execute code for each image stream. If the returned object of the operation <see cref="Func{T, TResult}"/> is <see cref="IDisposable"/> it will be disposed.
/// </summary>
/// <param name="operation">The operation to execute. If the returned object is &lt;see cref="IDisposable"/&gt; it will be disposed </param>
protected void ForEachStream(Func<MemoryStream, object> operation)
Expand Down Expand Up @@ -271,4 +271,4 @@ protected void ForEachSystemDrawingImage(Func<System.Drawing.Bitmap, MemoryStrea
}
}
}
}
}
4 changes: 2 additions & 2 deletions tests/ImageSharp.Benchmarks/Color/RgbToYCbCr.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Numerics;
Expand Down Expand Up @@ -228,7 +228,7 @@ public unsafe void RgbaToYcbCrScaledIntegerSimd()
}

/// <summary>
/// This should perform better. Coreclr emmitted Vector.Dot() code lacks the vectorization even with IsHardwareAccelerated == true.
/// This should perform better. Coreclr emitted Vector.Dot() code lacks the vectorization even with IsHardwareAccelerated == true.
/// Kept this benchmark because maybe it will be improved in a future CLR release.
/// <see>
/// <cref>https://www.gamedev.net/topic/673396-c-systemnumericsvectors-slow/</cref>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -76,8 +76,8 @@ public byte ClampNoMathsEqualsNoTernary()
public byte ClampBitwise()
{
int x = this.Value;
int absmax = byte.MaxValue - x;
x = (x + byte.MaxValue - AbsBitwiseVer(ref absmax)) >> 1;
int absMax = byte.MaxValue - x;
x = (x + byte.MaxValue - AbsBitwiseVer(ref absMax)) >> 1;
x = (x + byte.MinValue + AbsBitwiseVer(ref x)) >> 1;

return (byte)x;
Expand Down
22 changes: 11 additions & 11 deletions tests/ImageSharp.Benchmarks/General/CopyBuffers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -33,8 +33,8 @@ public class CopyBuffers

[Params(10, 50, 100, 1000, 10000)]
public int Count { get; set; }


[GlobalSetup]
public void Setup()
{
Expand Down Expand Up @@ -93,39 +93,39 @@ public unsafe void UnsafeCopyBlockReferences()
{
Unsafe.CopyBlock(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count);
}

[Benchmark(Description = "Unsafe.CopyBlock(ptr)")]
public unsafe void UnsafeCopyBlockPointers()
{
void* pinnedDestination = this.destHandle.Pointer;
void* pinnedSource = this.sourceHandle.Pointer;
Unsafe.CopyBlock(pinnedDestination, pinnedSource, (uint)this.Count);
}

[Benchmark(Description = "Unsafe.CopyBlockUnaligned(ref)")]
public unsafe void UnsafeCopyBlockUnalignedReferences()
{
Unsafe.CopyBlockUnaligned(ref this.destArray[0], ref this.sourceArray[0], (uint)this.Count);
}

[Benchmark(Description = "Unsafe.CopyBlockUnaligned(ptr)")]
public unsafe void UnsafeCopyBlockUnalignedPointers()
{
void* pinnedDestination = this.destHandle.Pointer;
void* pinnedSource = this.sourceHandle.Pointer;
Unsafe.CopyBlockUnaligned(pinnedDestination, pinnedSource, (uint)this.Count);
}

// BenchmarkDotNet=v0.11.3, OS=Windows 10.0.17134.706 (1803/April2018Update/Redstone4)
// Intel Core i7-7700HQ CPU 2.80GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
// Frequency=2742189 Hz, Resolution=364.6722 ns, Timer=TSC
// .NET Core SDK=2.2.202
// [Host] : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
// Clr : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3394.0
// Core : .NET Core 2.1.9 (CoreCLR 4.6.27414.06, CoreFX 4.6.27415.01), 64bit RyuJIT
//
// IterationCount=3 LaunchCount=1 WarmupCount=3
//
//
// IterationCount=3 LaunchCount=1 WarmupCount=3
//
// | Method | Job | Runtime | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
// |------------------------------- |----- |-------- |------ |-----------:|-----------:|----------:|------:|--------:|------:|------:|------:|----------:|
// | Array.Copy() | Clr | Clr | 10 | 23.636 ns | 2.5299 ns | 0.1387 ns | 1.00 | 0.00 | - | - | - | - |
Expand Down Expand Up @@ -228,4 +228,4 @@ public unsafe void UnsafeCopyBlockUnalignedPointers()
// | Unsafe.CopyBlockUnaligned(ref) | Core | Core | 10000 | 187.489 ns | 13.1527 ns | 0.7209 ns | 0.92 | 0.00 | - | - | - | - |
// | Unsafe.CopyBlockUnaligned(ptr) | Core | Core | 10000 | 186.586 ns | 4.6274 ns | 0.2536 ns | 0.91 | 0.00 | - | - | - | - |
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using System.Runtime.CompilerServices;

using BenchmarkDotNet.Attributes;
Expand Down Expand Up @@ -27,7 +27,7 @@ public void MagicMethod()

var bVec = new Vector<float>(256.0f / 255.0f);
var magicFloat = new Vector<float>(32768.0f);
var magicInt = new Vector<uint>(1191182336); // reinterpreded value of 32768.0f
var magicInt = new Vector<uint>(1191182336); // reinterpreted value of 32768.0f
var mask = new Vector<uint>(255);

for (int i = 0; i < n; i++)
Expand Down Expand Up @@ -110,4 +110,4 @@ public void StandardSimdFromInt_RefCast()
}
}
}
}
}
6 changes: 3 additions & 3 deletions tests/ImageSharp.Benchmarks/Samplers/Glow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
Expand Down Expand Up @@ -144,7 +144,7 @@ public static Vector4 PremultipliedLerp(Vector4 backdrop, Vector4 source, float
{
amount = amount.Clamp(0, 1);

// Santize on zero alpha
// Sanitize on zero alpha
if (Math.Abs(backdrop.W) < Constants.Epsilon)
{
source.W *= amount;
Expand Down Expand Up @@ -173,4 +173,4 @@ public static Vector4 PremultipliedLerp(Vector4 backdrop, Vector4 source, float
}
}
}
}
}
Loading