diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-03 12:37:11 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-03 12:37:11 +0100 |
| commit | 8d0dde19b1a055b8a6341045c025a95273f06186 (patch) | |
| tree | d8287031b088ef0e1f9cfd0bb2e77b0255f65ed7 /tools | |
| parent | 113187d5d1e7e5a079eb26f99b31e687d503cc07 (diff) | |
Add --keep-going option.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/dcpdiff.cc | 20 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 133 |
2 files changed, 114 insertions, 39 deletions
diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index dda7c3c3..e4225ebc 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -20,6 +20,7 @@ help (string n) << " -n, --names allow differing MXF names\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" + << " -k, --keep-going carry on in the event of errors, if possible\n" << "\n" << "The <DCP>s are the DCP directories to compare.\n" << "Comparison is of metadata and content, ignoring timestamps\n" @@ -40,6 +41,7 @@ main (int argc, char* argv[]) EqualityOptions options; options.max_mean_pixel_error = 5; options.max_std_dev_pixel_error = 5; + bool keep_going = false; int option_index = 0; while (1) { @@ -50,10 +52,11 @@ main (int argc, char* argv[]) { "names", no_argument, 0, 'n'}, { "mean-pixel", required_argument, 0, 'm'}, { "std-dev-pixel", required_argument, 0, 's'}, + { "keep-going", no_argument, 0, 'k'}, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "Vhvnm:s:", long_options, &option_index); + int c = getopt_long (argc, argv, "Vhvnm:s:k", long_options, &option_index); if (c == -1) { break; @@ -78,6 +81,9 @@ main (int argc, char* argv[]) case 's': options.max_std_dev_pixel_error = atof (optarg); break; + case 'k': + keep_going = true; + break; } } @@ -99,7 +105,11 @@ main (int argc, char* argv[]) DCP* a = 0; try { a = new DCP (argv[optind]); - a->read (); + list<string> errors; + a->read (keep_going, &errors); + for (list<string>::const_iterator i = errors.begin(); i != errors.end(); ++i) { + cerr << *i << "\n"; + } } catch (FileError& e) { cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << " " << e.filename() << "\n"; exit (EXIT_FAILURE); @@ -108,7 +118,11 @@ main (int argc, char* argv[]) DCP* b = 0; try { b = new DCP (argv[optind + 1]); - b->read (); + list<string> errors; + b->read (keep_going, &errors); + for (list<string>::const_iterator i = errors.begin(); i != errors.end(); ++i) { + cerr << *i << "\n"; + } } catch (FileError& e) { cerr << "Could not read DCP " << argv[optind + 1] << "; " << e.what() << " " << e.filename() << "\n"; exit (EXIT_FAILURE); diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index 62751202..c69de8a7 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -44,13 +44,66 @@ static void help (string n) { cerr << "Syntax: " << n << " [options] <DCP>\n" - << " -s, --subtitles list all subtitles\n"; + << " -s, --subtitles list all subtitles\n" + << " -k, --keep-going carry on in the event of errors, if possible\n"; +} + +static void +main_picture (shared_ptr<Reel> reel) +{ + if (reel->main_picture() && reel->main_picture()->mxf()) { + cout << " Picture: " + << reel->main_picture()->mxf()->size().width + << "x" + << reel->main_picture()->mxf()->size().height << "\n"; + } +} + +static void +main_sound (shared_ptr<Reel> reel) +{ + if (reel->main_sound() && reel->main_sound()->mxf()) { + cout << " Sound: " + << reel->main_sound()->mxf()->channels() + << " channels at " + << reel->main_sound()->mxf()->sampling_rate() << "Hz\n"; + } +} + +static void +main_subtitle (shared_ptr<Reel> reel, bool list_subtitles) +{ + if (!reel->main_subtitle()) { + return; + } + + list<shared_ptr<SubtitleString> > subs = reel->main_subtitle()->subtitle_content()->subtitles (); + cout << " Subtitle: " << subs.size() << " subtitles in " << reel->main_subtitle()->subtitle_content()->language() << "\n"; + if (list_subtitles) { + for (list<shared_ptr<SubtitleString> >::const_iterator k = subs.begin(); k != subs.end(); ++k) { + cout << " " << (*k)->text() << "\n"; + cout << " " + << "font:" << (*k)->font() << "; " + << "italic:" << (*k)->italic() << "; " + << "color:" << (*k)->color() << "; " + << "in:" << (*k)->in() << "; " + << "out:" << (*k)->out() << "; " + << "v_position:" << (*k)->v_position() << "; " + << "v_align:" << (*k)->v_align() << "; " + << "effect:" << (*k)->effect() << "; " + << "effect_color:" << (*k)->effect_color() << "; " + << "fade_up_time:" << (*k)->fade_up_time() << "; " + << "fade_down_time:" << (*k)->fade_down_time() << "; " + << "size: " << (*k)->size() << "\n"; + } + } } int main (int argc, char* argv[]) { bool subtitles = false; + bool keep_going = false; int option_index = 0; while (1) { @@ -58,10 +111,11 @@ 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'}, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "vhs", long_options, &option_index); + int c = getopt_long (argc, argv, "vhsk", long_options, &option_index); if (c == -1) { break; @@ -77,6 +131,9 @@ main (int argc, char* argv[]) case 's': subtitles = true; break; + case 'k': + keep_going = true; + break; } } @@ -91,16 +148,24 @@ main (int argc, char* argv[]) } DCP* dcp = 0; + list<string> errors; try { dcp = new DCP (argv[optind]); - dcp->read (); + dcp->read (keep_going, &errors); } catch (FileError& e) { - cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << " " << e.filename() << "\n"; + cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n"; + exit (EXIT_FAILURE); + } catch (DCPReadError& e) { + cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n"; exit (EXIT_FAILURE); } - + cout << "DCP: " << boost::filesystem::path(argv[optind]).filename().string() << "\n"; + for (list<string>::const_iterator i = errors.begin(); i != errors.end(); ++i) { + cerr << "Error: " << *i << "\n"; + } + list<shared_ptr<CPL> > cpls = dcp->cpls (); for (list<shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) { @@ -111,41 +176,37 @@ main (int argc, char* argv[]) int R = 1; for (list<shared_ptr<Reel> >::const_iterator j = reels.begin(); j != reels.end(); ++j) { cout << " Reel " << R << "\n"; - - if ((*j)->main_picture()) { - cout << " Picture: " - << (*j)->main_picture()->mxf()->size().width - << "x" - << (*j)->main_picture()->mxf()->size().height << "\n"; + + try { + main_picture (*j); + } catch (UnresolvedRefError& e) { + if (keep_going) { + cerr << e.what() << " (for main picture)\n"; + } else { + throw; + } } - if ((*j)->main_sound()) { - cout << " Sound: " - << (*j)->main_sound()->mxf()->channels() - << " channels at " - << (*j)->main_sound()->mxf()->sampling_rate() << "Hz\n"; + + try { + main_sound (*j); + } catch (UnresolvedRefError& e) { + if (keep_going) { + cerr << e.what() << " (for main sound)\n"; + } else { + throw; + } } - if ((*j)->main_subtitle()) { - list<shared_ptr<SubtitleString> > subs = (*j)->main_subtitle()->subtitle_content()->subtitles (); - cout << " Subtitle: " << subs.size() << " subtitles in " << (*j)->main_subtitle()->subtitle_content()->language() << "\n"; - if (subtitles) { - for (list<shared_ptr<SubtitleString> >::const_iterator k = subs.begin(); k != subs.end(); ++k) { - cout << " " << (*k)->text() << "\n"; - cout << " " - << "font:" << (*k)->font() << "; " - << "italic:" << (*k)->italic() << "; " - << "color:" << (*k)->color() << "; " - << "in:" << (*k)->in() << "; " - << "out:" << (*k)->out() << "; " - << "v_position:" << (*k)->v_position() << "; " - << "v_align:" << (*k)->v_align() << "; " - << "effect:" << (*k)->effect() << "; " - << "effect_color:" << (*k)->effect_color() << "; " - << "fade_up_time:" << (*k)->fade_up_time() << "; " - << "fade_down_time:" << (*k)->fade_down_time() << "; " - << "size: " << (*k)->size() << "\n"; - } + + try { + main_subtitle (*j, subtitles); + } catch (UnresolvedRefError& e) { + if (keep_going) { + cerr << e.what() << " (for main subtitle)\n"; + } else { + throw; } } + ++R; } } |
