Browse Source

Don't use GetWReference (it should return span)

pull/3153/head
winscripter 3 days ago
parent
commit
1b6e824f6d
  1. 4
      src/ImageSharp/Formats/Jxl/Processing/Modular/Encoding/ContextPrediction/JxlContextPrediction.cs
  2. 6
      src/ImageSharp/Formats/Jxl/Processing/Modular/Encoding/ContextPrediction/JxlModularHeader.cs
  3. 4
      src/ImageSharp/Formats/Jxl/Processing/Modular/Encoding/ContextPrediction/JxlModularState.cs

4
src/ImageSharp/Formats/Jxl/Processing/Modular/Encoding/ContextPrediction/JxlContextPrediction.cs

@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.Modular.Encoding.ContextPrediction;
@ -17,8 +16,7 @@ internal static class JxlContextPrediction
public static void SetPredictorMode(int i, JxlModularHeader header)
{
ref uint wr = ref header.GetWReference();
Span<uint> w = MemoryMarshal.CreateSpan(ref wr, 4);
Span<uint> w = header.GetW();
switch (i)
{

6
src/ImageSharp/Formats/Jxl/Processing/Modular/Encoding/ContextPrediction/JxlModularHeader.cs

@ -101,10 +101,10 @@ internal sealed class JxlModularHeader : IJxlFields
}
/// <summary>
/// Returns a reference to the first w item.
/// Returns a span to the w array.
/// </summary>
/// <returns>Reference to w[0]</returns>
public ref uint GetWReference() => ref this.w[0];
/// <returns>Reference to w</returns>
public Span<uint> GetW() => this.w;
public bool Visit(JxlVisitor v)
{

4
src/ImageSharp/Formats/Jxl/Processing/Modular/Encoding/ContextPrediction/JxlModularState.cs

@ -109,13 +109,13 @@ internal sealed class JxlModularState
int posNW = x > 0 ? posN - 1 : posN;
Span<uint> weights = stackalloc uint[4];
ref uint headerW = ref this.header.GetWReference();
Span<uint> headerW = this.header.GetW();
for (int i = 0; i < 4; i++)
{
Span<uint> error = this.predErrors[i].AsSpan();
weights[i] = error[posN] + error[posNE] + error[posNW];
weights[i] = ErrorWeight((int)weights[i], Unsafe.Add(ref headerW, i));
weights[i] = ErrorWeight((int)weights[i], headerW[i]);
}
n = AddBits(n);

Loading…
Cancel
Save