Browse Source

well ... that LLM implementation is actually NOT inaccurate

pull/322/head
Anton Firszov 9 years ago
parent
commit
ba0c8b8f11
  1. 21
      tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs
  2. 12
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs

21
tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

@ -76,26 +76,17 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(3)]
public void LLM_TransformIDCT_CompareToNonOptimized(int seed)
{
Span<float> sourceArray = JpegUtilityTestFixture.Create8x8RoundedRandomFloatData(-200, 200, seed);
float[] expectedDestArray = new float[64];
float[] tempArray = new float[64];
ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D_llm(sourceArray, expectedDestArray, tempArray);
float[] sourceArray = JpegUtilityTestFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed);
var source = Block8x8F.Load(sourceArray);
var dest = default(Block8x8F);
var temp = default(Block8x8F);
FastFloatingPointDCT.TransformIDCT(ref source, ref dest, ref temp);
Block8x8F expected = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref source);
float[] actualDestArray = new float[64];
dest.CopyTo(actualDestArray);
var temp = default(Block8x8F);
var actual = default(Block8x8F);
FastFloatingPointDCT.TransformIDCT(ref source, ref actual, ref temp);
this.Print8x8Data(expectedDestArray);
this.Output.WriteLine("**************");
this.Print8x8Data(actualDestArray);
Assert.Equal(expectedDestArray, actualDestArray, new ApproximateFloatComparer(1f));
Assert.Equal(expectedDestArray, actualDestArray, new ApproximateFloatComparer(1f));
this.CompareBlocks(expected, actual, 1f);
}
[Theory]

12
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs

@ -50,17 +50,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2, 200)]
public void LLM_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range)
{
int[] intData = JpegUtilityTestFixture.Create8x8RandomIntData(-range, range, seed);
float[] floatSrc = intData.ConvertAllToFloat();
float[] sourceArray = JpegUtilityTestFixture.Create8x8RoundedRandomFloatData(-1000, 1000, seed);
ReferenceImplementations.AccurateDCT.TransformIDCTInplace(intData);
var source = Block8x8F.Load(sourceArray);
float[] dest = new float[64];
float[] temp = new float[64];
Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source);
ReferenceImplementations.LLM_FloatingPoint_DCT.iDCT2D_llm(floatSrc, dest, temp);
Block8x8F actual = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref source);
this.CompareBlocks(intData.ConvertAllToFloat(), dest, 1f);
this.CompareBlocks(expected, actual, 1f);
}
[Theory]

Loading…
Cancel
Save