40 #include "compose.hpp"
44 #include "filesystem.h"
62 #include <libxml/parserInternals.h>
63 #include <xercesc/dom/DOMAttr.hpp>
64 #include <xercesc/dom/DOMDocument.hpp>
65 #include <xercesc/dom/DOMError.hpp>
66 #include <xercesc/dom/DOMErrorHandler.hpp>
67 #include <xercesc/dom/DOMException.hpp>
68 #include <xercesc/dom/DOMImplementation.hpp>
69 #include <xercesc/dom/DOMImplementationLS.hpp>
70 #include <xercesc/dom/DOMImplementationRegistry.hpp>
71 #include <xercesc/dom/DOMLSParser.hpp>
72 #include <xercesc/dom/DOMLocator.hpp>
73 #include <xercesc/dom/DOMNamedNodeMap.hpp>
74 #include <xercesc/dom/DOMNodeList.hpp>
75 #include <xercesc/framework/LocalFileInputSource.hpp>
76 #include <xercesc/framework/MemBufInputSource.hpp>
77 #include <xercesc/parsers/AbstractDOMParser.hpp>
78 #include <xercesc/parsers/XercesDOMParser.hpp>
79 #include <xercesc/sax/HandlerBase.hpp>
80 #include <xercesc/util/PlatformUtils.hpp>
81 #include <boost/algorithm/string.hpp>
91 using std::dynamic_pointer_cast;
94 using std::make_shared;
98 using std::shared_ptr;
101 using boost::optional;
105 using namespace xercesc;
110 xml_ch_to_string (XMLCh
const * a)
112 char* x = XMLString::transcode(a);
114 XMLString::release(&x);
123 : _message (xml_ch_to_string(e.getMessage()))
124 , _line (e.getLineNumber())
125 , _column (e.getColumnNumber())
126 , _public_id (e.getPublicId() ? xml_ch_to_string(e.getPublicId()) :
"")
127 , _system_id (e.getSystemId() ? xml_ch_to_string(e.getSystemId()) :
"")
132 string message ()
const {
136 uint64_t line ()
const {
140 uint64_t column ()
const {
144 string public_id ()
const {
148 string system_id ()
const {
164 void warning(
const SAXParseException& e)
override
169 void error(
const SAXParseException& e)
override
174 void fatalError(
const SAXParseException& e)
override
179 void resetErrors()
override {
183 list<XMLValidationError> errors ()
const {
192 e.message().find(
"schema document") != string::npos &&
193 e.message().find(
"has different target namespace from the one specified in instance document") != string::npos
198 _errors.push_back (e);
201 list<XMLValidationError> _errors;
210 _buffer = XMLString::transcode(a.c_str());
218 XMLString::release (&_buffer);
221 XMLCh
const * get ()
const {
234 : _xsd_dtd_directory (xsd_dtd_directory)
239 add(
"http://www.w3.org/2001/XMLSchema.dtd",
"XMLSchema.dtd");
240 add(
"http://www.w3.org/2001/03/xml.xsd",
"xml.xsd");
241 add(
"http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd",
"xmldsig-core-schema.xsd");
242 add(
"http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL.xsd",
"Main-Stereo-Picture-CPL.xsd");
243 add(
"http://www.digicine.com/PROTO-ASDCP-CPL-20040511.xsd",
"PROTO-ASDCP-CPL-20040511.xsd");
244 add(
"http://www.digicine.com/PROTO-ASDCP-PKL-20040311.xsd",
"PROTO-ASDCP-PKL-20040311.xsd");
245 add(
"http://www.digicine.com/PROTO-ASDCP-AM-20040311.xsd",
"PROTO-ASDCP-AM-20040311.xsd");
246 add(
"http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#",
"PROTO-ASDCP-CC-CPL-20070926.xsd");
247 add(
"interop-subs",
"DCSubtitle.v1.mattsson.xsd");
248 add(
"http://www.smpte-ra.org/schemas/428-7/2010/DCST.xsd",
"DCDMSubtitle-2010.xsd");
249 add(
"http://www.smpte-ra.org/schemas/428-7/2014/DCST.xsd",
"DCDMSubtitle-2014.xsd");
250 add(
"http://www.smpte-ra.org/schemas/429-16/2014/CPL-Metadata",
"SMPTE-429-16.xsd");
251 add(
"http://www.dolby.com/schemas/2012/AD",
"Dolby-2012-AD.xsd");
252 add(
"http://www.smpte-ra.org/schemas/429-10/2008/Main-Stereo-Picture-CPL",
"SMPTE-429-10-2008.xsd");
255 InputSource* resolveEntity(XMLCh
const *, XMLCh
const * system_id)
override
260 auto system_id_str = xml_ch_to_string (system_id);
261 auto p = _xsd_dtd_directory;
262 if (_files.find(system_id_str) == _files.end()) {
265 p /= _files[system_id_str];
268 return new LocalFileInputSource(ch.get());
272 void add (
string uri,
string file)
277 std::map<string, string> _files;
278 boost::filesystem::path _xsd_dtd_directory;
283 parse (XercesDOMParser& parser, boost::filesystem::path xml)
285 parser.parse(xml.c_str());
290 parse (XercesDOMParser& parser,
string xml)
292 xercesc::MemBufInputSource buf(
reinterpret_cast<unsigned char const*
>(xml.c_str()), xml.size(),
"");
299 validate_xml(
Context& context, T xml)
302 XMLPlatformUtils::Initialize ();
303 }
catch (XMLException& e) {
304 throw MiscError (
"Failed to initialise xerces library");
311 XercesDOMParser parser;
312 parser.setValidationScheme(XercesDOMParser::Val_Always);
313 parser.setDoNamespaces(
true);
314 parser.setDoSchema(
true);
316 vector<string> schema;
317 schema.push_back(
"xml.xsd");
318 schema.push_back(
"xmldsig-core-schema.xsd");
319 schema.push_back(
"SMPTE-429-7-2006-CPL.xsd");
320 schema.push_back(
"SMPTE-429-8-2006-PKL.xsd");
321 schema.push_back(
"SMPTE-429-9-2007-AM.xsd");
322 schema.push_back(
"Main-Stereo-Picture-CPL.xsd");
323 schema.push_back(
"PROTO-ASDCP-CPL-20040511.xsd");
324 schema.push_back(
"PROTO-ASDCP-PKL-20040311.xsd");
325 schema.push_back(
"PROTO-ASDCP-AM-20040311.xsd");
326 schema.push_back(
"DCSubtitle.v1.mattsson.xsd");
327 schema.push_back(
"DCDMSubtitle-2010.xsd");
328 schema.push_back(
"DCDMSubtitle-2014.xsd");
329 schema.push_back(
"PROTO-ASDCP-CC-CPL-20070926.xsd");
330 schema.push_back(
"SMPTE-429-16.xsd");
331 schema.push_back(
"Dolby-2012-AD.xsd");
332 schema.push_back(
"SMPTE-429-10-2008.xsd");
333 schema.push_back(
"xlink.xsd");
334 schema.push_back(
"SMPTE-335-2012.xsd");
335 schema.push_back(
"SMPTE-395-2014-13-1-aaf.xsd");
336 schema.push_back(
"isdcf-mca.xsd");
337 schema.push_back(
"SMPTE-429-12-2008.xsd");
344 for (
auto i: schema) {
345 locations += String::compose(
"%1 %1 ", i, i);
348 parser.setExternalSchemaLocation(locations.c_str());
349 parser.setValidationSchemaFullChecking(
true);
350 parser.setErrorHandler(&error_handler);
353 parser.setEntityResolver(&resolver);
356 parser.resetDocumentPool();
358 }
catch (XMLException& e) {
359 throw MiscError(xml_ch_to_string(e.getMessage()));
360 }
catch (DOMException& e) {
361 throw MiscError(xml_ch_to_string(e.getMessage()));
363 throw MiscError(
"Unknown exception from xerces");
367 XMLPlatformUtils::Terminate ();
369 for (
auto i: error_handler.errors()) {
373 boost::trim_copy(i.public_id() +
" " + i.system_id()),
380 enum class VerifyAssetResult {
387 static VerifyAssetResult
390 shared_ptr<const ReelFileAsset> reel_file_asset,
391 string* reference_hash,
392 string* calculated_hash
395 DCP_ASSERT(reference_hash);
396 DCP_ASSERT(calculated_hash);
403 reel_file_asset->asset_ref()->unset_hash();
404 *calculated_hash = reel_file_asset->asset_ref()->hash([&context](int64_t done, int64_t total) {
405 context.progress(
float(done) / total);
408 auto pkls = context.dcp->pkls();
410 DCP_ASSERT (!pkls.empty());
412 auto asset = reel_file_asset->asset_ref().asset();
414 optional<string> maybe_pkl_hash;
416 maybe_pkl_hash = i->hash (reel_file_asset->asset_ref()->id());
417 if (maybe_pkl_hash) {
422 DCP_ASSERT(maybe_pkl_hash);
423 *reference_hash = *maybe_pkl_hash;
425 auto cpl_hash = reel_file_asset->hash();
426 if (cpl_hash && *cpl_hash != *reference_hash) {
427 return VerifyAssetResult::CPL_PKL_DIFFER;
430 if (*calculated_hash != *reference_hash) {
431 return VerifyAssetResult::BAD;
434 return VerifyAssetResult::GOOD;
439 verify_language_tag(
Context& context,
string tag)
450 verify_picture_asset(
452 shared_ptr<const ReelFileAsset> reel_file_asset,
453 boost::filesystem::path file,
457 auto asset = dynamic_pointer_cast<J2KPictureAsset>(reel_file_asset->asset_ref().asset());
458 auto const duration = asset->intrinsic_duration ();
460 auto check_and_add = [&context](vector<VerificationNote>
const& j2k_notes) {
461 for (
auto i: j2k_notes) {
462 context.add_note_if_not_existing(i);
466 int const max_frame = rint(250 * 1000000 / (8 * asset->edit_rate().as_float()));
467 int const risky_frame = rint(230 * 1000000 / (8 * asset->edit_rate().as_float()));
469 bool any_bad_frames_seen =
false;
471 auto check_frame_size = [max_frame, risky_frame, file, start_frame, &any_bad_frames_seen](
Context& context,
int index,
int size,
int frame_rate) {
472 if (size > max_frame) {
476 ).set_frame(start_frame + index).set_frame_rate(frame_rate)
478 any_bad_frames_seen =
true;
479 }
else if (size > risky_frame) {
483 ).set_frame(start_frame + index).set_frame_rate(frame_rate)
485 any_bad_frames_seen =
true;
489 if (
auto mono_asset = dynamic_pointer_cast<MonoJ2KPictureAsset>(reel_file_asset->asset_ref().asset())) {
490 auto reader = mono_asset->start_read ();
491 for (int64_t i = 0; i < duration; ++i) {
492 auto frame = reader->get_frame (i);
493 check_frame_size(context, i, frame->size(), mono_asset->frame_rate().numerator);
494 if (!mono_asset->encrypted() || mono_asset->key()) {
495 vector<VerificationNote> j2k_notes;
496 verify_j2k(frame, start_frame, i, mono_asset->frame_rate().numerator, j2k_notes);
497 check_and_add (j2k_notes);
499 context.progress(
float(i) / duration);
501 }
else if (
auto stereo_asset = dynamic_pointer_cast<StereoJ2KPictureAsset>(asset)) {
502 auto reader = stereo_asset->start_read ();
503 for (int64_t i = 0; i < duration; ++i) {
504 auto frame = reader->get_frame (i);
505 check_frame_size(context, i, frame->left()->size(), stereo_asset->frame_rate().numerator);
506 check_frame_size(context, i, frame->right()->size(), stereo_asset->frame_rate().numerator);
507 if (!stereo_asset->encrypted() || stereo_asset->key()) {
508 vector<VerificationNote> j2k_notes;
509 verify_j2k(frame->left(), start_frame, i, stereo_asset->frame_rate().numerator, j2k_notes);
510 verify_j2k(frame->right(), start_frame, i, stereo_asset->frame_rate().numerator, j2k_notes);
511 check_and_add (j2k_notes);
513 context.progress(
float(i) / duration);
518 if (!any_bad_frames_seen) {
525 verify_main_picture_asset(
Context& context, shared_ptr<const ReelPictureAsset> reel_asset, int64_t start_frame)
527 auto asset = reel_asset->asset();
528 auto const file = *asset->file();
531 context.stage(
"Checking picture asset hash", file);
532 string reference_hash;
533 string calculated_hash;
534 auto const r = verify_asset(context, reel_asset, &reference_hash, &calculated_hash);
536 case VerifyAssetResult::BAD:
539 VerificationNote::Type::ERROR,
542 ).set_reference_hash(reference_hash).set_calculated_hash(calculated_hash)
545 case VerifyAssetResult::CPL_PKL_DIFFER:
554 context.stage(
"Checking picture frame sizes", asset->file());
555 verify_picture_asset(context, reel_asset, file, start_frame);
559 asset->size() !=
Size(2048, 858) &&
560 asset->size() !=
Size(1998, 1080) &&
561 asset->size() !=
Size(4096, 1716) &&
562 asset->size() !=
Size(3996, 2160)) {
568 (asset->size() ==
Size(2048, 858) || asset->size() ==
Size(1998, 1080)) &&
569 (asset->edit_rate() !=
Fraction(24, 1) && asset->edit_rate() !=
Fraction(25, 1) && asset->edit_rate() !=
Fraction(48, 1))
573 String::compose(
"%1/%2", asset->edit_rate().numerator, asset->edit_rate().denominator),
578 if (asset->size() ==
Size(4096, 1716) || asset->size() ==
Size(3996, 2160)) {
580 if (asset->edit_rate() !=
Fraction(24, 1)) {
583 String::compose(
"%1/%2", asset->edit_rate().numerator, asset->edit_rate().denominator),
589 if (dynamic_pointer_cast<const StereoJ2KPictureAsset>(asset)) {
592 String::compose(
"%1/%2", asset->edit_rate().numerator, asset->edit_rate().denominator),
602 verify_main_sound_asset(
Context& context, shared_ptr<const ReelSoundAsset> reel_asset)
604 auto asset = reel_asset->asset();
605 auto const file = *asset->file();
608 context.stage(
"Checking sound asset hash", file);
609 string reference_hash;
610 string calculated_hash;
611 auto const r = verify_asset(context, reel_asset, &reference_hash, &calculated_hash);
613 case VerifyAssetResult::BAD:
616 VerificationNote::Type::ERROR,
619 ).set_reference_hash(reference_hash).set_calculated_hash(calculated_hash)
622 case VerifyAssetResult::CPL_PKL_DIFFER:
630 if (!context.audio_channels) {
631 context.audio_channels = asset->channels();
632 }
else if (*context.audio_channels != asset->channels()) {
636 context.stage(
"Checking sound asset metadata", file);
638 if (
auto lang = asset->language()) {
639 verify_language_tag(context, *lang);
641 if (asset->sampling_rate() != 48000) {
644 if (asset->bit_depth() != 24) {
651 verify_main_subtitle_reel(
Context& context, shared_ptr<const ReelTextAsset> reel_asset)
654 if (reel_asset->language()) {
655 verify_language_tag(context, *reel_asset->language());
658 if (!reel_asset->entry_point()) {
660 }
else if (reel_asset->entry_point().get()) {
667 verify_closed_caption_reel(
Context& context, shared_ptr<const ReelTextAsset> reel_asset)
670 if (reel_asset->language()) {
671 verify_language_tag(context, *reel_asset->language());
674 if (!reel_asset->entry_point()) {
676 }
else if (reel_asset->entry_point().get()) {
686 shared_ptr<const SMPTETextAsset> asset,
687 optional<int64_t> reel_asset_duration
690 if (asset->language()) {
691 verify_language_tag(context, *asset->language());
696 auto const size = filesystem::file_size(asset->file().get());
697 if (size > 115 * 1024 * 1024) {
704 auto fonts = asset->font_data ();
706 for (
auto i: fonts) {
707 total_size += i.second.size();
709 if (total_size > 10 * 1024 * 1024) {
713 if (!asset->start_time()) {
715 }
else if (asset->start_time() !=
Time()) {
719 if (reel_asset_duration && *reel_asset_duration != asset->intrinsic_duration()) {
722 String::compose(
"%1 %2", *reel_asset_duration, asset->intrinsic_duration()),
733 if (asset->texts().empty()) {
736 auto const unresolved = asset->unresolved_fonts();
737 if (!unresolved.empty()) {
747 if (asset->language()) {
748 if (!context.subtitle_language) {
749 context.subtitle_language = *asset->language();
750 }
else if (context.subtitle_language != *asset->language()) {
755 DCP_ASSERT (asset->resource_id());
756 auto xml_id = asset->xml_id();
758 if (asset->resource_id().get() != xml_id) {
762 if (asset->id() == asset->resource_id().get() || asset->id() == xml_id) {
769 if (asset->raw_xml()) {
771 cxml::Document doc(
"SubtitleReel");
772 doc.read_string(*asset->raw_xml());
773 auto issue_date = doc.string_child(
"IssueDate");
774 std::regex reg(
"^\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d$");
775 if (!std::regex_match(issue_date, reg)) {
786 context.stage(
"Checking subtitle XML", asset->file());
790 if (asset->raw_xml()) {
791 validate_xml(context, asset->raw_xml().get());
796 auto namespace_count = [](shared_ptr<const TextAsset> asset,
string root_node) {
797 cxml::Document doc(root_node);
798 doc.read_string(asset->raw_xml().get());
799 auto root =
dynamic_cast<xmlpp::Element*
>(doc.node())->cobj();
801 for (
auto ns = root->nsDef; ns !=
nullptr; ns = ns->next) {
807 auto interop = dynamic_pointer_cast<const InteropTextAsset>(asset);
810 if (namespace_count(asset,
"DCSubtitle") > 1) {
815 auto smpte = dynamic_pointer_cast<const SMPTETextAsset>(asset);
820 if (asset->raw_xml() && namespace_count(asset,
"SubtitleReel") > 1) {
831 shared_ptr<const TextAsset> asset,
832 optional<int64_t> reel_asset_duration
835 context.stage(
"Checking closed caption XML", asset->file());
839 auto raw_xml = asset->raw_xml();
841 validate_xml(context, *raw_xml);
842 if (raw_xml->size() > 256 * 1024) {
849 auto interop = dynamic_pointer_cast<const InteropTextAsset>(asset);
854 auto smpte = dynamic_pointer_cast<const SMPTETextAsset>(asset);
866 vector<shared_ptr<Reel>> reels,
868 std::function<
bool (shared_ptr<Reel>)> check,
869 std::function<optional<string> (shared_ptr<Reel>)> xml,
870 std::function<int64_t (shared_ptr<Reel>)> duration,
871 std::function<std::string (shared_ptr<Reel>)>
id
875 optional<int64_t> last_out;
876 auto too_short =
false;
877 auto too_close =
false;
878 auto too_early =
false;
879 auto reel_overlap =
false;
880 auto empty_text =
false;
882 int64_t reel_offset = 0;
883 optional<string> missing_load_font_id;
885 std::function<void (cxml::ConstNodePtr, optional<int>, optional<Time>,
int,
bool,
bool&, vector<string>&)> parse;
887 parse = [&parse, &last_out, &too_short, &too_close, &too_early, &empty_text, &reel_offset, &missing_load_font_id](
888 cxml::ConstNodePtr node,
890 optional<Time> start_time,
894 vector<string>& font_ids
896 if (node->name() ==
"Subtitle") {
897 Time in (node->string_attribute(
"TimeIn"), tcr);
901 Time out (node->string_attribute(
"TimeOut"), tcr);
905 if (first_reel && tcr && in <
Time(0, 0, 4, 0, *tcr)) {
908 auto length = out - in;
909 if (length.as_editable_units_ceil(er) < 15) {
915 if (distance >= 0 && distance < 2) {
920 }
else if (node->name() ==
"Text") {
921 std::function<bool (cxml::ConstNodePtr)> node_has_content = [&](cxml::ConstNodePtr node) {
922 if (!node->content().empty()) {
925 for (
auto i: node->node_children()) {
926 if (node_has_content(i)) {
932 if (!node_has_content(node)) {
936 }
else if (node->name() ==
"LoadFont") {
937 if (
auto const id = node->optional_string_attribute(
"Id")) {
938 font_ids.push_back(*
id);
939 }
else if (
auto const id = node->optional_string_attribute(
"ID")) {
940 font_ids.push_back(*
id);
942 }
else if (node->name() ==
"Font") {
943 if (
auto const font_id = node->optional_string_attribute(
"Id")) {
944 if (std::find_if(font_ids.begin(), font_ids.end(), [font_id](
string const&
id) { return id == font_id; }) == font_ids.end()) {
945 missing_load_font_id = font_id;
949 for (
auto i: node->node_children()) {
950 parse(i, tcr, start_time, er, first_reel, has_text, font_ids);
954 for (
auto i = 0U; i < reels.size(); ++i) {
955 if (!check(reels[i])) {
959 auto reel_xml = xml(reels[i]);
969 shared_ptr<cxml::Document> doc;
971 optional<Time> start_time;
972 switch (context.dcp->standard().get_value_or(dcp::Standard::SMPTE)) {
973 case dcp::Standard::INTEROP:
974 doc = make_shared<cxml::Document>(
"DCSubtitle");
975 doc->read_string (*reel_xml);
977 case dcp::Standard::SMPTE:
978 doc = make_shared<cxml::Document>(
"SubtitleReel");
979 doc->read_string (*reel_xml);
980 tcr = doc->number_child<
int>(
"TimeCodeRate");
981 if (
auto start_time_string = doc->optional_string_child(
"StartTime")) {
982 start_time =
Time(*start_time_string, tcr);
986 bool has_text =
false;
987 vector<string> font_ids;
988 parse(doc, tcr, start_time, edit_rate, i == 0, has_text, font_ids);
989 auto end = reel_offset + duration(reels[i]);
990 if (last_out && *last_out > end) {
995 if (context.dcp->standard() && *context.dcp->standard() == dcp::Standard::SMPTE && has_text && font_ids.empty()) {
1000 if (last_out && *last_out > reel_offset) {
1001 reel_overlap =
true;
1024 if (missing_load_font_id) {
1032 verify_closed_caption_details(
Context& context, vector<shared_ptr<Reel>> reels)
1034 std::function<void (cxml::ConstNodePtr node, std::vector<cxml::ConstNodePtr>& text_or_image)> find_text_or_image;
1035 find_text_or_image = [&find_text_or_image](cxml::ConstNodePtr node, std::vector<cxml::ConstNodePtr>& text_or_image) {
1036 for (
auto i: node->node_children()) {
1037 if (i->name() ==
"Text") {
1038 text_or_image.push_back (i);
1040 find_text_or_image (i, text_or_image);
1045 auto mismatched_valign =
false;
1046 auto incorrect_order =
false;
1048 std::function<void (cxml::ConstNodePtr)> parse;
1049 parse = [&parse, &find_text_or_image, &mismatched_valign, &incorrect_order](cxml::ConstNodePtr node) {
1050 if (node->name() ==
"Subtitle") {
1051 vector<cxml::ConstNodePtr> text_or_image;
1052 find_text_or_image (node, text_or_image);
1053 optional<string> last_valign;
1054 optional<float> last_vpos;
1055 for (
auto i: text_or_image) {
1056 auto valign = i->optional_string_attribute(
"VAlign");
1058 valign = i->optional_string_attribute(
"Valign").get_value_or(
"center");
1060 auto vpos = i->optional_number_attribute<
float>(
"VPosition");
1062 vpos = i->optional_number_attribute<
float>(
"Vposition").get_value_or(50);
1066 if (*last_valign != valign) {
1067 mismatched_valign =
true;
1070 last_valign = valign;
1072 if (!mismatched_valign) {
1074 if (*last_valign ==
"top" || *last_valign ==
"center") {
1075 if (*vpos < *last_vpos) {
1076 incorrect_order =
true;
1079 if (*vpos > *last_vpos) {
1080 incorrect_order =
true;
1089 for (
auto i: node->node_children()) {
1094 for (
auto reel: reels) {
1095 for (
auto ccap: reel->closed_captions()) {
1096 auto reel_xml = ccap->asset()->raw_xml();
1106 shared_ptr<cxml::Document> doc;
1108 optional<Time> start_time;
1110 doc = make_shared<cxml::Document>(
"SubtitleReel");
1111 doc->read_string (*reel_xml);
1113 doc = make_shared<cxml::Document>(
"DCSubtitle");
1114 doc->read_string (*reel_xml);
1120 if (mismatched_valign) {
1124 if (incorrect_order) {
1132 shared_ptr<const TextAsset> asset,
1141 Event (
Time time_,
float position_,
int characters_)
1143 , position (position_)
1144 , characters (characters_)
1147 Event (
Time time_, shared_ptr<Event> start_)
1155 shared_ptr<Event> start;
1158 vector<shared_ptr<Event>> events;
1160 auto position = [](shared_ptr<const TextString> sub) {
1161 switch (sub->v_align()) {
1163 return lrintf(sub->v_position() * 100);
1165 return lrintf((0.5f + sub->v_position()) * 100);
1167 return lrintf((1.0f - sub->v_position()) * 100);
1174 for (
auto j: asset->texts()) {
1175 auto text = dynamic_pointer_cast<const TextString>(j);
1177 auto in = make_shared<Event>(text->in(), position(text), text->text().length());
1178 events.push_back(in);
1179 events.push_back(make_shared<Event>(text->out(), in));
1183 std::sort(events.begin(), events.end(), [](shared_ptr<Event>
const& a, shared_ptr<Event>
const& b) {
1184 return a->time < b->time;
1191 map<int, vector<shared_ptr<Event>>> current;
1192 for (
auto i: events) {
1193 if (current.size() > 3) {
1194 result->line_count_exceeded =
true;
1196 for (
auto j: current) {
1197 int length = std::accumulate(j.second.begin(), j.second.end(), 0, [](
int total, shared_ptr<const Event> event) { return total + event->characters; });
1198 if (length > warning_length) {
1199 result->warning_length_exceeded =
true;
1201 if (length > error_length) {
1202 result->error_length_exceeded =
true;
1208 DCP_ASSERT (current.find(i->start->position) != current.end());
1209 auto current_position = current[i->start->position];
1210 auto iter = std::find(current_position.begin(), current_position.end(), i->start);
1211 if (iter != current_position.end()) {
1212 current_position.erase(iter);
1214 if (current_position.empty()) {
1215 current.erase(i->start->position);
1219 if (current.find(i->position) == current.end()) {
1220 current[i->position] = vector<shared_ptr<Event>>{i};
1222 current[i->position].push_back(i);
1233 if (reels.empty()) {
1237 if (reels[0]->main_subtitle() && reels[0]->main_subtitle()->asset_ref().resolved()) {
1239 [](shared_ptr<Reel> reel) {
1240 return static_cast<bool>(reel->main_subtitle());
1242 [](shared_ptr<Reel> reel) {
1243 return reel->main_subtitle()->asset()->raw_xml();
1245 [](shared_ptr<Reel> reel) {
1246 return reel->main_subtitle()->actual_duration();
1248 [](shared_ptr<Reel> reel) {
1249 return reel->main_subtitle()->id();
1254 for (
auto i = 0U; i < reels[0]->closed_captions().size(); ++i) {
1255 verify_text_details(context, reels, reels[0]->closed_captions()[i]->edit_rate().numerator,
1256 [i](shared_ptr<Reel> reel) {
1257 return i < reel->closed_captions().size();
1259 [i](shared_ptr<Reel> reel) {
1260 return reel->closed_captions()[i]->asset()->raw_xml();
1262 [i](shared_ptr<Reel> reel) {
1263 return reel->closed_captions()[i]->actual_duration();
1265 [i](shared_ptr<Reel> reel) {
1266 return reel->closed_captions()[i]->id();
1271 verify_closed_caption_details(context, reels);
1276 dcp::verify_extension_metadata(
Context& context)
1278 DCP_ASSERT(context.cpl->file());
1279 cxml::Document doc (
"CompositionPlaylist");
1280 doc.read_file(dcp::filesystem::fix_long_path(context.cpl->file().get()));
1282 auto missing =
false;
1285 if (
auto reel_list = doc.node_child(
"ReelList")) {
1286 auto reels = reel_list->node_children(
"Reel");
1287 if (!reels.empty()) {
1288 if (
auto asset_list = reels[0]->optional_node_child(
"AssetList")) {
1289 if (
auto metadata = asset_list->optional_node_child(
"CompositionMetadataAsset")) {
1290 if (
auto extension_list = metadata->optional_node_child(
"ExtensionMetadataList")) {
1292 for (
auto extension: extension_list->node_children(
"ExtensionMetadata")) {
1293 if (extension->optional_string_attribute(
"scope").get_value_or(
"") !=
"http://isdcf.com/ns/cplmd/app") {
1297 if (
auto name = extension->optional_node_child(
"Name")) {
1298 if (name->content() !=
"Application") {
1299 malformed =
"<Name> should be 'Application'";
1302 if (
auto property_list = extension->optional_node_child(
"PropertyList")) {
1303 auto properties = property_list->node_children(
"Property");
1304 auto is_bv21 = [](shared_ptr<const cxml::Node> property) {
1305 auto name =
property->optional_node_child(
"Name");
1306 auto value =
property->optional_node_child(
"Value");
1307 return name && value && name->content() ==
"DCP Constraints Profile" && value->content() ==
"SMPTE-RDD-52:2020-Bv2.1";
1309 if (!std::any_of(properties.begin(), properties.end(), is_bv21)) {
1310 malformed =
"No correctly-formed DCP Constraints Profile found";
1324 }
else if (!malformed.empty()) {
1331 pkl_has_encrypted_assets(shared_ptr<const DCP>
dcp, shared_ptr<const PKL> pkl)
1333 vector<string> encrypted;
1334 for (
auto i:
dcp->cpls()) {
1335 for (
auto j: i->reel_file_assets()) {
1336 if (j->asset_ref().resolved()) {
1337 auto mxf = dynamic_pointer_cast<MXF>(j->asset_ref().asset());
1338 if (mxf && mxf->encrypted()) {
1339 encrypted.push_back(j->asset_ref().id());
1345 for (
auto i: pkl->assets()) {
1346 if (find(encrypted.begin(), encrypted.end(), i->id()) != encrypted.end()) {
1359 shared_ptr<const Reel> reel,
1360 int64_t start_frame,
1361 optional<dcp::Size> main_picture_active_area,
1362 bool* have_main_subtitle,
1363 bool* have_no_main_subtitle,
1364 size_t* most_closed_captions,
1365 size_t* fewest_closed_captions,
1366 map<Marker, Time>* markers_seen
1369 for (
auto i: reel->assets()) {
1370 if (i->duration() && (i->duration().get() * i->edit_rate().denominator / i->edit_rate().numerator) < 1) {
1373 if ((i->intrinsic_duration() * i->edit_rate().denominator / i->edit_rate().numerator) < 1) {
1376 auto file_asset = dynamic_pointer_cast<ReelFileAsset>(i);
1377 if (i->encryptable() && !file_asset->hash()) {
1382 if (context.dcp->standard() == Standard::SMPTE) {
1383 boost::optional<int64_t> duration;
1384 for (
auto i: reel->assets()) {
1386 duration = i->actual_duration();
1387 }
else if (*duration != i->actual_duration()) {
1394 if (reel->main_picture()) {
1396 auto const frame_rate = reel->main_picture()->frame_rate();
1397 if (frame_rate.denominator != 1 ||
1398 (frame_rate.numerator != 24 &&
1399 frame_rate.numerator != 25 &&
1400 frame_rate.numerator != 30 &&
1401 frame_rate.numerator != 48 &&
1402 frame_rate.numerator != 50 &&
1403 frame_rate.numerator != 60 &&
1404 frame_rate.numerator != 96)) {
1408 if (reel->main_picture()->asset_ref().resolved()) {
1409 verify_main_picture_asset(context, reel->main_picture(), start_frame);
1410 auto const asset_size = reel->main_picture()->asset()->size();
1411 if (main_picture_active_area) {
1412 if (main_picture_active_area->width > asset_size.width) {
1415 String::compose(
"width %1 is bigger than the asset width %2", main_picture_active_area->width, asset_size.width),
1416 context.cpl->file().get()
1419 if (main_picture_active_area->height > asset_size.height) {
1422 String::compose(
"height %1 is bigger than the asset height %2", main_picture_active_area->height, asset_size.height),
1423 context.cpl->file().get()
1431 if (reel->main_sound() && reel->main_sound()->asset_ref().resolved()) {
1432 verify_main_sound_asset(context, reel->main_sound());
1435 if (reel->main_subtitle()) {
1436 verify_main_subtitle_reel(context, reel->main_subtitle());
1437 if (reel->main_subtitle()->asset_ref().resolved()) {
1440 *have_main_subtitle =
true;
1442 *have_no_main_subtitle =
true;
1445 for (
auto i: reel->closed_captions()) {
1446 verify_closed_caption_reel(context, i);
1447 if (i->asset_ref().resolved()) {
1452 if (reel->main_markers()) {
1453 for (
auto const& i: reel->main_markers()->get()) {
1454 markers_seen->insert(i);
1456 if (reel->main_markers()->entry_point()) {
1459 if (reel->main_markers()->duration()) {
1464 *fewest_closed_captions = std::min(*fewest_closed_captions, reel->closed_captions().size());
1465 *most_closed_captions = std::max(*most_closed_captions, reel->closed_captions().size());
1472 verify_cpl(
Context& context, shared_ptr<const CPL> cpl)
1474 context.stage(
"Checking CPL", cpl->file());
1475 validate_xml(context, cpl->file().get());
1477 if (cpl->any_encrypted() && !cpl->all_encrypted()) {
1479 }
else if (cpl->all_encrypted()) {
1481 }
else if (!cpl->all_encrypted()) {
1485 for (
auto const& i: cpl->additional_subtitle_languages()) {
1486 verify_language_tag(context, i);
1489 if (!cpl->content_kind().scope() || *cpl->content_kind().scope() ==
"http://www.smpte-ra.org/schemas/429-7/2006/CPL#standard-content") {
1493 auto all = ContentKind::all();
1494 auto name = cpl->content_kind().name();
1495 transform(name.begin(), name.end(), name.begin(), ::tolower);
1496 auto iter = std::find_if(all.begin(), all.end(), [name](
ContentKind const& k) { return !k.scope() && k.name() == name; });
1497 if (iter == all.end()) {
1504 if (cpl->release_territory()) {
1505 if (!cpl->release_territory_scope() || cpl->release_territory_scope().get() !=
"http://www.smpte-ra.org/schemas/429-16/2014/CPL-Metadata#scope/release-territory/UNM49") {
1506 auto terr = cpl->release_territory().get();
1512 if (terr !=
"001") {
1523 for (
auto version: cpl->content_versions()) {
1524 if (version.label_text.empty()) {
1532 if (context.dcp->standard() == Standard::SMPTE) {
1533 if (!cpl->annotation_text()) {
1535 }
else if (cpl->annotation_text().get() != cpl->content_title_text()) {
1542 for (
auto i: context.dcp->pkls()) {
1544 optional<string> h = i->hash(cpl->id());
1546 if (h && calculated_cpl_hash != *h) {
1549 VerificationNote::Type::ERROR,
1552 ).set_calculated_hash(calculated_cpl_hash).set_reference_hash(*h)
1559 optional<string> required_annotation_text;
1560 for (
auto j: i->assets()) {
1562 for (
auto k: context.dcp->cpls()) {
1563 if (j->id() == k->id()) {
1564 if (!required_annotation_text) {
1566 required_annotation_text = cpl->content_title_text();
1569 required_annotation_text = boost::none;
1575 if (required_annotation_text && i->annotation_text() != required_annotation_text) {
1583 auto have_main_subtitle =
false;
1585 auto have_no_main_subtitle =
false;
1587 size_t fewest_closed_captions = SIZE_MAX;
1589 size_t most_closed_captions = 0;
1590 map<Marker, Time> markers_seen;
1592 auto const main_picture_active_area = cpl->main_picture_active_area();
1593 bool active_area_ok =
true;
1594 if (main_picture_active_area && (main_picture_active_area->width % 2)) {
1597 String::compose(
"width %1 is not a multiple of 2", main_picture_active_area->width),
1600 active_area_ok =
false;
1602 if (main_picture_active_area && (main_picture_active_area->height % 2)) {
1605 String::compose(
"height %1 is not a multiple of 2", main_picture_active_area->height),
1608 active_area_ok =
false;
1611 if (main_picture_active_area && active_area_ok) {
1619 for (
auto reel: cpl->reels()) {
1620 context.stage(
"Checking reel", optional<boost::filesystem::path>());
1625 main_picture_active_area,
1626 &have_main_subtitle,
1627 &have_no_main_subtitle,
1628 &most_closed_captions,
1629 &fewest_closed_captions,
1632 frame += reel->duration();
1637 if (context.dcp->standard() == Standard::SMPTE) {
1638 if (
auto msc = cpl->main_sound_configuration()) {
1639 if (context.audio_channels && msc->channels() != *context.audio_channels) {
1642 String::compose(
"MainSoundConfiguration has %1 channels but sound assets have %2", msc->channels(), *context.audio_channels),
1648 if (have_main_subtitle && have_no_main_subtitle) {
1652 if (fewest_closed_captions != most_closed_captions) {
1656 if (cpl->content_kind() == ContentKind::FEATURE) {
1657 if (markers_seen.find(
Marker::FFEC) == markers_seen.end()) {
1660 if (markers_seen.find(
Marker::FFMC) == markers_seen.end()) {
1666 if (ffoc == markers_seen.end()) {
1668 }
else if (ffoc->second.e != 1) {
1673 if (lfoc == markers_seen.end()) {
1676 auto lfoc_time = lfoc->second.as_editable_units_ceil(lfoc->second.tcr);
1677 if (lfoc_time != (cpl->reels().back()->duration() - 1)) {
1683 for (
auto reel: cpl->reels()) {
1684 if (reel->main_subtitle() && reel->main_subtitle()->asset_ref().resolved()) {
1689 if (result.line_count_exceeded) {
1692 if (result.error_length_exceeded) {
1694 }
else if (result.warning_length_exceeded) {
1699 for (
auto reel: cpl->reels()) {
1700 for (
auto i: reel->closed_captions()) {
1707 if (result.line_count_exceeded) {
1710 if (result.error_length_exceeded) {
1714 if (!cpl->read_composition_metadata()) {
1716 }
else if (!cpl->version_number()) {
1720 verify_extension_metadata(context);
1722 if (cpl->any_encrypted()) {
1723 cxml::Document doc(
"CompositionPlaylist");
1724 DCP_ASSERT(cpl->file());
1725 doc.read_file(dcp::filesystem::fix_long_path(cpl->file().get()));
1726 if (!doc.optional_node_child(
"Signature")) {
1736 verify_pkl(
Context& context, shared_ptr<const PKL> pkl)
1738 validate_xml(context, pkl->file().get());
1740 if (pkl_has_encrypted_assets(context.dcp, pkl)) {
1741 cxml::Document doc(
"PackingList");
1742 doc.read_file(dcp::filesystem::fix_long_path(pkl->file().get()));
1743 if (!doc.optional_node_child(
"Signature")) {
1748 set<string> uuid_set;
1749 for (
auto asset: pkl->assets()) {
1750 if (!uuid_set.insert(asset->id()).second) {
1761 verify_assetmap(
Context& context, shared_ptr<const DCP>
dcp)
1763 auto asset_map =
dcp->asset_map();
1764 DCP_ASSERT(asset_map);
1766 validate_xml(context, asset_map->file().get());
1768 set<string> uuid_set;
1769 for (
auto const& asset: asset_map->assets()) {
1770 if (!uuid_set.insert(asset.id()).second) {
1780 vector<boost::filesystem::path> directories,
1781 vector<dcp::DecryptedKDM> kdms,
1782 function<
void (
string, optional<boost::filesystem::path>)> stage,
1783 function<
void (
float)> progress,
1785 optional<boost::filesystem::path> xsd_dtd_directory
1788 if (!xsd_dtd_directory) {
1789 xsd_dtd_directory = resources_directory() /
"xsd";
1791 *xsd_dtd_directory = filesystem::canonical(*xsd_dtd_directory);
1793 vector<VerificationNote> notes;
1794 Context context(notes, *xsd_dtd_directory, stage, progress, options);
1796 vector<shared_ptr<DCP>> dcps;
1797 for (
auto i: directories) {
1798 dcps.push_back (make_shared<DCP>(i));
1801 for (
auto dcp: dcps) {
1802 stage (
"Checking DCP",
dcp->directory());
1806 bool carry_on =
true;
1808 dcp->read (¬es,
true);
1820 }
catch (cxml::Error& e) {
1822 }
catch (xmlpp::parse_error& e) {
1831 if (
dcp->standard() != Standard::SMPTE) {
1835 for (
auto kdm: kdms) {
1839 for (
auto cpl:
dcp->cpls()) {
1842 verify_cpl(context, cpl);
1843 context.cpl.reset();
1849 for (
auto pkl:
dcp->pkls()) {
1850 stage(
"Checking PKL", pkl->file());
1851 verify_pkl(context, pkl);
1854 if (
dcp->asset_map_file()) {
1855 stage(
"Checking ASSETMAP",
dcp->asset_map_file().get());
1856 verify_assetmap(context,
dcp);
1862 return { notes, dcps };
1867 dcp::note_to_string(
VerificationNote note,
function<
string (
string)> process_string,
function<
string (
string)> process_filename)
1880 auto filename = [note, process_filename]() {
1881 return process_filename(note.file()->filename().string());
1884 #define compose(format, ...) String::compose(process_string(format), __VA_ARGS__)
1886 switch (note.code()) {
1888 return process_string(*note.note());
1890 return process_string(
"The hash of the CPL in the PKL matches the CPL file.");
1892 return compose(
"The hash (%1) of the CPL (%2) in the PKL does not agree with the CPL file (%3).", note.reference_hash().get(), note.cpl_id().get(), note.calculated_hash().get());
1894 return compose(
"The picture in a reel has an invalid frame rate %1.", note.note().get());
1896 return compose(
"The hash (%1) of the picture asset %2 does not agree with the PKL file (%3).", note.calculated_hash().get(), filename(), note.reference_hash().get());
1898 return compose(
"The picture asset %1 has the expected hashes in the CPL and PKL.", filename());
1900 return compose(
"The PKL and CPL hashes differ for the picture asset %1.", filename());
1902 return compose(
"The hash (%1) of the sound asset %2 does not agree with the PKL file (%3).", note.calculated_hash().get(), filename(), note.reference_hash().get());
1904 return compose(
"The PKL and CPL hashes differ for the sound asset %1.", filename());
1906 return process_string(
"The asset map contains an empty asset path.");
1908 return compose(
"The file %1 for an asset in the asset map cannot be found.", filename());
1910 return process_string(
"The DCP contains both SMPTE and Interop parts.");
1912 return compose(
"An XML file is badly formed: %1 (%2:%3)", note.note().get(), filename(), note.line().get());
1914 return process_string(
"No valid ASSETMAP or ASSETMAP.xml was found.");
1916 return compose(
"The intrinsic duration of the asset %1 is less than 1 second.", note.note().get());
1918 return compose(
"The duration of the asset %1 is less than 1 second.", note.note().get());
1920 return compose(
"Each frame of the picture asset %1 has a bit rate safely under the limit of 250Mbit/s.", filename());
1923 "Frame %1 (timecode %2) in asset %3 has an instantaneous bit rate that is larger than the limit of 250Mbit/s.",
1925 dcp::Time(note.frame().get(), note.frame_rate().get(), note.frame_rate().get()).
as_string(dcp::Standard::SMPTE),
1930 "Frame %1 (timecode %2) in asset %3 has an instantaneous bit rate that is close to the limit of 250Mbit/s.",
1932 dcp::Time(note.frame().get(), note.frame_rate().get(), note.frame_rate().get()).
as_string(dcp::Standard::SMPTE),
1936 return compose(
"The asset %1 that this DCP refers to is not included in the DCP. It may be a VF.", note.note().get());
1938 return compose(
"The asset %1 is 3D but its MXF is marked as 2D.", filename());
1940 return "This DCP does not use the SMPTE standard.";
1942 return compose(
"The DCP specifies a language '%1' which does not conform to the RFC 5646 standard.", note.note().get());
1944 return compose(
"Valid release territory %1.", note.note().get());
1946 return compose(
"The size %1 of picture asset %2 is not allowed.", note.note().get(), filename());
1948 return compose(
"The frame rate %1 of picture asset %2 is not allowed for 2K DCPs.", note.note().get(), filename());
1950 return compose(
"The frame rate %1 of picture asset %2 is not allowed for 4K DCPs.", note.note().get(), filename());
1952 return process_string(
"3D 4K DCPs are not allowed.");
1954 return compose(
"The size %1 of the closed caption asset %2 is larger than the 256KB maximum.", note.note().get(), filename());
1956 return compose(
"The size %1 of the timed text asset %2 is larger than the 115MB maximum.", note.note().get(), filename());
1958 return compose(
"The size %1 of the fonts in timed text asset %2 is larger than the 10MB maximum.", note.note().get(), filename());
1960 return compose(
"The XML for the SMPTE subtitle asset %1 has no <Language> tag.", filename());
1962 return process_string(
"Some subtitle assets have different <Language> tags than others");
1964 return compose(
"The XML for the SMPTE subtitle asset %1 has no <StartTime> tag.", filename());
1966 return compose(
"The XML for a SMPTE subtitle asset %1 has a non-zero <StartTime> tag.", filename());
1968 return process_string(
"The first subtitle or closed caption is less than 4 seconds from the start of the DCP.");
1970 return process_string(
"At least one subtitle lasts less than 15 frames.");
1972 return process_string(
"At least one pair of subtitles is separated by less than 2 frames.");
1974 return process_string(
"At least one subtitle extends outside of its reel.");
1976 return process_string(
"There are more than 3 subtitle lines in at least one place in the DCP.");
1978 return process_string(
"There are more than 52 characters in at least one subtitle line.");
1980 return process_string(
"There are more than 79 characters in at least one subtitle line.");
1982 return process_string(
"There are more than 3 closed caption lines in at least one place.");
1984 return process_string(
"There are more than 32 characters in at least one closed caption line.");
1986 return compose(
"The sound asset %1 has a sampling rate of %2", filename(), note.note().get());
1988 return compose(
"The sound asset %1 has a bit depth of %2", filename(), note.note().get());
1990 return compose(
"The CPL %1 has no <AnnotationText> tag.", note.cpl_id().get());
1992 return compose(
"The CPL %1 has an <AnnotationText> which differs from its <ContentTitleText>.", note.cpl_id().get());
1994 return compose(
"Valid CPL annotation text %1", note.note().get());
1996 return process_string(
"All assets in a reel do not have the same duration.");
1998 return process_string(
"At least one reel contains a subtitle asset, but some reel(s) do not.");
2000 return process_string(
"At least one reel has closed captions, but reels have different numbers of closed caption assets.");
2002 return compose(
"The subtitle asset %1 has no <EntryPoint> tag.", note.note().get());
2004 return compose(
"The subtitle asset %1 has an <EntryPoint> other than 0.", note.note().get());
2006 return compose(
"The closed caption asset %1 has no <EntryPoint> tag.", note.note().get());
2008 return compose(
"The closed caption asset %1 has an <EntryPoint> other than 0.", note.note().get());
2010 return compose(
"The asset %1 has no <Hash> tag in the CPL.", note.note().get());
2012 return process_string(
"The DCP is marked as a Feature but there is no FFEC (first frame of end credits) marker.");
2014 return process_string(
"The DCP is marked as a Feature but there is no FFMC (first frame of moving credits) marker.");
2016 return process_string(
"There should be a FFOC (first frame of content) marker.");
2018 return process_string(
"There should be a LFOC (last frame of content) marker.");
2020 return compose(
"The FFOC marker is %1 instead of 1", note.note().get());
2022 return compose(
"The LFOC marker is %1 instead of 1 less than the duration of the last reel.", note.note().get());
2024 return compose(
"The CPL %1 has no <CompositionMetadataAsset> tag.", note.cpl_id().get());
2026 return compose(
"The CPL %1 has no <VersionNumber> in its <CompositionMetadataAsset>.", note.cpl_id().get());
2028 return compose(
"The CPL %1 has no <ExtensionMetadata> in its <CompositionMetadataAsset>.", note.cpl_id().get());
2030 return compose(
"The CPL %1 has a malformed <ExtensionMetadata> (%2).", filename(), note.note().get());
2032 return compose(
"The CPL %1, which has encrypted content, is not signed.", note.cpl_id().get());
2034 return compose(
"The PKL %1, which has encrypted content, is not signed.", note.note().get());
2036 return compose(
"The PKL %1 has only one CPL but its <AnnotationText> does not match the CPL's <ContentTitleText>.", note.note().get());
2038 return process_string(
"The PKL and CPL annotation texts match.");
2040 return process_string(
"All the assets are encrypted.");
2042 return process_string(
"All the assets are unencrypted.");
2044 return process_string(
"Some assets are encrypted but some are not.");
2047 "Frame %1 (timecode %2) has an invalid JPEG2000 codestream (%3).",
2049 dcp::Time(note.frame().get(), note.frame_rate().get(), note.frame_rate().get()).
as_string(dcp::Standard::SMPTE),
2053 return compose(
"The JPEG2000 codestream uses %1 guard bits in a 2K image instead of 1.", note.note().get());
2055 return compose(
"The JPEG2000 codestream uses %1 guard bits in a 4K image instead of 2.", note.note().get());
2057 return process_string(
"The JPEG2000 tile size is not the same as the image size.");
2059 return compose(
"The JPEG2000 codestream uses a code block width of %1 instead of 32.", note.note().get());
2061 return compose(
"The JPEG2000 codestream uses a code block height of %1 instead of 32.", note.note().get());
2063 return compose(
"%1 POC markers found in 2K JPEG2000 codestream instead of 0.", note.note().get());
2065 return compose(
"%1 POC markers found in 4K JPEG2000 codestream instead of 1.", note.note().get());
2067 return compose(
"Incorrect POC marker content found (%1).", note.note().get());
2069 return process_string(
"POC marker found outside main header.");
2071 return compose(
"The JPEG2000 codestream has %1 tile parts in a 2K image instead of 3.", note.note().get());
2073 return compose(
"The JPEG2000 codestream has %1 tile parts in a 4K image instead of 6.", note.note().get());
2075 return process_string(
"No TLM marker was found in a JPEG2000 codestream.");
2077 return process_string(
"The Resource ID in a timed text MXF did not match the ID of the contained XML.");
2079 return process_string(
"The Asset ID in a timed text MXF is the same as the Resource ID or that of the contained XML.");
2082 vector<string> parts;
2083 boost::split (parts, note.note().get(), boost::is_any_of(
" "));
2084 DCP_ASSERT (parts.size() == 2);
2085 return compose(
"The reel duration of some timed text (%1) is not the same as the ContainerDuration of its MXF (%2).", parts[0], parts[1]);
2088 return process_string(
"Some aspect of this DCP could not be checked because it is encrypted.");
2090 return process_string(
"There is an empty <Text> node in a subtitle or closed caption.");
2092 return process_string(
"Some closed <Text> or <Image> nodes have different vertical alignments within a <Subtitle>.");
2094 return process_string(
"Some closed captions are not listed in the order of their vertical position.");
2096 return process_string(
"There is an <EntryPoint> node inside a <MainMarkers>.");
2098 return process_string(
"There is an <Duration> node inside a <MainMarkers>.");
2100 return compose(
"<ContentKind> has an invalid value %1.", note.note().get());
2102 return compose(
"Valid <ContentKind> %1.", note.note().get());
2104 return compose(
"<MainPictureActiveaArea> has an invalid value: %1", note.note().get());
2106 return compose(
"<MainPictureActiveaArea> %1 is valid", note.note().get());
2108 return compose(
"The PKL %1 has more than one asset with the same ID.", note.note().get());
2110 return compose(
"The ASSETMAP %1 has more than one asset with the same ID.", note.note().get());
2112 return compose(
"The subtitle asset %1 has no subtitles.", note.note().get());
2114 return compose(
"<IssueDate> has an invalid value: %1", note.note().get());
2116 return compose(
"The sound assets do not all have the same channel count; the first to differ is %1", filename());
2118 return compose(
"<MainSoundConfiguration> has an invalid value: %1", note.note().get());
2120 return compose(
"The font file for font ID \"%1\" was not found, or was not referred to in the ASSETMAP.", note.note().get());
2123 "Frame %1 has an image component that is too large (component %2 is %3 bytes in size).",
2124 note.frame().get(), note.component().get(), note.size().get()
2127 return compose(
"The XML in the subtitle asset %1 has more than one namespace declaration.", note.note().get());
2129 return compose(
"A subtitle or closed caption refers to a font with ID %1 that does not have a corresponding <LoadFont> node", note.id().get());
2131 return compose(
"The SMPTE subtitle asset %1 has <Text> nodes but no <LoadFont> node", note.id().get());
2133 return compose(
"The asset with ID %1 in the asset map actually has an id of %2", note.id().get(), note.other_id().get());
2135 return compose(
"The <LabelText> in a <ContentVersion> in CPL %1 is empty", note.cpl_id().get());
2137 return compose(
"CPL has valid <ContentVersion> %1", note.note().get());
2139 return compose(
"The namespace %1 in CPL %2 is invalid", note.note().get(), note.cpl_id().get());
2141 return compose(
"The CPL %1 has no <ContentVersion> tag", note.cpl_id().get());
2143 return compose(
"The namespace %1 in PKL %2 is invalid", note.note().get(), note.file()->filename());
2153 return a.type() == b.type() &&
2154 a.code() == b.code() &&
2155 a.note() == b.note() &&
2156 a.file() == b.file() &&
2157 a.line() == b.line() &&
2158 a.frame() == b.frame() &&
2159 a.component() == b.component() &&
2160 a.size() == b.size() &&
2162 a.other_id() == b.other_id() &&
2163 a.frame_rate() == b.frame_rate() &&
2164 a.cpl_id() == b.cpl_id() &&
2165 a.reference_hash() == b.reference_hash() &&
2166 a.calculated_hash() == b.calculated_hash();
2180 if (a.type() != b.type()) {
2181 return a.type() < b.type();
2184 if (a.code() != b.code()) {
2185 return a.code() < b.code();
2188 if (a.note() != b.note()) {
2189 return a.note().get_value_or(
"") < b.note().get_value_or(
"");
2192 if (a.file() != b.file()) {
2193 return a.file().get_value_or(
"") < b.file().get_value_or(
"");
2196 if (a.line() != b.line()) {
2197 return a.line().get_value_or(0) < b.line().get_value_or(0);
2200 if (a.frame() != b.frame()) {
2201 return a.frame().get_value_or(0) < b.frame().get_value_or(0);
2204 if (a.component() != b.component()) {
2205 return a.component().get_value_or(0) < b.component().get_value_or(0);
2208 if (a.size() != b.size()) {
2209 return a.size().get_value_or(0) < b.size().get_value_or(0);
2212 if (a.id() != b.id()) {
2213 return a.id().get_value_or(
"") < b.id().get_value_or(
"");
2216 if (a.other_id() != b.other_id()) {
2217 return a.other_id().get_value_or(
"") < b.other_id().get_value_or(
"");
2220 return a.frame_rate().get_value_or(0) != b.frame_rate().get_value_or(0);
2227 s << note_to_string (note);
2229 s <<
" [" << note.note().get() <<
"]";
2232 s <<
" [" << note.file().get() <<
"]";
2235 s <<
" [" << note.line().get() <<
"]";
Class to hold an arbitrary block of data.
A fraction (i.e. a thing with an integer numerator and an integer denominator).
An exception related to an MXF file.
A miscellaneous exception.
Thrown when no ASSETMAP was found when trying to read a DCP.
Any error that occurs when reading data from a DCP.
A representation of time within a DCP.
int64_t as_editable_units_ceil(int tcr_) const
int64_t as_editable_units_floor(int tcr_) const
std::string as_string(Standard standard) const
@ INVALID_INTRINSIC_DURATION
@ INVALID_CLOSED_CAPTION_LINE_COUNT
@ INVALID_PICTURE_FRAME_RATE_FOR_4K
@ MISMATCHED_CPL_ANNOTATION_TEXT
@ MISSING_EXTENSION_METADATA
@ MISMATCHED_ASSET_MAP_ID
@ INVALID_SUBTITLE_FIRST_TEXT_TIME
@ MISSING_JPEG200_TLM_MARKER
@ INVALID_MAIN_PICTURE_ACTIVE_AREA
@ MISMATCHED_SUBTITLE_LANGUAGES
@ MISMATCHED_SOUND_CHANNEL_COUNTS
@ VALID_MAIN_PICTURE_ACTIVE_AREA
@ VALID_RELEASE_TERRITORY
@ MISSING_CPL_CONTENT_VERSION
@ DUPLICATE_ASSET_ID_IN_ASSETMAP
@ INVALID_JPEG2000_TILE_PARTS_FOR_2K
@ INVALID_JPEG2000_CODE_BLOCK_HEIGHT
@ INVALID_TIMED_TEXT_SIZE_IN_BYTES
@ INVALID_JPEG2000_CODESTREAM
@ NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES
@ INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES
@ INCORRECT_JPEG2000_POC_MARKER
@ INVALID_SUBTITLE_LINE_COUNT
@ UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT
@ MATCHING_PKL_ANNOTATION_TEXT_WITH_CPL
@ INVALID_JPEG2000_GUARD_BITS_FOR_2K
@ THREED_ASSET_MARKED_AS_TWOD
@ INVALID_SUBTITLE_ISSUE_DATE
@ INCORRECT_SUBTITLE_ENTRY_POINT
@ MISSING_FFMC_IN_FEATURE
@ EMPTY_CONTENT_VERSION_LABEL_TEXT
@ INVALID_SUBTITLE_SPACING
@ MISSED_CHECK_OF_ENCRYPTED
@ MISMATCHED_CLOSED_CAPTION_VALIGN
@ MISSING_SUBTITLE_START_TIME
@ INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D
@ INVALID_SOUND_FRAME_RATE
@ MISMATCHED_ASSET_DURATION
@ MISSING_CPL_ANNOTATION_TEXT
@ MISSING_SUBTITLE_ENTRY_POINT
@ INVALID_EXTENSION_METADATA
@ MISMATCHED_CLOSED_CAPTION_ASSET_COUNTS
@ INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_2K
@ INVALID_SOUND_BIT_DEPTH
@ INCORRECT_CLOSED_CAPTION_ORDERING
@ MISMATCHED_TIMED_TEXT_RESOURCE_ID
@ INVALID_PICTURE_FRAME_RATE_FOR_2K
@ INVALID_SUBTITLE_DURATION
@ MISSING_LOAD_FONT_FOR_FONT
@ INVALID_CLOSED_CAPTION_LINE_LENGTH
@ MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL
@ SUBTITLE_OVERLAPS_REEL_BOUNDARY
@ MISMATCHED_TIMED_TEXT_DURATION
@ VALID_CONTENT_VERSION_LABEL_TEXT
@ INVALID_SUBTITLE_START_TIME
@ MISMATCHED_SOUND_HASHES
@ MISSING_FFEC_IN_FEATURE
@ INVALID_JPEG2000_TILE_SIZE
@ INVALID_JPEG2000_TILE_PART_SIZE
@ INVALID_MAIN_SOUND_CONFIGURATION
@ INVALID_JPEG2000_POC_MARKER_LOCATION
@ DUPLICATE_ASSET_ID_IN_PKL
@ MISMATCHED_PICTURE_HASHES
@ MISSING_SUBTITLE_LANGUAGE
@ INCORRECT_TIMED_TEXT_ASSET_ID
@ VALID_PICTURE_FRAME_SIZES_IN_BYTES
@ MISSING_CPL_METADATA_VERSION_NUMBER
@ INCORRECT_SUBTITLE_NAMESPACE_COUNT
@ INVALID_PICTURE_SIZE_IN_PIXELS
@ MISSING_CLOSED_CAPTION_ENTRY_POINT
@ INCORRECT_CLOSED_CAPTION_ENTRY_POINT
@ INVALID_JPEG2000_TILE_PARTS_FOR_4K
@ INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_4K
@ INVALID_PICTURE_FRAME_RATE
@ UNSIGNED_CPL_WITH_ENCRYPTED_CONTENT
@ INVALID_JPEG2000_CODE_BLOCK_WIDTH
@ INVALID_SUBTITLE_LINE_LENGTH
@ VALID_CPL_ANNOTATION_TEXT
@ INVALID_JPEG2000_GUARD_BITS_FOR_4K
@ MISSING_MAIN_SUBTITLE_FROM_SOME_REELS
@ INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES
@ INVALID_PICTURE_FRAME_SIZE_IN_BYTES
@ NEARLY_INVALID_SUBTITLE_LINE_LENGTH
@ BV21_ERROR
may not always be considered an error, but violates a "shall" requirement of Bv2.1
Exceptions thrown by libdcp.
MonoJ2KPictureAsset class.
MonoJ2KPictureFrame class.
Namespace for everything in libdcp.
void verify_j2k(std::shared_ptr< const Data > data, int start_index, int frame_index, int frame_rate, std::vector< VerificationNote > ¬es)
@ FFEC
first frame of end credits
@ FFMC
first frame of moving credits
@ LFOC
last frame of composition
@ FFOC
first frame of composition
void verify_text_lines_and_characters(std::shared_ptr< const dcp::TextAsset > asset, int warning_length, int error_length, dcp::LinesCharactersResult *result)
std::string make_digest(boost::filesystem::path filename, boost::function< void(int64_t, int64_t)>)
Methods for conversion to/from string.
ReelInteropTextAsset class.
ReelSMPTETextAsset class.
StereoJ2KPictureAsset class.
StereoJ2KPictureFrame class.
The integer, two-dimensional size of something.
boost::optional< boost::uintmax_t > maximum_asset_size_for_hash_check
< If set, any assets larger than this number of bytes will not have their hashes checked
void verify_smpte_timed_text_asset(Context &context, shared_ptr< const SMPTETextAsset > asset, optional< int64_t > reel_asset_duration)
static void verify_closed_caption_asset(Context &context, shared_ptr< const TextAsset > asset, optional< int64_t > reel_asset_duration)
static void verify_text_details(Context &context, vector< shared_ptr< Reel >> reels, int edit_rate, std::function< bool(shared_ptr< Reel >)> check, std::function< optional< string >(shared_ptr< Reel >)> xml, std::function< int64_t(shared_ptr< Reel >)> duration, std::function< std::string(shared_ptr< Reel >)> id)
static void verify_subtitle_asset(Context &context, shared_ptr< const TextAsset > asset, optional< int64_t > reel_asset_duration)
void verify_smpte_subtitle_asset(Context &context, shared_ptr< const SMPTETextAsset > asset)
void verify_interop_text_asset(Context &context, shared_ptr< const InteropTextAsset > asset)
dcp::verify() method and associated code
Verification-related things exposed for testing.
Verification that JPEG2000 files meet requirements.