1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

LibGfx/JPEGXL: Perform size computation in a floating point type

The computation was copied from the spec, but I forgot that they mention
that every "/" should be performed without truncation or rounding. Let's
use `double`s instead of integers.
This commit is contained in:
Lucas CHOLLET 2023-07-26 18:10:12 -04:00 committed by Andreas Kling
parent b5b17269c4
commit ea8384219f

View file

@ -1561,8 +1561,8 @@ static ErrorOr<Frame> read_frame(LittleEndianInputBitStream& stream,
}
if (frame.frame_header.upsampling > 1) {
frame.width = ceil(frame.width / frame.frame_header.upsampling);
frame.height = ceil(frame.height / frame.frame_header.upsampling);
frame.width = ceil(static_cast<double>(frame.width) / frame.frame_header.upsampling);
frame.height = ceil(static_cast<double>(frame.height) / frame.frame_header.upsampling);
}
if (frame.frame_header.lf_level > 0)
@ -1571,8 +1571,10 @@ static ErrorOr<Frame> read_frame(LittleEndianInputBitStream& stream,
// F.2 - FrameHeader
auto const group_dim = 128 << frame.frame_header.group_size_shift;
frame.num_groups = ceil(frame.width / group_dim) * ceil(frame.height / group_dim);
frame.num_lf_groups = ceil(frame.width / (group_dim * 8)) * ceil(frame.height / (group_dim * 8));
auto const frame_width = static_cast<double>(frame.width);
auto const frame_height = static_cast<double>(frame.height);
frame.num_groups = ceil(frame_width / group_dim) * ceil(frame_height / group_dim);
frame.num_lf_groups = ceil(frame_width / (group_dim * 8)) * ceil(frame_height / (group_dim * 8));
frame.toc = TRY(read_toc(stream, frame.frame_header, frame.num_groups, frame.num_lf_groups));