1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:17:46 +00:00

LibGfx/JPEG: Make ycck jpegs with just cc subsampled decode correctly

We currently assume that the K (black) channel uses the same sampling
as the Y channel already, so this already works as long as we don't
error out on it.
This commit is contained in:
Nico Weber 2023-12-28 20:58:35 -05:00 committed by Tim Flynn
parent 4236798244
commit a2bd19fdac
2 changed files with 7 additions and 2 deletions

View file

@ -1282,7 +1282,12 @@ static ErrorOr<void> read_start_of_frame(JPEGStream& stream, JPEGLoadingContext&
return Error::from_string_literal("Unsupported luma subsampling factors");
}
} else {
if (component.hsample_factor != 1 || component.vsample_factor != 1) {
// YCCK with just CC subsampled and K matching Y is fine.
auto const& y_component = context.components[0];
bool channel_matches_y_factor = component.hsample_factor == y_component.hsample_factor && component.vsample_factor == y_component.vsample_factor;
bool k_channel_matches_y = context.color_transform == ColorTransform::YCCK && i == 3 && channel_matches_y_factor;
if ((component.hsample_factor != 1 || component.vsample_factor != 1) && !k_channel_matches_y) {
dbgln_if(JPEG_DEBUG, "Unsupported chroma subsampling factors: horizontal: {}, vertical: {}",
component.hsample_factor,
component.vsample_factor);