Browse Source

Prefer inline arrays

pull/3153/head
winscripter 4 weeks ago
parent
commit
d1f66463bc
  1. 14
      src/ImageSharp/Formats/Jxl/IO/Metadata/JxlOpsinInverseMatrix.cs
  2. 13
      src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlOpsinParameters.cs

14
src/ImageSharp/Formats/Jxl/IO/Metadata/JxlOpsinInverseMatrix.cs

@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#pragma warning disable SA1401 // Fields should be private
using SixLabors.ImageSharp.Formats.Jxl.Fields;
using SixLabors.ImageSharp.Formats.Jxl.Processing;
@ -8,17 +10,13 @@ namespace SixLabors.ImageSharp.Formats.Jxl.IO.Metadata;
internal sealed class JxlOpsinInverseMatrix : IJxlFields
{
public bool AllDefault { get; set; }
public InlineArray3<float> OpsinBiases;
public JxlMatrix3x3F InverseMatrix { get; set; }
public InlineArray3<float> QuantBiases;
// Prefer arrays so we can set values like this:
// JxlOpsinInverseMatrix m = ...;
// m.OpsinBiases[0] = 1f;
// An InlineArray can't do that.
public float[] OpsinBiases { get; set; } = new float[3];
public bool AllDefault { get; set; }
public float[] QuantBiases { get; set; } = new float[4];
public JxlMatrix3x3F InverseMatrix { get; set; }
public bool Visit(JxlVisitor visitor) => throw new NotImplementedException();
}

13
src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlOpsinParameters.cs

@ -1,18 +1,17 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#pragma warning disable SA1401 // Fields should be private
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.Decoder;
internal sealed class JxlOpsinParameters
{
// Use arrays instead of InlineArrays because, with inline arrays we can't do:
// JxlOpsinParameters parameters = ...;
// parameters.OpsinBiasesCbrt[0] /* <-- error */ = 1.25f;
public float[] InverseOpsinMatrix { get; set; } = new float[36];
public InlineArray36<float> InverseOpsinMatrix;
public float[] OpsinBiases { get; set; } = new float[4];
public InlineArray4<float> OpsinBiases;
public float[] OpsinBiasesCbrt { get; set; } = new float[4];
public InlineArray4<float> OpsinBiasesCbrt;
public float[] QuantBiases { get; set; } = new float[4];
public InlineArray4<float> QuantBiases;
}

Loading…
Cancel
Save