mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
LibGfx: Fix JPG decoding bug on rare grayscale images
Some grayscale JPG images might have the horizontal and vertical sample factor set to 2. However, the macroblocks in these images are not interleaved as they would be in color images.
This commit is contained in:
parent
10581cfaeb
commit
7dcfb82e16
Notes:
sideshowbarker
2024-07-17 18:31:17 +09:00
Author: https://github.com/msvisser Commit: https://github.com/SerenityOS/serenity/commit/7dcfb82e16 Pull-request: https://github.com/SerenityOS/serenity/pull/12664
1 changed files with 6 additions and 0 deletions
|
@ -742,6 +742,12 @@ static bool read_start_of_frame(InputMemoryStream& stream, JPGLoadingContext& co
|
|||
component.vsample_factor = subsample_factors & 0x0F;
|
||||
|
||||
if (i == 0) {
|
||||
// If there is only a single component, i.e. grayscale, the macroblocks will not be interleaved, even if
|
||||
// the horizontal or vertical sample factor is larger than 1.
|
||||
if (context.component_count == 1) {
|
||||
component.hsample_factor = 1;
|
||||
component.vsample_factor = 1;
|
||||
}
|
||||
// By convention, downsampling is applied only on chroma components. So we should
|
||||
// hope to see the maximum sampling factor in the luma component.
|
||||
if (!validate_luma_and_modify_context(component, context)) {
|
||||
|
|
Loading…
Reference in a new issue