summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-25 22:22:12 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-25 22:22:12 +0100
commitf3f92c6924c145a4995e3e7c71e237a4f6464c8f (patch)
treefe043d4271b008ef4921b3067bc44ea131ead4ca /src
parent0a87232762148a3cb97e3650fb219b3b07a05d1d (diff)
Check J2K Rsiz (capabilities) word.
Diffstat (limited to 'src')
-rw-r--r--src/verify.cc3
-rw-r--r--src/verify.h4
-rw-r--r--src/verify_j2k.cc9
3 files changed, 15 insertions, 1 deletions
diff --git a/src/verify.cc b/src/verify.cc
index b6df354c..7a2fd5cd 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -2089,6 +2089,9 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
return compose("The JPEG2000 codestream has %1 tile parts in a 2K image instead of 3.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_4K:
return compose("The JPEG2000 codestream has %1 tile parts in a 4K image instead of 6.", note.note().get());
+ case VerificationNote::Code::INVALID_JPEG2000_RSIZ_FOR_2K:
+ case VerificationNote::Code::INVALID_JPEG2000_RSIZ_FOR_4K:
+ return compose("The JPEG2000 codestream has an invalid Rsiz (capabilities) value of %1.", note.note().get());
case VerificationNote::Code::MISSING_JPEG200_TLM_MARKER:
return process_string("No TLM marker was found in a JPEG2000 codestream.");
case VerificationNote::Code::MISMATCHED_TIMED_TEXT_RESOURCE_ID:
diff --git a/src/verify.h b/src/verify.h
index 8644ab15..8a75dfa3 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -406,6 +406,10 @@ public:
* note contains the number of tile parts
*/
INVALID_JPEG2000_TILE_PARTS_FOR_4K,
+ /** Invalid Rsiz (capabilities) value in 2K JPEG2000 stream */
+ INVALID_JPEG2000_RSIZ_FOR_2K,
+ /** Invalid Rsiz (capabilities) value in 4K JPEG2000 stream */
+ INVALID_JPEG2000_RSIZ_FOR_4K,
/** No TLM marker was found [Bv2.1_10.2.1] */
MISSING_JPEG200_TLM_MARKER,
/** The MXF _ResourceID_ of a timed text resource was not the same as that of the contained XML essence [Bv2.1_10.4.3] */
diff --git a/src/verify_j2k.cc b/src/verify_j2k.cc
index f1bed1ed..474bf2f5 100644
--- a/src/verify_j2k.cc
+++ b/src/verify_j2k.cc
@@ -42,6 +42,7 @@
#include "raw_convert.h"
#include "verify.h"
#include "verify_j2k.h"
+#include <openjpeg.h>
#include <fmt/format.h>
#include <memory>
#include <vector>
@@ -165,10 +166,16 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in
throw InvalidCodestream("unexpected SIZ size " + fmt::to_string(L_siz));
}
- get_16(); // CA: codestream capabilities
+ // Codestream capabilities (CA, or Rsiz)
+ auto const rsiz = get_16();
auto const image_width = get_32();
auto const image_height = get_32();
auto const fourk = image_width > 2048;
+ if (!fourk && rsiz != OPJ_PROFILE_CINEMA_2K) {
+ notes.push_back({ VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_JPEG2000_RSIZ_FOR_2K, fmt::to_string(rsiz) });
+ } else if (fourk && rsiz != OPJ_PROFILE_CINEMA_4K) {
+ notes.push_back({ VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_JPEG2000_RSIZ_FOR_4K, fmt::to_string(rsiz) });
+ }
require_32 (0, "invalid top-left image x coordinate %1");
require_32 (0, "invalid top-left image y coordinate %1");
auto const tile_width = get_32();