Browse Source

Use ColdPath for Block8x8F

pull/3115/head
James Jackson-South 3 months ago
parent
commit
9304b57022
  1. 2
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs
  2. 10
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs

2
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs

@ -14,7 +14,7 @@ internal partial struct Block8x8F
public void ScaledCopyFrom(ref float areaOrigin, int areaStride) =>
CopyFrom1x1Scale(ref Unsafe.As<float, byte>(ref areaOrigin), ref Unsafe.As<Block8x8F, byte>(ref this), areaStride);
[MethodImpl(InliningOptions.ShortMethod)]
[MethodImpl(InliningOptions.ColdPath)]
public void ScaledCopyTo(ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale)
{
if (horizontalScale == 1 && verticalScale == 1)

10
src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs

@ -111,6 +111,14 @@ internal sealed class DownScalingComponentProcessor8 : ComponentProcessor
return;
}
// The common 1x, 2x, and 4x integral scales are specialized above.
// Uncommon legal factor-3 scales use the generic fallback.
CopyArbitraryScale(value, ref destRef, destStrideWidth, horizontalScale, verticalScale);
}
[MethodImpl(InliningOptions.ColdPath)]
private static float CopyArbitraryScale(float value, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale)
{
// The common 1x, 2x, and 4x integral scales are specialized above.
// Uncommon legal factor-3 scales use the generic fallback.
for (nuint y = 0; y < (uint)verticalScale; y++)
@ -122,6 +130,8 @@ internal sealed class DownScalingComponentProcessor8 : ComponentProcessor
destRef = ref Unsafe.Add(ref destRef, (uint)destStrideWidth);
}
return destRef;
}
/// <summary>

Loading…
Cancel
Save