From f3e1e8f42d366b5613b6232e57fa826993194aa5 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Wed, 18 Apr 2018 18:04:25 -0700 Subject: [PATCH] Cleanup tests --- .../Formats/Jpg/AdobeMarkerTests.cs | 10 ++--- .../Jpg/Block8x8FTests.CopyToBufferArea.cs | 18 ++++----- .../Formats/Jpg/Block8x8FTests.cs | 37 ++++++++----------- .../Formats/Jpg/Block8x8Tests.cs | 23 ++++++------ .../Formats/Jpg/GenericBlock8x8Tests.cs | 28 +++++++------- .../Formats/Jpg/JFifMarkerTests.cs | 9 ++--- .../Formats/Jpg/JpegColorConverterTests.cs | 23 ++++++------ .../Formats/Jpg/JpegEncoderTests.cs | 22 +++-------- .../Jpg/JpegImagePostProcessorTests.cs | 23 ++++++------ .../Formats/Jpg/JpegProfilingBenchmarks.cs | 33 ++++++++--------- .../Formats/Jpg/LibJpegToolsTests.cs | 12 +++--- .../Formats/Jpg/ParseStreamTests.cs | 21 ++++++----- .../Formats/Jpg/ProfileResolverTests.cs | 10 ++--- ...ferenceImplementationsTests.AccurateDCT.cs | 12 +++--- ...plementationsTests.FastFloatingPointDCT.cs | 18 ++++----- ...ImplementationsTests.StandardIntegerDCT.cs | 22 +++++------ .../Formats/Jpg/SpectralJpegTests.cs | 32 ++++++++-------- .../Formats/Jpg/Utils/JpegFixture.cs | 36 +++++++++--------- .../Jpg/Utils/LibJpegTools.ComponentData.cs | 12 +++--- .../Jpg/Utils/LibJpegTools.SpectralData.cs | 32 ++++++++-------- .../Formats/Jpg/Utils/LibJpegTools.cs | 4 +- .../ReferenceImplementations.AccurateDCT.cs | 12 +++--- ...nceImplementations.GT_FloatingPoint_DCT.cs | 4 +- ...ceImplementations.LLM_FloatingPoint_DCT.cs | 30 +++++++-------- ...renceImplementations.StandardIntegerDCT.cs | 8 ++-- .../Jpg/Utils/ReferenceImplementations.cs | 11 ++---- .../Formats/Jpg/Utils/SpanExtensions.cs | 10 ++--- 27 files changed, 245 insertions(+), 267 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs index b98a6fe8e..2ee9498e0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs @@ -1,13 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; - using Xunit; +using Xunit; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class AdobeMarkerTests { // Taken from actual test image diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs index e50d84852..4b5cf526b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs @@ -1,23 +1,19 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. - - // Uncomment this to turn unit tests into benchmarks: //#define BENCHMARKING -// ReSharper disable InconsistentNaming +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using SixLabors.Primitives; + +using Xunit; +using Xunit.Abstractions; namespace SixLabors.ImageSharp.Tests.Formats.Jpg { - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Memory; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using SixLabors.Primitives; - - using Xunit; - using Xunit.Abstractions; - public partial class Block8x8FTests : JpegFixture { public class CopyToBufferArea : JpegFixture diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index 8c12b0050..ac8bed13b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -1,24 +1,20 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. - - // Uncomment this to turn unit tests into benchmarks: //#define BENCHMARKING -// ReSharper disable InconsistentNaming +using System; +using System.Diagnostics; -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System; - using System.Diagnostics; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - - using Xunit; - using Xunit.Abstractions; +using Xunit; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public partial class Block8x8FTests : JpegFixture { #if BENCHMARKING @@ -65,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg }); Assert.Equal(sum, 64f * 63f * 0.5f); } - + [Fact] public void Indexer_ReferenceBenchmarkWithArray() { @@ -207,7 +203,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg sw.Stop(); this.Output.WriteLine($"TranposeInto_PinningImpl_Benchmark finished in {sw.ElapsedMilliseconds} ms"); } - + private static float[] Create8x8ColorCropTestData() { float[] result = new float[64]; @@ -233,7 +229,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Block8x8F dest = block; dest.NormalizeColorsInplace(); - + float[] array = new float[64]; dest.CopyTo(array); this.Output.WriteLine("Result:"); @@ -268,7 +264,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg this.CompareBlocks(expected, actual, 0); } - [Theory] [InlineData(1)] [InlineData(2)] @@ -297,7 +292,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(expected, actual); } } - + [Fact] public void RoundInto() { @@ -312,7 +307,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg for (int i = 0; i < Block8x8.Size; i++) { float expectedFloat = data[i]; - short expectedShort = (short) Math.Round(expectedFloat); + short expectedShort = (short)Math.Round(expectedFloat); short actualShort = dest[i]; Assert.Equal(expectedShort, actualShort); @@ -349,12 +344,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Block8x8F m = CreateRandomFloatBlock(-500, 500, 42); Block8x8F actual = original; - + actual.MultiplyInplace(ref m); for (int i = 0; i < Block8x8F.Size; i++) { - Assert.Equal(original[i]*m[i], actual[i]); + Assert.Equal(original[i] * m[i], actual[i]); } } @@ -410,7 +405,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg for (int i = 0; i < 64; i++) { - Assert.Equal(original[i]*42f, actual[i]); + Assert.Equal(original[i] * 42f, actual[i]); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index c2fa8c8d4..c7869a6ba 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -1,12 +1,14 @@ -// ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using Xunit; - using Xunit.Abstractions; +using Xunit; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class Block8x8Tests : JpegFixture { public Block8x8Tests(ITestOutputHelper output) @@ -26,11 +28,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(data[i], block[i]); } } - + [Fact] public void Indexer_Set() { - var block = default(Block8x8); + Block8x8 block = default; block[17] = 17; block[42] = 42; @@ -40,7 +42,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.Equal(42, block[42]); } - [Fact] public unsafe void Indexer_GetScalarAt_SetScalarAt() { @@ -117,7 +118,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [Fact] public void IndexerXY() { - var block = default(Block8x8); + Block8x8 block = default; block[8 * 3 + 5] = 42; short value = block[5, 3]; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs index 31c95fae6..5bb3ded0b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs @@ -1,13 +1,15 @@ -// ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System; +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.PixelFormats; - using Xunit; +using Xunit; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class GenericBlock8x8Tests { public static Image CreateTestImage() @@ -20,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { for (int j = 0; j < 10; j++) { - var rgba = new Rgba32((byte)(i+1), (byte)(j+1), (byte)200, (byte)255); + var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), (byte)200, (byte)255); var color = default(TPixel); color.PackFromRgba32(rgba); @@ -107,11 +109,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg span[i] = new Rgb24((byte)i, (byte)(2 * i), (byte)(3 * i)); } - Rgb24 expected00 = new Rgb24(0, 0, 0); - Rgb24 expected07 = new Rgb24(7, 14, 21); - Rgb24 expected11 = new Rgb24(9, 18, 27); - Rgb24 expected77 = new Rgb24(63, 126, 189); - Rgb24 expected67 = new Rgb24(62, 124, 186); + var expected00 = new Rgb24(0, 0, 0); + var expected07 = new Rgb24(7, 14, 21); + var expected11 = new Rgb24(9, 18, 27); + var expected77 = new Rgb24(63, 126, 189); + var expected67 = new Rgb24(62, 124, 186); Assert.Equal(expected00, block[0, 0]); Assert.Equal(expected07, block[7, 0]); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs index cc06d5701..4e63c97de 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs @@ -1,13 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; - using Xunit; +using Xunit; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class JFifMarkerTests { // Taken from actual test image diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 70a35f182..d2f064175 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -1,19 +1,20 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + using System; using System.Numerics; using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; +using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters; using SixLabors.ImageSharp.Memory; using Xunit; using Xunit.Abstractions; -// ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg { - using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters; - public class JpegColorConverterTests { private const float Precision = 0.1f / 255; @@ -69,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void FromYCbCrSimd_ConvertCore(int size, int seed) { JpegColorConverter.ComponentValues values = CreateRandomValues(3, size, seed); - Vector4[] result = new Vector4[size]; + var result = new Vector4[size]; JpegColorConverter.FromYCbCrSimd.ConvertCore(values, result); @@ -134,7 +135,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg int times = 50000; JpegColorConverter.ComponentValues values = CreateRandomValues(3, count, 1); - Vector4[] result = new Vector4[count]; + var result = new Vector4[count]; JpegColorConverter converter = simd ? (JpegColorConverter)new JpegColorConverter.FromYCbCrSimd() : new JpegColorConverter.FromYCbCrBasic(); @@ -159,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var converter = JpegColorConverter.GetConverter(JpegColorSpace.Cmyk); JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed); - Vector4[] result = new Vector4[resultBufferLength]; + var result = new Vector4[resultBufferLength]; converter.ConvertToRGBA(values, result); @@ -192,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { var converter = JpegColorConverter.GetConverter(JpegColorSpace.Grayscale); JpegColorConverter.ComponentValues values = CreateRandomValues(1, inputBufferLength, seed); - Vector4[] result = new Vector4[resultBufferLength]; + var result = new Vector4[resultBufferLength]; converter.ConvertToRGBA(values, result); @@ -214,7 +215,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { var converter = JpegColorConverter.GetConverter(JpegColorSpace.RGB); JpegColorConverter.ComponentValues values = CreateRandomValues(3, inputBufferLength, seed); - Vector4[] result = new Vector4[resultBufferLength]; + var result = new Vector4[resultBufferLength]; converter.ConvertToRGBA(values, result); @@ -241,7 +242,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var converter = JpegColorConverter.GetConverter(JpegColorSpace.Ycck); JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed); - Vector4[] result = new Vector4[resultBufferLength]; + var result = new Vector4[resultBufferLength]; converter.ConvertToRGBA(values, result); @@ -278,7 +279,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg float maxVal = 255f) { var rnd = new Random(seed); - Buffer2D[] buffers = new Buffer2D[componentCount]; + var buffers = new Buffer2D[componentCount]; for (int i = 0; i < componentCount; i++) { float[] values = new float[inputBufferLength]; @@ -317,7 +318,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg int seed) { JpegColorConverter.ComponentValues values = CreateRandomValues(componentCount, inputBufferLength, seed); - Vector4[] result = new Vector4[resultBufferLength]; + var result = new Vector4[resultBufferLength]; converter.ConvertToRGBA(values, result); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index ec3469153..911812ebb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -1,26 +1,16 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System.IO; +using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; - -// ReSharper disable InconsistentNaming +using Xunit; namespace SixLabors.ImageSharp.Tests.Formats.Jpg { - using System.Collections.Generic; - using System.IO; - - using SixLabors.ImageSharp.Formats.Bmp; - using SixLabors.ImageSharp.Formats.Jpeg; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; - using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; - using SixLabors.Primitives; - - using Xunit; - using Xunit.Abstractions; - public class JpegEncoderTests { public static readonly TheoryData BitsPerPixel_Quality = diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs index ec4a42104..ffaccb3f7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs @@ -1,14 +1,17 @@ -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. - using Xunit; - using Xunit.Abstractions; +using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; +using Xunit; +using Xunit.Abstractions; + +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class JpegImagePostProcessorTests { public static string[] BaselineTestJpegs = @@ -100,8 +103,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Assert.True(report.TotalNormalizedDifference.Value < 0.005f); } } - - } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index 4eca62cab..49c76dc4e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -1,25 +1,22 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -// ReSharper disable InconsistentNaming - +using System; +using System.IO; +using System.Linq; +using System.Numerics; + +using SixLabors.ImageSharp.Formats; +using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; using SixLabors.ImageSharp.PixelFormats; +using Xunit; +using Xunit.Abstractions; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg { - using System; - using System.IO; - using System.Linq; - using System.Numerics; - - using SixLabors.ImageSharp.Formats; - using SixLabors.ImageSharp.Formats.Jpeg; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; - using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; - - using Xunit; - using Xunit.Abstractions; - public class JpegProfilingBenchmarks : MeasureFixture { public JpegProfilingBenchmarks(ITestOutputHelper output) @@ -102,14 +99,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg tf => TestImageProvider.File(tf, pixelTypeOverride: PixelTypes.Rgba32).GetImage()) .ToArray(); - using (MemoryStream ms = new MemoryStream()) + using (var ms = new MemoryStream()) { this.Measure(executionCount, () => { foreach (Image img in testImages) { - JpegEncoder options = new JpegEncoder { Quality = quality, Subsample = subsample }; + var options = new JpegEncoder { Quality = quality, Subsample = subsample }; img.Save(ms, options); ms.Seek(0, SeekOrigin.Begin); } @@ -121,4 +118,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } } -} +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs index 773d7112b..3d09f4b38 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs @@ -1,12 +1,12 @@ -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System.IO; +using System.IO; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using Xunit; +using Xunit; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class LibJpegToolsTests { [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index eb8ee90f9..0d563a7b7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System.Text; using SixLabors.ImageSharp.Formats.Jpeg.Common; using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; @@ -6,14 +9,12 @@ using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.Primitives; + using Xunit; using Xunit.Abstractions; -// ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Formats.Jpg { - using System.Text; - public class ParseStreamTests { private ITestOutputHelper Output { get; } @@ -65,19 +66,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg [InlineData(TestImages.Jpeg.Baseline.Cmyk)] public void PrintComponentData(string imageFile) { - StringBuilder bld = new StringBuilder(); + var sb = new StringBuilder(); using (OrigJpegDecoderCore decoder = JpegFixture.ParseStream(imageFile, true)) { - bld.AppendLine(imageFile); - bld.AppendLine($"Size:{decoder.ImageSizeInPixels} MCU:{decoder.ImageSizeInMCU}"); + sb.AppendLine(imageFile); + sb.AppendLine($"Size:{decoder.ImageSizeInPixels} MCU:{decoder.ImageSizeInMCU}"); OrigComponent c0 = decoder.Components[0]; OrigComponent c1 = decoder.Components[1]; - bld.AppendLine($"Luma: SAMP: {c0.SamplingFactors} BLOCKS: {c0.SizeInBlocks}"); - bld.AppendLine($"Chroma: {c1.SamplingFactors} BLOCKS: {c1.SizeInBlocks}"); + sb.AppendLine($"Luma: SAMP: {c0.SamplingFactors} BLOCKS: {c0.SizeInBlocks}"); + sb.AppendLine($"Chroma: {c1.SamplingFactors} BLOCKS: {c1.SizeInBlocks}"); } - this.Output.WriteLine(bld.ToString()); + this.Output.WriteLine(sb.ToString()); } public static readonly TheoryData ComponentVerificationData = new TheoryData() diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs index 1d368d1f5..fa06f91da 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs @@ -1,14 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System.Text; +using System.Text; - using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; +using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder; - using Xunit; +using Xunit; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class ProfileResolverTests { private static readonly byte[] JFifMarker = Encoding.ASCII.GetBytes("JFIF\0"); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs index 6b9e98d66..b9ae97409 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs @@ -1,11 +1,11 @@ -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using Xunit; - using Xunit.Abstractions; +using Xunit; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public partial class ReferenceImplementationsTests { public class AccurateDCT : JpegFixture diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index 1fc47726b..11612d3e2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -1,14 +1,15 @@ // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System; - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using System; + +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using Xunit; - using Xunit.Abstractions; +using Xunit; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public partial class ReferenceImplementationsTests { public class FastFloatingPointDCT : JpegFixture @@ -79,7 +80,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg this.CompareBlocks(fExpected, fActual, 2); } - [Theory] [InlineData(42)] [InlineData(1)] @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { float[] floatData = JpegFixture.Create8x8RandomFloatData(-1000, 1000); - Block8x8F source = default(Block8x8F); + Block8x8F source = default; source.LoadFrom(floatData); Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformFDCT(ref source); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs index f384a76c4..f249aa93b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs @@ -1,14 +1,15 @@ // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System; - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using System; - using Xunit; - using Xunit.Abstractions; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using Xunit; +using Xunit.Abstractions; + +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public partial class ReferenceImplementationsTests { public class StandardIntegerDCT : JpegFixture @@ -26,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { int[] data = Create8x8RandomIntData(-range, range, seed); - Block8x8 source = default(Block8x8); + Block8x8 source = default; source.LoadFrom(data); Block8x8 expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source); @@ -43,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { int[] data = Create8x8RandomIntData(-1000, 1000, seed); - Block8x8F source = default(Block8x8F); + Block8x8F source = default; source.LoadFrom(data); Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformFDCT(ref source); @@ -53,11 +54,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg Block8x8 actual8 = ReferenceImplementations.StandardIntegerDCT.Subtract128_TransformFDCT_Upscale8(ref temp); Block8x8F actual = actual8.AsFloatBlock(); actual /= 8; - + this.CompareBlocks(expected, actual, 1f); } - [Theory] [InlineData(42, 0)] [InlineData(1, 0)] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index f1ec4af8b..9c134ada9 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -1,19 +1,19 @@ // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg -{ - using System; - using System.IO; - using System.Linq; +using System; +using System.IO; +using System.Linq; - using SixLabors.ImageSharp.Formats.Jpeg; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; - using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; +using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; - using Xunit; - using Xunit.Abstractions; +using Xunit; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg +{ public class SpectralJpegTests { public SpectralJpegTests(ITestOutputHelper output) @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void PdfJsDecoder_ParseStream_SaveSpectralResult(TestImageProvider provider) where TPixel : struct, IPixel { - PdfJsJpegDecoderCore decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder()); + var decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder()); byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg public void OriginalDecoder_ParseStream_SaveSpectralResult(TestImageProvider provider) where TPixel : struct, IPixel { - OrigJpegDecoderCore decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder()); + var decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder()); byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; @@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg return; } - PdfJsJpegDecoderCore decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder()); + var decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder()); byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg return; } - OrigJpegDecoderCore decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder()); + var decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder()); byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index 07268ef21..3e66af50a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -1,24 +1,22 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. - - // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils -{ - using System; - using System.Diagnostics; - using System.IO; - using System.Text; +using System; +using System.Diagnostics; +using System.IO; +using System.Text; - using SixLabors.ImageSharp.Formats.Jpeg; - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; - using Xunit; - using Xunit.Abstractions; +using Xunit; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils +{ public class JpegFixture : MeasureFixture { public JpegFixture(ITestOutputHelper output) : base(output) @@ -70,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils // ReSharper disable once InconsistentNaming public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42) { - Random rnd = new Random(seed); + var rnd = new Random(seed); int[] result = new int[64]; for (int i = 0; i < 8; i++) { @@ -87,7 +85,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42) { - Random rnd = new Random(seed); + var rnd = new Random(seed); float[] result = new float[64]; for (int i = 0; i < 8; i++) { @@ -132,12 +130,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { if (count < 0) count = data.Length; - StringBuilder bld = new StringBuilder(); + var sb = new StringBuilder(); for (int i = 0; i < count; i++) { - bld.Append($"{data[i],3} "); + sb.Append($"{data[i],3} "); } - this.Output.WriteLine(bld.ToString()); + this.Output.WriteLine(sb.ToString()); } protected void Print(string msg) @@ -154,7 +152,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils internal void CompareBlocks(Span a, Span b, float tolerance) { - ApproximateFloatComparer comparer = new ApproximateFloatComparer(tolerance); + var comparer = new ApproximateFloatComparer(tolerance); double totalDifference = 0.0; bool failed = false; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs index a003f749e..45df1d0fc 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs @@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public Image CreateGrayScaleImage() { - Image result = new Image(this.WidthInBlocks * 8, this.HeightInBlocks * 8); + var result = new Image(this.WidthInBlocks * 8, this.HeightInBlocks * 8); for (int by = 0; by < this.HeightInBlocks; by++) { @@ -119,10 +119,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { for (int x = 0; x < 8; x++) { - var val = this.GetBlockValue(block, x, y); + float val = this.GetBlockValue(block, x, y); - Vector4 v = new Vector4(val, val, val, 1); - Rgba32 color = default(Rgba32); + var v = new Vector4(val, val, val, 1); + Rgba32 color = default; color.PackFromVector4(v); int yy = by * 8 + y; @@ -143,8 +143,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public bool Equals(ComponentData other) { - if (Object.ReferenceEquals(null, other)) return false; - if (Object.ReferenceEquals(this, other)) return true; + if (object.ReferenceEquals(null, other)) return false; + if (object.ReferenceEquals(this, other)) return true; bool ok = this.Index == other.Index && this.HeightInBlocks == other.HeightInBlocks && this.WidthInBlocks == other.WidthInBlocks; //&& this.MinVal == other.MinVal diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs index a353b288a..8ce1f111d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs @@ -1,16 +1,16 @@ +using System; +using System.Linq; +using System.Numerics; + +using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; +using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder; +using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; +using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { - using System; - using System.Linq; - using System.Numerics; - - using SixLabors.ImageSharp.Formats.Jpeg.Common; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; - using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder; - using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; - using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components; internal static partial class LibJpegTools { @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils return null; } - Image result = new Image(c0.WidthInBlocks * 8, c0.HeightInBlocks * 8); + var result = new Image(c0.WidthInBlocks * 8, c0.HeightInBlocks * 8); for (int by = 0; by < c0.HeightInBlocks; by++) { @@ -92,8 +92,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils float val1 = c0.GetBlockValue(block1, x, y); float val2 = c0.GetBlockValue(block2, x, y); - Vector4 v = new Vector4(val0, val1, val2, 1); - Rgba32 color = default(Rgba32); + var v = new Vector4(val0, val1, val2, 1); + Rgba32 color = default; color.PackFromVector4(v); int yy = by * 8 + y; @@ -105,8 +105,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public bool Equals(SpectralData other) { - if (Object.ReferenceEquals(null, other)) return false; - if (Object.ReferenceEquals(this, other)) return true; + if (object.ReferenceEquals(null, other)) return false; + if (object.ReferenceEquals(this, other)) return true; if (this.ComponentCount != other.ComponentCount) { return false; @@ -123,8 +123,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils public override bool Equals(object obj) { - if (Object.ReferenceEquals(null, obj)) return false; - if (Object.ReferenceEquals(this, obj)) return true; + if (object.ReferenceEquals(null, obj)) return false; + if (object.ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return this.Equals((SpectralData)obj); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index 5b9c77f32..9ce027e30 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -4,10 +4,10 @@ using System.Diagnostics; using System.IO; using System.Numerics; +using SixLabors.ImageSharp.Formats.Jpeg.Common; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { - using SixLabors.ImageSharp.Formats.Jpeg.Common; - /// /// Utilities to read raw libjpeg data for reference conversion. /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index 6a1e09a9b..08ef40952 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -1,9 +1,9 @@ -namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils -{ - using System; +using System; - using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils +{ internal static partial class ReferenceImplementations { /// @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { int x, y, u, v; double tmp, tmp2; - Block8x8F res = default(Block8x8F); + Block8x8F res = default; for (y=0; y<8; y++) { for (x=0; x<8; x++) { @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { int x, y, u, v; double tmp, tmp2; - Block8x8F res = default(Block8x8F); + Block8x8F res = default; for (v = 0; v < 8; v++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs index 2e2f12fbc..3742e45bd 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs @@ -1,9 +1,9 @@ // ReSharper disable InconsistentNaming +using System; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { - using System; - internal static partial class ReferenceImplementations { /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index e18323f84..e3bae95c8 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -1,14 +1,14 @@ // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils -{ - using System; - using System.Numerics; - using System.Runtime.CompilerServices; +using System; +using System.Numerics; +using System.Runtime.CompilerServices; - using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Formats.Jpeg.Common; - using Xunit.Abstractions; +using Xunit.Abstractions; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils +{ internal static partial class ReferenceImplementations { /// @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils float[] temp = new float[64]; iDCT2D_llm(s, d, temp); - Block8x8F result = default(Block8x8F); + Block8x8F result = default; result.LoadFrom(d); return result; } @@ -48,12 +48,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils float[] temp = new float[64]; fDCT2D_llm(s, d, temp); - Block8x8F result = default(Block8x8F); + Block8x8F result = default; result.LoadFrom(d); return result; } - private static double cos(double x) => Math.Cos(x); + private static double Cos(double x) => Math.Cos(x); private const double M_PI = Math.PI; @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils float[] r = new float[8]; for (int i = 0; i < 8; i++) { - r[i] = (float)(cos((double)i / 16.0 * M_PI) * M_SQRT2); + r[i] = (float)(Cos((double)i / 16.0 * M_PI) * M_SQRT2); output?.WriteLine($"float r{i} = {r[i]:R}f;"); } return r; @@ -214,8 +214,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils /*y[0] = c0 + c1; y[4] = c0 - c1;*/ - Vector4 w0 = new Vector4(0.541196f); - Vector4 w1 = new Vector4(1.306563f); + var w0 = new Vector4(0.541196f); + var w1 = new Vector4(1.306563f); _mm_store_ps(d, 16, ((w0 * c2) + (w1 * c3))); @@ -248,7 +248,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils _mm_store_ps(d, 40, (c3 - c1)); //y[5] = c3 - c1; y[3] = c0 - c2; - Vector4 invsqrt2 = new Vector4(0.707107f); + var invsqrt2 = new Vector4(0.707107f); c0 = ((c0 + c2) * invsqrt2); c3 = ((c3 + c1) * invsqrt2); //c0 = (c0 + c2) * invsqrt2; @@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils fDCT2D8x4_32f(temp.Slice(4), d.Slice(4)); - Vector4 c = new Vector4(0.1250f); + var c = new Vector4(0.1250f); _mm_store_ps(d, 0, (_mm_load_ps(d, 0) * c)); d = d.Slice(4);//0 _mm_store_ps(d, 0, (_mm_load_ps(d, 0) * c)); d = d.Slice(4);//1 diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs index 9afc4b0b3..3d2cbe54f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs @@ -1,10 +1,10 @@ // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils -{ - using System; +using System; - using SixLabors.ImageSharp.Formats.Jpeg.Common; +using SixLabors.ImageSharp.Formats.Jpeg.Common; +namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils +{ internal static partial class ReferenceImplementations { /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs index f1eed08b9..3e3a732e7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs @@ -1,18 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. - - // ReSharper disable InconsistentNaming +using System; +using System.Runtime.CompilerServices; + +using SixLabors.ImageSharp.Formats.Jpeg.Common; namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { - using System; - using System.Runtime.CompilerServices; - - using SixLabors.ImageSharp.Formats.Jpeg.Common; - /// /// This class contains simplified (unefficient) reference implementations to produce verification data for unit tests /// Floating point DCT code Ported from https://github.com/norishigefukushima/dct_simd diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index 988b9e478..e9527e4c3 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -1,12 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; +using System.Numerics; +using System.Runtime.CompilerServices; + namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils { - using System; - using System.Numerics; - using System.Runtime.CompilerServices; - /// /// Span Extensions /// @@ -118,4 +118,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils return result; } } -} +} \ No newline at end of file