Browse Source

Jpeg encoder no uses Numerics.Log2 as fallback

pull/1663/head
Dmitry Pentin 5 years ago
parent
commit
a5210b21a5
  1. 2
      src/ImageSharp/Common/Helpers/Numerics.cs
  2. 2
      src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs

2
src/ImageSharp/Common/Helpers/Numerics.cs

@ -861,7 +861,7 @@ namespace SixLabors.ImageSharp
/// https://cstheory.stackexchange.com/questions/19524/using-the-de-bruijn-sequence-to-find-the-lceil-log-2-v-rceil-of-an-integer
/// </remarks>
/// <param name="value">The value.</param>
internal static int Log2SoftwareFallback(uint value)
private static int Log2SoftwareFallback(uint value)
{
// No AggressiveInlining due to large method size
// Has conventional contract 0->0 (Log(0) is undefined) by default, no need for if checking

2
src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs

@ -420,7 +420,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
// Because of the 16 bit value constraint it won't overflow
// With that input value change we no longer need to add 1 before returning
// And this eliminates need to check if input value is zero - it is a standard convention which Log2SoftwareFallback adheres to
return Numerics.Log2SoftwareFallback(value << 1);
return Numerics.Log2(value << 1);
#endif
}
}

Loading…
Cancel
Save