From 0f2f26d5aad7b22b208fa5b87997ed117621cdd9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 21 Dec 2022 12:27:06 +0100 Subject: Relax the COC component number verification error (DoM #2395). A DCP is seen in the wild with 1 here and it doesn't seem unreasonable that there should be a COC for each component. --- src/verify_j2k.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/verify_j2k.cc b/src/verify_j2k.cc index 7b60034d..86ffb5b4 100644 --- a/src/verify_j2k.cc +++ b/src/verify_j2k.cc @@ -259,7 +259,14 @@ dcp::verify_j2k (shared_ptr j2k, vector& notes) ptr += L_qcd - 3; } else if (*marker_name == "COC") { get_16(); // length - require_8(0, "invalid COC component number %1"); + auto const coc_component_number = get_8(); + /* I don't know if this is really a requirement, but it seems to make sense that there should only + * be components 0, 1 and 2. DoM bug #2395 is about a DCP with COC component number 1 which seems + * like it should be OK. + */ + if (coc_component_number > 2) { + throw InvalidCodestream(String::compose("invalid COC component number %1", coc_component_number)); + } require_8(1, "invalid coding style %1"); require_8(5, "invalid number of transform levels %1"); require_8(3, "invalid code block width exponent %1"); -- cgit v1.2.3