mirror of https://github.com/SixLabors/ImageSharp
19 changed files with 2190 additions and 129 deletions
@ -1,10 +1,184 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Adst16Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Adst16Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[16]; |
||||
|
Span<int> temp1 = stackalloc int[16]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
Guard.IsFalse(output == input, nameof(output), "Cannot operate on same buffer for input and output."); |
||||
|
temp1[0] = input; |
||||
|
temp1[1] = -Unsafe.Add(ref input, 15); |
||||
|
temp1[2] = -Unsafe.Add(ref input, 7); |
||||
|
temp1[3] = Unsafe.Add(ref input, 8); |
||||
|
temp1[4] = -Unsafe.Add(ref input, 3); |
||||
|
temp1[5] = Unsafe.Add(ref input, 12); |
||||
|
temp1[6] = Unsafe.Add(ref input, 4); |
||||
|
temp1[7] = -Unsafe.Add(ref input, 11); |
||||
|
temp1[8] = -Unsafe.Add(ref input, 1); |
||||
|
temp1[9] = Unsafe.Add(ref input, 14); |
||||
|
temp1[10] = Unsafe.Add(ref input, 6); |
||||
|
temp1[11] = -Unsafe.Add(ref input, 9); |
||||
|
temp1[12] = Unsafe.Add(ref input, 2); |
||||
|
temp1[13] = -Unsafe.Add(ref input, 13); |
||||
|
temp1[14] = -Unsafe.Add(ref input, 5); |
||||
|
temp1[15] = Unsafe.Add(ref input, 10); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[2], cospi[32], temp1[3], cosBit); |
||||
|
temp0[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[2], -cospi[32], temp1[3], cosBit); |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[6], cospi[32], temp1[7], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[6], -cospi[32], temp1[7], cosBit); |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[10], cospi[32], temp1[11], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[10], -cospi[32], temp1[11], cosBit); |
||||
|
temp0[12] = temp1[12]; |
||||
|
temp0[13] = temp1[13]; |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[14], cospi[32], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[14], -cospi[32], temp1[15], cosBit); |
||||
|
|
||||
|
// stage 3
|
||||
|
temp1[0] = temp0[0] + temp0[2]; |
||||
|
temp1[1] = temp0[1] + temp0[3]; |
||||
|
temp1[2] = temp0[0] - temp0[2]; |
||||
|
temp1[3] = temp0[1] - temp0[3]; |
||||
|
temp1[4] = temp0[4] + temp0[6]; |
||||
|
temp1[5] = temp0[5] + temp0[7]; |
||||
|
temp1[6] = temp0[4] - temp0[6]; |
||||
|
temp1[7] = temp0[5] - temp0[7]; |
||||
|
temp1[8] = temp0[8] + temp0[10]; |
||||
|
temp1[9] = temp0[9] + temp0[11]; |
||||
|
temp1[10] = temp0[8] - temp0[10]; |
||||
|
temp1[11] = temp0[9] - temp0[11]; |
||||
|
temp1[12] = temp0[12] + temp0[14]; |
||||
|
temp1[13] = temp0[13] + temp0[15]; |
||||
|
temp1[14] = temp0[12] - temp0[14]; |
||||
|
temp1[15] = temp0[13] - temp0[15]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[4], cospi[48], temp1[5], cosBit); |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[4], -cospi[16], temp1[5], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[6], cospi[16], temp1[7], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[6], cospi[48], temp1[7], cosBit); |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = temp1[10]; |
||||
|
temp0[11] = temp1[11]; |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[12], cospi[48], temp1[13], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[12], -cospi[16], temp1[13], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[14], cospi[16], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[14], cospi[48], temp1[15], cosBit); |
||||
|
|
||||
|
// stage 5
|
||||
|
temp1[0] = temp0[0] + temp0[4]; |
||||
|
temp1[1] = temp0[1] + temp0[5]; |
||||
|
temp1[2] = temp0[2] + temp0[6]; |
||||
|
temp1[3] = temp0[3] + temp0[7]; |
||||
|
temp1[4] = temp0[0] - temp0[4]; |
||||
|
temp1[5] = temp0[1] - temp0[5]; |
||||
|
temp1[6] = temp0[2] - temp0[6]; |
||||
|
temp1[7] = temp0[3] - temp0[7]; |
||||
|
temp1[8] = temp0[8] + temp0[12]; |
||||
|
temp1[9] = temp0[9] + temp0[13]; |
||||
|
temp1[10] = temp0[10] + temp0[14]; |
||||
|
temp1[11] = temp0[11] + temp0[15]; |
||||
|
temp1[12] = temp0[8] - temp0[12]; |
||||
|
temp1[13] = temp0[9] - temp0[13]; |
||||
|
temp1[14] = temp0[10] - temp0[14]; |
||||
|
temp1[15] = temp0[11] - temp0[15]; |
||||
|
|
||||
|
// stage 6
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = temp1[6]; |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp1[8], cospi[56], temp1[9], cosBit); |
||||
|
temp0[9] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[8], -cospi[8], temp1[9], cosBit); |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp1[10], cospi[24], temp1[11], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[10], -cospi[40], temp1[11], cosBit); |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp1[12], cospi[8], temp1[13], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp1[12], cospi[56], temp1[13], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp1[14], cospi[40], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp1[14], cospi[24], temp1[15], cosBit); |
||||
|
|
||||
|
// stage 7
|
||||
|
temp1[0] = temp0[0] + temp0[8]; |
||||
|
temp1[1] = temp0[1] + temp0[9]; |
||||
|
temp1[2] = temp0[2] + temp0[10]; |
||||
|
temp1[3] = temp0[3] + temp0[11]; |
||||
|
temp1[4] = temp0[4] + temp0[12]; |
||||
|
temp1[5] = temp0[5] + temp0[13]; |
||||
|
temp1[6] = temp0[6] + temp0[14]; |
||||
|
temp1[7] = temp0[7] + temp0[15]; |
||||
|
temp1[8] = temp0[0] - temp0[8]; |
||||
|
temp1[9] = temp0[1] - temp0[9]; |
||||
|
temp1[10] = temp0[2] - temp0[10]; |
||||
|
temp1[11] = temp0[3] - temp0[11]; |
||||
|
temp1[12] = temp0[4] - temp0[12]; |
||||
|
temp1[13] = temp0[5] - temp0[13]; |
||||
|
temp1[14] = temp0[6] - temp0[14]; |
||||
|
temp1[15] = temp0[7] - temp0[15]; |
||||
|
|
||||
|
// stage 8
|
||||
|
temp0[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[2], temp1[0], cospi[62], temp1[1], cosBit); |
||||
|
temp0[1] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[62], temp1[0], -cospi[2], temp1[1], cosBit); |
||||
|
temp0[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[10], temp1[2], cospi[54], temp1[3], cosBit); |
||||
|
temp0[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[54], temp1[2], -cospi[10], temp1[3], cosBit); |
||||
|
temp0[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[18], temp1[4], cospi[46], temp1[5], cosBit); |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[46], temp1[4], -cospi[18], temp1[5], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[26], temp1[6], cospi[38], temp1[7], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[38], temp1[6], -cospi[26], temp1[7], cosBit); |
||||
|
temp0[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[34], temp1[8], cospi[30], temp1[9], cosBit); |
||||
|
temp0[9] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[30], temp1[8], -cospi[34], temp1[9], cosBit); |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[42], temp1[10], cospi[22], temp1[11], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[22], temp1[10], -cospi[42], temp1[11], cosBit); |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[50], temp1[12], cospi[14], temp1[13], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[14], temp1[12], -cospi[50], temp1[13], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[58], temp1[14], cospi[6], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[6], temp1[14], -cospi[58], temp1[15], cosBit); |
||||
|
|
||||
|
// stage 9
|
||||
|
output = temp0[1]; |
||||
|
Unsafe.Add(ref output, 1) = temp0[14]; |
||||
|
Unsafe.Add(ref output, 2) = temp0[3]; |
||||
|
Unsafe.Add(ref output, 3) = temp0[12]; |
||||
|
Unsafe.Add(ref output, 4) = temp0[5]; |
||||
|
Unsafe.Add(ref output, 5) = temp0[10]; |
||||
|
Unsafe.Add(ref output, 6) = temp0[7]; |
||||
|
Unsafe.Add(ref output, 7) = temp0[8]; |
||||
|
Unsafe.Add(ref output, 8) = temp0[9]; |
||||
|
Unsafe.Add(ref output, 9) = temp0[6]; |
||||
|
Unsafe.Add(ref output, 10) = temp0[11]; |
||||
|
Unsafe.Add(ref output, 11) = temp0[4]; |
||||
|
Unsafe.Add(ref output, 12) = temp0[13]; |
||||
|
Unsafe.Add(ref output, 13) = temp0[2]; |
||||
|
Unsafe.Add(ref output, 14) = temp0[15]; |
||||
|
Unsafe.Add(ref output, 15) = temp0[0]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,395 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Adst32Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Adst32Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int outputRef, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[32]; |
||||
|
Span<int> temp1 = stackalloc int[32]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
temp1[0] = Unsafe.Add(ref input, 31); |
||||
|
temp1[1] = input; |
||||
|
temp1[2] = Unsafe.Add(ref input, 29); |
||||
|
temp1[3] = Unsafe.Add(ref input, 2); |
||||
|
temp1[4] = Unsafe.Add(ref input, 27); |
||||
|
temp1[5] = Unsafe.Add(ref input, 4); |
||||
|
temp1[6] = Unsafe.Add(ref input, 25); |
||||
|
temp1[7] = Unsafe.Add(ref input, 6); |
||||
|
temp1[8] = Unsafe.Add(ref input, 23); |
||||
|
temp1[9] = Unsafe.Add(ref input, 8); |
||||
|
temp1[10] = Unsafe.Add(ref input, 21); |
||||
|
temp1[11] = Unsafe.Add(ref input, 10); |
||||
|
temp1[12] = Unsafe.Add(ref input, 19); |
||||
|
temp1[13] = Unsafe.Add(ref input, 12); |
||||
|
temp1[14] = Unsafe.Add(ref input, 17); |
||||
|
temp1[15] = Unsafe.Add(ref input, 14); |
||||
|
temp1[16] = Unsafe.Add(ref input, 15); |
||||
|
temp1[17] = Unsafe.Add(ref input, 16); |
||||
|
temp1[18] = Unsafe.Add(ref input, 13); |
||||
|
temp1[19] = Unsafe.Add(ref input, 18); |
||||
|
temp1[20] = Unsafe.Add(ref input, 11); |
||||
|
temp1[21] = Unsafe.Add(ref input, 20); |
||||
|
temp1[22] = Unsafe.Add(ref input, 9); |
||||
|
temp1[23] = Unsafe.Add(ref input, 22); |
||||
|
temp1[24] = Unsafe.Add(ref input, 7); |
||||
|
temp1[25] = Unsafe.Add(ref input, 24); |
||||
|
temp1[26] = Unsafe.Add(ref input, 5); |
||||
|
temp1[27] = Unsafe.Add(ref input, 26); |
||||
|
temp1[28] = Unsafe.Add(ref input, 3); |
||||
|
temp1[29] = Unsafe.Add(ref input, 28); |
||||
|
temp1[30] = Unsafe.Add(ref input, 1); |
||||
|
temp1[31] = Unsafe.Add(ref input, 30); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp0[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[1], temp1[0], cospi[63], temp1[1], cosBit); |
||||
|
temp0[1] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[1], temp1[1], cospi[63], temp1[0], cosBit); |
||||
|
temp0[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[5], temp1[2], cospi[59], temp1[3], cosBit); |
||||
|
temp0[3] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[5], temp1[3], cospi[59], temp1[2], cosBit); |
||||
|
temp0[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[9], temp1[4], cospi[55], temp1[5], cosBit); |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[9], temp1[5], cospi[55], temp1[4], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[13], temp1[6], cospi[51], temp1[7], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[13], temp1[7], cospi[51], temp1[6], cosBit); |
||||
|
temp0[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[17], temp1[8], cospi[47], temp1[9], cosBit); |
||||
|
temp0[9] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[17], temp1[9], cospi[47], temp1[8], cosBit); |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[21], temp1[10], cospi[43], temp1[11], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[21], temp1[11], cospi[43], temp1[10], cosBit); |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[25], temp1[12], cospi[39], temp1[13], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[25], temp1[13], cospi[39], temp1[12], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[29], temp1[14], cospi[35], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[29], temp1[15], cospi[35], temp1[14], cosBit); |
||||
|
temp0[16] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[33], temp1[16], cospi[31], temp1[17], cosBit); |
||||
|
temp0[17] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[33], temp1[17], cospi[31], temp1[16], cosBit); |
||||
|
temp0[18] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[37], temp1[18], cospi[27], temp1[19], cosBit); |
||||
|
temp0[19] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[37], temp1[19], cospi[27], temp1[18], cosBit); |
||||
|
temp0[20] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[41], temp1[20], cospi[23], temp1[21], cosBit); |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[41], temp1[21], cospi[23], temp1[20], cosBit); |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[45], temp1[22], cospi[19], temp1[23], cosBit); |
||||
|
temp0[23] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[45], temp1[23], cospi[19], temp1[22], cosBit); |
||||
|
temp0[24] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[49], temp1[24], cospi[15], temp1[25], cosBit); |
||||
|
temp0[25] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[49], temp1[25], cospi[15], temp1[24], cosBit); |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[53], temp1[26], cospi[11], temp1[27], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[53], temp1[27], cospi[11], temp1[26], cosBit); |
||||
|
temp0[28] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[57], temp1[28], cospi[7], temp1[29], cosBit); |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[57], temp1[29], cospi[7], temp1[28], cosBit); |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[61], temp1[30], cospi[3], temp1[31], cosBit); |
||||
|
temp0[31] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[61], temp1[31], cospi[3], temp1[30], cosBit); |
||||
|
|
||||
|
// stage 3
|
||||
|
temp1[0] = temp0[0] + temp0[16]; |
||||
|
temp1[1] = temp0[1] + temp0[17]; |
||||
|
temp1[2] = temp0[2] + temp0[18]; |
||||
|
temp1[3] = temp0[3] + temp0[19]; |
||||
|
temp1[4] = temp0[4] + temp0[20]; |
||||
|
temp1[5] = temp0[5] + temp0[21]; |
||||
|
temp1[6] = temp0[6] + temp0[22]; |
||||
|
temp1[7] = temp0[7] + temp0[23]; |
||||
|
temp1[8] = temp0[8] + temp0[24]; |
||||
|
temp1[9] = temp0[9] + temp0[25]; |
||||
|
temp1[10] = temp0[10] + temp0[26]; |
||||
|
temp1[11] = temp0[11] + temp0[27]; |
||||
|
temp1[12] = temp0[12] + temp0[28]; |
||||
|
temp1[13] = temp0[13] + temp0[29]; |
||||
|
temp1[14] = temp0[14] + temp0[30]; |
||||
|
temp1[15] = temp0[15] + temp0[31]; |
||||
|
temp1[16] = -temp0[16] + temp0[0]; |
||||
|
temp1[17] = -temp0[17] + temp0[1]; |
||||
|
temp1[18] = -temp0[18] + temp0[2]; |
||||
|
temp1[19] = -temp0[19] + temp0[3]; |
||||
|
temp1[20] = -temp0[20] + temp0[4]; |
||||
|
temp1[21] = -temp0[21] + temp0[5]; |
||||
|
temp1[22] = -temp0[22] + temp0[6]; |
||||
|
temp1[23] = -temp0[23] + temp0[7]; |
||||
|
temp1[24] = -temp0[24] + temp0[8]; |
||||
|
temp1[25] = -temp0[25] + temp0[9]; |
||||
|
temp1[26] = -temp0[26] + temp0[10]; |
||||
|
temp1[27] = -temp0[27] + temp0[11]; |
||||
|
temp1[28] = -temp0[28] + temp0[12]; |
||||
|
temp1[29] = -temp0[29] + temp0[13]; |
||||
|
temp1[30] = -temp0[30] + temp0[14]; |
||||
|
temp1[31] = -temp0[31] + temp0[15]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = temp1[6]; |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = temp1[10]; |
||||
|
temp0[11] = temp1[11]; |
||||
|
temp0[12] = temp1[12]; |
||||
|
temp0[13] = temp1[13]; |
||||
|
temp0[14] = temp1[14]; |
||||
|
temp0[15] = temp1[15]; |
||||
|
temp0[16] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[4], temp1[16], cospi[60], temp1[17], cosBit); |
||||
|
temp0[17] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[4], temp1[17], cospi[60], temp1[16], cosBit); |
||||
|
temp0[18] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[20], temp1[18], cospi[44], temp1[19], cosBit); |
||||
|
temp0[19] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[20], temp1[19], cospi[44], temp1[18], cosBit); |
||||
|
temp0[20] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[36], temp1[20], cospi[28], temp1[21], cosBit); |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[36], temp1[21], cospi[28], temp1[20], cosBit); |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[52], temp1[22], cospi[12], temp1[23], cosBit); |
||||
|
temp0[23] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[52], temp1[23], cospi[12], temp1[22], cosBit); |
||||
|
temp0[24] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[60], temp1[24], cospi[4], temp1[25], cosBit); |
||||
|
temp0[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp1[25], cospi[4], temp1[24], cosBit); |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[44], temp1[26], cospi[20], temp1[27], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp1[27], cospi[20], temp1[26], cosBit); |
||||
|
temp0[28] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[28], temp1[28], cospi[36], temp1[29], cosBit); |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp1[29], cospi[36], temp1[28], cosBit); |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[12], temp1[30], cospi[52], temp1[31], cosBit); |
||||
|
temp0[31] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp1[31], cospi[52], temp1[30], cosBit); |
||||
|
|
||||
|
// stage 5
|
||||
|
temp1[0] = temp0[0] + temp0[8]; |
||||
|
temp1[1] = temp0[1] + temp0[9]; |
||||
|
temp1[2] = temp0[2] + temp0[10]; |
||||
|
temp1[3] = temp0[3] + temp0[11]; |
||||
|
temp1[4] = temp0[4] + temp0[12]; |
||||
|
temp1[5] = temp0[5] + temp0[13]; |
||||
|
temp1[6] = temp0[6] + temp0[14]; |
||||
|
temp1[7] = temp0[7] + temp0[15]; |
||||
|
temp1[8] = -temp0[8] + temp0[0]; |
||||
|
temp1[9] = -temp0[9] + temp0[1]; |
||||
|
temp1[10] = -temp0[10] + temp0[2]; |
||||
|
temp1[11] = -temp0[11] + temp0[3]; |
||||
|
temp1[12] = -temp0[12] + temp0[4]; |
||||
|
temp1[13] = -temp0[13] + temp0[5]; |
||||
|
temp1[14] = -temp0[14] + temp0[6]; |
||||
|
temp1[15] = -temp0[15] + temp0[7]; |
||||
|
temp1[16] = temp0[16] + temp0[24]; |
||||
|
temp1[17] = temp0[17] + temp0[25]; |
||||
|
temp1[18] = temp0[18] + temp0[26]; |
||||
|
temp1[19] = temp0[19] + temp0[27]; |
||||
|
temp1[20] = temp0[20] + temp0[28]; |
||||
|
temp1[21] = temp0[21] + temp0[29]; |
||||
|
temp1[22] = temp0[22] + temp0[30]; |
||||
|
temp1[23] = temp0[23] + temp0[31]; |
||||
|
temp1[24] = -temp0[24] + temp0[16]; |
||||
|
temp1[25] = -temp0[25] + temp0[17]; |
||||
|
temp1[26] = -temp0[26] + temp0[18]; |
||||
|
temp1[27] = -temp0[27] + temp0[19]; |
||||
|
temp1[28] = -temp0[28] + temp0[20]; |
||||
|
temp1[29] = -temp0[29] + temp0[21]; |
||||
|
temp1[30] = -temp0[30] + temp0[22]; |
||||
|
temp1[31] = -temp0[31] + temp0[23]; |
||||
|
|
||||
|
// stage 6
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = temp1[6]; |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp1[8], cospi[56], temp1[9], cosBit); |
||||
|
temp0[9] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[8], temp1[9], cospi[56], temp1[8], cosBit); |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp1[10], cospi[24], temp1[11], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[40], temp1[11], cospi[24], temp1[10], cosBit); |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp1[12], cospi[8], temp1[13], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[13], cospi[8], temp1[12], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp1[14], cospi[40], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[15], cospi[40], temp1[14], cosBit); |
||||
|
temp0[16] = temp1[16]; |
||||
|
temp0[17] = temp1[17]; |
||||
|
temp0[18] = temp1[18]; |
||||
|
temp0[19] = temp1[19]; |
||||
|
temp0[20] = temp1[20]; |
||||
|
temp0[21] = temp1[21]; |
||||
|
temp0[22] = temp1[22]; |
||||
|
temp0[23] = temp1[23]; |
||||
|
temp0[24] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp1[24], cospi[56], temp1[25], cosBit); |
||||
|
temp0[25] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[8], temp1[25], cospi[56], temp1[24], cosBit); |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp1[26], cospi[24], temp1[27], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[40], temp1[27], cospi[24], temp1[26], cosBit); |
||||
|
temp0[28] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp1[28], cospi[8], temp1[29], cosBit); |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[29], cospi[8], temp1[28], cosBit); |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp1[30], cospi[40], temp1[31], cosBit); |
||||
|
temp0[31] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[31], cospi[40], temp1[30], cosBit); |
||||
|
|
||||
|
// stage 7
|
||||
|
temp1[0] = temp0[0] + temp0[4]; |
||||
|
temp1[1] = temp0[1] + temp0[5]; |
||||
|
temp1[2] = temp0[2] + temp0[6]; |
||||
|
temp1[3] = temp0[3] + temp0[7]; |
||||
|
temp1[4] = -temp0[4] + temp0[0]; |
||||
|
temp1[5] = -temp0[5] + temp0[1]; |
||||
|
temp1[6] = -temp0[6] + temp0[2]; |
||||
|
temp1[7] = -temp0[7] + temp0[3]; |
||||
|
temp1[8] = temp0[8] + temp0[12]; |
||||
|
temp1[9] = temp0[9] + temp0[13]; |
||||
|
temp1[10] = temp0[10] + temp0[14]; |
||||
|
temp1[11] = temp0[11] + temp0[15]; |
||||
|
temp1[12] = -temp0[12] + temp0[8]; |
||||
|
temp1[13] = -temp0[13] + temp0[9]; |
||||
|
temp1[14] = -temp0[14] + temp0[10]; |
||||
|
temp1[15] = -temp0[15] + temp0[11]; |
||||
|
temp1[16] = temp0[16] + temp0[20]; |
||||
|
temp1[17] = temp0[17] + temp0[21]; |
||||
|
temp1[18] = temp0[18] + temp0[22]; |
||||
|
temp1[19] = temp0[19] + temp0[23]; |
||||
|
temp1[20] = -temp0[20] + temp0[16]; |
||||
|
temp1[21] = -temp0[21] + temp0[17]; |
||||
|
temp1[22] = -temp0[22] + temp0[18]; |
||||
|
temp1[23] = -temp0[23] + temp0[19]; |
||||
|
temp1[24] = temp0[24] + temp0[28]; |
||||
|
temp1[25] = temp0[25] + temp0[29]; |
||||
|
temp1[26] = temp0[26] + temp0[30]; |
||||
|
temp1[27] = temp0[27] + temp0[31]; |
||||
|
temp1[28] = -temp0[28] + temp0[24]; |
||||
|
temp1[29] = -temp0[29] + temp0[25]; |
||||
|
temp1[30] = -temp0[30] + temp0[26]; |
||||
|
temp1[31] = -temp0[31] + temp0[27]; |
||||
|
|
||||
|
// stage 8
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[4], cospi[48], temp1[5], cosBit); |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[5], cospi[48], temp1[4], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[6], cospi[16], temp1[7], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[7], cospi[16], temp1[6], cosBit); |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = temp1[10]; |
||||
|
temp0[11] = temp1[11]; |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[12], cospi[48], temp1[13], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[13], cospi[48], temp1[12], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[14], cospi[16], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[15], cospi[16], temp1[14], cosBit); |
||||
|
temp0[16] = temp1[16]; |
||||
|
temp0[17] = temp1[17]; |
||||
|
temp0[18] = temp1[18]; |
||||
|
temp0[19] = temp1[19]; |
||||
|
temp0[20] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[20], cospi[48], temp1[21], cosBit); |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[21], cospi[48], temp1[20], cosBit); |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[22], cospi[16], temp1[23], cosBit); |
||||
|
temp0[23] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[23], cospi[16], temp1[22], cosBit); |
||||
|
temp0[24] = temp1[24]; |
||||
|
temp0[25] = temp1[25]; |
||||
|
temp0[26] = temp1[26]; |
||||
|
temp0[27] = temp1[27]; |
||||
|
temp0[28] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[28], cospi[48], temp1[29], cosBit); |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[29], cospi[48], temp1[28], cosBit); |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[30], cospi[16], temp1[31], cosBit); |
||||
|
temp0[31] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[31], cospi[16], temp1[30], cosBit); |
||||
|
|
||||
|
// stage 9
|
||||
|
temp1[0] = temp0[0] + temp0[2]; |
||||
|
temp1[1] = temp0[1] + temp0[3]; |
||||
|
temp1[2] = -temp0[2] + temp0[0]; |
||||
|
temp1[3] = -temp0[3] + temp0[1]; |
||||
|
temp1[4] = temp0[4] + temp0[6]; |
||||
|
temp1[5] = temp0[5] + temp0[7]; |
||||
|
temp1[6] = -temp0[6] + temp0[4]; |
||||
|
temp1[7] = -temp0[7] + temp0[5]; |
||||
|
temp1[8] = temp0[8] + temp0[10]; |
||||
|
temp1[9] = temp0[9] + temp0[11]; |
||||
|
temp1[10] = -temp0[10] + temp0[8]; |
||||
|
temp1[11] = -temp0[11] + temp0[9]; |
||||
|
temp1[12] = temp0[12] + temp0[14]; |
||||
|
temp1[13] = temp0[13] + temp0[15]; |
||||
|
temp1[14] = -temp0[14] + temp0[12]; |
||||
|
temp1[15] = -temp0[15] + temp0[13]; |
||||
|
temp1[16] = temp0[16] + temp0[18]; |
||||
|
temp1[17] = temp0[17] + temp0[19]; |
||||
|
temp1[18] = -temp0[18] + temp0[16]; |
||||
|
temp1[19] = -temp0[19] + temp0[17]; |
||||
|
temp1[20] = temp0[20] + temp0[22]; |
||||
|
temp1[21] = temp0[21] + temp0[23]; |
||||
|
temp1[22] = -temp0[22] + temp0[20]; |
||||
|
temp1[23] = -temp0[23] + temp0[21]; |
||||
|
temp1[24] = temp0[24] + temp0[26]; |
||||
|
temp1[25] = temp0[25] + temp0[27]; |
||||
|
temp1[26] = -temp0[26] + temp0[24]; |
||||
|
temp1[27] = -temp0[27] + temp0[25]; |
||||
|
temp1[28] = temp0[28] + temp0[30]; |
||||
|
temp1[29] = temp0[29] + temp0[31]; |
||||
|
temp1[30] = -temp0[30] + temp0[28]; |
||||
|
temp1[31] = -temp0[31] + temp0[29]; |
||||
|
|
||||
|
// stage 10
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[2], cospi[32], temp1[3], cosBit); |
||||
|
temp0[3] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[3], cospi[32], temp1[2], cosBit); |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[6], cospi[32], temp1[7], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[7], cospi[32], temp1[6], cosBit); |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[10], cospi[32], temp1[11], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[11], cospi[32], temp1[10], cosBit); |
||||
|
temp0[12] = temp1[12]; |
||||
|
temp0[13] = temp1[13]; |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[14], cospi[32], temp1[15], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[15], cospi[32], temp1[14], cosBit); |
||||
|
temp0[16] = temp1[16]; |
||||
|
temp0[17] = temp1[17]; |
||||
|
temp0[18] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[18], cospi[32], temp1[19], cosBit); |
||||
|
temp0[19] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[19], cospi[32], temp1[18], cosBit); |
||||
|
temp0[20] = temp1[20]; |
||||
|
temp0[21] = temp1[21]; |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[22], cospi[32], temp1[23], cosBit); |
||||
|
temp0[23] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[23], cospi[32], temp1[22], cosBit); |
||||
|
temp0[24] = temp1[24]; |
||||
|
temp0[25] = temp1[25]; |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[26], cospi[32], temp1[27], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[27], cospi[32], temp1[26], cosBit); |
||||
|
temp0[28] = temp1[28]; |
||||
|
temp0[29] = temp1[29]; |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[30], cospi[32], temp1[31], cosBit); |
||||
|
temp0[31] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[31], cospi[32], temp1[30], cosBit); |
||||
|
|
||||
|
// stage 11
|
||||
|
outputRef = temp0[0]; |
||||
|
Unsafe.Add(ref outputRef, 1) = -temp0[16]; |
||||
|
Unsafe.Add(ref outputRef, 2) = temp0[24]; |
||||
|
Unsafe.Add(ref outputRef, 3) = -temp0[8]; |
||||
|
Unsafe.Add(ref outputRef, 4) = temp0[12]; |
||||
|
Unsafe.Add(ref outputRef, 5) = -temp0[28]; |
||||
|
Unsafe.Add(ref outputRef, 6) = temp0[20]; |
||||
|
Unsafe.Add(ref outputRef, 7) = -temp0[4]; |
||||
|
Unsafe.Add(ref outputRef, 8) = temp0[6]; |
||||
|
Unsafe.Add(ref outputRef, 9) = -temp0[22]; |
||||
|
Unsafe.Add(ref outputRef, 10) = temp0[30]; |
||||
|
Unsafe.Add(ref outputRef, 11) = -temp0[14]; |
||||
|
Unsafe.Add(ref outputRef, 12) = temp0[10]; |
||||
|
Unsafe.Add(ref outputRef, 13) = -temp0[26]; |
||||
|
Unsafe.Add(ref outputRef, 14) = temp0[18]; |
||||
|
Unsafe.Add(ref outputRef, 15) = -temp0[2]; |
||||
|
Unsafe.Add(ref outputRef, 16) = temp0[3]; |
||||
|
Unsafe.Add(ref outputRef, 17) = -temp0[19]; |
||||
|
Unsafe.Add(ref outputRef, 18) = temp0[27]; |
||||
|
Unsafe.Add(ref outputRef, 19) = -temp0[11]; |
||||
|
Unsafe.Add(ref outputRef, 20) = temp0[15]; |
||||
|
Unsafe.Add(ref outputRef, 21) = -temp0[31]; |
||||
|
Unsafe.Add(ref outputRef, 22) = temp0[23]; |
||||
|
Unsafe.Add(ref outputRef, 23) = -temp0[7]; |
||||
|
Unsafe.Add(ref outputRef, 24) = temp0[5]; |
||||
|
Unsafe.Add(ref outputRef, 25) = -temp0[21]; |
||||
|
Unsafe.Add(ref outputRef, 26) = temp0[29]; |
||||
|
Unsafe.Add(ref outputRef, 27) = -temp0[13]; |
||||
|
Unsafe.Add(ref outputRef, 28) = temp0[9]; |
||||
|
Unsafe.Add(ref outputRef, 29) = -temp0[25]; |
||||
|
Unsafe.Add(ref outputRef, 30) = temp0[17]; |
||||
|
Unsafe.Add(ref outputRef, 31) = -temp0[1]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,72 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Adst4Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Adst4Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> sinpi = Av1SinusConstants.SinusPi(cosBit); |
||||
|
int x0, x1, x2, x3; |
||||
|
int s0, s1, s2, s3, s4, s5, s6, s7; |
||||
|
|
||||
|
// stage 0
|
||||
|
x0 = input; |
||||
|
x1 = Unsafe.Add(ref input, 1); |
||||
|
x2 = Unsafe.Add(ref input, 2); |
||||
|
x3 = Unsafe.Add(ref input, 3); |
||||
|
|
||||
|
if (!(x0 != 0 | x1 != 0 | x2 != 0 | x3 != 0)) |
||||
|
{ |
||||
|
output = 0; |
||||
|
Unsafe.Add(ref output, 1) = 0; |
||||
|
Unsafe.Add(ref output, 2) = 0; |
||||
|
Unsafe.Add(ref output, 3) = 0; |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// stage 1
|
||||
|
s0 = sinpi[1] * x0; |
||||
|
s1 = sinpi[4] * x0; |
||||
|
s2 = sinpi[2] * x1; |
||||
|
s3 = sinpi[1] * x1; |
||||
|
s4 = sinpi[3] * x2; |
||||
|
s5 = sinpi[4] * x3; |
||||
|
s6 = sinpi[2] * x3; |
||||
|
s7 = x0 + x1; |
||||
|
|
||||
|
// stage 2
|
||||
|
s7 -= x3; |
||||
|
|
||||
|
// stage 3
|
||||
|
x0 = s0 + s2; |
||||
|
x1 = sinpi[3] * s7; |
||||
|
x2 = s1 - s3; |
||||
|
x3 = s4; |
||||
|
|
||||
|
// stage 4
|
||||
|
x0 += s5; |
||||
|
x2 += s6; |
||||
|
|
||||
|
// stage 5
|
||||
|
s0 = x0 + x3; |
||||
|
s1 = x1; |
||||
|
s2 = x2 - x3; |
||||
|
s3 = x2 - x0; |
||||
|
|
||||
|
// stage 6
|
||||
|
s3 += x3; |
||||
|
|
||||
|
// 1-D transform scaling factor is sqrt(2).
|
||||
|
output = Av1Math.RoundShift(s0, cosBit); |
||||
|
Unsafe.Add(ref output, 1) = Av1Math.RoundShift(s1, cosBit); |
||||
|
Unsafe.Add(ref output, 2) = Av1Math.RoundShift(s2, cosBit); |
||||
|
Unsafe.Add(ref output, 3) = Av1Math.RoundShift(s3, cosBit); |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,92 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Adst8Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Adst8Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[8]; |
||||
|
Span<int> temp1 = stackalloc int[8]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
Guard.IsFalse(output == input, nameof(output), "Cannot operate on same buffer for input and output."); |
||||
|
temp0[0] = input; |
||||
|
temp0[1] = -Unsafe.Add(ref input, 7); |
||||
|
temp0[2] = -Unsafe.Add(ref input, 3); |
||||
|
temp0[3] = Unsafe.Add(ref input, 4); |
||||
|
temp0[4] = -Unsafe.Add(ref input, 1); |
||||
|
temp0[5] = Unsafe.Add(ref input, 6); |
||||
|
temp0[6] = Unsafe.Add(ref input, 2); |
||||
|
temp0[7] = -Unsafe.Add(ref input, 5); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[2], cospi[32], temp0[3], cosBit); |
||||
|
temp1[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[2], -cospi[32], temp0[3], cosBit); |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = temp0[5]; |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[6], cospi[32], temp0[7], cosBit); |
||||
|
temp1[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[6], -cospi[32], temp0[7], cosBit); |
||||
|
|
||||
|
// stage 3
|
||||
|
temp0[0] = temp1[0] + temp1[2]; |
||||
|
temp0[1] = temp1[1] + temp1[3]; |
||||
|
temp0[2] = temp1[0] - temp1[2]; |
||||
|
temp0[3] = temp1[1] - temp1[3]; |
||||
|
temp0[4] = temp1[4] + temp1[6]; |
||||
|
temp0[5] = temp1[5] + temp1[7]; |
||||
|
temp0[6] = temp1[4] - temp1[6]; |
||||
|
temp0[7] = temp1[5] - temp1[7]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[4], cospi[48], temp0[5], cosBit); |
||||
|
temp1[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[4], -cospi[16], temp0[5], cosBit); |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[6], cospi[16], temp0[7], cosBit); |
||||
|
temp1[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[6], cospi[48], temp0[7], cosBit); |
||||
|
|
||||
|
// stage 5
|
||||
|
temp0[0] = temp1[0] + temp1[4]; |
||||
|
temp0[1] = temp1[1] + temp1[5]; |
||||
|
temp0[2] = temp1[2] + temp1[6]; |
||||
|
temp0[3] = temp1[3] + temp1[7]; |
||||
|
temp0[4] = temp1[0] - temp1[4]; |
||||
|
temp0[5] = temp1[1] - temp1[5]; |
||||
|
temp0[6] = temp1[2] - temp1[6]; |
||||
|
temp0[7] = temp1[3] - temp1[7]; |
||||
|
|
||||
|
// stage 6
|
||||
|
temp1[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[4], temp0[0], cospi[60], temp0[1], cosBit); |
||||
|
temp1[1] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp0[0], -cospi[4], temp0[1], cosBit); |
||||
|
temp1[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[20], temp0[2], cospi[44], temp0[3], cosBit); |
||||
|
temp1[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp0[2], -cospi[20], temp0[3], cosBit); |
||||
|
temp1[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[36], temp0[4], cospi[28], temp0[5], cosBit); |
||||
|
temp1[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp0[4], -cospi[36], temp0[5], cosBit); |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[52], temp0[6], cospi[12], temp0[7], cosBit); |
||||
|
temp1[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp0[6], -cospi[52], temp0[7], cosBit); |
||||
|
|
||||
|
// stage 7
|
||||
|
output = temp1[1]; |
||||
|
Unsafe.Add(ref output, 1) = temp1[6]; |
||||
|
Unsafe.Add(ref output, 2) = temp1[3]; |
||||
|
Unsafe.Add(ref output, 3) = temp1[4]; |
||||
|
Unsafe.Add(ref output, 4) = temp1[5]; |
||||
|
Unsafe.Add(ref output, 5) = temp1[2]; |
||||
|
Unsafe.Add(ref output, 6) = temp1[7]; |
||||
|
Unsafe.Add(ref output, 7) = temp1[0]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,147 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Dct16Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Dct16Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[16]; |
||||
|
Span<int> temp1 = stackalloc int[16]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
temp0[0] = Unsafe.Add(ref input, 0) + Unsafe.Add(ref input, 15); |
||||
|
temp0[1] = Unsafe.Add(ref input, 1) + Unsafe.Add(ref input, 14); |
||||
|
temp0[2] = Unsafe.Add(ref input, 2) + Unsafe.Add(ref input, 13); |
||||
|
temp0[3] = Unsafe.Add(ref input, 3) + Unsafe.Add(ref input, 12); |
||||
|
temp0[4] = Unsafe.Add(ref input, 4) + Unsafe.Add(ref input, 11); |
||||
|
temp0[5] = Unsafe.Add(ref input, 5) + Unsafe.Add(ref input, 10); |
||||
|
temp0[6] = Unsafe.Add(ref input, 6) + Unsafe.Add(ref input, 9); |
||||
|
temp0[7] = Unsafe.Add(ref input, 7) + Unsafe.Add(ref input, 8); |
||||
|
temp0[8] = -Unsafe.Add(ref input, 8) + Unsafe.Add(ref input, 7); |
||||
|
temp0[9] = -Unsafe.Add(ref input, 9) + Unsafe.Add(ref input, 6); |
||||
|
temp0[10] = -Unsafe.Add(ref input, 10) + Unsafe.Add(ref input, 5); |
||||
|
temp0[11] = -Unsafe.Add(ref input, 11) + Unsafe.Add(ref input, 4); |
||||
|
temp0[12] = -Unsafe.Add(ref input, 12) + Unsafe.Add(ref input, 3); |
||||
|
temp0[13] = -Unsafe.Add(ref input, 13) + Unsafe.Add(ref input, 2); |
||||
|
temp0[14] = -Unsafe.Add(ref input, 14) + Unsafe.Add(ref input, 1); |
||||
|
temp0[15] = -Unsafe.Add(ref input, 15) + Unsafe.Add(ref input, 0); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp1[0] = temp0[0] + temp0[7]; |
||||
|
temp1[1] = temp0[1] + temp0[6]; |
||||
|
temp1[2] = temp0[2] + temp0[5]; |
||||
|
temp1[3] = temp0[3] + temp0[4]; |
||||
|
temp1[4] = -temp0[4] + temp0[3]; |
||||
|
temp1[5] = -temp0[5] + temp0[2]; |
||||
|
temp1[6] = -temp0[6] + temp0[1]; |
||||
|
temp1[7] = -temp0[7] + temp0[0]; |
||||
|
temp1[8] = temp0[8]; |
||||
|
temp1[9] = temp0[9]; |
||||
|
temp1[10] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[10], cospi[32], temp0[13], cosBit); |
||||
|
temp1[11] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[11], cospi[32], temp0[12], cosBit); |
||||
|
temp1[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[12], cospi[32], temp0[11], cosBit); |
||||
|
temp1[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[13], cospi[32], temp0[10], cosBit); |
||||
|
temp1[14] = temp0[14]; |
||||
|
temp1[15] = temp0[15]; |
||||
|
|
||||
|
// stage 3
|
||||
|
temp0[0] = temp1[0] + temp1[3]; |
||||
|
temp0[1] = temp1[1] + temp1[2]; |
||||
|
temp0[2] = -temp1[2] + temp1[1]; |
||||
|
temp0[3] = -temp1[3] + temp1[0]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[5], cospi[32], temp1[6], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[6], cospi[32], temp1[5], cosBit); |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = temp1[8] + temp1[11]; |
||||
|
temp0[9] = temp1[9] + temp1[10]; |
||||
|
temp0[10] = -temp1[10] + temp1[9]; |
||||
|
temp0[11] = -temp1[11] + temp1[8]; |
||||
|
temp0[12] = -temp1[12] + temp1[15]; |
||||
|
temp0[13] = -temp1[13] + temp1[14]; |
||||
|
temp0[14] = temp1[14] + temp1[13]; |
||||
|
temp0[15] = temp1[15] + temp1[12]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp1[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[0], cospi[32], temp0[1], cosBit); |
||||
|
temp1[1] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[1], cospi[32], temp0[0], cosBit); |
||||
|
temp1[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[2], cospi[16], temp0[3], cosBit); |
||||
|
temp1[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[3], -cospi[16], temp0[2], cosBit); |
||||
|
temp1[4] = temp0[4] + temp0[5]; |
||||
|
temp1[5] = -temp0[5] + temp0[4]; |
||||
|
temp1[6] = -temp0[6] + temp0[7]; |
||||
|
temp1[7] = temp0[7] + temp0[6]; |
||||
|
temp1[8] = temp0[8]; |
||||
|
temp1[9] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[9], cospi[48], temp0[14], cosBit); |
||||
|
temp1[10] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[10], -cospi[16], temp0[13], cosBit); |
||||
|
temp1[11] = temp0[11]; |
||||
|
temp1[12] = temp0[12]; |
||||
|
temp1[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[13], -cospi[16], temp0[10], cosBit); |
||||
|
temp1[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[14], cospi[48], temp0[9], cosBit); |
||||
|
temp1[15] = temp0[15]; |
||||
|
|
||||
|
// stage 5
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[4], cospi[8], temp1[7], cosBit); |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[5], cospi[40], temp1[6], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[6], -cospi[40], temp1[5], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[7], -cospi[8], temp1[4], cosBit); |
||||
|
temp0[8] = temp1[8] + temp1[9]; |
||||
|
temp0[9] = -temp1[9] + temp1[8]; |
||||
|
temp0[10] = -temp1[10] + temp1[11]; |
||||
|
temp0[11] = temp1[11] + temp1[10]; |
||||
|
temp0[12] = temp1[12] + temp1[13]; |
||||
|
temp0[13] = -temp1[13] + temp1[12]; |
||||
|
temp0[14] = -temp1[14] + temp1[15]; |
||||
|
temp0[15] = temp1[15] + temp1[14]; |
||||
|
|
||||
|
// stage 6
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = temp0[5]; |
||||
|
temp1[6] = temp0[6]; |
||||
|
temp1[7] = temp0[7]; |
||||
|
temp1[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp0[8], cospi[4], temp0[15], cosBit); |
||||
|
temp1[9] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp0[9], cospi[36], temp0[14], cosBit); |
||||
|
temp1[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp0[10], cospi[20], temp0[13], cosBit); |
||||
|
temp1[11] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp0[11], cospi[52], temp0[12], cosBit); |
||||
|
temp1[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp0[12], -cospi[52], temp0[11], cosBit); |
||||
|
temp1[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp0[13], -cospi[20], temp0[10], cosBit); |
||||
|
temp1[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp0[14], -cospi[36], temp0[9], cosBit); |
||||
|
temp1[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp0[15], -cospi[4], temp0[8], cosBit); |
||||
|
|
||||
|
// stage 7
|
||||
|
output = temp1[0]; |
||||
|
Unsafe.Add(ref output, 1) = temp1[8]; |
||||
|
Unsafe.Add(ref output, 2) = temp1[4]; |
||||
|
Unsafe.Add(ref output, 3) = temp1[12]; |
||||
|
Unsafe.Add(ref output, 4) = temp1[2]; |
||||
|
Unsafe.Add(ref output, 5) = temp1[10]; |
||||
|
Unsafe.Add(ref output, 6) = temp1[6]; |
||||
|
Unsafe.Add(ref output, 7) = temp1[14]; |
||||
|
Unsafe.Add(ref output, 8) = temp1[1]; |
||||
|
Unsafe.Add(ref output, 9) = temp1[9]; |
||||
|
Unsafe.Add(ref output, 10) = temp1[5]; |
||||
|
Unsafe.Add(ref output, 11) = temp1[13]; |
||||
|
Unsafe.Add(ref output, 12) = temp1[3]; |
||||
|
Unsafe.Add(ref output, 13) = temp1[11]; |
||||
|
Unsafe.Add(ref output, 14) = temp1[7]; |
||||
|
Unsafe.Add(ref output, 15) = temp1[15]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,327 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Dct32Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Dct32Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[32]; |
||||
|
Span<int> temp1 = stackalloc int[32]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
temp0[0] = Unsafe.Add(ref input, 0) + Unsafe.Add(ref input, 31); |
||||
|
temp0[1] = Unsafe.Add(ref input, 1) + Unsafe.Add(ref input, 30); |
||||
|
temp0[2] = Unsafe.Add(ref input, 2) + Unsafe.Add(ref input, 29); |
||||
|
temp0[3] = Unsafe.Add(ref input, 3) + Unsafe.Add(ref input, 28); |
||||
|
temp0[4] = Unsafe.Add(ref input, 4) + Unsafe.Add(ref input, 27); |
||||
|
temp0[5] = Unsafe.Add(ref input, 5) + Unsafe.Add(ref input, 26); |
||||
|
temp0[6] = Unsafe.Add(ref input, 6) + Unsafe.Add(ref input, 25); |
||||
|
temp0[7] = Unsafe.Add(ref input, 7) + Unsafe.Add(ref input, 24); |
||||
|
temp0[8] = Unsafe.Add(ref input, 8) + Unsafe.Add(ref input, 23); |
||||
|
temp0[9] = Unsafe.Add(ref input, 9) + Unsafe.Add(ref input, 22); |
||||
|
temp0[10] = Unsafe.Add(ref input, 10) + Unsafe.Add(ref input, 21); |
||||
|
temp0[11] = Unsafe.Add(ref input, 11) + Unsafe.Add(ref input, 20); |
||||
|
temp0[12] = Unsafe.Add(ref input, 12) + Unsafe.Add(ref input, 19); |
||||
|
temp0[13] = Unsafe.Add(ref input, 13) + Unsafe.Add(ref input, 18); |
||||
|
temp0[14] = Unsafe.Add(ref input, 14) + Unsafe.Add(ref input, 17); |
||||
|
temp0[15] = Unsafe.Add(ref input, 15) + Unsafe.Add(ref input, 16); |
||||
|
temp0[16] = -Unsafe.Add(ref input, 16) + Unsafe.Add(ref input, 15); |
||||
|
temp0[17] = -Unsafe.Add(ref input, 17) + Unsafe.Add(ref input, 14); |
||||
|
temp0[18] = -Unsafe.Add(ref input, 18) + Unsafe.Add(ref input, 13); |
||||
|
temp0[19] = -Unsafe.Add(ref input, 19) + Unsafe.Add(ref input, 12); |
||||
|
temp0[20] = -Unsafe.Add(ref input, 20) + Unsafe.Add(ref input, 11); |
||||
|
temp0[21] = -Unsafe.Add(ref input, 21) + Unsafe.Add(ref input, 10); |
||||
|
temp0[22] = -Unsafe.Add(ref input, 22) + Unsafe.Add(ref input, 9); |
||||
|
temp0[23] = -Unsafe.Add(ref input, 23) + Unsafe.Add(ref input, 8); |
||||
|
temp0[24] = -Unsafe.Add(ref input, 24) + Unsafe.Add(ref input, 7); |
||||
|
temp0[25] = -Unsafe.Add(ref input, 25) + Unsafe.Add(ref input, 6); |
||||
|
temp0[26] = -Unsafe.Add(ref input, 26) + Unsafe.Add(ref input, 5); |
||||
|
temp0[27] = -Unsafe.Add(ref input, 27) + Unsafe.Add(ref input, 4); |
||||
|
temp0[28] = -Unsafe.Add(ref input, 28) + Unsafe.Add(ref input, 3); |
||||
|
temp0[29] = -Unsafe.Add(ref input, 29) + Unsafe.Add(ref input, 2); |
||||
|
temp0[30] = -Unsafe.Add(ref input, 30) + Unsafe.Add(ref input, 1); |
||||
|
temp0[31] = -Unsafe.Add(ref input, 31) + Unsafe.Add(ref input, 0); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp1[0] = temp0[0] + temp0[15]; |
||||
|
temp1[1] = temp0[1] + temp0[14]; |
||||
|
temp1[2] = temp0[2] + temp0[13]; |
||||
|
temp1[3] = temp0[3] + temp0[12]; |
||||
|
temp1[4] = temp0[4] + temp0[11]; |
||||
|
temp1[5] = temp0[5] + temp0[10]; |
||||
|
temp1[6] = temp0[6] + temp0[9]; |
||||
|
temp1[7] = temp0[7] + temp0[8]; |
||||
|
temp1[8] = -temp0[8] + temp0[7]; |
||||
|
temp1[9] = -temp0[9] + temp0[6]; |
||||
|
temp1[10] = -temp0[10] + temp0[5]; |
||||
|
temp1[11] = -temp0[11] + temp0[4]; |
||||
|
temp1[12] = -temp0[12] + temp0[3]; |
||||
|
temp1[13] = -temp0[13] + temp0[2]; |
||||
|
temp1[14] = -temp0[14] + temp0[1]; |
||||
|
temp1[15] = -temp0[15] + temp0[0]; |
||||
|
temp1[16] = temp0[16]; |
||||
|
temp1[17] = temp0[17]; |
||||
|
temp1[18] = temp0[18]; |
||||
|
temp1[19] = temp0[19]; |
||||
|
temp1[20] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[20], cospi[32], temp0[27], cosBit); |
||||
|
temp1[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[21], cospi[32], temp0[26], cosBit); |
||||
|
temp1[22] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[22], cospi[32], temp0[25], cosBit); |
||||
|
temp1[23] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[23], cospi[32], temp0[24], cosBit); |
||||
|
temp1[24] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[24], cospi[32], temp0[23], cosBit); |
||||
|
temp1[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[25], cospi[32], temp0[22], cosBit); |
||||
|
temp1[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[26], cospi[32], temp0[21], cosBit); |
||||
|
temp1[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[27], cospi[32], temp0[20], cosBit); |
||||
|
temp1[28] = temp0[28]; |
||||
|
temp1[29] = temp0[29]; |
||||
|
temp1[30] = temp0[30]; |
||||
|
temp1[31] = temp0[31]; |
||||
|
|
||||
|
// stage 3
|
||||
|
temp0[0] = temp1[0] + temp1[7]; |
||||
|
temp0[1] = temp1[1] + temp1[6]; |
||||
|
temp0[2] = temp1[2] + temp1[5]; |
||||
|
temp0[3] = temp1[3] + temp1[4]; |
||||
|
temp0[4] = -temp1[4] + temp1[3]; |
||||
|
temp0[5] = -temp1[5] + temp1[2]; |
||||
|
temp0[6] = -temp1[6] + temp1[1]; |
||||
|
temp0[7] = -temp1[7] + temp1[0]; |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[10], cospi[32], temp1[13], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[11], cospi[32], temp1[12], cosBit); |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[12], cospi[32], temp1[11], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[13], cospi[32], temp1[10], cosBit); |
||||
|
temp0[14] = temp1[14]; |
||||
|
temp0[15] = temp1[15]; |
||||
|
temp0[16] = temp1[16] + temp1[23]; |
||||
|
temp0[17] = temp1[17] + temp1[22]; |
||||
|
temp0[18] = temp1[18] + temp1[21]; |
||||
|
temp0[19] = temp1[19] + temp1[20]; |
||||
|
temp0[20] = -temp1[20] + temp1[19]; |
||||
|
temp0[21] = -temp1[21] + temp1[18]; |
||||
|
temp0[22] = -temp1[22] + temp1[17]; |
||||
|
temp0[23] = -temp1[23] + temp1[16]; |
||||
|
temp0[24] = -temp1[24] + temp1[31]; |
||||
|
temp0[25] = -temp1[25] + temp1[30]; |
||||
|
temp0[26] = -temp1[26] + temp1[29]; |
||||
|
temp0[27] = -temp1[27] + temp1[28]; |
||||
|
temp0[28] = temp1[28] + temp1[27]; |
||||
|
temp0[29] = temp1[29] + temp1[26]; |
||||
|
temp0[30] = temp1[30] + temp1[25]; |
||||
|
temp0[31] = temp1[31] + temp1[24]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp1[0] = temp0[0] + temp0[3]; |
||||
|
temp1[1] = temp0[1] + temp0[2]; |
||||
|
temp1[2] = -temp0[2] + temp0[1]; |
||||
|
temp1[3] = -temp0[3] + temp0[0]; |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[5], cospi[32], temp0[6], cosBit); |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[6], cospi[32], temp0[5], cosBit); |
||||
|
temp1[7] = temp0[7]; |
||||
|
temp1[8] = temp0[8] + temp0[11]; |
||||
|
temp1[9] = temp0[9] + temp0[10]; |
||||
|
temp1[10] = -temp0[10] + temp0[9]; |
||||
|
temp1[11] = -temp0[11] + temp0[8]; |
||||
|
temp1[12] = -temp0[12] + temp0[15]; |
||||
|
temp1[13] = -temp0[13] + temp0[14]; |
||||
|
temp1[14] = temp0[14] + temp0[13]; |
||||
|
temp1[15] = temp0[15] + temp0[12]; |
||||
|
temp1[16] = temp0[16]; |
||||
|
temp1[17] = temp0[17]; |
||||
|
temp1[18] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[18], cospi[48], temp0[29], cosBit); |
||||
|
temp1[19] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[19], cospi[48], temp0[28], cosBit); |
||||
|
temp1[20] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[20], -cospi[16], temp0[27], cosBit); |
||||
|
temp1[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[21], -cospi[16], temp0[26], cosBit); |
||||
|
temp1[22] = temp0[22]; |
||||
|
temp1[23] = temp0[23]; |
||||
|
temp1[24] = temp0[24]; |
||||
|
temp1[25] = temp0[25]; |
||||
|
temp1[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[26], -cospi[16], temp0[21], cosBit); |
||||
|
temp1[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[27], -cospi[16], temp0[20], cosBit); |
||||
|
temp1[28] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[28], cospi[48], temp0[19], cosBit); |
||||
|
temp1[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[29], cospi[48], temp0[18], cosBit); |
||||
|
temp1[30] = temp0[30]; |
||||
|
temp1[31] = temp0[31]; |
||||
|
|
||||
|
// stage 5
|
||||
|
temp0[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[0], cospi[32], temp1[1], cosBit); |
||||
|
temp0[1] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[1], cospi[32], temp1[0], cosBit); |
||||
|
temp0[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[2], cospi[16], temp1[3], cosBit); |
||||
|
temp0[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[3], -cospi[16], temp1[2], cosBit); |
||||
|
temp0[4] = temp1[4] + temp1[5]; |
||||
|
temp0[5] = -temp1[5] + temp1[4]; |
||||
|
temp0[6] = -temp1[6] + temp1[7]; |
||||
|
temp0[7] = temp1[7] + temp1[6]; |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[9], cospi[48], temp1[14], cosBit); |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[10], -cospi[16], temp1[13], cosBit); |
||||
|
temp0[11] = temp1[11]; |
||||
|
temp0[12] = temp1[12]; |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[13], -cospi[16], temp1[10], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[14], cospi[48], temp1[9], cosBit); |
||||
|
temp0[15] = temp1[15]; |
||||
|
temp0[16] = temp1[16] + temp1[19]; |
||||
|
temp0[17] = temp1[17] + temp1[18]; |
||||
|
temp0[18] = -temp1[18] + temp1[17]; |
||||
|
temp0[19] = -temp1[19] + temp1[16]; |
||||
|
temp0[20] = -temp1[20] + temp1[23]; |
||||
|
temp0[21] = -temp1[21] + temp1[22]; |
||||
|
temp0[22] = temp1[22] + temp1[21]; |
||||
|
temp0[23] = temp1[23] + temp1[20]; |
||||
|
temp0[24] = temp1[24] + temp1[27]; |
||||
|
temp0[25] = temp1[25] + temp1[26]; |
||||
|
temp0[26] = -temp1[26] + temp1[25]; |
||||
|
temp0[27] = -temp1[27] + temp1[24]; |
||||
|
temp0[28] = -temp1[28] + temp1[31]; |
||||
|
temp0[29] = -temp1[29] + temp1[30]; |
||||
|
temp0[30] = temp1[30] + temp1[29]; |
||||
|
temp0[31] = temp1[31] + temp1[28]; |
||||
|
|
||||
|
// stage 6
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[4], cospi[8], temp0[7], cosBit); |
||||
|
temp1[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[5], cospi[40], temp0[6], cosBit); |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[6], -cospi[40], temp0[5], cosBit); |
||||
|
temp1[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[7], -cospi[8], temp0[4], cosBit); |
||||
|
temp1[8] = temp0[8] + temp0[9]; |
||||
|
temp1[9] = -temp0[9] + temp0[8]; |
||||
|
temp1[10] = -temp0[10] + temp0[11]; |
||||
|
temp1[11] = temp0[11] + temp0[10]; |
||||
|
temp1[12] = temp0[12] + temp0[13]; |
||||
|
temp1[13] = -temp0[13] + temp0[12]; |
||||
|
temp1[14] = -temp0[14] + temp0[15]; |
||||
|
temp1[15] = temp0[15] + temp0[14]; |
||||
|
temp1[16] = temp0[16]; |
||||
|
temp1[17] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[8], temp0[17], cospi[56], temp0[30], cosBit); |
||||
|
temp1[18] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp0[18], -cospi[8], temp0[29], cosBit); |
||||
|
temp1[19] = temp0[19]; |
||||
|
temp1[20] = temp0[20]; |
||||
|
temp1[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[40], temp0[21], cospi[24], temp0[26], cosBit); |
||||
|
temp1[22] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp0[22], -cospi[40], temp0[25], cosBit); |
||||
|
temp1[23] = temp0[23]; |
||||
|
temp1[24] = temp0[24]; |
||||
|
temp1[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[25], -cospi[40], temp0[22], cosBit); |
||||
|
temp1[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp0[26], cospi[24], temp0[21], cosBit); |
||||
|
temp1[27] = temp0[27]; |
||||
|
temp1[28] = temp0[28]; |
||||
|
temp1[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[29], -cospi[8], temp0[18], cosBit); |
||||
|
temp1[30] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp0[30], cospi[56], temp0[17], cosBit); |
||||
|
temp1[31] = temp0[31]; |
||||
|
|
||||
|
// stage 7
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = temp1[6]; |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp1[8], cospi[4], temp1[15], cosBit); |
||||
|
temp0[9] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp1[9], cospi[36], temp1[14], cosBit); |
||||
|
temp0[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp1[10], cospi[20], temp1[13], cosBit); |
||||
|
temp0[11] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp1[11], cospi[52], temp1[12], cosBit); |
||||
|
temp0[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp1[12], -cospi[52], temp1[11], cosBit); |
||||
|
temp0[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp1[13], -cospi[20], temp1[10], cosBit); |
||||
|
temp0[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp1[14], -cospi[36], temp1[9], cosBit); |
||||
|
temp0[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp1[15], -cospi[4], temp1[8], cosBit); |
||||
|
temp0[16] = temp1[16] + temp1[17]; |
||||
|
temp0[17] = -temp1[17] + temp1[16]; |
||||
|
temp0[18] = -temp1[18] + temp1[19]; |
||||
|
temp0[19] = temp1[19] + temp1[18]; |
||||
|
temp0[20] = temp1[20] + temp1[21]; |
||||
|
temp0[21] = -temp1[21] + temp1[20]; |
||||
|
temp0[22] = -temp1[22] + temp1[23]; |
||||
|
temp0[23] = temp1[23] + temp1[22]; |
||||
|
temp0[24] = temp1[24] + temp1[25]; |
||||
|
temp0[25] = -temp1[25] + temp1[24]; |
||||
|
temp0[26] = -temp1[26] + temp1[27]; |
||||
|
temp0[27] = temp1[27] + temp1[26]; |
||||
|
temp0[28] = temp1[28] + temp1[29]; |
||||
|
temp0[29] = -temp1[29] + temp1[28]; |
||||
|
temp0[30] = -temp1[30] + temp1[31]; |
||||
|
temp0[31] = temp1[31] + temp1[30]; |
||||
|
|
||||
|
// stage 8
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = temp0[5]; |
||||
|
temp1[6] = temp0[6]; |
||||
|
temp1[7] = temp0[7]; |
||||
|
temp1[8] = temp0[8]; |
||||
|
temp1[9] = temp0[9]; |
||||
|
temp1[10] = temp0[10]; |
||||
|
temp1[11] = temp0[11]; |
||||
|
temp1[12] = temp0[12]; |
||||
|
temp1[13] = temp0[13]; |
||||
|
temp1[14] = temp0[14]; |
||||
|
temp1[15] = temp0[15]; |
||||
|
temp1[16] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[62], temp0[16], cospi[2], temp0[31], cosBit); |
||||
|
temp1[17] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[30], temp0[17], cospi[34], temp0[30], cosBit); |
||||
|
temp1[18] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[46], temp0[18], cospi[18], temp0[29], cosBit); |
||||
|
temp1[19] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[14], temp0[19], cospi[50], temp0[28], cosBit); |
||||
|
temp1[20] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[54], temp0[20], cospi[10], temp0[27], cosBit); |
||||
|
temp1[21] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[22], temp0[21], cospi[42], temp0[26], cosBit); |
||||
|
temp1[22] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[38], temp0[22], cospi[26], temp0[25], cosBit); |
||||
|
temp1[23] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[6], temp0[23], cospi[58], temp0[24], cosBit); |
||||
|
temp1[24] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[6], temp0[24], -cospi[58], temp0[23], cosBit); |
||||
|
temp1[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[38], temp0[25], -cospi[26], temp0[22], cosBit); |
||||
|
temp1[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[22], temp0[26], -cospi[42], temp0[21], cosBit); |
||||
|
temp1[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[54], temp0[27], -cospi[10], temp0[20], cosBit); |
||||
|
temp1[28] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[14], temp0[28], -cospi[50], temp0[19], cosBit); |
||||
|
temp1[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[46], temp0[29], -cospi[18], temp0[18], cosBit); |
||||
|
temp1[30] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[30], temp0[30], -cospi[34], temp0[17], cosBit); |
||||
|
temp1[31] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[62], temp0[31], -cospi[2], temp0[16], cosBit); |
||||
|
|
||||
|
// stage 9
|
||||
|
Unsafe.Add(ref output, 0) = temp1[0]; |
||||
|
Unsafe.Add(ref output, 1) = temp1[16]; |
||||
|
Unsafe.Add(ref output, 2) = temp1[8]; |
||||
|
Unsafe.Add(ref output, 3) = temp1[24]; |
||||
|
Unsafe.Add(ref output, 4) = temp1[4]; |
||||
|
Unsafe.Add(ref output, 5) = temp1[20]; |
||||
|
Unsafe.Add(ref output, 6) = temp1[12]; |
||||
|
Unsafe.Add(ref output, 7) = temp1[28]; |
||||
|
Unsafe.Add(ref output, 8) = temp1[2]; |
||||
|
Unsafe.Add(ref output, 9) = temp1[18]; |
||||
|
Unsafe.Add(ref output, 10) = temp1[10]; |
||||
|
Unsafe.Add(ref output, 11) = temp1[26]; |
||||
|
Unsafe.Add(ref output, 12) = temp1[6]; |
||||
|
Unsafe.Add(ref output, 13) = temp1[22]; |
||||
|
Unsafe.Add(ref output, 14) = temp1[14]; |
||||
|
Unsafe.Add(ref output, 15) = temp1[30]; |
||||
|
Unsafe.Add(ref output, 16) = temp1[1]; |
||||
|
Unsafe.Add(ref output, 17) = temp1[17]; |
||||
|
Unsafe.Add(ref output, 18) = temp1[9]; |
||||
|
Unsafe.Add(ref output, 19) = temp1[25]; |
||||
|
Unsafe.Add(ref output, 20) = temp1[5]; |
||||
|
Unsafe.Add(ref output, 21) = temp1[21]; |
||||
|
Unsafe.Add(ref output, 22) = temp1[13]; |
||||
|
Unsafe.Add(ref output, 23) = temp1[29]; |
||||
|
Unsafe.Add(ref output, 24) = temp1[3]; |
||||
|
Unsafe.Add(ref output, 25) = temp1[19]; |
||||
|
Unsafe.Add(ref output, 26) = temp1[11]; |
||||
|
Unsafe.Add(ref output, 27) = temp1[27]; |
||||
|
Unsafe.Add(ref output, 28) = temp1[7]; |
||||
|
Unsafe.Add(ref output, 29) = temp1[23]; |
||||
|
Unsafe.Add(ref output, 30) = temp1[15]; |
||||
|
Unsafe.Add(ref output, 31) = temp1[31]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,747 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Dct64Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Dct64Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransforScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransforScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[64]; |
||||
|
Span<int> temp1 = stackalloc int[64]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
temp0[0] = Unsafe.Add(ref input, 0) + Unsafe.Add(ref input, 63); |
||||
|
temp0[1] = Unsafe.Add(ref input, 1) + Unsafe.Add(ref input, 62); |
||||
|
temp0[2] = Unsafe.Add(ref input, 2) + Unsafe.Add(ref input, 61); |
||||
|
temp0[3] = Unsafe.Add(ref input, 3) + Unsafe.Add(ref input, 60); |
||||
|
temp0[4] = Unsafe.Add(ref input, 4) + Unsafe.Add(ref input, 59); |
||||
|
temp0[5] = Unsafe.Add(ref input, 5) + Unsafe.Add(ref input, 58); |
||||
|
temp0[6] = Unsafe.Add(ref input, 6) + Unsafe.Add(ref input, 57); |
||||
|
temp0[7] = Unsafe.Add(ref input, 7) + Unsafe.Add(ref input, 56); |
||||
|
temp0[8] = Unsafe.Add(ref input, 8) + Unsafe.Add(ref input, 55); |
||||
|
temp0[9] = Unsafe.Add(ref input, 9) + Unsafe.Add(ref input, 54); |
||||
|
temp0[10] = Unsafe.Add(ref input, 10) + Unsafe.Add(ref input, 53); |
||||
|
temp0[11] = Unsafe.Add(ref input, 11) + Unsafe.Add(ref input, 52); |
||||
|
temp0[12] = Unsafe.Add(ref input, 12) + Unsafe.Add(ref input, 51); |
||||
|
temp0[13] = Unsafe.Add(ref input, 13) + Unsafe.Add(ref input, 50); |
||||
|
temp0[14] = Unsafe.Add(ref input, 14) + Unsafe.Add(ref input, 49); |
||||
|
temp0[15] = Unsafe.Add(ref input, 15) + Unsafe.Add(ref input, 48); |
||||
|
temp0[16] = Unsafe.Add(ref input, 16) + Unsafe.Add(ref input, 47); |
||||
|
temp0[17] = Unsafe.Add(ref input, 17) + Unsafe.Add(ref input, 46); |
||||
|
temp0[18] = Unsafe.Add(ref input, 18) + Unsafe.Add(ref input, 45); |
||||
|
temp0[19] = Unsafe.Add(ref input, 19) + Unsafe.Add(ref input, 44); |
||||
|
temp0[20] = Unsafe.Add(ref input, 20) + Unsafe.Add(ref input, 43); |
||||
|
temp0[21] = Unsafe.Add(ref input, 21) + Unsafe.Add(ref input, 42); |
||||
|
temp0[22] = Unsafe.Add(ref input, 22) + Unsafe.Add(ref input, 41); |
||||
|
temp0[23] = Unsafe.Add(ref input, 23) + Unsafe.Add(ref input, 40); |
||||
|
temp0[24] = Unsafe.Add(ref input, 24) + Unsafe.Add(ref input, 39); |
||||
|
temp0[25] = Unsafe.Add(ref input, 25) + Unsafe.Add(ref input, 38); |
||||
|
temp0[26] = Unsafe.Add(ref input, 26) + Unsafe.Add(ref input, 37); |
||||
|
temp0[27] = Unsafe.Add(ref input, 27) + Unsafe.Add(ref input, 36); |
||||
|
temp0[28] = Unsafe.Add(ref input, 28) + Unsafe.Add(ref input, 35); |
||||
|
temp0[29] = Unsafe.Add(ref input, 29) + Unsafe.Add(ref input, 34); |
||||
|
temp0[30] = Unsafe.Add(ref input, 30) + Unsafe.Add(ref input, 33); |
||||
|
temp0[31] = Unsafe.Add(ref input, 31) + Unsafe.Add(ref input, 32); |
||||
|
temp0[32] = -Unsafe.Add(ref input, 32) + Unsafe.Add(ref input, 31); |
||||
|
temp0[33] = -Unsafe.Add(ref input, 33) + Unsafe.Add(ref input, 30); |
||||
|
temp0[34] = -Unsafe.Add(ref input, 34) + Unsafe.Add(ref input, 29); |
||||
|
temp0[35] = -Unsafe.Add(ref input, 35) + Unsafe.Add(ref input, 28); |
||||
|
temp0[36] = -Unsafe.Add(ref input, 36) + Unsafe.Add(ref input, 27); |
||||
|
temp0[37] = -Unsafe.Add(ref input, 37) + Unsafe.Add(ref input, 26); |
||||
|
temp0[38] = -Unsafe.Add(ref input, 38) + Unsafe.Add(ref input, 25); |
||||
|
temp0[39] = -Unsafe.Add(ref input, 39) + Unsafe.Add(ref input, 24); |
||||
|
temp0[40] = -Unsafe.Add(ref input, 40) + Unsafe.Add(ref input, 23); |
||||
|
temp0[41] = -Unsafe.Add(ref input, 41) + Unsafe.Add(ref input, 22); |
||||
|
temp0[42] = -Unsafe.Add(ref input, 42) + Unsafe.Add(ref input, 21); |
||||
|
temp0[43] = -Unsafe.Add(ref input, 43) + Unsafe.Add(ref input, 20); |
||||
|
temp0[44] = -Unsafe.Add(ref input, 44) + Unsafe.Add(ref input, 19); |
||||
|
temp0[45] = -Unsafe.Add(ref input, 45) + Unsafe.Add(ref input, 18); |
||||
|
temp0[46] = -Unsafe.Add(ref input, 46) + Unsafe.Add(ref input, 17); |
||||
|
temp0[47] = -Unsafe.Add(ref input, 47) + Unsafe.Add(ref input, 16); |
||||
|
temp0[48] = -Unsafe.Add(ref input, 48) + Unsafe.Add(ref input, 15); |
||||
|
temp0[49] = -Unsafe.Add(ref input, 49) + Unsafe.Add(ref input, 14); |
||||
|
temp0[50] = -Unsafe.Add(ref input, 50) + Unsafe.Add(ref input, 13); |
||||
|
temp0[51] = -Unsafe.Add(ref input, 51) + Unsafe.Add(ref input, 12); |
||||
|
temp0[52] = -Unsafe.Add(ref input, 52) + Unsafe.Add(ref input, 11); |
||||
|
temp0[53] = -Unsafe.Add(ref input, 53) + Unsafe.Add(ref input, 10); |
||||
|
temp0[54] = -Unsafe.Add(ref input, 54) + Unsafe.Add(ref input, 9); |
||||
|
temp0[55] = -Unsafe.Add(ref input, 55) + Unsafe.Add(ref input, 8); |
||||
|
temp0[56] = -Unsafe.Add(ref input, 56) + Unsafe.Add(ref input, 7); |
||||
|
temp0[57] = -Unsafe.Add(ref input, 57) + Unsafe.Add(ref input, 6); |
||||
|
temp0[58] = -Unsafe.Add(ref input, 58) + Unsafe.Add(ref input, 5); |
||||
|
temp0[59] = -Unsafe.Add(ref input, 59) + Unsafe.Add(ref input, 4); |
||||
|
temp0[60] = -Unsafe.Add(ref input, 60) + Unsafe.Add(ref input, 3); |
||||
|
temp0[61] = -Unsafe.Add(ref input, 61) + Unsafe.Add(ref input, 2); |
||||
|
temp0[62] = -Unsafe.Add(ref input, 62) + Unsafe.Add(ref input, 1); |
||||
|
temp0[63] = -Unsafe.Add(ref input, 63) + Unsafe.Add(ref input, 0); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp1[0] = temp0[0] + temp0[31]; |
||||
|
temp1[1] = temp0[1] + temp0[30]; |
||||
|
temp1[2] = temp0[2] + temp0[29]; |
||||
|
temp1[3] = temp0[3] + temp0[28]; |
||||
|
temp1[4] = temp0[4] + temp0[27]; |
||||
|
temp1[5] = temp0[5] + temp0[26]; |
||||
|
temp1[6] = temp0[6] + temp0[25]; |
||||
|
temp1[7] = temp0[7] + temp0[24]; |
||||
|
temp1[8] = temp0[8] + temp0[23]; |
||||
|
temp1[9] = temp0[9] + temp0[22]; |
||||
|
temp1[10] = temp0[10] + temp0[21]; |
||||
|
temp1[11] = temp0[11] + temp0[20]; |
||||
|
temp1[12] = temp0[12] + temp0[19]; |
||||
|
temp1[13] = temp0[13] + temp0[18]; |
||||
|
temp1[14] = temp0[14] + temp0[17]; |
||||
|
temp1[15] = temp0[15] + temp0[16]; |
||||
|
temp1[16] = -temp0[16] + temp0[15]; |
||||
|
temp1[17] = -temp0[17] + temp0[14]; |
||||
|
temp1[18] = -temp0[18] + temp0[13]; |
||||
|
temp1[19] = -temp0[19] + temp0[12]; |
||||
|
temp1[20] = -temp0[20] + temp0[11]; |
||||
|
temp1[21] = -temp0[21] + temp0[10]; |
||||
|
temp1[22] = -temp0[22] + temp0[9]; |
||||
|
temp1[23] = -temp0[23] + temp0[8]; |
||||
|
temp1[24] = -temp0[24] + temp0[7]; |
||||
|
temp1[25] = -temp0[25] + temp0[6]; |
||||
|
temp1[26] = -temp0[26] + temp0[5]; |
||||
|
temp1[27] = -temp0[27] + temp0[4]; |
||||
|
temp1[28] = -temp0[28] + temp0[3]; |
||||
|
temp1[29] = -temp0[29] + temp0[2]; |
||||
|
temp1[30] = -temp0[30] + temp0[1]; |
||||
|
temp1[31] = -temp0[31] + temp0[0]; |
||||
|
temp1[32] = temp0[32]; |
||||
|
temp1[33] = temp0[33]; |
||||
|
temp1[34] = temp0[34]; |
||||
|
temp1[35] = temp0[35]; |
||||
|
temp1[36] = temp0[36]; |
||||
|
temp1[37] = temp0[37]; |
||||
|
temp1[38] = temp0[38]; |
||||
|
temp1[39] = temp0[39]; |
||||
|
temp1[40] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[40], cospi[32], temp0[55], cosBit); |
||||
|
temp1[41] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[41], cospi[32], temp0[54], cosBit); |
||||
|
temp1[42] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[42], cospi[32], temp0[53], cosBit); |
||||
|
temp1[43] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[43], cospi[32], temp0[52], cosBit); |
||||
|
temp1[44] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[44], cospi[32], temp0[51], cosBit); |
||||
|
temp1[45] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[45], cospi[32], temp0[50], cosBit); |
||||
|
temp1[46] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[46], cospi[32], temp0[49], cosBit); |
||||
|
temp1[47] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[47], cospi[32], temp0[48], cosBit); |
||||
|
temp1[48] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[48], cospi[32], temp0[47], cosBit); |
||||
|
temp1[49] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[49], cospi[32], temp0[46], cosBit); |
||||
|
temp1[50] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[50], cospi[32], temp0[45], cosBit); |
||||
|
temp1[51] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[51], cospi[32], temp0[44], cosBit); |
||||
|
temp1[52] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[52], cospi[32], temp0[43], cosBit); |
||||
|
temp1[53] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[53], cospi[32], temp0[42], cosBit); |
||||
|
temp1[54] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[54], cospi[32], temp0[41], cosBit); |
||||
|
temp1[55] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[55], cospi[32], temp0[40], cosBit); |
||||
|
temp1[56] = temp0[56]; |
||||
|
temp1[57] = temp0[57]; |
||||
|
temp1[58] = temp0[58]; |
||||
|
temp1[59] = temp0[59]; |
||||
|
temp1[60] = temp0[60]; |
||||
|
temp1[61] = temp0[61]; |
||||
|
temp1[62] = temp0[62]; |
||||
|
temp1[63] = temp0[63]; |
||||
|
|
||||
|
// stage 3
|
||||
|
temp0[0] = temp1[0] + temp1[15]; |
||||
|
temp0[1] = temp1[1] + temp1[14]; |
||||
|
temp0[2] = temp1[2] + temp1[13]; |
||||
|
temp0[3] = temp1[3] + temp1[12]; |
||||
|
temp0[4] = temp1[4] + temp1[11]; |
||||
|
temp0[5] = temp1[5] + temp1[10]; |
||||
|
temp0[6] = temp1[6] + temp1[9]; |
||||
|
temp0[7] = temp1[7] + temp1[8]; |
||||
|
temp0[8] = -temp1[8] + temp1[7]; |
||||
|
temp0[9] = -temp1[9] + temp1[6]; |
||||
|
temp0[10] = -temp1[10] + temp1[5]; |
||||
|
temp0[11] = -temp1[11] + temp1[4]; |
||||
|
temp0[12] = -temp1[12] + temp1[3]; |
||||
|
temp0[13] = -temp1[13] + temp1[2]; |
||||
|
temp0[14] = -temp1[14] + temp1[1]; |
||||
|
temp0[15] = -temp1[15] + temp1[0]; |
||||
|
temp0[16] = temp1[16]; |
||||
|
temp0[17] = temp1[17]; |
||||
|
temp0[18] = temp1[18]; |
||||
|
temp0[19] = temp1[19]; |
||||
|
temp0[20] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[20], cospi[32], temp1[27], cosBit); |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[21], cospi[32], temp1[26], cosBit); |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[22], cospi[32], temp1[25], cosBit); |
||||
|
temp0[23] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[23], cospi[32], temp1[24], cosBit); |
||||
|
temp0[24] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[24], cospi[32], temp1[23], cosBit); |
||||
|
temp0[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[25], cospi[32], temp1[22], cosBit); |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[26], cospi[32], temp1[21], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[27], cospi[32], temp1[20], cosBit); |
||||
|
temp0[28] = temp1[28]; |
||||
|
temp0[29] = temp1[29]; |
||||
|
temp0[30] = temp1[30]; |
||||
|
temp0[31] = temp1[31]; |
||||
|
temp0[32] = temp1[32] + temp1[47]; |
||||
|
temp0[33] = temp1[33] + temp1[46]; |
||||
|
temp0[34] = temp1[34] + temp1[45]; |
||||
|
temp0[35] = temp1[35] + temp1[44]; |
||||
|
temp0[36] = temp1[36] + temp1[43]; |
||||
|
temp0[37] = temp1[37] + temp1[42]; |
||||
|
temp0[38] = temp1[38] + temp1[41]; |
||||
|
temp0[39] = temp1[39] + temp1[40]; |
||||
|
temp0[40] = -temp1[40] + temp1[39]; |
||||
|
temp0[41] = -temp1[41] + temp1[38]; |
||||
|
temp0[42] = -temp1[42] + temp1[37]; |
||||
|
temp0[43] = -temp1[43] + temp1[36]; |
||||
|
temp0[44] = -temp1[44] + temp1[35]; |
||||
|
temp0[45] = -temp1[45] + temp1[34]; |
||||
|
temp0[46] = -temp1[46] + temp1[33]; |
||||
|
temp0[47] = -temp1[47] + temp1[32]; |
||||
|
temp0[48] = -temp1[48] + temp1[63]; |
||||
|
temp0[49] = -temp1[49] + temp1[62]; |
||||
|
temp0[50] = -temp1[50] + temp1[61]; |
||||
|
temp0[51] = -temp1[51] + temp1[60]; |
||||
|
temp0[52] = -temp1[52] + temp1[59]; |
||||
|
temp0[53] = -temp1[53] + temp1[58]; |
||||
|
temp0[54] = -temp1[54] + temp1[57]; |
||||
|
temp0[55] = -temp1[55] + temp1[56]; |
||||
|
temp0[56] = temp1[56] + temp1[55]; |
||||
|
temp0[57] = temp1[57] + temp1[54]; |
||||
|
temp0[58] = temp1[58] + temp1[53]; |
||||
|
temp0[59] = temp1[59] + temp1[52]; |
||||
|
temp0[60] = temp1[60] + temp1[51]; |
||||
|
temp0[61] = temp1[61] + temp1[50]; |
||||
|
temp0[62] = temp1[62] + temp1[49]; |
||||
|
temp0[63] = temp1[63] + temp1[48]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp1[0] = temp0[0] + temp0[7]; |
||||
|
temp1[1] = temp0[1] + temp0[6]; |
||||
|
temp1[2] = temp0[2] + temp0[5]; |
||||
|
temp1[3] = temp0[3] + temp0[4]; |
||||
|
temp1[4] = -temp0[4] + temp0[3]; |
||||
|
temp1[5] = -temp0[5] + temp0[2]; |
||||
|
temp1[6] = -temp0[6] + temp0[1]; |
||||
|
temp1[7] = -temp0[7] + temp0[0]; |
||||
|
temp1[8] = temp0[8]; |
||||
|
temp1[9] = temp0[9]; |
||||
|
temp1[10] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[10], cospi[32], temp0[13], cosBit); |
||||
|
temp1[11] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[11], cospi[32], temp0[12], cosBit); |
||||
|
temp1[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[12], cospi[32], temp0[11], cosBit); |
||||
|
temp1[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[13], cospi[32], temp0[10], cosBit); |
||||
|
temp1[14] = temp0[14]; |
||||
|
temp1[15] = temp0[15]; |
||||
|
temp1[16] = temp0[16] + temp0[23]; |
||||
|
temp1[17] = temp0[17] + temp0[22]; |
||||
|
temp1[18] = temp0[18] + temp0[21]; |
||||
|
temp1[19] = temp0[19] + temp0[20]; |
||||
|
temp1[20] = -temp0[20] + temp0[19]; |
||||
|
temp1[21] = -temp0[21] + temp0[18]; |
||||
|
temp1[22] = -temp0[22] + temp0[17]; |
||||
|
temp1[23] = -temp0[23] + temp0[16]; |
||||
|
temp1[24] = -temp0[24] + temp0[31]; |
||||
|
temp1[25] = -temp0[25] + temp0[30]; |
||||
|
temp1[26] = -temp0[26] + temp0[29]; |
||||
|
temp1[27] = -temp0[27] + temp0[28]; |
||||
|
temp1[28] = temp0[28] + temp0[27]; |
||||
|
temp1[29] = temp0[29] + temp0[26]; |
||||
|
temp1[30] = temp0[30] + temp0[25]; |
||||
|
temp1[31] = temp0[31] + temp0[24]; |
||||
|
temp1[32] = temp0[32]; |
||||
|
temp1[33] = temp0[33]; |
||||
|
temp1[34] = temp0[34]; |
||||
|
temp1[35] = temp0[35]; |
||||
|
temp1[36] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[36], cospi[48], temp0[59], cosBit); |
||||
|
temp1[37] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[37], cospi[48], temp0[58], cosBit); |
||||
|
temp1[38] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[38], cospi[48], temp0[57], cosBit); |
||||
|
temp1[39] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[39], cospi[48], temp0[56], cosBit); |
||||
|
temp1[40] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[40], -cospi[16], temp0[55], cosBit); |
||||
|
temp1[41] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[41], -cospi[16], temp0[54], cosBit); |
||||
|
temp1[42] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[42], -cospi[16], temp0[53], cosBit); |
||||
|
temp1[43] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[43], -cospi[16], temp0[52], cosBit); |
||||
|
temp1[44] = temp0[44]; |
||||
|
temp1[45] = temp0[45]; |
||||
|
temp1[46] = temp0[46]; |
||||
|
temp1[47] = temp0[47]; |
||||
|
temp1[48] = temp0[48]; |
||||
|
temp1[49] = temp0[49]; |
||||
|
temp1[50] = temp0[50]; |
||||
|
temp1[51] = temp0[51]; |
||||
|
temp1[52] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[52], -cospi[16], temp0[43], cosBit); |
||||
|
temp1[53] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[53], -cospi[16], temp0[42], cosBit); |
||||
|
temp1[54] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[54], -cospi[16], temp0[41], cosBit); |
||||
|
temp1[55] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[55], -cospi[16], temp0[40], cosBit); |
||||
|
temp1[56] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[56], cospi[48], temp0[39], cosBit); |
||||
|
temp1[57] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[57], cospi[48], temp0[38], cosBit); |
||||
|
temp1[58] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[58], cospi[48], temp0[37], cosBit); |
||||
|
temp1[59] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[59], cospi[48], temp0[36], cosBit); |
||||
|
temp1[60] = temp0[60]; |
||||
|
temp1[61] = temp0[61]; |
||||
|
temp1[62] = temp0[62]; |
||||
|
temp1[63] = temp0[63]; |
||||
|
|
||||
|
// stage 5
|
||||
|
temp0[0] = temp1[0] + temp1[3]; |
||||
|
temp0[1] = temp1[1] + temp1[2]; |
||||
|
temp0[2] = -temp1[2] + temp1[1]; |
||||
|
temp0[3] = -temp1[3] + temp1[0]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[5], cospi[32], temp1[6], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[6], cospi[32], temp1[5], cosBit); |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = temp1[8] + temp1[11]; |
||||
|
temp0[9] = temp1[9] + temp1[10]; |
||||
|
temp0[10] = -temp1[10] + temp1[9]; |
||||
|
temp0[11] = -temp1[11] + temp1[8]; |
||||
|
temp0[12] = -temp1[12] + temp1[15]; |
||||
|
temp0[13] = -temp1[13] + temp1[14]; |
||||
|
temp0[14] = temp1[14] + temp1[13]; |
||||
|
temp0[15] = temp1[15] + temp1[12]; |
||||
|
temp0[16] = temp1[16]; |
||||
|
temp0[17] = temp1[17]; |
||||
|
temp0[18] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[18], cospi[48], temp1[29], cosBit); |
||||
|
temp0[19] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp1[19], cospi[48], temp1[28], cosBit); |
||||
|
temp0[20] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[20], -cospi[16], temp1[27], cosBit); |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp1[21], -cospi[16], temp1[26], cosBit); |
||||
|
temp0[22] = temp1[22]; |
||||
|
temp0[23] = temp1[23]; |
||||
|
temp0[24] = temp1[24]; |
||||
|
temp0[25] = temp1[25]; |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[26], -cospi[16], temp1[21], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[27], -cospi[16], temp1[20], cosBit); |
||||
|
temp0[28] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[28], cospi[48], temp1[19], cosBit); |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp1[29], cospi[48], temp1[18], cosBit); |
||||
|
temp0[30] = temp1[30]; |
||||
|
temp0[31] = temp1[31]; |
||||
|
temp0[32] = temp1[32] + temp1[39]; |
||||
|
temp0[33] = temp1[33] + temp1[38]; |
||||
|
temp0[34] = temp1[34] + temp1[37]; |
||||
|
temp0[35] = temp1[35] + temp1[36]; |
||||
|
temp0[36] = -temp1[36] + temp1[35]; |
||||
|
temp0[37] = -temp1[37] + temp1[34]; |
||||
|
temp0[38] = -temp1[38] + temp1[33]; |
||||
|
temp0[39] = -temp1[39] + temp1[32]; |
||||
|
temp0[40] = -temp1[40] + temp1[47]; |
||||
|
temp0[41] = -temp1[41] + temp1[46]; |
||||
|
temp0[42] = -temp1[42] + temp1[45]; |
||||
|
temp0[43] = -temp1[43] + temp1[44]; |
||||
|
temp0[44] = temp1[44] + temp1[43]; |
||||
|
temp0[45] = temp1[45] + temp1[42]; |
||||
|
temp0[46] = temp1[46] + temp1[41]; |
||||
|
temp0[47] = temp1[47] + temp1[40]; |
||||
|
temp0[48] = temp1[48] + temp1[55]; |
||||
|
temp0[49] = temp1[49] + temp1[54]; |
||||
|
temp0[50] = temp1[50] + temp1[53]; |
||||
|
temp0[51] = temp1[51] + temp1[52]; |
||||
|
temp0[52] = -temp1[52] + temp1[51]; |
||||
|
temp0[53] = -temp1[53] + temp1[50]; |
||||
|
temp0[54] = -temp1[54] + temp1[49]; |
||||
|
temp0[55] = -temp1[55] + temp1[48]; |
||||
|
temp0[56] = -temp1[56] + temp1[63]; |
||||
|
temp0[57] = -temp1[57] + temp1[62]; |
||||
|
temp0[58] = -temp1[58] + temp1[61]; |
||||
|
temp0[59] = -temp1[59] + temp1[60]; |
||||
|
temp0[60] = temp1[60] + temp1[59]; |
||||
|
temp0[61] = temp1[61] + temp1[58]; |
||||
|
temp0[62] = temp1[62] + temp1[57]; |
||||
|
temp0[63] = temp1[63] + temp1[56]; |
||||
|
|
||||
|
// stage 6
|
||||
|
temp1[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[0], cospi[32], temp0[1], cosBit); |
||||
|
temp1[1] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[1], cospi[32], temp0[0], cosBit); |
||||
|
temp1[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[2], cospi[16], temp0[3], cosBit); |
||||
|
temp1[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[3], -cospi[16], temp0[2], cosBit); |
||||
|
temp1[4] = temp0[4] + temp0[5]; |
||||
|
temp1[5] = -temp0[5] + temp0[4]; |
||||
|
temp1[6] = -temp0[6] + temp0[7]; |
||||
|
temp1[7] = temp0[7] + temp0[6]; |
||||
|
temp1[8] = temp0[8]; |
||||
|
temp1[9] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[16], temp0[9], cospi[48], temp0[14], cosBit); |
||||
|
temp1[10] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[48], temp0[10], -cospi[16], temp0[13], cosBit); |
||||
|
temp1[11] = temp0[11]; |
||||
|
temp1[12] = temp0[12]; |
||||
|
temp1[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp0[13], -cospi[16], temp0[10], cosBit); |
||||
|
temp1[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[16], temp0[14], cospi[48], temp0[9], cosBit); |
||||
|
temp1[15] = temp0[15]; |
||||
|
temp1[16] = temp0[16] + temp0[19]; |
||||
|
temp1[17] = temp0[17] + temp0[18]; |
||||
|
temp1[18] = -temp0[18] + temp0[17]; |
||||
|
temp1[19] = -temp0[19] + temp0[16]; |
||||
|
temp1[20] = -temp0[20] + temp0[23]; |
||||
|
temp1[21] = -temp0[21] + temp0[22]; |
||||
|
temp1[22] = temp0[22] + temp0[21]; |
||||
|
temp1[23] = temp0[23] + temp0[20]; |
||||
|
temp1[24] = temp0[24] + temp0[27]; |
||||
|
temp1[25] = temp0[25] + temp0[26]; |
||||
|
temp1[26] = -temp0[26] + temp0[25]; |
||||
|
temp1[27] = -temp0[27] + temp0[24]; |
||||
|
temp1[28] = -temp0[28] + temp0[31]; |
||||
|
temp1[29] = -temp0[29] + temp0[30]; |
||||
|
temp1[30] = temp0[30] + temp0[29]; |
||||
|
temp1[31] = temp0[31] + temp0[28]; |
||||
|
temp1[32] = temp0[32]; |
||||
|
temp1[33] = temp0[33]; |
||||
|
temp1[34] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[8], temp0[34], cospi[56], temp0[61], cosBit); |
||||
|
temp1[35] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[8], temp0[35], cospi[56], temp0[60], cosBit); |
||||
|
temp1[36] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp0[36], -cospi[8], temp0[59], cosBit); |
||||
|
temp1[37] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp0[37], -cospi[8], temp0[58], cosBit); |
||||
|
temp1[38] = temp0[38]; |
||||
|
temp1[39] = temp0[39]; |
||||
|
temp1[40] = temp0[40]; |
||||
|
temp1[41] = temp0[41]; |
||||
|
temp1[42] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[40], temp0[42], cospi[24], temp0[53], cosBit); |
||||
|
temp1[43] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[40], temp0[43], cospi[24], temp0[52], cosBit); |
||||
|
temp1[44] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp0[44], -cospi[40], temp0[51], cosBit); |
||||
|
temp1[45] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp0[45], -cospi[40], temp0[50], cosBit); |
||||
|
temp1[46] = temp0[46]; |
||||
|
temp1[47] = temp0[47]; |
||||
|
temp1[48] = temp0[48]; |
||||
|
temp1[49] = temp0[49]; |
||||
|
temp1[50] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[50], -cospi[40], temp0[45], cosBit); |
||||
|
temp1[51] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[51], -cospi[40], temp0[44], cosBit); |
||||
|
temp1[52] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp0[52], cospi[24], temp0[43], cosBit); |
||||
|
temp1[53] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp0[53], cospi[24], temp0[42], cosBit); |
||||
|
temp1[54] = temp0[54]; |
||||
|
temp1[55] = temp0[55]; |
||||
|
temp1[56] = temp0[56]; |
||||
|
temp1[57] = temp0[57]; |
||||
|
temp1[58] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[58], -cospi[8], temp0[37], cosBit); |
||||
|
temp1[59] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[59], -cospi[8], temp0[36], cosBit); |
||||
|
temp1[60] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp0[60], cospi[56], temp0[35], cosBit); |
||||
|
temp1[61] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp0[61], cospi[56], temp0[34], cosBit); |
||||
|
temp1[62] = temp0[62]; |
||||
|
temp1[63] = temp0[63]; |
||||
|
|
||||
|
// stage 7
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[4], cospi[8], temp1[7], cosBit); |
||||
|
temp0[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[5], cospi[40], temp1[6], cosBit); |
||||
|
temp0[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[6], -cospi[40], temp1[5], cosBit); |
||||
|
temp0[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[7], -cospi[8], temp1[4], cosBit); |
||||
|
temp0[8] = temp1[8] + temp1[9]; |
||||
|
temp0[9] = -temp1[9] + temp1[8]; |
||||
|
temp0[10] = -temp1[10] + temp1[11]; |
||||
|
temp0[11] = temp1[11] + temp1[10]; |
||||
|
temp0[12] = temp1[12] + temp1[13]; |
||||
|
temp0[13] = -temp1[13] + temp1[12]; |
||||
|
temp0[14] = -temp1[14] + temp1[15]; |
||||
|
temp0[15] = temp1[15] + temp1[14]; |
||||
|
temp0[16] = temp1[16]; |
||||
|
temp0[17] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[8], temp1[17], cospi[56], temp1[30], cosBit); |
||||
|
temp0[18] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[56], temp1[18], -cospi[8], temp1[29], cosBit); |
||||
|
temp0[19] = temp1[19]; |
||||
|
temp0[20] = temp1[20]; |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[40], temp1[21], cospi[24], temp1[26], cosBit); |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[24], temp1[22], -cospi[40], temp1[25], cosBit); |
||||
|
temp0[23] = temp1[23]; |
||||
|
temp0[24] = temp1[24]; |
||||
|
temp0[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp1[25], -cospi[40], temp1[22], cosBit); |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[40], temp1[26], cospi[24], temp1[21], cosBit); |
||||
|
temp0[27] = temp1[27]; |
||||
|
temp0[28] = temp1[28]; |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp1[29], -cospi[8], temp1[18], cosBit); |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[8], temp1[30], cospi[56], temp1[17], cosBit); |
||||
|
temp0[31] = temp1[31]; |
||||
|
temp0[32] = temp1[32] + temp1[35]; |
||||
|
temp0[33] = temp1[33] + temp1[34]; |
||||
|
temp0[34] = -temp1[34] + temp1[33]; |
||||
|
temp0[35] = -temp1[35] + temp1[32]; |
||||
|
temp0[36] = -temp1[36] + temp1[39]; |
||||
|
temp0[37] = -temp1[37] + temp1[38]; |
||||
|
temp0[38] = temp1[38] + temp1[37]; |
||||
|
temp0[39] = temp1[39] + temp1[36]; |
||||
|
temp0[40] = temp1[40] + temp1[43]; |
||||
|
temp0[41] = temp1[41] + temp1[42]; |
||||
|
temp0[42] = -temp1[42] + temp1[41]; |
||||
|
temp0[43] = -temp1[43] + temp1[40]; |
||||
|
temp0[44] = -temp1[44] + temp1[47]; |
||||
|
temp0[45] = -temp1[45] + temp1[46]; |
||||
|
temp0[46] = temp1[46] + temp1[45]; |
||||
|
temp0[47] = temp1[47] + temp1[44]; |
||||
|
temp0[48] = temp1[48] + temp1[51]; |
||||
|
temp0[49] = temp1[49] + temp1[50]; |
||||
|
temp0[50] = -temp1[50] + temp1[49]; |
||||
|
temp0[51] = -temp1[51] + temp1[48]; |
||||
|
temp0[52] = -temp1[52] + temp1[55]; |
||||
|
temp0[53] = -temp1[53] + temp1[54]; |
||||
|
temp0[54] = temp1[54] + temp1[53]; |
||||
|
temp0[55] = temp1[55] + temp1[52]; |
||||
|
temp0[56] = temp1[56] + temp1[59]; |
||||
|
temp0[57] = temp1[57] + temp1[58]; |
||||
|
temp0[58] = -temp1[58] + temp1[57]; |
||||
|
temp0[59] = -temp1[59] + temp1[56]; |
||||
|
temp0[60] = -temp1[60] + temp1[63]; |
||||
|
temp0[61] = -temp1[61] + temp1[62]; |
||||
|
temp0[62] = temp1[62] + temp1[61]; |
||||
|
temp0[63] = temp1[63] + temp1[60]; |
||||
|
|
||||
|
// stage 8
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = temp0[5]; |
||||
|
temp1[6] = temp0[6]; |
||||
|
temp1[7] = temp0[7]; |
||||
|
temp1[8] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp0[8], cospi[4], temp0[15], cosBit); |
||||
|
temp1[9] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp0[9], cospi[36], temp0[14], cosBit); |
||||
|
temp1[10] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp0[10], cospi[20], temp0[13], cosBit); |
||||
|
temp1[11] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp0[11], cospi[52], temp0[12], cosBit); |
||||
|
temp1[12] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp0[12], -cospi[52], temp0[11], cosBit); |
||||
|
temp1[13] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp0[13], -cospi[20], temp0[10], cosBit); |
||||
|
temp1[14] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp0[14], -cospi[36], temp0[9], cosBit); |
||||
|
temp1[15] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp0[15], -cospi[4], temp0[8], cosBit); |
||||
|
temp1[16] = temp0[16] + temp0[17]; |
||||
|
temp1[17] = -temp0[17] + temp0[16]; |
||||
|
temp1[18] = -temp0[18] + temp0[19]; |
||||
|
temp1[19] = temp0[19] + temp0[18]; |
||||
|
temp1[20] = temp0[20] + temp0[21]; |
||||
|
temp1[21] = -temp0[21] + temp0[20]; |
||||
|
temp1[22] = -temp0[22] + temp0[23]; |
||||
|
temp1[23] = temp0[23] + temp0[22]; |
||||
|
temp1[24] = temp0[24] + temp0[25]; |
||||
|
temp1[25] = -temp0[25] + temp0[24]; |
||||
|
temp1[26] = -temp0[26] + temp0[27]; |
||||
|
temp1[27] = temp0[27] + temp0[26]; |
||||
|
temp1[28] = temp0[28] + temp0[29]; |
||||
|
temp1[29] = -temp0[29] + temp0[28]; |
||||
|
temp1[30] = -temp0[30] + temp0[31]; |
||||
|
temp1[31] = temp0[31] + temp0[30]; |
||||
|
temp1[32] = temp0[32]; |
||||
|
temp1[33] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[4], temp0[33], cospi[60], temp0[62], cosBit); |
||||
|
temp1[34] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[60], temp0[34], -cospi[4], temp0[61], cosBit); |
||||
|
temp1[35] = temp0[35]; |
||||
|
temp1[36] = temp0[36]; |
||||
|
temp1[37] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[36], temp0[37], cospi[28], temp0[58], cosBit); |
||||
|
temp1[38] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[28], temp0[38], -cospi[36], temp0[57], cosBit); |
||||
|
temp1[39] = temp0[39]; |
||||
|
temp1[40] = temp0[40]; |
||||
|
temp1[41] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[20], temp0[41], cospi[44], temp0[54], cosBit); |
||||
|
temp1[42] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[44], temp0[42], -cospi[20], temp0[53], cosBit); |
||||
|
temp1[43] = temp0[43]; |
||||
|
temp1[44] = temp0[44]; |
||||
|
temp1[45] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[52], temp0[45], cospi[12], temp0[50], cosBit); |
||||
|
temp1[46] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[12], temp0[46], -cospi[52], temp0[49], cosBit); |
||||
|
temp1[47] = temp0[47]; |
||||
|
temp1[48] = temp0[48]; |
||||
|
temp1[49] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[12], temp0[49], -cospi[52], temp0[46], cosBit); |
||||
|
temp1[50] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[52], temp0[50], cospi[12], temp0[45], cosBit); |
||||
|
temp1[51] = temp0[51]; |
||||
|
temp1[52] = temp0[52]; |
||||
|
temp1[53] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[44], temp0[53], -cospi[20], temp0[42], cosBit); |
||||
|
temp1[54] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[20], temp0[54], cospi[44], temp0[41], cosBit); |
||||
|
temp1[55] = temp0[55]; |
||||
|
temp1[56] = temp0[56]; |
||||
|
temp1[57] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[28], temp0[57], -cospi[36], temp0[38], cosBit); |
||||
|
temp1[58] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[36], temp0[58], cospi[28], temp0[37], cosBit); |
||||
|
temp1[59] = temp0[59]; |
||||
|
temp1[60] = temp0[60]; |
||||
|
temp1[61] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[60], temp0[61], -cospi[4], temp0[34], cosBit); |
||||
|
temp1[62] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[4], temp0[62], cospi[60], temp0[33], cosBit); |
||||
|
temp1[63] = temp0[63]; |
||||
|
|
||||
|
// stage 9
|
||||
|
temp0[0] = temp1[0]; |
||||
|
temp0[1] = temp1[1]; |
||||
|
temp0[2] = temp1[2]; |
||||
|
temp0[3] = temp1[3]; |
||||
|
temp0[4] = temp1[4]; |
||||
|
temp0[5] = temp1[5]; |
||||
|
temp0[6] = temp1[6]; |
||||
|
temp0[7] = temp1[7]; |
||||
|
temp0[8] = temp1[8]; |
||||
|
temp0[9] = temp1[9]; |
||||
|
temp0[10] = temp1[10]; |
||||
|
temp0[11] = temp1[11]; |
||||
|
temp0[12] = temp1[12]; |
||||
|
temp0[13] = temp1[13]; |
||||
|
temp0[14] = temp1[14]; |
||||
|
temp0[15] = temp1[15]; |
||||
|
temp0[16] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[62], temp1[16], cospi[2], temp1[31], cosBit); |
||||
|
temp0[17] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[30], temp1[17], cospi[34], temp1[30], cosBit); |
||||
|
temp0[18] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[46], temp1[18], cospi[18], temp1[29], cosBit); |
||||
|
temp0[19] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[14], temp1[19], cospi[50], temp1[28], cosBit); |
||||
|
temp0[20] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[54], temp1[20], cospi[10], temp1[27], cosBit); |
||||
|
temp0[21] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[22], temp1[21], cospi[42], temp1[26], cosBit); |
||||
|
temp0[22] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[38], temp1[22], cospi[26], temp1[25], cosBit); |
||||
|
temp0[23] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[6], temp1[23], cospi[58], temp1[24], cosBit); |
||||
|
temp0[24] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[6], temp1[24], -cospi[58], temp1[23], cosBit); |
||||
|
temp0[25] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[38], temp1[25], -cospi[26], temp1[22], cosBit); |
||||
|
temp0[26] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[22], temp1[26], -cospi[42], temp1[21], cosBit); |
||||
|
temp0[27] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[54], temp1[27], -cospi[10], temp1[20], cosBit); |
||||
|
temp0[28] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[14], temp1[28], -cospi[50], temp1[19], cosBit); |
||||
|
temp0[29] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[46], temp1[29], -cospi[18], temp1[18], cosBit); |
||||
|
temp0[30] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[30], temp1[30], -cospi[34], temp1[17], cosBit); |
||||
|
temp0[31] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[62], temp1[31], -cospi[2], temp1[16], cosBit); |
||||
|
temp0[32] = temp1[32] + temp1[33]; |
||||
|
temp0[33] = -temp1[33] + temp1[32]; |
||||
|
temp0[34] = -temp1[34] + temp1[35]; |
||||
|
temp0[35] = temp1[35] + temp1[34]; |
||||
|
temp0[36] = temp1[36] + temp1[37]; |
||||
|
temp0[37] = -temp1[37] + temp1[36]; |
||||
|
temp0[38] = -temp1[38] + temp1[39]; |
||||
|
temp0[39] = temp1[39] + temp1[38]; |
||||
|
temp0[40] = temp1[40] + temp1[41]; |
||||
|
temp0[41] = -temp1[41] + temp1[40]; |
||||
|
temp0[42] = -temp1[42] + temp1[43]; |
||||
|
temp0[43] = temp1[43] + temp1[42]; |
||||
|
temp0[44] = temp1[44] + temp1[45]; |
||||
|
temp0[45] = -temp1[45] + temp1[44]; |
||||
|
temp0[46] = -temp1[46] + temp1[47]; |
||||
|
temp0[47] = temp1[47] + temp1[46]; |
||||
|
temp0[48] = temp1[48] + temp1[49]; |
||||
|
temp0[49] = -temp1[49] + temp1[48]; |
||||
|
temp0[50] = -temp1[50] + temp1[51]; |
||||
|
temp0[51] = temp1[51] + temp1[50]; |
||||
|
temp0[52] = temp1[52] + temp1[53]; |
||||
|
temp0[53] = -temp1[53] + temp1[52]; |
||||
|
temp0[54] = -temp1[54] + temp1[55]; |
||||
|
temp0[55] = temp1[55] + temp1[54]; |
||||
|
temp0[56] = temp1[56] + temp1[57]; |
||||
|
temp0[57] = -temp1[57] + temp1[56]; |
||||
|
temp0[58] = -temp1[58] + temp1[59]; |
||||
|
temp0[59] = temp1[59] + temp1[58]; |
||||
|
temp0[60] = temp1[60] + temp1[61]; |
||||
|
temp0[61] = -temp1[61] + temp1[60]; |
||||
|
temp0[62] = -temp1[62] + temp1[63]; |
||||
|
temp0[63] = temp1[63] + temp1[62]; |
||||
|
|
||||
|
// stage 10
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = temp0[5]; |
||||
|
temp1[6] = temp0[6]; |
||||
|
temp1[7] = temp0[7]; |
||||
|
temp1[8] = temp0[8]; |
||||
|
temp1[9] = temp0[9]; |
||||
|
temp1[10] = temp0[10]; |
||||
|
temp1[11] = temp0[11]; |
||||
|
temp1[12] = temp0[12]; |
||||
|
temp1[13] = temp0[13]; |
||||
|
temp1[14] = temp0[14]; |
||||
|
temp1[15] = temp0[15]; |
||||
|
temp1[16] = temp0[16]; |
||||
|
temp1[17] = temp0[17]; |
||||
|
temp1[18] = temp0[18]; |
||||
|
temp1[19] = temp0[19]; |
||||
|
temp1[20] = temp0[20]; |
||||
|
temp1[21] = temp0[21]; |
||||
|
temp1[22] = temp0[22]; |
||||
|
temp1[23] = temp0[23]; |
||||
|
temp1[24] = temp0[24]; |
||||
|
temp1[25] = temp0[25]; |
||||
|
temp1[26] = temp0[26]; |
||||
|
temp1[27] = temp0[27]; |
||||
|
temp1[28] = temp0[28]; |
||||
|
temp1[29] = temp0[29]; |
||||
|
temp1[30] = temp0[30]; |
||||
|
temp1[31] = temp0[31]; |
||||
|
temp1[32] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[63], temp0[32], cospi[1], temp0[63], cosBit); |
||||
|
temp1[33] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[31], temp0[33], cospi[33], temp0[62], cosBit); |
||||
|
temp1[34] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[47], temp0[34], cospi[17], temp0[61], cosBit); |
||||
|
temp1[35] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[15], temp0[35], cospi[49], temp0[60], cosBit); |
||||
|
temp1[36] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[55], temp0[36], cospi[9], temp0[59], cosBit); |
||||
|
temp1[37] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[23], temp0[37], cospi[41], temp0[58], cosBit); |
||||
|
temp1[38] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[39], temp0[38], cospi[25], temp0[57], cosBit); |
||||
|
temp1[39] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[7], temp0[39], cospi[57], temp0[56], cosBit); |
||||
|
temp1[40] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[59], temp0[40], cospi[5], temp0[55], cosBit); |
||||
|
temp1[41] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[27], temp0[41], cospi[37], temp0[54], cosBit); |
||||
|
temp1[42] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[43], temp0[42], cospi[21], temp0[53], cosBit); |
||||
|
temp1[43] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[11], temp0[43], cospi[53], temp0[52], cosBit); |
||||
|
temp1[44] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[51], temp0[44], cospi[13], temp0[51], cosBit); |
||||
|
temp1[45] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[19], temp0[45], cospi[45], temp0[50], cosBit); |
||||
|
temp1[46] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[35], temp0[46], cospi[29], temp0[49], cosBit); |
||||
|
temp1[47] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[3], temp0[47], cospi[61], temp0[48], cosBit); |
||||
|
temp1[48] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[3], temp0[48], -cospi[61], temp0[47], cosBit); |
||||
|
temp1[49] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[35], temp0[49], -cospi[29], temp0[46], cosBit); |
||||
|
temp1[50] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[19], temp0[50], -cospi[45], temp0[45], cosBit); |
||||
|
temp1[51] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[51], temp0[51], -cospi[13], temp0[44], cosBit); |
||||
|
temp1[52] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[11], temp0[52], -cospi[53], temp0[43], cosBit); |
||||
|
temp1[53] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[43], temp0[53], -cospi[21], temp0[42], cosBit); |
||||
|
temp1[54] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[27], temp0[54], -cospi[37], temp0[41], cosBit); |
||||
|
temp1[55] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[59], temp0[55], -cospi[5], temp0[40], cosBit); |
||||
|
temp1[56] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[7], temp0[56], -cospi[57], temp0[39], cosBit); |
||||
|
temp1[57] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[39], temp0[57], -cospi[25], temp0[38], cosBit); |
||||
|
temp1[58] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[23], temp0[58], -cospi[41], temp0[37], cosBit); |
||||
|
temp1[59] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[55], temp0[59], -cospi[9], temp0[36], cosBit); |
||||
|
temp1[60] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[15], temp0[60], -cospi[49], temp0[35], cosBit); |
||||
|
temp1[61] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[47], temp0[61], -cospi[17], temp0[34], cosBit); |
||||
|
temp1[62] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[31], temp0[62], -cospi[33], temp0[33], cosBit); |
||||
|
temp1[63] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[63], temp0[63], -cospi[1], temp0[32], cosBit); |
||||
|
|
||||
|
// stage 11
|
||||
|
Unsafe.Add(ref output, 0) = temp1[0]; |
||||
|
Unsafe.Add(ref output, 1) = temp1[32]; |
||||
|
Unsafe.Add(ref output, 2) = temp1[16]; |
||||
|
Unsafe.Add(ref output, 3) = temp1[48]; |
||||
|
Unsafe.Add(ref output, 4) = temp1[8]; |
||||
|
Unsafe.Add(ref output, 5) = temp1[40]; |
||||
|
Unsafe.Add(ref output, 6) = temp1[24]; |
||||
|
Unsafe.Add(ref output, 7) = temp1[56]; |
||||
|
Unsafe.Add(ref output, 8) = temp1[4]; |
||||
|
Unsafe.Add(ref output, 9) = temp1[36]; |
||||
|
Unsafe.Add(ref output, 10) = temp1[20]; |
||||
|
Unsafe.Add(ref output, 11) = temp1[52]; |
||||
|
Unsafe.Add(ref output, 12) = temp1[12]; |
||||
|
Unsafe.Add(ref output, 13) = temp1[44]; |
||||
|
Unsafe.Add(ref output, 14) = temp1[28]; |
||||
|
Unsafe.Add(ref output, 15) = temp1[60]; |
||||
|
Unsafe.Add(ref output, 16) = temp1[2]; |
||||
|
Unsafe.Add(ref output, 17) = temp1[34]; |
||||
|
Unsafe.Add(ref output, 18) = temp1[18]; |
||||
|
Unsafe.Add(ref output, 19) = temp1[50]; |
||||
|
Unsafe.Add(ref output, 20) = temp1[10]; |
||||
|
Unsafe.Add(ref output, 21) = temp1[42]; |
||||
|
Unsafe.Add(ref output, 22) = temp1[26]; |
||||
|
Unsafe.Add(ref output, 23) = temp1[58]; |
||||
|
Unsafe.Add(ref output, 24) = temp1[6]; |
||||
|
Unsafe.Add(ref output, 25) = temp1[38]; |
||||
|
Unsafe.Add(ref output, 26) = temp1[22]; |
||||
|
Unsafe.Add(ref output, 27) = temp1[54]; |
||||
|
Unsafe.Add(ref output, 28) = temp1[14]; |
||||
|
Unsafe.Add(ref output, 29) = temp1[46]; |
||||
|
Unsafe.Add(ref output, 30) = temp1[30]; |
||||
|
Unsafe.Add(ref output, 31) = temp1[62]; |
||||
|
Unsafe.Add(ref output, 32) = temp1[1]; |
||||
|
Unsafe.Add(ref output, 33) = temp1[33]; |
||||
|
Unsafe.Add(ref output, 34) = temp1[17]; |
||||
|
Unsafe.Add(ref output, 35) = temp1[49]; |
||||
|
Unsafe.Add(ref output, 36) = temp1[9]; |
||||
|
Unsafe.Add(ref output, 37) = temp1[41]; |
||||
|
Unsafe.Add(ref output, 38) = temp1[25]; |
||||
|
Unsafe.Add(ref output, 39) = temp1[57]; |
||||
|
Unsafe.Add(ref output, 40) = temp1[5]; |
||||
|
Unsafe.Add(ref output, 41) = temp1[37]; |
||||
|
Unsafe.Add(ref output, 42) = temp1[21]; |
||||
|
Unsafe.Add(ref output, 43) = temp1[53]; |
||||
|
Unsafe.Add(ref output, 44) = temp1[13]; |
||||
|
Unsafe.Add(ref output, 45) = temp1[45]; |
||||
|
Unsafe.Add(ref output, 46) = temp1[29]; |
||||
|
Unsafe.Add(ref output, 47) = temp1[61]; |
||||
|
Unsafe.Add(ref output, 48) = temp1[3]; |
||||
|
Unsafe.Add(ref output, 49) = temp1[35]; |
||||
|
Unsafe.Add(ref output, 50) = temp1[19]; |
||||
|
Unsafe.Add(ref output, 51) = temp1[51]; |
||||
|
Unsafe.Add(ref output, 52) = temp1[11]; |
||||
|
Unsafe.Add(ref output, 53) = temp1[43]; |
||||
|
Unsafe.Add(ref output, 54) = temp1[27]; |
||||
|
Unsafe.Add(ref output, 55) = temp1[59]; |
||||
|
Unsafe.Add(ref output, 56) = temp1[7]; |
||||
|
Unsafe.Add(ref output, 57) = temp1[39]; |
||||
|
Unsafe.Add(ref output, 58) = temp1[23]; |
||||
|
Unsafe.Add(ref output, 59) = temp1[55]; |
||||
|
Unsafe.Add(ref output, 60) = temp1[15]; |
||||
|
Unsafe.Add(ref output, 61) = temp1[47]; |
||||
|
Unsafe.Add(ref output, 62) = temp1[31]; |
||||
|
Unsafe.Add(ref output, 63) = temp1[63]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,71 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Dct8Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Dct8Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output, cosBit); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output, int cosBit) |
||||
|
{ |
||||
|
Span<int> temp0 = stackalloc int[8]; |
||||
|
Span<int> temp1 = stackalloc int[8]; |
||||
|
|
||||
|
// stage 0;
|
||||
|
|
||||
|
// stage 1;
|
||||
|
temp0[0] = Unsafe.Add(ref input, 0) + Unsafe.Add(ref input, 7); |
||||
|
temp0[1] = Unsafe.Add(ref input, 1) + Unsafe.Add(ref input, 6); |
||||
|
temp0[2] = Unsafe.Add(ref input, 2) + Unsafe.Add(ref input, 5); |
||||
|
temp0[3] = Unsafe.Add(ref input, 3) + Unsafe.Add(ref input, 4); |
||||
|
temp0[4] = -Unsafe.Add(ref input, 4) + Unsafe.Add(ref input, 3); |
||||
|
temp0[5] = -Unsafe.Add(ref input, 5) + Unsafe.Add(ref input, 2); |
||||
|
temp0[6] = -Unsafe.Add(ref input, 6) + Unsafe.Add(ref input, 1); |
||||
|
temp0[7] = -Unsafe.Add(ref input, 7) + Unsafe.Add(ref input, 0); |
||||
|
|
||||
|
// stage 2
|
||||
|
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); |
||||
|
temp1[0] = temp0[0] + temp0[3]; |
||||
|
temp1[1] = temp0[1] + temp0[2]; |
||||
|
temp1[2] = -temp0[2] + temp0[1]; |
||||
|
temp1[3] = -temp0[3] + temp0[0]; |
||||
|
temp1[4] = temp0[4]; |
||||
|
temp1[5] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp0[5], cospi[32], temp0[6], cosBit); |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp0[6], cospi[32], temp0[5], cosBit); |
||||
|
temp1[7] = temp0[7]; |
||||
|
|
||||
|
// stage 3
|
||||
|
temp0[0] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[32], temp1[0], cospi[32], temp1[1], cosBit); |
||||
|
temp0[1] = Av1Dct4Forward1dTransformer.HalfButterfly(-cospi[32], temp1[1], cospi[32], temp1[0], cosBit); |
||||
|
temp0[2] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[2], cospi[16], temp1[3], cosBit); |
||||
|
temp0[3] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[48], temp1[3], -cospi[16], temp1[2], cosBit); |
||||
|
temp0[4] = temp1[4] + temp1[5]; |
||||
|
temp0[5] = -temp1[5] + temp1[4]; |
||||
|
temp0[6] = -temp1[6] + temp1[7]; |
||||
|
temp0[7] = temp1[7] + temp1[6]; |
||||
|
|
||||
|
// stage 4
|
||||
|
temp1[0] = temp0[0]; |
||||
|
temp1[1] = temp0[1]; |
||||
|
temp1[2] = temp0[2]; |
||||
|
temp1[3] = temp0[3]; |
||||
|
temp1[4] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[4], cospi[8], temp0[7], cosBit); |
||||
|
temp1[5] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[5], cospi[40], temp0[6], cosBit); |
||||
|
temp1[6] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[24], temp0[6], -cospi[40], temp0[5], cosBit); |
||||
|
temp1[7] = Av1Dct4Forward1dTransformer.HalfButterfly(cospi[56], temp0[7], -cospi[8], temp0[4], cosBit); |
||||
|
|
||||
|
// stage 5
|
||||
|
Unsafe.Add(ref output, 0) = temp1[0]; |
||||
|
Unsafe.Add(ref output, 1) = temp1[4]; |
||||
|
Unsafe.Add(ref output, 2) = temp1[2]; |
||||
|
Unsafe.Add(ref output, 3) = temp1[6]; |
||||
|
Unsafe.Add(ref output, 4) = temp1[1]; |
||||
|
Unsafe.Add(ref output, 5) = temp1[5]; |
||||
|
Unsafe.Add(ref output, 6) = temp1[3]; |
||||
|
Unsafe.Add(ref output, 7) = temp1[7]; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,34 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Identity16Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Identity16Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
|
private const int TwiceNewSqrt2 = 2 * 5793; |
||||
|
|
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output) |
||||
|
{ |
||||
|
output = Av1Math.RoundShift((long)input * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 1) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 1) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 2) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 2) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 3) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 3) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 4) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 4) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 5) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 5) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 6) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 6) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 7) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 7) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 8) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 8) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 9) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 9) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 10) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 10) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 11) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 11) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 12) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 12) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 13) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 13) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 14) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 14) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 15) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 15) * TwiceNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,29 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Identity32Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Identity32Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
{ |
||||
|
TransformScalar(ref input, ref output); |
||||
|
TransformScalar(ref Unsafe.Add(ref input, 8), ref Unsafe.Add(ref output, 8)); |
||||
|
TransformScalar(ref Unsafe.Add(ref input, 16), ref Unsafe.Add(ref output, 16)); |
||||
|
TransformScalar(ref Unsafe.Add(ref input, 24), ref Unsafe.Add(ref output, 24)); |
||||
|
} |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output) |
||||
|
{ |
||||
|
output = input << 2; |
||||
|
Unsafe.Add(ref output, 1) = Unsafe.Add(ref input, 1) << 2; |
||||
|
Unsafe.Add(ref output, 2) = Unsafe.Add(ref input, 2) << 2; |
||||
|
Unsafe.Add(ref output, 3) = Unsafe.Add(ref input, 3) << 2; |
||||
|
Unsafe.Add(ref output, 4) = Unsafe.Add(ref input, 4) << 2; |
||||
|
Unsafe.Add(ref output, 5) = Unsafe.Add(ref input, 5) << 2; |
||||
|
Unsafe.Add(ref output, 6) = Unsafe.Add(ref input, 6) << 2; |
||||
|
Unsafe.Add(ref output, 7) = Unsafe.Add(ref input, 7) << 2; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,20 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Identity4Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Identity4Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output) |
||||
|
{ |
||||
|
output = Av1Math.RoundShift((long)input * Av1Forward2dTransformerBase.NewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 1) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 1) * Av1Forward2dTransformerBase.NewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 2) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 2) * Av1Forward2dTransformerBase.NewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 3) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 3) * Av1Forward2dTransformerBase.NewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,39 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Identity64Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Identity64Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
|
private const int QuadNewSqrt2 = 4 * 5793; |
||||
|
|
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
{ |
||||
|
TransformScalar(ref input, ref output); |
||||
|
TransformScalar(ref Unsafe.Add(ref input, 16), ref Unsafe.Add(ref output, 16)); |
||||
|
TransformScalar(ref Unsafe.Add(ref input, 32), ref Unsafe.Add(ref output, 32)); |
||||
|
TransformScalar(ref Unsafe.Add(ref input, 48), ref Unsafe.Add(ref output, 48)); |
||||
|
} |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output) |
||||
|
{ |
||||
|
output = Av1Math.RoundShift((long)input * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 1) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 1) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 2) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 2) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 3) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 3) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 4) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 4) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 5) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 5) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 6) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 6) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 7) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 7) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 8) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 8) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 9) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 9) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 10) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 10) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 11) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 11) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 12) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 12) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 13) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 13) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 14) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 14) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
Unsafe.Add(ref output, 15) = Av1Math.RoundShift((long)Unsafe.Add(ref input, 15) * QuadNewSqrt2, Av1Forward2dTransformerBase.NewSqrt2BitCount); |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -1,10 +1,24 @@ |
|||||
// Copyright (c) Six Labors.
|
// Copyright (c) Six Labors.
|
||||
// Licensed under the Six Labors Split License.
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; |
||||
|
|
||||
internal class Av1Identity8Forward1dTransformer : IAv1Forward1dTransformer |
internal class Av1Identity8Forward1dTransformer : IAv1Forward1dTransformer |
||||
{ |
{ |
||||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) |
||||
=> throw new NotImplementedException(); |
=> TransformScalar(ref input, ref output); |
||||
|
|
||||
|
private static void TransformScalar(ref int input, ref int output) |
||||
|
{ |
||||
|
output = input << 1; |
||||
|
Unsafe.Add(ref output, 1) = Unsafe.Add(ref input, 1) << 1; |
||||
|
Unsafe.Add(ref output, 2) = Unsafe.Add(ref input, 2) << 1; |
||||
|
Unsafe.Add(ref output, 3) = Unsafe.Add(ref input, 3) << 1; |
||||
|
Unsafe.Add(ref output, 4) = Unsafe.Add(ref input, 4) << 1; |
||||
|
Unsafe.Add(ref output, 5) = Unsafe.Add(ref input, 5) << 1; |
||||
|
Unsafe.Add(ref output, 6) = Unsafe.Add(ref input, 6) << 1; |
||||
|
Unsafe.Add(ref output, 7) = Unsafe.Add(ref input, 7) << 1; |
||||
|
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue