LibGfx/WebP: Move kCodeLengthCodeOrder to WebPSharedLossless.h

...and make it an Array while at it.

(This makes it look a little less like the spec, but that seems
worth it.)

No behavior change.
This commit is contained in:
Nico Weber 2024-05-20 20:40:05 -04:00 committed by Andreas Kling
parent d95e4831be
commit 756a8fa02d
2 changed files with 3 additions and 3 deletions

View file

@ -89,9 +89,7 @@ static ErrorOr<CanonicalCode> decode_webp_chunk_VP8L_prefix_code(LittleEndianInp
dbgln_if(WEBP_DEBUG, " num_code_lengths {}", num_code_lengths);
VERIFY(num_code_lengths <= 19);
constexpr int kCodeLengthCodes = 19;
int kCodeLengthCodeOrder[kCodeLengthCodes] = { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
u8 code_length_code_lengths[kCodeLengthCodes] = { 0 }; // "All zeros" [sic]
u8 code_length_code_lengths[kCodeLengthCodeOrder.size()] = { 0 }; // "All zeros" [sic]
for (int i = 0; i < num_code_lengths; ++i)
code_length_code_lengths[kCodeLengthCodeOrder[i]] = TRY(bit_stream.read_bits(3));

View file

@ -10,6 +10,8 @@
namespace Gfx {
constexpr Array kCodeLengthCodeOrder = { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
// WebP-lossless's CanonicalCodes are almost identical to deflate's.
// One difference is that codes with a single element in webp-lossless consume 0 bits to produce that single element,
// while they consume 1 bit in Compress::CanonicalCode. This class wraps Compress::CanonicalCode to handle the case