Exemplo n.º 1
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));
            }
        }
Exemplo n.º 2
0
        public void TransposeInto()
        {
            float[] expected = Create8x8FloatData();
            ReferenceImplementations.Transpose8x8(expected);

            Block8x8F source = new Block8x8F();

            source.LoadFrom(Create8x8FloatData());

            Block8x8F dest = new Block8x8F();

            source.TransposeInto(ref dest);

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

            Assert.Equal(expected, actual);
        }
        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));
            }
        }
Exemplo n.º 4
0
        public void iDCT2D8x4_RightPart()
        {
            MutableSpan <float> sourceArray       = Create8x8FloatData();
            MutableSpan <float> expectedDestArray = new float[64];

            ReferenceImplementations.iDCT2D8x4_32f(sourceArray.Slice(4), expectedDestArray.Slice(4));

            Block8x8F source = new Block8x8F();

            source.LoadFrom(sourceArray);

            Block8x8F dest = new Block8x8F();

            source.IDCT8x4_RightPart(ref dest);

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

            Print8x8Data(expectedDestArray);
            Output.WriteLine("**************");
            Print8x8Data(actualDestArray);

            Assert.Equal(expectedDestArray.Data, actualDestArray);
        }