diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index c2a95989d3..160e6a4f9a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/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(ref areaOrigin), ref Unsafe.As(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) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs index ef17bf002c..0d881977f0 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentProcessors/DownScalingComponentProcessor8.cs +++ b/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; } ///