@@ -16,8 +16,6 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
1616 /// </summary>
1717 internal static unsafe class QuantEnc
1818 {
19- private static readonly byte [ ] Zigzag = { 0 , 1 , 4 , 8 , 5 , 2 , 3 , 6 , 9 , 12 , 13 , 10 , 7 , 11 , 14 , 15 } ;
20-
2119 private static readonly ushort [ ] WeightY = { 38 , 32 , 20 , 9 , 32 , 28 , 17 , 7 , 20 , 17 , 10 , 4 , 9 , 7 , 4 , 2 } ;
2220
2321 private const int MaxLevel = 2047 ;
@@ -47,6 +45,9 @@ internal static unsafe class QuantEnc
4745 private const int DSHIFT = 4 ;
4846 private const int DSCALE = 1 ; // storage descaling, needed to make the error fit byte
4947
48+ // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs.
49+ private static ReadOnlySpan < byte > Zigzag => new byte [ ] { 0 , 1 , 4 , 8 , 5 , 2 , 3 , 6 , 9 , 12 , 13 , 10 , 7 , 11 , 14 , 15 } ;
50+
5051 public static void PickBestIntra16 ( Vp8EncIterator it , ref Vp8ModeScore rd , Vp8SegmentInfo [ ] segmentInfos , Vp8EncProba proba )
5152 {
5253 const int numBlocks = 16 ;
0 commit comments