LibGfx/JPEG2000: Decode tile-part QCD and QCC marker segment data

This commit is contained in:
Nico Weber 2024-04-08 21:49:21 -04:00 committed by Tim Flynn
parent 8ba7c23165
commit dbe179f0d5
Notes: sideshowbarker 2024-07-17 22:55:25 +09:00

View file

@ -469,6 +469,8 @@ struct TilePartData {
};
struct TileData {
Optional<QuantizationDefault> qcd;
Vector<QuantizationComponent> qccs;
Vector<TilePartData> tile_parts;
};
@ -660,7 +662,13 @@ static ErrorOr<void> parse_codestream_tile_header(JPEG2000LoadingContext& contex
case J2K_PLT:
case J2K_COM: {
auto marker = TRY(read_marker_at_cursor(context));
if (marker.marker == J2K_COM) {
if (marker.marker == J2K_QCD) {
if (tile.qcd.has_value())
return Error::from_string_literal("JPEG2000ImageDecoderPlugin: Multiple QCD markers in tile header");
tile.qcd = TRY(read_quantization_default(marker.data.value()));
} else if (marker.marker == J2K_QCC) {
tile.qccs.append(TRY(read_quantization_component(marker.data.value(), context.siz.components.size())));
} else if (marker.marker == J2K_COM) {
tile_part.coms.append(TRY(read_comment(marker.data.value())));
} else {
// FIXME: These are valid main header markers. Parse contents.