From 8a9f929137b810ce799f24c454b9a9c31d2eae54 Mon Sep 17 00:00:00 2001 From: Ingo Bauersachs Date: Thu, 19 Jan 2017 10:24:01 +0100 Subject: [PATCH 1/5] Add a .NET 4.6.1 profile to use its System.Numerics.Vectors The downgrade from 4.6.1 to 4.6 in the benchmark is required to force the System.Numerics.Vectors dependency to NuGet. The 4.6.1 version does not contain the used generic vector type. Closes #81 --- src/ImageSharp.Drawing/project.json | 18 ++++++++++++++++-- src/ImageSharp.Formats.Bmp/project.json | 18 +++++++++++++++--- src/ImageSharp.Formats.Gif/project.json | 18 +++++++++++++++--- src/ImageSharp.Formats.Jpeg/project.json | 18 +++++++++++++++--- src/ImageSharp.Formats.Png/project.json | 18 +++++++++++++++--- src/ImageSharp.Processing/project.json | 18 +++++++++++++++--- src/ImageSharp/project.json | 18 +++++++++++++++--- tests/ImageSharp.Benchmarks/project.json | 2 +- 8 files changed, 107 insertions(+), 21 deletions(-) diff --git a/src/ImageSharp.Drawing/project.json b/src/ImageSharp.Drawing/project.json index ece92f438e..a73dee21b5 100644 --- a/src/ImageSharp.Drawing/project.json +++ b/src/ImageSharp.Drawing/project.json @@ -51,7 +51,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -63,6 +62,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -76,7 +76,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0" + "System.Numerics.Vectors": "4.1.1", + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/src/ImageSharp.Formats.Bmp/project.json b/src/ImageSharp.Formats.Bmp/project.json index 4ed92c7e5b..fe7f487e95 100644 --- a/src/ImageSharp.Formats.Bmp/project.json +++ b/src/ImageSharp.Formats.Bmp/project.json @@ -47,7 +47,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -59,6 +58,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -72,9 +72,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0", + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/src/ImageSharp.Formats.Gif/project.json b/src/ImageSharp.Formats.Gif/project.json index c0710a3e40..395ea77b8d 100644 --- a/src/ImageSharp.Formats.Gif/project.json +++ b/src/ImageSharp.Formats.Gif/project.json @@ -47,7 +47,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -59,6 +58,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -72,9 +72,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0", + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/src/ImageSharp.Formats.Jpeg/project.json b/src/ImageSharp.Formats.Jpeg/project.json index 6366f507e8..e0fdeeef25 100644 --- a/src/ImageSharp.Formats.Jpeg/project.json +++ b/src/ImageSharp.Formats.Jpeg/project.json @@ -47,7 +47,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -59,6 +58,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -72,9 +72,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0", + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/src/ImageSharp.Formats.Png/project.json b/src/ImageSharp.Formats.Png/project.json index bce68ddca5..17dac21713 100644 --- a/src/ImageSharp.Formats.Png/project.json +++ b/src/ImageSharp.Formats.Png/project.json @@ -47,7 +47,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -59,6 +58,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -72,9 +72,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0", + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/src/ImageSharp.Processing/project.json b/src/ImageSharp.Processing/project.json index eb3ea59db6..9b96b53121 100644 --- a/src/ImageSharp.Processing/project.json +++ b/src/ImageSharp.Processing/project.json @@ -47,7 +47,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -59,6 +58,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -72,9 +72,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0", + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/src/ImageSharp/project.json b/src/ImageSharp/project.json index 8ddaa8bcc2..28cb7b4099 100644 --- a/src/ImageSharp/project.json +++ b/src/ImageSharp/project.json @@ -43,7 +43,6 @@ "type": "build" }, "System.Buffers": "4.0.0", - "System.Numerics.Vectors": "4.1.1", "System.Runtime.CompilerServices.Unsafe": "4.0.0" }, "frameworks": { @@ -55,6 +54,7 @@ "System.IO": "4.1.0", "System.IO.Compression": "4.1.0", "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", "System.ObjectModel": "4.0.12", "System.Resources.ResourceManager": "4.0.1", "System.Runtime.Extensions": "4.1.0", @@ -68,9 +68,21 @@ }, "net45": { "dependencies": { - "System.Runtime": "4.0.0", - "System.IO": "4.0.0", + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.0.0" + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": "4.0.20.0", + "System.Numerics": "4.0.0.0", + "System.Numerics.Vectors": "4.0.0.0" } } } diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json index 10790bc156..8650a8af41 100644 --- a/tests/ImageSharp.Benchmarks/project.json +++ b/tests/ImageSharp.Benchmarks/project.json @@ -48,7 +48,7 @@ "ImageSharp.Benchmarks": "ImageSharp.Benchmarks" }, "frameworks": { - "net461": { + "net46": { "dependencies": { }, "frameworkAssemblies": { From 7ed5f8fb52639bcb9789d44061fad24866233290 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 20 Jan 2017 12:38:09 +1100 Subject: [PATCH 2/5] Much reduce file size for output. All the other encoders were using 4:2:0 --- src/ImageSharp.Formats.Jpeg/JpegEncoder.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp.Formats.Jpeg/JpegEncoder.cs b/src/ImageSharp.Formats.Jpeg/JpegEncoder.cs index a672949c35..6f404c9bb3 100644 --- a/src/ImageSharp.Formats.Jpeg/JpegEncoder.cs +++ b/src/ImageSharp.Formats.Jpeg/JpegEncoder.cs @@ -63,7 +63,13 @@ namespace ImageSharp.Formats /// public void Encode(Image image, Stream stream) where TColor : struct, IPackedPixel, IEquatable - { + { + // Ensure that quality can be set but has a fallback. + if (image.Quality > 0) + { + this.Quality = image.Quality; + } + JpegEncoderCore encode = new JpegEncoderCore(); if (this.subsampleSet) { @@ -71,8 +77,8 @@ namespace ImageSharp.Formats } else { - // Match Photoshop and use 4:2:0 SUpsampling at quality < 51% - encode.Encode(image, stream, this.Quality, this.Quality >= 51 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); + // Use 4:2:0 Subsampling at quality < 91% for reduced filesize. + encode.Encode(image, stream, this.Quality, this.Quality >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); } } } From d76d02dccc25b94b5764cf3a5f203d89528d1ae0 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 21 Jan 2017 01:43:36 +0100 Subject: [PATCH 3/5] var. var never changes --- .../ImageSharp.Tests/Formats/Jpg/JpegTests.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs index d21a4edf75..650ef799ff 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs @@ -34,7 +34,7 @@ namespace ImageSharp.Tests public void LoadResizeSave(TestImageProvider provider, int quality, JpegSubsample subsample) where TColor : struct, IPackedPixel, IEquatable { - var image = provider.GetImage() + Image image = provider.GetImage() .Resize(new ResizeOptions { Size = new Size(150, 100), @@ -61,7 +61,7 @@ namespace ImageSharp.Tests .Concat(new[] { TestImages.Jpeg.Calliphora, TestImages.Jpeg.Cmyk }) .ToArray(); - var testImages = + Image[] testImages = testFiles.Select( tf => TestImageProvider.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage()) .ToArray(); @@ -91,7 +91,7 @@ namespace ImageSharp.Tests public void OpenJpeg_SaveBmp(TestImageProvider provider) where TColor : struct, IPackedPixel, IEquatable { - var image = provider.GetImage(); + Image image = provider.GetImage(); provider.Utility.SaveTestOutputFile(image, "bmp"); } @@ -105,9 +105,9 @@ namespace ImageSharp.Tests public void OpenBmp_SaveJpeg(TestImageProvider provider, JpegSubsample subSample, int quality) where TColor : struct, IPackedPixel, IEquatable { - var image = provider.GetImage(); + Image image = provider.GetImage(); - var utility = provider.Utility; + ImagingTestCaseUtility utility = provider.Utility; utility.TestName += "_" + subSample + "_Q" + quality; using (var outputStream = File.OpenWrite(utility.GetTestOutputFileName("jpg"))) @@ -152,6 +152,7 @@ namespace ImageSharp.Tests { Image img = new Image(bytes); }, + // ReSharper disable once ExplicitCallerInfoArgument $"Decode {fileName}"); } @@ -162,11 +163,11 @@ namespace ImageSharp.Tests public void Benchmark_JpegEncoder(TestImageProvider provider, JpegSubsample subSample, int quality) where TColor : struct, IPackedPixel, IEquatable { - var image = provider.GetImage(); + Image image = provider.GetImage(); using (var outputStream = new MemoryStream()) { - var encoder = new JpegEncoder() + JpegEncoder encoder = new JpegEncoder() { Subsample = subSample, Quality = quality @@ -185,7 +186,7 @@ namespace ImageSharp.Tests { Image image = factory.CreateImage(10, 10); - using (var pixels = image.Lock()) + using (PixelAccessor pixels = image.Lock()) { for (int i = 0; i < 10; i++) { @@ -208,10 +209,10 @@ namespace ImageSharp.Tests public void CopyStretchedRGBTo_FromOrigo(TestImageProvider provider) where TColor : struct, IPackedPixel, IEquatable { - var src = provider.GetImage(); + Image src = provider.GetImage(); PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz); - var dest = provider.Factory.CreateImage(8, 8); + Image dest = provider.Factory.CreateImage(8, 8); using (var s = src.Lock()) { @@ -233,12 +234,12 @@ namespace ImageSharp.Tests public void CopyStretchedRGBTo_WithOffset(TestImageProvider provider) where TColor : struct, IPackedPixel, IEquatable { - var src = provider.GetImage(); + Image src = provider.GetImage(); PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz); - var dest = provider.Factory.CreateImage(8, 8); + Image dest = provider.Factory.CreateImage(8, 8); - using (var s = src.Lock()) + using (PixelAccessor s = src.Lock()) { using (var d = dest.Lock()) { From d2f9619ff6b1da4794fd3ef9ff7fc939f8d6fa14 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 21 Jan 2017 17:55:20 +0100 Subject: [PATCH 4/5] ImageSharp.Sandbox46.csproj uses net461 dll-s --- .../ImageSharp.Sandbox46.csproj | 18 +++++++----------- tests/ImageSharp.Sandbox46/packages.config | 1 - .../Jpg/ReferenceImplementationsTests.cs | 8 +------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 19ff65f1d6..d7c5d8eaad 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -38,10 +38,6 @@ - - ..\..\packages\System.Numerics.Vectors.4.1.1\lib\net46\System.Numerics.Vectors.dll - True - @@ -67,25 +63,25 @@ - ..\..\src\ImageSharp\bin\$(Configuration)\net45\ImageSharp.dll + ..\..\src\ImageSharp\bin\$(Configuration)\net461\ImageSharp.dll - ..\..\src\ImageSharp.Drawing\bin\$(Configuration)\net45\ImageSharp.Drawing.dll + ..\..\src\ImageSharp.Drawing\bin\$(Configuration)\net461\ImageSharp.Drawing.dll - ..\..\src\ImageSharp.Formats.Bmp\bin\$(Configuration)\net45\ImageSharp.Formats.Bmp.dll + ..\..\src\ImageSharp.Formats.Bmp\bin\$(Configuration)\net461\ImageSharp.Formats.Bmp.dll - ..\..\src\ImageSharp.Formats.Gif\bin\$(Configuration)\net45\ImageSharp.Formats.Gif.dll + ..\..\src\ImageSharp.Formats.Gif\bin\$(Configuration)\net461\ImageSharp.Formats.Gif.dll - ..\..\src\ImageSharp.Formats.Jpeg\bin\$(Configuration)\net45\ImageSharp.Formats.Jpeg.dll + ..\..\src\ImageSharp.Formats.Jpeg\bin\$(Configuration)\net461\ImageSharp.Formats.Jpeg.dll - ..\..\src\ImageSharp.Formats.Png\bin\$(Configuration)\net45\ImageSharp.Formats.Png.dll + ..\..\src\ImageSharp.Formats.Png\bin\$(Configuration)\net461\ImageSharp.Formats.Png.dll - ..\..\src\ImageSharp.Processing\bin\$(Configuration)\net45\ImageSharp.Processing.dll + ..\..\src\ImageSharp.Processing\bin\$(Configuration)\net461\ImageSharp.Processing.dll diff --git a/tests/ImageSharp.Sandbox46/packages.config b/tests/ImageSharp.Sandbox46/packages.config index 8163e6e2e8..8b4f34078a 100644 --- a/tests/ImageSharp.Sandbox46/packages.config +++ b/tests/ImageSharp.Sandbox46/packages.config @@ -1,6 +1,5 @@  - diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs index 63878ea34a..5dd6b87aa5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs @@ -97,13 +97,7 @@ namespace ImageSharp.Tests.Formats.Jpg Assert.Equal(expected, actual, new ApproximateFloatComparer(2f)); } } - - [Fact] - public void HowMuchIsTheFish() - { - Output.WriteLine(Vector.Count.ToString()); - } - + [Theory] [InlineData(42)] [InlineData(1)] From 77e9bb373c52ba8660b1e4c9827d80fb197683b9 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 21 Jan 2017 18:08:59 +0100 Subject: [PATCH 5/5] added some comments to Block8x8F stuff --- .../Components/Block8x8F.cs | 19 ++----------------- .../Formats/Jpg/ReferenceImplementations.cs | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs b/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs index 5ba7599570..13475af09e 100644 --- a/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs @@ -377,23 +377,6 @@ namespace ImageSharp.Formats.Jpg } } - /// - /// Performs division and rounding of a rational number represented by a dividend and a divisior into an integer. - /// - /// The dividend - /// The divisor - /// The result integer - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static int DivideRound(int dividend, int divisor) - { - if (dividend >= 0) - { - return (dividend + (divisor >> 1)) / divisor; - } - - return -((-dividend + (divisor >> 1)) / divisor); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void DivideRoundAll(ref Block8x8F a, ref Block8x8F b) { @@ -418,9 +401,11 @@ namespace ImageSharp.Formats.Jpg [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 DivideRound(Vector4 dividend, Vector4 divisor) { + // sign(v) = max(min(v, 1), -1) Vector4 sign = Vector4.Min(dividend, Vector4.One); sign = Vector4.Max(sign, new Vector4(-1)); + // AlmostRound(dividend/divisor) = dividend/divisior + 0.5*sign(dividend) return (dividend / divisor) + (sign * new Vector4(0.5f)); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementations.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementations.cs index 06882719c9..e76a11cec9 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementations.cs @@ -21,7 +21,7 @@ namespace ImageSharp.Tests internal static class ReferenceImplementations { /// - /// Transpose 8x8 block stored linearly in a span (inplace) + /// Transpose 8x8 block stored linearly in a (inplace) /// /// internal static void Transpose8x8(MutableSpan data) @@ -39,7 +39,7 @@ namespace ImageSharp.Tests } /// - /// Transpose 8x8 block stored linearly in a span + /// Transpose 8x8 block stored linearly in a /// internal static void Transpose8x8(MutableSpan src, MutableSpan dest) { @@ -876,6 +876,14 @@ namespace ImageSharp.Tests } } + /// + /// Reference implementation to test . + /// Rounding is done used an integer-based algorithm defined in . + /// + /// The input block + /// The destination block of integers + /// The quantization table + /// Pointer to public static unsafe void UnZigDivRoundRational(Block8x8F* src, int* dest, Block8x8F* qt, int* unzigPtr) { float* s = (float*)src; @@ -891,6 +899,12 @@ namespace ImageSharp.Tests } } + /// + /// Rounds a rational number defined as dividend/divisor into an integer + /// + /// The dividend + /// The divisior + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int RationalRound(int dividend, int divisor) {