LibGfx/CCITT: Add PDF-specific options for CCITT3 1D

These two options are additions of the PDF specification. They are valid
for both 1D and 2D, but let's bail out if we encounter them in a 2D
image, as we don't have a test case yet.
This commit is contained in:
Lucas CHOLLET 2024-03-18 13:26:30 -04:00 committed by Andreas Kling
commit 7730b743db
Notes: sideshowbarker 2024-07-17 06:29:49 +09:00
2 changed files with 22 additions and 1 deletions

View file

@ -596,13 +596,19 @@ ErrorOr<ByteBuffer> decode_ccitt_group3(ReadonlyBytes bytes, u32 image_width, u3
// NOTE: For whatever reason, the last EOL doesn't seem to be included
for (u32 i = 0; i < image_height; ++i) {
TRY(read_eol(*bit_stream, options.use_fill_bits));
if (options.require_end_of_line == Group3Options::RequireEndOfLine::Yes)
TRY(read_eol(*bit_stream, options.use_fill_bits));
TRY(decode_single_ccitt3_1d_line(*bit_stream, *decoded_bits, image_width));
if (options.encoded_byte_aligned == Group3Options::EncodedByteAligned::Yes)
bit_stream->align_to_byte_boundary();
}
return decoded_bytes;
}
if (options.require_end_of_line == Group3Options::RequireEndOfLine::No || options.encoded_byte_aligned == Group3Options::EncodedByteAligned::Yes)
return Error::from_string_literal("CCITTDecoder: Unsupported option for CCITT3 2D decoding");
TRY(decode_single_ccitt3_2d_block(*bit_stream, *decoded_bits, image_width, image_height, options.use_fill_bits));
return decoded_bytes;
}