diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 6c475bf8ca..e5b924c6ae 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -325,7 +325,7 @@ TEST_CASE(test_jpeg_ycck) { Array test_inputs = { TEST_INPUT("jpg/ycck-1111.jpg"sv), - // TEST_INPUT("jpg/ycck-2111.jpg"sv), // FIXME: Enable once this decodes correctly + TEST_INPUT("jpg/ycck-2111.jpg"sv), TEST_INPUT("jpg/ycck-2112.jpg"sv), }; diff --git a/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp index 2fc251458c..071c03f815 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JPEGLoader.cpp @@ -1287,12 +1287,9 @@ static ErrorOr read_start_of_frame(JPEGStream& stream, JPEGLoadingContext& return Error::from_string_literal("Unsupported luma subsampling factors"); } } else { - // YCCK with just CC subsampled and K matching Y is fine. auto const& y_component = context.components[0]; - bool channel_matches_y_factor = component.sampling_factors == y_component.sampling_factors; - bool k_channel_matches_y = context.color_transform == ColorTransform::YCCK && i == 3 && channel_matches_y_factor; - - if (((component.sampling_factors != SamplingFactors { 1, 1 }) && !k_channel_matches_y) || (i == 3 && !channel_matches_y_factor)) { + if (y_component.sampling_factors.horizontal % component.sampling_factors.horizontal != 0 + || y_component.sampling_factors.vertical % component.sampling_factors.vertical != 0) { dbgln_if(JPEG_DEBUG, "Unsupported chroma subsampling factors: horizontal: {}, vertical: {}", component.sampling_factors.horizontal, component.sampling_factors.vertical); @@ -1589,8 +1586,7 @@ static void inverse_dct(JPEGLoadingContext const& context, Vector& m static void undo_subsampling(JPEGLoadingContext const& context, Vector& macroblocks) { // The first component has sampling factors of context.sampling_factors, while the others - // are either 1x1 or for the 4th component also context.sampling_factors. See - // read_start_of_frame() which currently enforces these restrictions. + // divide the first component's sampling factors. This is enforced by read_start_of_frame(). // This function undoes the subsampling by duplicating the values of the smaller components. // See https://www.w3.org/Graphics/JPEG/itu-t81.pdf, A.2 Order of source image data encoding. //