-
-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
453 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
...orward/Av1Identity16ForwardTransformer.cs → .../Forward/Av1Adst16Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.Intrinsics; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Identity16ForwardTransformer : IAv1ForwardTransformer | ||
internal class Av1Adst16Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> throw new NotImplementedException(); | ||
|
||
public void TransformAvx2(ref Vector256<int> input, ref Vector256<int> output, int cosBit, int columnNumber) | ||
=> throw new NotImplementedException(); | ||
} |
15 changes: 0 additions & 15 deletions
15
src/ImageSharp/Formats/Heif/Av1/Transform/Forward/Av1Adst16ForwardTransformer.cs
This file was deleted.
Oops, something went wrong.
7 changes: 1 addition & 6 deletions
7
...orward/Av1Identity32ForwardTransformer.cs → .../Forward/Av1Adst32Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.Intrinsics; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Identity32ForwardTransformer : IAv1ForwardTransformer | ||
internal class Av1Adst32Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> throw new NotImplementedException(); | ||
|
||
public void TransformAvx2(ref Vector256<int> input, ref Vector256<int> output, int cosBit, int columnNumber) | ||
=> throw new NotImplementedException(); | ||
} |
15 changes: 0 additions & 15 deletions
15
src/ImageSharp/Formats/Heif/Av1/Transform/Forward/Av1Adst32ForwardTransformer.cs
This file was deleted.
Oops, something went wrong.
7 changes: 1 addition & 6 deletions
7
...Forward/Av1Identity4ForwardTransformer.cs → ...m/Forward/Av1Adst4Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.Intrinsics; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Identity4ForwardTransformer : IAv1ForwardTransformer | ||
internal class Av1Adst4Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> throw new NotImplementedException(); | ||
|
||
public void TransformAvx2(ref Vector256<int> input, ref Vector256<int> output, int cosBit, int columnNumber) | ||
=> throw new NotImplementedException(); | ||
} |
7 changes: 1 addition & 6 deletions
7
...Forward/Av1Identity8ForwardTransformer.cs → ...m/Forward/Av1Adst8Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.Intrinsics; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Identity8ForwardTransformer : IAv1ForwardTransformer | ||
internal class Av1Adst8Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> throw new NotImplementedException(); | ||
|
||
public void TransformAvx2(ref Vector256<int> input, ref Vector256<int> output, int cosBit, int columnNumber) | ||
=> throw new NotImplementedException(); | ||
} |
7 changes: 1 addition & 6 deletions
7
...form/Forward/Av1Dct8ForwardTransformer.cs → ...m/Forward/Av1Dct16Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.Intrinsics; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Dct8ForwardTransformer : IAv1ForwardTransformer | ||
internal class Av1Dct16Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> throw new NotImplementedException(); | ||
|
||
public void TransformAvx2(ref Vector256<int> input, ref Vector256<int> output, int cosBit, int columnNumber) | ||
=> throw new NotImplementedException(); | ||
} |
15 changes: 0 additions & 15 deletions
15
src/ImageSharp/Formats/Heif/Av1/Transform/Forward/Av1Dct16ForwardTransformer.cs
This file was deleted.
Oops, something went wrong.
7 changes: 1 addition & 6 deletions
7
...orm/Forward/Av1Adst8ForwardTransformer.cs → ...m/Forward/Av1Dct32Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.Intrinsics; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Adst8ForwardTransformer : IAv1ForwardTransformer | ||
internal class Av1Dct32Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> throw new NotImplementedException(); | ||
|
||
public void TransformAvx2(ref Vector256<int> input, ref Vector256<int> output, int cosBit, int columnNumber) | ||
=> throw new NotImplementedException(); | ||
} |
67 changes: 67 additions & 0 deletions
67
src/ImageSharp/Formats/Heif/Av1/Transform/Forward/Av1Dct4Forward1dTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform.Forward; | ||
|
||
internal class Av1Dct4Forward1dTransformer : IAv1Forward1dTransformer | ||
{ | ||
public void Transform(ref int input, ref int output, int cosBit, Span<byte> stageRange) | ||
=> TransformScalar(ref input, ref output, cosBit); | ||
|
||
private static void TransformScalar(ref int input, ref int output, int cosBit) | ||
{ | ||
Span<int> cospi = Av1SinusConstants.CosinusPi(cosBit); | ||
ref int bf0 = ref output; | ||
ref int bf1 = ref output; | ||
Span<int> stepSpan = new int[4]; | ||
ref int step0 = ref stepSpan[0]; | ||
ref int step1 = ref Unsafe.Add(ref step0, 1); | ||
ref int step2 = ref Unsafe.Add(ref step0, 2); | ||
ref int step3 = ref Unsafe.Add(ref step0, 3); | ||
ref int output1 = ref Unsafe.Add(ref output, 1); | ||
ref int output2 = ref Unsafe.Add(ref output, 2); | ||
ref int output3 = ref Unsafe.Add(ref output, 3); | ||
|
||
// stage 0; | ||
|
||
// stage 1; | ||
output = input + Unsafe.Add(ref input, 3); | ||
output1 = Unsafe.Add(ref input, 1) + Unsafe.Add(ref input, 2); | ||
output2 = -Unsafe.Add(ref input, 2) + Unsafe.Add(ref input, 1); | ||
output3 = -Unsafe.Add(ref input, 3) + Unsafe.Add(ref input, 0); | ||
|
||
// stage 2 | ||
step0 = HalfBtf(cospi[32], output, cospi[32], output1, cosBit); | ||
step1 = HalfBtf(-cospi[32], output1, cospi[32], output, cosBit); | ||
step2 = HalfBtf(cospi[48], output2, cospi[16], output3, cosBit); | ||
step3 = HalfBtf(cospi[48], output3, -cospi[16], output2, cosBit); | ||
|
||
// stage 3 | ||
output = step0; | ||
output1 = step2; | ||
output2 = step1; | ||
output3 = step3; | ||
} | ||
|
||
private static int HalfBtf(int w0, int in0, int w1, int in1, int bit) | ||
{ | ||
long result64 = (long)(w0 * in0) + (w1 * in1); | ||
long intermediate = result64 + (1L << (bit - 1)); | ||
|
||
// NOTE(david.barker): The value 'result_64' may not necessarily fit | ||
// into 32 bits. However, the result of this function is nominally | ||
// ROUND_POWER_OF_TWO_64(result_64, bit) | ||
// and that is required to fit into stage_range[stage] many bits | ||
// (checked by range_check_buf()). | ||
// | ||
// Here we've unpacked that rounding operation, and it can be shown | ||
// that the value of 'intermediate' here *does* fit into 32 bits | ||
// for any conformant bitstream. | ||
// The upshot is that, if you do all this calculation using | ||
// wrapping 32-bit arithmetic instead of (non-wrapping) 64-bit arithmetic, | ||
// then you'll still get the correct result. | ||
return (int)(intermediate >> bit); | ||
} | ||
} |
Oops, something went wrong.