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

LibGfx/JPEGWriter: Add a named constant in add_frame_header()

No behavior change.
This commit is contained in:
Nico Weber 2024-01-31 20:31:47 -05:00 committed by Andreas Kling
parent ad7d25f089
commit 4a8e7f44dc

View file

@ -397,8 +397,10 @@ ErrorOr<void> add_frame_header(Stream& stream, JPEGEncodingContext const& contex
// B.2.2 - Frame header syntax
TRY(stream.write_value<BigEndian<Marker>>(JPEG_SOF0));
// Lf = 8 + 3 × Nf, we only support a single image per frame so Nf = 3
TRY(stream.write_value<BigEndian<u16>>(17));
u16 const Nf = 3;
// Lf = 8 + 3 × Nf
TRY(stream.write_value<BigEndian<u16>>(8 + 3 * Nf));
// P
TRY(stream.write_value<u8>(8));
@ -409,11 +411,11 @@ ErrorOr<void> add_frame_header(Stream& stream, JPEGEncodingContext const& contex
// X
TRY(stream.write_value<BigEndian<u16>>(bitmap.width()));
// Nf, as mentioned earlier, we only support Nf = 3
TRY(stream.write_value<u8>(3));
// Nf
TRY(stream.write_value<u8>(Nf));
// Encode 3 components
for (u8 i {}; i < 3; ++i) {
// Encode Nf components
for (u8 i {}; i < Nf; ++i) {
// Ci
TRY(stream.write_value<u8>(i + 1));