Example #1
0
            public void LLM_TransformIDCT_CompareToAccurate(int seed)
            {
                float[] sourceArray = Create8x8RoundedRandomFloatData(MinAllowedValue, MaxAllowedValue, seed);

                var srcBlock = Block8x8F.Load(sourceArray);

                // reference
                Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref srcBlock);

                // testee
                // Part of the IDCT calculations is fused into the quantization step
                // We must multiply input block with adjusted no-quantization matrix
                // before applying IDCT
                // Dequantization using unit matrix - no values are upscaled
                Block8x8F dequantMatrix = CreateBlockFromScalar(1);

                // This step is needed to apply adjusting multipliers to the input block
                FastFloatingPointDCT.AdjustToIDCT(ref dequantMatrix);

                // IDCT implementation tranforms blocks after transposition
                srcBlock.TransposeInplace();
                srcBlock.MultiplyInPlace(ref dequantMatrix);

                // IDCT calculation
                FastFloatingPointDCT.TransformIDCT(ref srcBlock);

                this.CompareBlocks(expected, srcBlock, 1f);
            }
Example #2
0
            public void LLM_IDCT_IsEquivalentTo_AccurateImplementation(int seed, int range)
            {
                float[] sourceArray = JpegFixture.Create8x8RoundedRandomFloatData(-range, range, seed);

                var source = Block8x8F.Load(sourceArray);

                Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source);

                Block8x8F actual = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref source);

                this.CompareBlocks(expected, actual, 0.1f);
            }
Example #3
0
            public void LLM_TransformIDCT_CompareToAccurate(int seed)
            {
                float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed);

                var srcBlock = Block8x8F.Load(sourceArray);

                Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref srcBlock);

                var temp = default(Block8x8F);

                FastFloatingPointDCT.TransformIDCT(ref srcBlock, ref temp);

                this.CompareBlocks(expected, srcBlock, 1f);
            }
Example #4
0
            public void LLM_TransformIDCT_CompareToNonOptimized(int seed)
            {
                float[] sourceArray = Create8x8RoundedRandomFloatData(-1000, 1000, seed);

                var source = Block8x8F.Load(sourceArray);

                Block8x8F expected = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref source);

                var temp   = default(Block8x8F);
                var actual = default(Block8x8F);

                FastFloatingPointDCT.TransformIDCT(ref source, ref actual, ref temp);

                this.CompareBlocks(expected, actual, 1f);
            }
        public void Setup()
        {
            var random = new Random();

            float[] f = new float[8 * 8];
            for (int i = 0; i < f.Length; i++)
            {
                f[i] = (float)random.NextDouble();
            }

            for (int i = 0; i < 4; i++)
            {
                this.target[i] = Block8x8F.Load(f);
            }

            this.source = Block8x8F.Load(f);
        }
Example #6
0
 internal static Block8x8F CreateRoundedRandomFloatBlock(int minValue, int maxValue, int seed = 42) =>
 Block8x8F.Load(Create8x8RoundedRandomFloatData(minValue, maxValue, seed));