diff --git a/src/ImageSharp/Formats/Heif/Av1/Entropy/Av1SymbolContextHelper.cs b/src/ImageSharp/Formats/Heif/Av1/Entropy/Av1SymbolContextHelper.cs index 563d914a15..6cf8fa432d 100644 --- a/src/ImageSharp/Formats/Heif/Av1/Entropy/Av1SymbolContextHelper.cs +++ b/src/ImageSharp/Formats/Heif/Av1/Entropy/Av1SymbolContextHelper.cs @@ -214,10 +214,14 @@ internal static class Av1SymbolContextHelper DebugGuard.MustBeGreaterThan(position.X + position.Y, 0, nameof(position)); Span row0 = levels.GetRow(position.Y); Span row1 = levels.GetRow(position.Y + 1); + + // No need to clip quantized values to COEFF_BASE_RANGE + NUM_BASE_LEVELS + // + 1, because we clip the overall output to 6 and the unclipped + // quantized values will always result in an output of greater than 6. int mag = - Math.Min((int)row0[position.X + 1], Av1Constants.MaxBaseRange) + - Math.Min((int)row1[position.X], Av1Constants.MaxBaseRange) + - Math.Min((int)row1[position.X + 1], Av1Constants.MaxBaseRange); + row0[position.X + 1] + // {0, 1} + row1[position.X] + // {1, 0} + row1[position.X + 1]; // {1, 1} mag = Math.Min((mag + 1) >> 1, 6); if ((position.Y | position.X) < 2) { diff --git a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1CoefficientsEntropyTests.cs b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1CoefficientsEntropyTests.cs index 866e509a58..bb9c31d6d6 100644 --- a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1CoefficientsEntropyTests.cs +++ b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1CoefficientsEntropyTests.cs @@ -115,21 +115,6 @@ public class Av1CoefficientsEntropyTests RoundTripCoefficientsCore(endOfBlock, componentType, blockSize, transformSize, transformType, intraDirection, filterIntraMode); } - [Theory] - [MemberData(nameof(GetTransformTypes))] - public void RoundTripFullCoefficientsYSize8x8(int txType) - { - // Assign - const ushort endOfBlock = 16; - const Av1ComponentType componentType = Av1ComponentType.Luminance; - Av1BlockSize blockSize = Av1BlockSize.Block8x8; - Av1TransformSize transformSize = blockSize.GetMaximumTransformSize(); - Av1TransformType transformType = (Av1TransformType)txType; - Av1PredictionMode intraDirection = Av1PredictionMode.DC; - Av1FilterIntraMode filterIntraMode = Av1FilterIntraMode.DC; - RoundTripCoefficientsCore(endOfBlock, componentType, blockSize, transformSize, transformType, intraDirection, filterIntraMode); - } - [Theory] [MemberData(nameof(GetTransformTypes))] public void RoundTripFullCoefficientsUvSize4x4(int txType) diff --git a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1InverseTransformTests.cs b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1InverseTransformTests.cs index a327c69110..8f71751396 100644 --- a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1InverseTransformTests.cs +++ b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1InverseTransformTests.cs @@ -48,7 +48,7 @@ public class Av1InverseTransformTests public void AccuracyOfAdst1dTransformSize16Test() => AssertAccuracy1d(Av1TransformType.AdstAdst, Av1TransformSize.Size16x16, 3, 3); - [Fact] + // Not mentioned in the spec. public void AccuracyOfAdst1dTransformSize32Test() => AssertAccuracy1d(Av1TransformType.AdstAdst, Av1TransformSize.Size32x32, 4, 3); @@ -243,7 +243,7 @@ public class Av1InverseTransformTests { const int bitDepth = 10; Random rnd = new(0); - const int testBlockCount = 100; // Originally set to: 5000 + const int testBlockCount = 30; // Originally set to: 5000 Av1Transform2dFlipConfiguration config = new(transformType, transformSize); config.GenerateStageRange(bitDepth); int width = config.TransformSize.GetWidth();