Browse Source

Eliminate AV1 scalar predictor allocations

pull/2633/head
James Jackson-South 1 week ago
parent
commit
92f5ce63d0
  1. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcFillPredictor.cs
  2. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcLeftPredictor.cs
  3. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcPredictor.cs
  4. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcTopPredictor.cs
  5. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DirectionalZone1Predictor.cs
  6. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DirectionalZone2Predictor.cs
  7. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DirectionalZone3Predictor.cs
  8. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1HorizontalPredictor.cs
  9. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1PaethPredictor.cs
  10. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1SmoothHorizontalPredictor.cs
  11. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1SmoothPredictor.cs
  12. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1SmoothVerticalPredictor.cs
  13. 6
      src/ImageSharp/Formats/Heif/Av1/Prediction/Av1VerticalPredictor.cs

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcFillPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block with the sample-domain midpoint when neither top nor left neighbors are available.
/// </summary>
internal class Av1DcFillPredictor : IAv1Predictor
internal readonly struct Av1DcFillPredictor : IAv1Predictor
{
/// <summary>
/// The number of samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1DcFillPredictor : IAv1Predictor
private readonly uint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcFillPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1DcFillPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1DcFillPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1DcFillPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcFillPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1DcFillPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1DcFillPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcLeftPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block from the rounded average of its available left neighboring samples.
/// </summary>
internal class Av1DcLeftPredictor : IAv1Predictor
internal readonly struct Av1DcLeftPredictor : IAv1Predictor
{
/// <summary>
/// The number of samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1DcLeftPredictor : IAv1Predictor
private readonly uint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcLeftPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1DcLeftPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1DcLeftPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1DcLeftPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcLeftPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1DcLeftPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1DcLeftPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block from the rounded average of its top and left neighboring samples.
/// </summary>
internal class Av1DcPredictor : IAv1Predictor
internal readonly struct Av1DcPredictor : IAv1Predictor
{
/// <summary>
/// The number of top samples averaged and samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1DcPredictor : IAv1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1DcPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1DcPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1DcPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1DcPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1DcPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DcTopPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block from the rounded average of its available top neighboring samples.
/// </summary>
internal class Av1DcTopPredictor : IAv1Predictor
internal readonly struct Av1DcTopPredictor : IAv1Predictor
{
/// <summary>
/// The number of top samples averaged and samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1DcTopPredictor : IAv1Predictor
private readonly uint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcTopPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1DcTopPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1DcTopPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1DcTopPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DcTopPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1DcTopPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1DcTopPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DirectionalZone1Predictor.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// Zone 1 projects the top reference samples into the block for prediction angles less than 90 degrees.
/// The scalar prediction follows the directional prediction process in section 7.11.2.4 of the AV1 specification.
/// </remarks>
internal class Av1DirectionalZone1Predictor
internal readonly struct Av1DirectionalZone1Predictor
{
/// <summary>
/// The width of the prediction block in samples.
@ -26,7 +26,7 @@ internal class Av1DirectionalZone1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DirectionalZone1Predictor"/> class for the specified block dimensions.
/// Initializes a new instance of the <see cref="Av1DirectionalZone1Predictor"/> struct for the specified block dimensions.
/// </summary>
/// <param name="blockSize">The dimensions of the prediction block.</param>
public Av1DirectionalZone1Predictor(Size blockSize)
@ -36,7 +36,7 @@ internal class Av1DirectionalZone1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DirectionalZone1Predictor"/> class for the specified transform size.
/// Initializes a new instance of the <see cref="Av1DirectionalZone1Predictor"/> struct for the specified transform size.
/// </summary>
/// <param name="transformSize">The transform size that determines the prediction block dimensions.</param>
public Av1DirectionalZone1Predictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DirectionalZone2Predictor.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// Zone 2 projects both top and left reference samples into the block for prediction angles between 90 and 180 degrees.
/// The scalar prediction follows the directional prediction process in section 7.11.2.4 of the AV1 specification.
/// </remarks>
internal class Av1DirectionalZone2Predictor
internal readonly struct Av1DirectionalZone2Predictor
{
/// <summary>
/// The width of the prediction block in samples.
@ -28,7 +28,7 @@ internal class Av1DirectionalZone2Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DirectionalZone2Predictor"/> class for the specified block dimensions.
/// Initializes a new instance of the <see cref="Av1DirectionalZone2Predictor"/> struct for the specified block dimensions.
/// </summary>
/// <param name="blockSize">The dimensions of the prediction block.</param>
public Av1DirectionalZone2Predictor(Size blockSize)
@ -38,7 +38,7 @@ internal class Av1DirectionalZone2Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DirectionalZone2Predictor"/> class for the specified transform size.
/// Initializes a new instance of the <see cref="Av1DirectionalZone2Predictor"/> struct for the specified transform size.
/// </summary>
/// <param name="transformSize">The transform size that determines the prediction block dimensions.</param>
public Av1DirectionalZone2Predictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1DirectionalZone3Predictor.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// Zone 3 projects the left reference samples into the block for prediction angles greater than 180 degrees.
/// The scalar prediction follows the directional prediction process in section 7.11.2.4 of the AV1 specification.
/// </remarks>
internal class Av1DirectionalZone3Predictor
internal readonly struct Av1DirectionalZone3Predictor
{
/// <summary>
/// The width of the prediction block in samples.
@ -27,7 +27,7 @@ internal class Av1DirectionalZone3Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1DirectionalZone3Predictor"/> class for the specified block dimensions.
/// Initializes a new instance of the <see cref="Av1DirectionalZone3Predictor"/> struct for the specified block dimensions.
/// </summary>
/// <param name="blockSize">The dimensions of the prediction block.</param>
public Av1DirectionalZone3Predictor(Size blockSize)
@ -37,7 +37,7 @@ internal class Av1DirectionalZone3Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1DirectionalZone3Predictor"/> class for the specified transform size.
/// Initializes a new instance of the <see cref="Av1DirectionalZone3Predictor"/> struct for the specified transform size.
/// </summary>
/// <param name="transformSize">The transform size that determines the prediction block dimensions.</param>
public Av1DirectionalZone3Predictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1HorizontalPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block by extending each left neighboring sample across its destination row.
/// </summary>
internal class Av1HorizontalPredictor : IAv1Predictor
internal readonly struct Av1HorizontalPredictor : IAv1Predictor
{
/// <summary>
/// The number of samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1HorizontalPredictor : IAv1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1HorizontalPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1HorizontalPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1HorizontalPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1HorizontalPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1HorizontalPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1HorizontalPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1HorizontalPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1PaethPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block by selecting the top, left, or top-left neighbor with the smallest local gradient.
/// </summary>
internal class Av1PaethPredictor : IAv1Predictor
internal readonly struct Av1PaethPredictor : IAv1Predictor
{
/// <summary>
/// The number of top samples consumed and samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1PaethPredictor : IAv1Predictor
private readonly uint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1PaethPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1PaethPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1PaethPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1PaethPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1PaethPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1PaethPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1PaethPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1SmoothHorizontalPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block by smoothly blending each left neighbor toward the top-right reference sample.
/// </summary>
internal class Av1SmoothHorizontalPredictor : IAv1Predictor
internal readonly struct Av1SmoothHorizontalPredictor : IAv1Predictor
{
/// <summary>
/// The number of interpolation weights and samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1SmoothHorizontalPredictor : IAv1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1SmoothHorizontalPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1SmoothHorizontalPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1SmoothHorizontalPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1SmoothHorizontalPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1SmoothHorizontalPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1SmoothHorizontalPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1SmoothHorizontalPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1SmoothPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block by blending top-to-bottom and left-to-right smooth interpolation surfaces.
/// </summary>
internal class Av1SmoothPredictor : IAv1Predictor
internal readonly struct Av1SmoothPredictor : IAv1Predictor
{
// Weights are quadratic from '1' to '1 / BlockSize', scaled by
// 2^sm_weight_log2_scale.
@ -61,7 +61,7 @@ internal class Av1SmoothPredictor : IAv1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1SmoothPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1SmoothPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1SmoothPredictor(Size blockSize)
@ -71,7 +71,7 @@ internal class Av1SmoothPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1SmoothPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1SmoothPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1SmoothPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1SmoothVerticalPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block by smoothly blending each top neighbor toward the bottom-left reference sample.
/// </summary>
internal class Av1SmoothVerticalPredictor : IAv1Predictor
internal readonly struct Av1SmoothVerticalPredictor : IAv1Predictor
{
/// <summary>
/// The number of top samples consumed and samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1SmoothVerticalPredictor : IAv1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1SmoothVerticalPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1SmoothVerticalPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1SmoothVerticalPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1SmoothVerticalPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1SmoothVerticalPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1SmoothVerticalPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1SmoothVerticalPredictor(Av1TransformSize transformSize)

6
src/ImageSharp/Formats/Heif/Av1/Prediction/Av1VerticalPredictor.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Heif.Av1.Prediction;
/// <summary>
/// Predicts an 8-bit AV1 block by copying the top neighboring samples into every destination row.
/// </summary>
internal class Av1VerticalPredictor : IAv1Predictor
internal readonly struct Av1VerticalPredictor : IAv1Predictor
{
/// <summary>
/// The number of top samples consumed and samples written to each destination row.
@ -22,7 +22,7 @@ internal class Av1VerticalPredictor : IAv1Predictor
private readonly nuint blockHeight;
/// <summary>
/// Initializes a new instance of the <see cref="Av1VerticalPredictor"/> class for explicit block dimensions.
/// Initializes a new instance of the <see cref="Av1VerticalPredictor"/> struct for explicit block dimensions.
/// </summary>
/// <param name="blockSize">The predicted block dimensions in samples.</param>
public Av1VerticalPredictor(Size blockSize)
@ -32,7 +32,7 @@ internal class Av1VerticalPredictor : IAv1Predictor
}
/// <summary>
/// Initializes a new instance of the <see cref="Av1VerticalPredictor"/> class for a transform size.
/// Initializes a new instance of the <see cref="Av1VerticalPredictor"/> struct for a transform size.
/// </summary>
/// <param name="transformSize">The transform size whose dimensions define the predicted block.</param>
public Av1VerticalPredictor(Av1TransformSize transformSize)

Loading…
Cancel
Save