mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
LibGfx/JPEGXL: Add support for complex distribution clustering
Complex distribution - distributions that are encoded using an internal symbol decoder with a single distribution, are very often used for lz77 compressed images. This is a requirement for the lz77_flower test case.
This commit is contained in:
parent
18c511f54c
commit
a8f041ae11
1 changed files with 17 additions and 4 deletions
|
@ -1214,16 +1214,29 @@ private:
|
|||
|
||||
u16 num_clusters = 0;
|
||||
|
||||
if (is_simple) {
|
||||
u8 const nbits = TRY(stream.read_bits(2));
|
||||
auto const read_clusters = [&](auto&& reader) -> ErrorOr<void> {
|
||||
for (u8 i {}; i < num_distrib; ++i) {
|
||||
m_clusters[i] = TRY(stream.read_bits(nbits));
|
||||
m_clusters[i] = TRY(reader());
|
||||
if (m_clusters[i] >= num_clusters)
|
||||
num_clusters = m_clusters[i] + 1;
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
||||
if (is_simple) {
|
||||
u8 const nbits = TRY(stream.read_bits(2));
|
||||
TRY(read_clusters([nbits, &stream]() { return stream.read_bits(nbits); }));
|
||||
} else {
|
||||
TODO();
|
||||
auto const use_mtf = TRY(stream.read_bit());
|
||||
if (num_distrib == 2)
|
||||
TODO();
|
||||
|
||||
auto decoder = TRY(EntropyDecoder::create(stream, 1));
|
||||
|
||||
TRY(read_clusters([&]() { return decoder.decode_hybrid_uint(stream, 0); }));
|
||||
|
||||
if (use_mtf)
|
||||
TODO();
|
||||
}
|
||||
TRY(m_configs.try_resize(num_clusters));
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue