Squash squash
@ -5,8 +5,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
{
/// <summary>
/// A compiled look-up table representation of a huffmanSpec.
/// Each value maps to a uint32 of which the 8 most significant bits hold the
/// Each value maps to a int32 of which the 24 most significant bits hold the
/// codeword size in bits and the 24 least significant bits hold the codeword.
/// codeword in bits and the 8 least significant bits hold the codeword size.
/// The maximum codeword size is 16 bits.
/// </summary>
internal readonly struct HuffmanLut
@ -51,10 +51,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
for (int i = 0; i < spec.Count.Length; i++)
int bits = (i + 1) << 24;
int len = i + 1;
for (int j = 0; j < spec.Count[i]; j++)
this.Values[spec.Values[k]] = bits | code;
this.Values[spec.Values[k]] = len | (code << 8);
code++;
k++;
}
@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
@ -354,7 +355,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
private void EmitHuff(int[] table, int value)
int x = table[value];
this.Emit(x & ((1 << 24) - 1), x >> 24);
this.Emit(x >> 8, x & 0xff);
@ -24,9 +24,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
0, 0, 0
},
new byte[]
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
}),
// Luminance AC.
new HuffmanSpec(