mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:57:47 +00:00
LibGfx/CCITT: Abstract the code to read a single CCITT 2D line
This commit is contained in:
parent
e8133c8297
commit
e9dd1cda3e
1 changed files with 86 additions and 81 deletions
|
@ -413,16 +413,8 @@ enum class Search : u8 {
|
|||
B2,
|
||||
};
|
||||
|
||||
ErrorOr<void> decode_single_ccitt3_2d_block(BigEndianInputBitStream& input_bit_stream, BigEndianOutputBitStream& decoded_bits, u32 image_width, u32 image_height, Group3Options::UseFillBits use_fill_bits)
|
||||
ErrorOr<ReferenceLine> decode_single_ccitt_2d_line(BigEndianInputBitStream& input_bit_stream, BigEndianOutputBitStream& decoded_bits, ReferenceLine&& reference_line, u32 image_width)
|
||||
{
|
||||
ReferenceLine reference_line;
|
||||
for (u32 i = 0; i < image_height; ++i) {
|
||||
TRY(read_eol(input_bit_stream, use_fill_bits));
|
||||
bool const next_is_1D = TRY(input_bit_stream.read_bit()) == 1;
|
||||
|
||||
if (next_is_1D) {
|
||||
reference_line = TRY(decode_single_ccitt3_1d_line(input_bit_stream, decoded_bits, image_width));
|
||||
} else {
|
||||
ReferenceLine current_line {};
|
||||
Color current_color { ccitt_white };
|
||||
u32 column {};
|
||||
|
@ -498,12 +490,25 @@ ErrorOr<void> decode_single_ccitt3_2d_block(BigEndianInputBitStream& input_bit_s
|
|||
return Error::from_string_literal("CCITTDecoder: Unsupported mode for 2D decoding");
|
||||
}
|
||||
}
|
||||
reference_line = move(current_line);
|
||||
}
|
||||
}
|
||||
|
||||
TRY(decoded_bits.align_to_byte_boundary());
|
||||
|
||||
return current_line;
|
||||
}
|
||||
|
||||
ErrorOr<void> decode_single_ccitt3_2d_block(BigEndianInputBitStream& input_bit_stream, BigEndianOutputBitStream& decoded_bits, u32 image_width, u32 image_height, Group3Options::UseFillBits use_fill_bits)
|
||||
{
|
||||
ReferenceLine reference_line;
|
||||
for (u32 i = 0; i < image_height; ++i) {
|
||||
TRY(read_eol(input_bit_stream, use_fill_bits));
|
||||
bool const next_is_1D = TRY(input_bit_stream.read_bit()) == 1;
|
||||
|
||||
if (next_is_1D)
|
||||
reference_line = TRY(decode_single_ccitt3_1d_line(input_bit_stream, decoded_bits, image_width));
|
||||
else
|
||||
reference_line = TRY(decode_single_ccitt_2d_line(input_bit_stream, decoded_bits, move(reference_line), image_width));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue