mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:47:35 +00:00
LibGfx/JPEGXL: Use the correct condition to read save_before_ct
During the original implementation, I mixed the condition for `save_before_ct` and the one for `save_before_ct`, resulting in a bogus code. That's fixed now!
This commit is contained in:
parent
338d64abd9
commit
fee3eff947
1 changed files with 15 additions and 8 deletions
|
@ -421,16 +421,13 @@ struct BlendingInfo {
|
||||||
u8 source {};
|
u8 source {};
|
||||||
};
|
};
|
||||||
|
|
||||||
static ErrorOr<BlendingInfo> read_blending_info(LittleEndianInputBitStream& stream, ImageMetadata const& metadata, bool have_crop)
|
static ErrorOr<BlendingInfo> read_blending_info(LittleEndianInputBitStream& stream, ImageMetadata const& metadata, bool full_frame)
|
||||||
{
|
{
|
||||||
BlendingInfo blending_info;
|
BlendingInfo blending_info;
|
||||||
|
|
||||||
blending_info.mode = static_cast<BlendingInfo::BlendMode>(U32(0, 1, 2, 3 + TRY(stream.read_bits(2))));
|
blending_info.mode = static_cast<BlendingInfo::BlendMode>(U32(0, 1, 2, 3 + TRY(stream.read_bits(2))));
|
||||||
|
|
||||||
bool const extra = metadata.num_extra_channels > 0;
|
bool const extra = metadata.num_extra_channels > 0;
|
||||||
// FIXME: also consider "cropped" image of the dimension of the frame
|
|
||||||
VERIFY(!have_crop);
|
|
||||||
bool const full_frame = !have_crop;
|
|
||||||
|
|
||||||
if (extra) {
|
if (extra) {
|
||||||
TODO();
|
TODO();
|
||||||
|
@ -537,7 +534,10 @@ struct FrameHeader {
|
||||||
|
|
||||||
BlendingInfo blending_info {};
|
BlendingInfo blending_info {};
|
||||||
|
|
||||||
|
u32 duration {};
|
||||||
|
|
||||||
bool is_last { true };
|
bool is_last { true };
|
||||||
|
u8 save_as_reference {};
|
||||||
bool save_before_ct {};
|
bool save_before_ct {};
|
||||||
|
|
||||||
String name {};
|
String name {};
|
||||||
|
@ -598,8 +598,12 @@ static ErrorOr<FrameHeader> read_frame_header(LittleEndianInputBitStream& stream
|
||||||
bool const normal_frame = frame_header.frame_type == FrameHeader::FrameType::kRegularFrame
|
bool const normal_frame = frame_header.frame_type == FrameHeader::FrameType::kRegularFrame
|
||||||
|| frame_header.frame_type == FrameHeader::FrameType::kSkipProgressive;
|
|| frame_header.frame_type == FrameHeader::FrameType::kSkipProgressive;
|
||||||
|
|
||||||
|
// FIXME: also consider "cropped" image of the dimension of the frame
|
||||||
|
VERIFY(!frame_header.have_crop);
|
||||||
|
bool const full_frame = !frame_header.have_crop;
|
||||||
|
|
||||||
if (normal_frame) {
|
if (normal_frame) {
|
||||||
frame_header.blending_info = TRY(read_blending_info(stream, metadata, frame_header.have_crop));
|
frame_header.blending_info = TRY(read_blending_info(stream, metadata, full_frame));
|
||||||
|
|
||||||
for (u16 i {}; i < metadata.num_extra_channels; ++i)
|
for (u16 i {}; i < metadata.num_extra_channels; ++i)
|
||||||
TODO();
|
TODO();
|
||||||
|
@ -613,14 +617,17 @@ static ErrorOr<FrameHeader> read_frame_header(LittleEndianInputBitStream& stream
|
||||||
// FIXME: Ensure that is_last has the correct default value
|
// FIXME: Ensure that is_last has the correct default value
|
||||||
VERIFY(normal_frame);
|
VERIFY(normal_frame);
|
||||||
|
|
||||||
|
auto const resets_canvas = full_frame && frame_header.blending_info.mode == BlendingInfo::BlendMode::kReplace;
|
||||||
|
auto const can_reference = !frame_header.is_last && (frame_header.duration == 0 || frame_header.save_as_reference != 0) && frame_header.frame_type != FrameHeader::FrameType::kLFFrame;
|
||||||
|
|
||||||
if (frame_header.frame_type != FrameHeader::FrameType::kLFFrame) {
|
if (frame_header.frame_type != FrameHeader::FrameType::kLFFrame) {
|
||||||
if (!frame_header.is_last)
|
if (!frame_header.is_last)
|
||||||
TODO();
|
TODO();
|
||||||
frame_header.save_before_ct = TRY(stream.read_bit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Ensure that save_before_ct has the correct default value
|
frame_header.save_before_ct = !normal_frame;
|
||||||
VERIFY(frame_header.frame_type != FrameHeader::FrameType::kLFFrame);
|
if (frame_header.frame_type == FrameHeader::FrameType::kReferenceOnly || (resets_canvas && can_reference))
|
||||||
|
frame_header.save_before_ct = TRY(stream.read_bit());
|
||||||
|
|
||||||
auto const name_length = U32(0, TRY(stream.read_bits(4)), 16 + TRY(stream.read_bits(5)), 48 + TRY(stream.read_bits(10)));
|
auto const name_length = U32(0, TRY(stream.read_bits(4)), 16 + TRY(stream.read_bits(5)), 48 + TRY(stream.read_bits(10)));
|
||||||
auto string_buffer = TRY(FixedArray<u8>::create(name_length));
|
auto string_buffer = TRY(FixedArray<u8>::create(name_length));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue