mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-18 15:32:22 +00:00
LibGfx/JBIG2: Extract check_valid_adaptive_template_pixel()
No behavior change.
This commit is contained in:
parent
200e36aad3
commit
154d0bb458
Notes:
sideshowbarker
2024-07-17 10:16:43 +09:00
Author: https://github.com/nico
Commit: 154d0bb458
Pull-request: https://github.com/SerenityOS/serenity/pull/23842
1 changed files with 14 additions and 13 deletions
|
@ -900,6 +900,17 @@ struct AdaptiveTemplatePixel {
|
||||||
i8 y { 0 };
|
i8 y { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Figure 7 – Field to which AT pixel locations are restricted
|
||||||
|
static ErrorOr<void> check_valid_adaptive_template_pixel(AdaptiveTemplatePixel const& adaptive_template_pixel)
|
||||||
|
{
|
||||||
|
// Don't have to check < -127 or > 127: The offsets are stored in an i8, so they can't be out of those bounds.
|
||||||
|
if (adaptive_template_pixel.y > 0)
|
||||||
|
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Adaptive pixel y too big");
|
||||||
|
if (adaptive_template_pixel.y == 0 && adaptive_template_pixel.x > -1)
|
||||||
|
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Adaptive pixel x too big");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
// 6.2.2 Input parameters
|
// 6.2.2 Input parameters
|
||||||
// Table 2 – Parameters for the generic region decoding procedure
|
// Table 2 – Parameters for the generic region decoding procedure
|
||||||
struct GenericRegionDecodingInputParameters {
|
struct GenericRegionDecodingInputParameters {
|
||||||
|
@ -945,19 +956,9 @@ static ErrorOr<NonnullOwnPtr<BitBuffer>> generic_region_decoding_procedure(Gener
|
||||||
if (inputs.is_extended_reference_template_used)
|
if (inputs.is_extended_reference_template_used)
|
||||||
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot decode EXTTEMPLATE yet");
|
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot decode EXTTEMPLATE yet");
|
||||||
|
|
||||||
// Figure 7 – Field to which AT pixel locations are restricted
|
int number_of_adaptive_template_pixels = inputs.gb_template == 0 ? 4 : 1;
|
||||||
int number_of_adaptive_template_pixels = 0;
|
for (int i = 0; i < number_of_adaptive_template_pixels; ++i)
|
||||||
if (inputs.gb_template == 0)
|
TRY(check_valid_adaptive_template_pixel(inputs.adaptive_template_pixels[i]));
|
||||||
number_of_adaptive_template_pixels = 4;
|
|
||||||
else
|
|
||||||
number_of_adaptive_template_pixels = 1;
|
|
||||||
for (int i = 0; i < number_of_adaptive_template_pixels; ++i) {
|
|
||||||
// Don't have to check < -127 or > 127: The offsets are stored in an i8, so they can't be out of those bounds.
|
|
||||||
if (inputs.adaptive_template_pixels[i].y > 0)
|
|
||||||
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Adaptive pixel y too big");
|
|
||||||
if (inputs.adaptive_template_pixels[i].y == 0 && inputs.adaptive_template_pixels[i].x > -1)
|
|
||||||
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Adaptive pixel x too big");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.skip_pattern.has_value())
|
if (inputs.skip_pattern.has_value())
|
||||||
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot decode USESKIP yet");
|
return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot decode USESKIP yet");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue