Skip to content

Commit 9304b57

Browse files
Use ColdPath for Block8x8F
1 parent 83007f2 commit 9304b57

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal partial struct Block8x8F
1414
public void ScaledCopyFrom(ref float areaOrigin, int areaStride) =>
1515
CopyFrom1x1Scale(ref Unsafe.As<float, byte>(ref areaOrigin), ref Unsafe.As<Block8x8F, byte>(ref this), areaStride);
1616

17-
[MethodImpl(InliningOptions.ShortMethod)]
17+
[MethodImpl(InliningOptions.ColdPath)]
1818
public void ScaledCopyTo(ref float areaOrigin, int areaStride, int horizontalScale, int verticalScale)
1919
{
2020
if (horizontalScale == 1 && verticalScale == 1)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ public static void ScaledCopyTo(float value, ref float destRef, int destStrideWi
111111
return;
112112
}
113113

114+
// The common 1x, 2x, and 4x integral scales are specialized above.
115+
// Uncommon legal factor-3 scales use the generic fallback.
116+
CopyArbitraryScale(value, ref destRef, destStrideWidth, horizontalScale, verticalScale);
117+
}
118+
119+
[MethodImpl(InliningOptions.ColdPath)]
120+
private static float CopyArbitraryScale(float value, ref float destRef, int destStrideWidth, int horizontalScale, int verticalScale)
121+
{
114122
// The common 1x, 2x, and 4x integral scales are specialized above.
115123
// Uncommon legal factor-3 scales use the generic fallback.
116124
for (nuint y = 0; y < (uint)verticalScale; y++)
@@ -122,6 +130,8 @@ public static void ScaledCopyTo(float value, ref float destRef, int destStrideWi
122130

123131
destRef = ref Unsafe.Add(ref destRef, (uint)destStrideWidth);
124132
}
133+
134+
return destRef;
125135
}
126136

127137
/// <summary>

0 commit comments

Comments
 (0)