Exemple #1
0
        internal static void fDCT2D_llm(
            MutableSpan <float> s,
            MutableSpan <float> d,
            MutableSpan <float> temp,
            bool downscaleBy8         = false,
            bool offsetSourceByNeg128 = false)
        {
            MutableSpan <float> sWorker = offsetSourceByNeg128 ? s.AddScalarToAllValues(-128f) : s;

            for (int j = 0; j < 8; j++)
            {
                fDCT1Dllm_32f(sWorker.Slice(j * 8), temp.Slice(j * 8));
            }

            Transpose8x8(temp, d);

            for (int j = 0; j < 8; j++)
            {
                fDCT1Dllm_32f(d.Slice(j * 8), temp.Slice(j * 8));
            }

            Transpose8x8(temp, d);

            if (downscaleBy8)
            {
                for (int j = 0; j < 64; j++)
                {
                    d[j] *= 0.125f;
                }
            }
        }
        public void IntegerDCT_ForwardThenInverse(int seed, int startAt)
        {
            MutableSpan <int> original = Create8x8RandomIntData(-200, 200, seed);

            var block = original.AddScalarToAllValues(128);

            ReferenceImplementations.IntegerReferenceDCT.TransformFDCTInplace(block);

            for (int i = 0; i < 64; i++)
            {
                block[i] /= 8;
            }

            ReferenceImplementations.IntegerReferenceDCT.TransformIDCTInplace(block);

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

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