diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-12-06 10:47:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-12-22 01:21:00 +0100 |
| commit | 30dfa051113792305f9704d5a76ffaf57c21063d (patch) | |
| tree | 4a4055b40bfb64ebf5b7509ef81a104db4a52e46 /tools | |
| parent | 9cb23adda9ebe6a76992b68db78ccb638348dac1 (diff) | |
Use VerificationNote for non-fatal errors in DCP::read.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/common.cc | 10 | ||||
| -rw-r--r-- | tools/common.h | 6 | ||||
| -rw-r--r-- | tools/dcpdiff.cc | 26 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 43 | ||||
| -rw-r--r-- | tools/dcprecover.cc | 8 | ||||
| -rw-r--r-- | tools/dcpverify.cc | 23 |
6 files changed, 35 insertions, 81 deletions
diff --git a/tools/common.cc b/tools/common.cc index cda6817b..7ae3dae0 100644 --- a/tools/common.cc +++ b/tools/common.cc @@ -39,15 +39,15 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; void -dcp::filter_errors (dcp::DCP::ReadErrors& errors, bool ignore_missing_assets) +dcp::filter_notes (list<dcp::VerificationNote>& notes, bool ignore_missing_assets) { - for (DCP::ReadErrors::iterator i = errors.begin(); i != errors.end(); ) { + for (list<dcp::VerificationNote>::iterator i = notes.begin(); i != notes.end(); ) { - DCP::ReadErrors::iterator tmp = i; + list<dcp::VerificationNote>::iterator tmp = i; ++tmp; - if (ignore_missing_assets && dynamic_pointer_cast<MissingAssetError> (*i)) { - errors.erase (i); + if (ignore_missing_assets && i->code() == dcp::VerificationNote::Code::MISSING_ASSET) { + notes.erase (i); } i = tmp; diff --git a/tools/common.h b/tools/common.h index cea183db..0ef0b081 100644 --- a/tools/common.h +++ b/tools/common.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -17,10 +17,10 @@ along with libdcp. If not, see <http://www.gnu.org/licenses/>. */ -#include "exceptions.h" +#include "verify.h" namespace dcp { -extern void filter_errors (std::list<boost::shared_ptr<DCPReadError> >& errors, bool ignore_missing_assets); +extern void filter_notes (std::list<dcp::VerificationNote>& notes, bool ignore_missing_assets); } diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index 5e0560a0..976a2919 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -39,6 +39,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> #include <boost/filesystem.hpp> +#include <boost/foreach.hpp> #include <iostream> #include <list> @@ -67,7 +68,6 @@ help (string n) << " -m, --mean-pixel maximum allowed mean pixel error (default 5)\n" << " -s, --std-dev-pixel maximum allowed standard deviation of pixel error (default 5)\n" << " --key hexadecimal key to use to decrypt MXFs\n" - << " -k, --keep-going carry on in the event of errors, if possible\n" << " --ignore-missing-assets ignore missing asset files\n" << "\n" << "The <DCP>s are the DCP directories to compare.\n" @@ -84,17 +84,18 @@ note (NoteType t, string n) } } +static DCP * -load_dcp (boost::filesystem::path path, bool keep_going, bool ignore_missing_assets, optional<string> key) +load_dcp (boost::filesystem::path path, bool ignore_missing_assets, optional<string> key) { DCP* dcp = 0; try { dcp = new DCP (path); - DCP::ReadErrors errors; - dcp->read (keep_going, &errors); - filter_errors (errors, ignore_missing_assets); - for (DCP::ReadErrors::const_iterator i = errors.begin(); i != errors.end(); ++i) { - cerr << (*i)->what() << "\n"; + list<dcp::VerificationNote> notes; + dcp->read (¬es); + filter_notes (notes, ignore_missing_assets); + BOOST_FOREACH (dcp::VerificationNote i, notes) { + cerr << dcp::note_to_string(i) << "\n"; } if (key) { @@ -123,7 +124,6 @@ main (int argc, char* argv[]) options.max_std_dev_pixel_error = 5; options.reel_hashes_can_differ = true; options.reel_annotation_texts_can_differ = false; - options.keep_going = false; bool ignore_missing_assets = false; optional<string> key; @@ -135,7 +135,6 @@ main (int argc, char* argv[]) { "verbose", no_argument, 0, 'v'}, { "mean-pixel", required_argument, 0, 'm'}, { "std-dev-pixel", required_argument, 0, 's'}, - { "keep-going", no_argument, 0, 'k'}, { "annotation-texts", no_argument, 0, 'a'}, { "issue-dates", no_argument, 0, 'd'}, /* From here we're using random capital letters for the short option */ @@ -146,7 +145,7 @@ main (int argc, char* argv[]) { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "Vhvm:s:kadACD:E", long_options, &option_index); + int c = getopt_long (argc, argv, "Vhvm:s:adACD:E", long_options, &option_index); if (c == -1) { break; @@ -168,9 +167,6 @@ main (int argc, char* argv[]) case 's': options.max_std_dev_pixel_error = atof (optarg); break; - case 'k': - options.keep_going = true; - break; case 'a': options.cpl_annotation_texts_can_differ = options.reel_annotation_texts_can_differ = true; break; @@ -208,8 +204,8 @@ main (int argc, char* argv[]) exit (EXIT_FAILURE); } - DCP* a = load_dcp (argv[optind], options.keep_going, ignore_missing_assets, key); - DCP* b = load_dcp (argv[optind + 1], options.keep_going, ignore_missing_assets, key); + DCP* a = load_dcp (argv[optind], ignore_missing_assets, key); + DCP* b = load_dcp (argv[optind + 1], ignore_missing_assets, key); /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */ options.max_audio_sample_error = 255; diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index d06d2068..7010bbab 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -76,7 +76,6 @@ help (string n) << " -s, --subtitles list all subtitles\n" << " -p, --picture analyse picture\n" << " -d, --decompress decompress picture when analysing (this is slow)\n" - << " -k, --keep-going carry on in the event of errors, if possible\n" << " --kdm KDM to decrypt DCP\n" << " --private-key private key for the certificate that the KDM is targeted at\n" << " --ignore-missing-assets ignore missing asset files\n"; @@ -217,7 +216,6 @@ int main (int argc, char* argv[]) { bool subtitles = false; - bool keep_going = false; bool picture = false; bool decompress = false; bool ignore_missing_assets = false; @@ -230,7 +228,6 @@ main (int argc, char* argv[]) { "version", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' }, { "subtitles", no_argument, 0, 's' }, - { "keep-going", no_argument, 0, 'k' }, { "picture", no_argument, 0, 'p' }, { "decompress", no_argument, 0, 'd' }, { "ignore-missing-assets", no_argument, 0, 'A' }, @@ -239,7 +236,7 @@ main (int argc, char* argv[]) { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "vhskpdAB:C:", long_options, &option_index); + int c = getopt_long (argc, argv, "vhspdAB:C:", long_options, &option_index); if (c == -1) { break; @@ -255,9 +252,6 @@ main (int argc, char* argv[]) case 's': subtitles = true; break; - case 'k': - keep_going = true; - break; case 'p': picture = true; break; @@ -289,10 +283,10 @@ main (int argc, char* argv[]) list<shared_ptr<CPL> > cpls; if (boost::filesystem::is_directory(argv[optind])) { DCP* dcp = 0; - DCP::ReadErrors errors; + list<dcp::VerificationNote> notes; try { dcp = new DCP (argv[optind]); - dcp->read (keep_going, &errors); + dcp->read (¬es); if (kdm && private_key) { dcp->add(DecryptedKDM(EncryptedKDM(file_to_string(*kdm)), file_to_string(*private_key))); } @@ -309,15 +303,14 @@ main (int argc, char* argv[]) cout << "DCP: " << boost::filesystem::path(argv[optind]).string() << "\n"; - dcp::filter_errors (errors, ignore_missing_assets); - for (DCP::ReadErrors::const_iterator i = errors.begin(); i != errors.end(); ++i) { - cerr << "Error: " << (*i)->what() << "\n"; + dcp::filter_notes (notes, ignore_missing_assets); + BOOST_FOREACH (dcp::VerificationNote i, notes) { + cerr << "Error: " << note_to_string(i) << "\n"; } cpls = dcp->cpls (); } else { cpls.push_back (shared_ptr<CPL>(new CPL(boost::filesystem::path(argv[optind])))); - keep_going = true; ignore_missing_assets = true; } @@ -331,36 +324,24 @@ main (int argc, char* argv[]) try { main_picture (j, picture, decompress); } catch (UnresolvedRefError& e) { - if (keep_going) { - if (!ignore_missing_assets) { - cerr << e.what() << " (for main picture)\n"; - } - } else { - throw; + if (!ignore_missing_assets) { + cerr << e.what() << " (for main picture)\n"; } } try { main_sound (j); } catch (UnresolvedRefError& e) { - if (keep_going) { - if (!ignore_missing_assets) { - cerr << e.what() << " (for main sound)\n"; - } - } else { - throw; + if (!ignore_missing_assets) { + cerr << e.what() << " (for main sound)\n"; } } try { main_subtitle (j, subtitles); } catch (UnresolvedRefError& e) { - if (keep_going) { - if (!ignore_missing_assets) { - cerr << e.what() << " (for main subtitle)\n"; - } - } else { - throw; + if (!ignore_missing_assets) { + cerr << e.what() << " (for main subtitle)\n"; } } diff --git a/tools/dcprecover.cc b/tools/dcprecover.cc index b747a5da..eb3b0d82 100644 --- a/tools/dcprecover.cc +++ b/tools/dcprecover.cc @@ -100,15 +100,15 @@ main (int argc, char* argv[]) /* Try to read it and report errors */ dcp::DCP dcp (dcp_dir); - dcp::DCP::ReadErrors errors; + list<dcp::VerificationNote> notes; try { - dcp.read (true, &errors, true); + dcp.read (¬es, true); } catch (dcp::DCPReadError& e) { cout << "Error:" << e.what() << "\n"; } - BOOST_FOREACH (shared_ptr<dcp::DCPReadError> i, errors) { - cout << "Error: " << i->what() << "\n"; + BOOST_FOREACH (dcp::VerificationNote i, notes) { + cout << "Error: " << dcp::note_to_string(i) << "\n"; } /* Look for a CPL */ diff --git a/tools/dcpverify.cc b/tools/dcpverify.cc index 675b7522..0c69ba78 100644 --- a/tools/dcpverify.cc +++ b/tools/dcpverify.cc @@ -73,29 +73,6 @@ progress () } -std::string -note_to_string (dcp::VerificationNote note) -{ - switch (note.code()) { - case dcp::VerificationNote::GENERAL_READ: - return *note.note(); - case dcp::VerificationNote::CPL_HASH_INCORRECT: - return "The hash of the CPL in the PKL does not agree with the CPL file"; - case dcp::VerificationNote::INVALID_PICTURE_FRAME_RATE: - return "The picture in a reel has an invalid frame rate"; - case dcp::VerificationNote::PICTURE_HASH_INCORRECT: - return dcp::String::compose("The hash of the picture asset %1 does not agree with the PKL file", note.file()->filename()); - case dcp::VerificationNote::PKL_CPL_PICTURE_HASHES_DISAGREE: - return "The PKL and CPL hashes disagree for a picture asset."; - case dcp::VerificationNote::SOUND_HASH_INCORRECT: - return dcp::String::compose("The hash of the sound asset %1 does not agree with the PKL file", note.file()->filename()); - case dcp::VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE: - return "The PKL and CPL hashes disagree for a sound asset."; - } - - return ""; -} - int main (int argc, char* argv[]) { |
