Browse Source

Add references to SVT library method names

pull/2633/head
Ynse Hoornenborg 2 years ago
parent
commit
0e2679b358
  1. 6
      src/ImageSharp/Formats/Heif/Av1/Pipeline/Av1FrameDecoder.cs
  2. 10
      src/ImageSharp/Formats/Heif/Av1/Pipeline/Quantification/Av1InverseQuantizer.cs
  3. 2
      src/ImageSharp/Formats/Heif/Av1/Transform/Av1BlockDecoder.cs
  4. 38
      src/ImageSharp/Formats/Heif/Av1/Transform/Av1InverseTransformer.cs
  5. 3
      src/ImageSharp/Formats/Heif/Av1/Transform/Av1InverseTransformerFactory.cs

6
src/ImageSharp/Formats/Heif/Av1/Pipeline/Av1FrameDecoder.cs

@ -95,6 +95,9 @@ internal class Av1FrameDecoder
}
}
/// <summary>
/// SVT: svt_aom_decode_super_block
/// </summary>
private void DecodeSuperblock(Point modeInfoPosition, Av1SuperblockInfo superblockInfo, Av1TileInfo tileInfo)
{
this.blockDecoder.UpdateSuperblock(superblockInfo);
@ -102,6 +105,9 @@ internal class Av1FrameDecoder
this.DecodePartition(modeInfoPosition, superblockInfo, tileInfo);
}
/// <summary>
/// SVT: decode_partition
/// </summary>
private void DecodePartition(Point modeInfoPosition, Av1SuperblockInfo superblockInfo, Av1TileInfo tileInfo)
{
Av1BlockModeInfo modeInfo = superblockInfo.GetModeInfo(modeInfoPosition);

10
src/ImageSharp/Formats/Heif/Av1/Pipeline/Quantification/Av1InverseQuantizer.cs

@ -78,6 +78,9 @@ internal class Av1InverseQuantizer
}
}
/// <summary>
/// SVT: svt_aom_inverse_quantize
/// </summary>
public int InverseQuantize(Av1BlockModeInfo mode, Span<int> level, Span<int> qCoefficients, Av1TransformType transformType, Av1TransformSize transformSize, Av1Plane plane)
{
Guard.NotNull(this.deQuantsDeltaQ);
@ -135,12 +138,15 @@ internal class Av1InverseQuantizer
return coefficientCount;
}
/// <summary>
/// SVT: get_dqv
/// </summary>
private static int GetDeQuantizedValue(short dequant, int coefficientIndex, ref int iqMatrix)
{
const int bias = 1 << (Av1ScanOrderConstants.QuantizationMatrixLevelBitCount - 1);
int deQuantifiedValue = dequant;
// TODO: Check order of operators
deQuantifiedValue = ((Unsafe.Add(ref iqMatrix, coefficientIndex) * deQuantifiedValue) + (1 << (Av1ScanOrderConstants.QuantizationMatrixLevelBitCount - 1))) >> Av1ScanOrderConstants.QuantizationMatrixLevelBitCount;
deQuantifiedValue = ((Unsafe.Add(ref iqMatrix, coefficientIndex) * deQuantifiedValue) + bias) >> Av1ScanOrderConstants.QuantizationMatrixLevelBitCount;
return deQuantifiedValue;
}
}

2
src/ImageSharp/Formats/Heif/Av1/Transform/Av1BlockDecoder.cs

@ -183,8 +183,6 @@ internal class Av1BlockDecoder
quantizationCoefficients,
transformBlockReconstructionBuffer,
reconstructionStride,
transformBlockReconstructionBuffer,
reconstructionStride,
transformSize,
transformType,
plane,

38
src/ImageSharp/Formats/Heif/Av1/Transform/Av1InverseTransformer.cs

@ -8,7 +8,7 @@ internal class Av1InverseTransformer
/// <summary>
/// SVT: svt_aom_inv_transform_recon8bit
/// </summary>
public static void Reconstruct8Bit(Span<int> coefficientsBuffer, Span<byte> reconstructionBufferRead, int reconstructionReadStride, Span<byte> reconstructionBufferWrite, int reconstructionWriteStride, Av1TransformSize transformSize, Av1TransformType transformType, int plane, int numberOfCoefficients, bool isLossless)
public static void Reconstruct8Bit(Span<int> coefficientsBuffer, Span<byte> reconstructionBuffer, int reconstructionStride, Av1TransformSize transformSize, Av1TransformType transformType, int plane, int numberOfCoefficients, bool isLossless)
{
Av1TransformFunctionParameters transformFunctionParameters = new()
{
@ -20,33 +20,31 @@ internal class Av1InverseTransformer
Is16BitPipeline = false
};
if (reconstructionBufferRead != reconstructionBufferWrite)
{
/* When output pointers to read and write are differents,
* then kernel copy also all buffer from read to write,
* and cannot be limited by End Of Buffer calculations. */
transformFunctionParameters.EndOfBuffer = GetMaxEndOfBuffer(transformSize);
}
Av1InverseTransformerFactory.InverseTransformAdd(
coefficientsBuffer, reconstructionBufferRead, reconstructionReadStride, reconstructionBufferWrite, reconstructionWriteStride, transformFunctionParameters);
coefficientsBuffer, reconstructionBuffer, reconstructionStride, reconstructionBuffer, reconstructionStride, transformFunctionParameters);
}
/// <summary>
/// SVT: av1_get_max_eob
/// SVT: svt_aom_inv_transform_recon8bit
/// </summary>
private static int GetMaxEndOfBuffer(Av1TransformSize transformSize)
public static void Reconstruct8Bit(Span<int> coefficientsBuffer, Span<byte> reconstructionBufferRead, int reconstructionReadStride, Span<byte> reconstructionBufferWrite, int reconstructionWriteStride, Av1TransformSize transformSize, Av1TransformType transformType, int plane, int numberOfCoefficients, bool isLossless)
{
if (transformSize is Av1TransformSize.Size64x64 or Av1TransformSize.Size64x32 or Av1TransformSize.Size32x64)
Av1TransformFunctionParameters transformFunctionParameters = new()
{
return 1024;
}
TransformType = transformType,
TransformSize = transformSize,
EndOfBuffer = numberOfCoefficients,
IsLossless = isLossless,
BitDepth = 8,
Is16BitPipeline = false
};
if (transformSize is Av1TransformSize.Size16x64 or Av1TransformSize.Size64x16)
{
return 512;
}
/* When output pointers to read and write are differents,
* then kernel copy also all buffer from read to write,
* and cannot be limited by End Of Buffer calculations. */
transformFunctionParameters.EndOfBuffer = Av1InverseTransformMath.GetMaxEndOfBuffer(transformSize);
return transformSize.GetSize2d();
Av1InverseTransformerFactory.InverseTransformAdd(
coefficientsBuffer, reconstructionBufferRead, reconstructionReadStride, reconstructionBufferWrite, reconstructionWriteStride, transformFunctionParameters);
}
}

3
src/ImageSharp/Formats/Heif/Av1/Transform/Av1InverseTransformerFactory.cs

@ -7,6 +7,9 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Transform;
internal static class Av1InverseTransformerFactory
{
/// <summary>
/// SVT: svt_av1_inv_txfm_add
/// </summary>
public static unsafe void InverseTransformAdd(Span<int> coefficients, Span<byte> readBuffer, int readStride, Span<byte> writeBuffer, int writeStride, Av1TransformFunctionParameters transformFunctionParameters)
{
Guard.MustBeLessThanOrEqualTo(transformFunctionParameters.BitDepth, 8, nameof(transformFunctionParameters));

Loading…
Cancel
Save