public static void IDCT8x4_LeftPart(ref Block8x8F s, ref Block8x8F d) { Vector4 my1 = s.V1L; Vector4 my7 = s.V7L; Vector4 mz0 = my1 + my7; Vector4 my3 = s.V3L; Vector4 mz2 = my3 + my7; Vector4 my5 = s.V5L; Vector4 mz1 = my3 + my5; Vector4 mz3 = my1 + my5; Vector4 mz4 = (mz0 + mz1) * C_1_175876; mz2 = (mz2 * C_1_961571) + mz4; mz3 = (mz3 * C_0_390181) + mz4; mz0 = mz0 * C_0_899976; mz1 = mz1 * C_2_562915; Vector4 mb3 = (my7 * C_0_298631) + mz0 + mz2; Vector4 mb2 = (my5 * C_2_053120) + mz1 + mz3; Vector4 mb1 = (my3 * C_3_072711) + mz1 + mz2; Vector4 mb0 = (my1 * C_1_501321) + mz0 + mz3; Vector4 my2 = s.V2L; Vector4 my6 = s.V6L; mz4 = (my2 + my6) * C_0_541196; Vector4 my0 = s.V0L; Vector4 my4 = s.V4L; mz0 = my0 + my4; mz1 = my0 - my4; mz2 = mz4 + (my6 * C_1_847759); mz3 = mz4 + (my2 * C_0_765367); my0 = mz0 + mz3; my3 = mz0 - mz3; my1 = mz1 + mz2; my2 = mz1 - mz2; d.V0L = my0 + mb0; d.V7L = my0 - mb0; d.V1L = my1 + mb1; d.V6L = my1 - mb1; d.V2L = my2 + mb2; d.V5L = my2 - mb2; d.V3L = my3 + mb3; d.V4L = my3 - mb3; }
/// <summary> /// Apply floating point IDCT transformation into dest, using a temporary block 'temp' provided by the caller (optimization). /// Ported from https://github.com/norishigefukushima/dct_simd/blob/master/dct/dct8x8_simd.cpp#L239 /// </summary> /// <param name="src">Source</param> /// <param name="dest">Destination</param> /// <param name="temp">Temporary block provided by the caller</param> public static void TransformIDCT(ref Block8x8F src, ref Block8x8F dest, ref Block8x8F temp) { src.TransposeInto(ref temp); IDCT8x4_LeftPart(ref temp, ref dest); IDCT8x4_RightPart(ref temp, ref dest); dest.TransposeInto(ref temp); IDCT8x4_LeftPart(ref temp, ref dest); IDCT8x4_RightPart(ref temp, ref dest); // TODO: What if we leave the blocks in a scaled-by-x8 state until final color packing? dest.MultiplyInPlace(C_0_125); }
/// <summary> /// Apply floating point IDCT transformation into dest, using a temporary block 'temp' provided by the caller (optimization) /// </summary> /// <param name="src">Source</param> /// <param name="dest">Destination</param> /// <param name="temp">Temporary block provided by the caller</param> /// <param name="offsetSourceByNeg128">If true, a constant -128.0 offset is applied for all values before FDCT </param> public static void TransformFDCT( ref Block8x8F src, ref Block8x8F dest, ref Block8x8F temp, bool offsetSourceByNeg128 = true) { src.TransposeInto(ref temp); if (offsetSourceByNeg128) { temp.AddInPlace(-128F); } FDCT8x4_LeftPart(ref temp, ref dest); FDCT8x4_RightPart(ref temp, ref dest); dest.TransposeInto(ref temp); FDCT8x4_LeftPart(ref temp, ref dest); FDCT8x4_RightPart(ref temp, ref dest); dest.MultiplyInPlace(C_0_125); }