summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-30 22:48:00 +0100
committerCarl Hetherington <cth@carlh.net>2025-01-09 02:03:53 +0100
commit99abebca58819185b7ef7254a436d6192aa714bd (patch)
tree62004b6b297d7f17e08e657896640876274cbd21
parent12521ed5affb71b32dd6380ccf878f3c8395ba58 (diff)
Add a way to get more context from DCP verification messages.
-rw-r--r--src/verify.cc17
-rw-r--r--src/verify.h1
-rw-r--r--src/verify_report.cc2
-rw-r--r--tools/dcpverify.cc4
4 files changed, 22 insertions, 2 deletions
diff --git a/src/verify.cc b/src/verify.cc
index b4fde4e7..d04cdf2f 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -1869,7 +1869,7 @@ dcp::verify (
string
-dcp::note_to_string(VerificationNote note, function<string (string)> process_string, function<string (string)> process_filename)
+dcp::note_to_string(VerificationNote note, map<string, string>* context, function<string (string)> process_string, function<string (string)> process_filename)
{
/** These strings should say what is wrong, incorporating any extra details (ID, filenames etc.).
*
@@ -1886,6 +1886,17 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
return process_filename(note.file()->filename().string());
};
+ auto maybe_add_cpl_details_to_context = [note, context]() {
+ if (context) {
+ if (note.cpl_id()) {
+ (*context)["CPL ID"] = note.cpl_id().get();
+ }
+ if (note.cpl_content_title_text()) {
+ (*context)["CPL Title"] = note.cpl_content_title_text().get();
+ }
+ }
+ };
+
#define compose(format, ...) String::compose(process_string(format), __VA_ARGS__)
switch (note.code()) {
@@ -1924,6 +1935,7 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES:
return compose("Each frame of the picture asset %1 has a bit rate safely under the limit of 250Mbit/s.", filename());
case VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES:
+ maybe_add_cpl_details_to_context();
return compose(
"Frame %1 (timecode %2) in asset %3 has an instantaneous bit rate that is larger than the limit of 250Mbit/s.",
note.frame().get(),
@@ -1931,6 +1943,7 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
filename()
);
case VerificationNote::Code::NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES:
+ maybe_add_cpl_details_to_context();
return compose(
"Frame %1 (timecode %2) in asset %3 has an instantaneous bit rate that is close to the limit of 250Mbit/s.",
note.frame().get(),
@@ -2048,6 +2061,7 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::PARTIALLY_ENCRYPTED:
return process_string("Some assets are encrypted but some are not.");
case VerificationNote::Code::INVALID_JPEG2000_CODESTREAM:
+ maybe_add_cpl_details_to_context();
return compose(
"Frame %1 (timecode %2) has an invalid JPEG2000 codestream (%3).",
note.frame().get(),
@@ -2124,6 +2138,7 @@ dcp::note_to_string(VerificationNote note, function<string (string)> process_str
case VerificationNote::Code::MISSING_FONT:
return compose("The font file for font ID \"%1\" was not found, or was not referred to in the ASSETMAP.", note.note().get());
case VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE:
+ maybe_add_cpl_details_to_context();
return compose(
"Frame %1 (timecode %2) has an image component that is too large (component %3 is %4 bytes in size).",
note.frame().get(), note.timecode().get(), note.component().get(), note.size().get()
diff --git a/src/verify.h b/src/verify.h
index afcaa620..d9f5815e 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -741,6 +741,7 @@ VerificationResult verify(
std::string note_to_string(
dcp::VerificationNote note,
+ std::map<std::string, std::string>* context = nullptr,
std::function<std::string (std::string)> process_string = [](std::string s) { return s; },
std::function<std::string (std::string)> process_filename = [](std::string s) { return s; }
);
diff --git a/src/verify_report.cc b/src/verify_report.cc
index bcbda1ff..d727a0e8 100644
--- a/src/verify_report.cc
+++ b/src/verify_report.cc
@@ -91,7 +91,7 @@ dcp::verify_report(dcp::VerificationResult const& result, Formatter& formatter)
auto write_notes = [&formatter](dcp::VerificationResult const& result, optional<string> cpl_id) {
for (auto note: result.notes) {
if (note.cpl_id() == cpl_id) {
- auto const note_as_string = dcp::note_to_string(note, formatter.process_string(), formatter.process_filename());
+ auto const note_as_string = dcp::note_to_string(note, nullptr, formatter.process_string(), formatter.process_filename());
switch (note.type()) {
case dcp::VerificationNote::Type::OK:
formatter.list_item(note_as_string, string("ok"));
diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc
index 88f0d705..7eca11f1 100644
--- a/tools/dcpverify.cc
+++ b/tools/dcpverify.cc
@@ -193,6 +193,10 @@ main (int argc, char* argv[])
if (ignore_bv21_smpte && i.code() == dcp::VerificationNote::Code::INVALID_STANDARD) {
continue;
}
+
+ map<string, string> context_values;
+ string const message = note_to_string(i, &context_values);
+
switch (i.type()) {
case dcp::VerificationNote::Type::OK:
break;