Browse Source

Reduce errors in AC strategy code

pull/3153/head
winscripter 1 week ago
parent
commit
dfd99a0d8a
  1. 6
      src/ImageSharp/Formats/Jxl/Processing/JxlAcStrategy.cs
  2. 4
      src/ImageSharp/Formats/Jxl/Processing/JxlAcStrategyImage.cs

6
src/ImageSharp/Formats/Jxl/Processing/JxlAcStrategy.cs

@ -81,9 +81,9 @@ internal struct JxlAcStrategy
public readonly JxlAcStrategyType Strategy { get; }
public void ComputeNaturalCoefficientOrder(ref int order) => CoefficientOrderAndLookup(this, false, ref order);
public readonly void ComputeNaturalCoefficientOrder(Span<int> order) => CoefficientOrderAndLookup(this, false, order);
public void ComputeNaturalCoefficientOrderLookup(ref int lookup) => CoefficientOrderAndLookup(this, true, ref lookup);
public readonly void ComputeNaturalCoefficientOrderLookup(Span<int> lookup) => CoefficientOrderAndLookup(this, true, lookup);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetTypeBit(JxlAcStrategyType type) => 1 << (int)type;
@ -97,7 +97,7 @@ internal struct JxlAcStrategy
int cx = strategy.CoveredBlocksX;
int cy = strategy.CoveredBlocksY;
CoefficientLayout(ref cx, ref cy);
JxlForwardCoefficientOrder.CoefficientLayout(ref cx, ref cy);
int xs = cx / cy;
int xsm = xs - 1;

4
src/ImageSharp/Formats/Jxl/Processing/JxlAcStrategyImage.cs

@ -103,11 +103,11 @@ internal sealed class JxlAcStrategyImage : IDisposable
return this.SetNoBoundsChecks(x, y, type, check: false);
}
public void FillDct8(in Rectangle rect) => this.FillPlane(((int)JxlAcStrategyType.DCT << 1) | 1, this.layers, in rect);
public void FillDct8(in Rectangle rect) => JxlImageOperations.FillPlane((byte)(((int)JxlAcStrategyType.DCT << 1) | 1), this.layers ?? throw new InvalidOperationException("Image is missing"), rect);
public void FillDct8() => this.FillDct8(this.layers!.GetRectangle());
public void FillInvalid() => this.FillImage(Invalid, this.layers);
public void FillInvalid() => JxlImageOperations.FillImage(Invalid, this.layers ?? throw new InvalidOperationException("Image is missing"));
public void Dispose()
{

Loading…
Cancel
Save