コード例 #1
0
ファイル: Block8x8FTests.cs プロジェクト: zoroz/ImageSharp
        public void IDCTInto()
        {
            float[] sourceArray       = Create8x8FloatData();
            float[] expectedDestArray = new float[64];
            float[] tempArray         = new float[64];

            ReferenceImplementations.iDCT2D_llm(sourceArray, expectedDestArray, tempArray);

            //ReferenceImplementations.iDCT8x8_llm_sse(sourceArray, expectedDestArray, tempArray);

            Block8x8F source = new Block8x8F();

            source.LoadFrom(sourceArray);

            Block8x8F dest       = new Block8x8F();
            Block8x8F tempBuffer = new Block8x8F();

            source.TransformIDCTInto(ref dest, ref tempBuffer);

            float[] actualDestArray = new float[64];
            dest.CopyTo(actualDestArray);

            Print8x8Data(expectedDestArray);
            Output.WriteLine("**************");
            Print8x8Data(actualDestArray);
            Assert.Equal(expectedDestArray, actualDestArray, new ApproximateFloatComparer());
            Assert.Equal(expectedDestArray, actualDestArray, new ApproximateFloatComparer());
        }
コード例 #2
0
        public void FloatingPointDCT_ReferenceImplementation_ForwardThenInverse(int seed, int startAt)
        {
            var data = Create8x8RandomIntData(-200, 200, seed);
            MutableSpan <float> src  = new MutableSpan <int>(data).ConvertToFloat32MutableSpan();
            MutableSpan <float> dest = new MutableSpan <float>(64);
            MutableSpan <float> temp = new MutableSpan <float>(64);

            ReferenceImplementations.fDCT2D_llm(src, dest, temp, true);
            ReferenceImplementations.iDCT2D_llm(dest, src, temp);

            for (int i = startAt; i < 64; i++)
            {
                float expected = data[i];
                float actual   = (float)src[i];

                Assert.Equal(expected, actual, new ApproximateFloatComparer(2f));
            }
        }
コード例 #3
0
        public void Idct_FloatingPointReferenceImplementation_IsEquivalentToIntegerImplementation(int seed)
        {
            MutableSpan <int>   intData  = Create8x8RandomIntData(-200, 200, seed);
            MutableSpan <float> floatSrc = intData.ConvertToFloat32MutableSpan();

            ReferenceImplementations.IntegerReferenceDCT.TransformIDCTInplace(intData);

            MutableSpan <float> dest = new MutableSpan <float>(64);
            MutableSpan <float> temp = new MutableSpan <float>(64);

            ReferenceImplementations.iDCT2D_llm(floatSrc, dest, temp);

            for (int i = 0; i < 64; i++)
            {
                float expected = intData[i];
                float actual   = dest[i];

                Assert.Equal(expected, actual, new ApproximateFloatComparer(1f));
            }
        }