2 #include <boost/filesystem.hpp>
5 #include "exceptions.h"
11 static bool verbose = false;
16 cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
17 << " -V, --version show libdcp version\n"
18 << " -h, --help show this help\n"
19 << " -v, --verbose be verbose\n"
20 << " -n, --names allow differing MXF names\n"
21 << " -m, --mean-pixel maximum allowed mean pixel error (default 5)\n"
22 << " -s, --std-dev-pixel maximum allowed standard deviation of pixel error (default 5)\n"
23 << " -k, --keep-going carry on in the event of errors, if possible\n"
25 << "The <DCP>s are the DCP directories to compare.\n"
26 << "Comparison is of metadata and content, ignoring timestamps\n"
27 << "and differing UUIDs.\n";
31 note (NoteType t, string n)
33 if (t == ERROR || verbose) {
34 cout << " " << n << "\n";
39 main (int argc, char* argv[])
41 EqualityOptions options;
42 options.max_mean_pixel_error = 5;
43 options.max_std_dev_pixel_error = 5;
44 bool keep_going = false;
48 static struct option long_options[] = {
49 { "version", no_argument, 0, 'V'},
50 { "help", no_argument, 0, 'h'},
51 { "verbose", no_argument, 0, 'v'},
52 { "names", no_argument, 0, 'n'},
53 { "mean-pixel", required_argument, 0, 'm'},
54 { "std-dev-pixel", required_argument, 0, 's'},
55 { "keep-going", no_argument, 0, 'k'},
59 int c = getopt_long (argc, argv, "Vhvnm:s:k", long_options, &option_index);
67 cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
76 options.mxf_names_can_differ = true;
79 options.max_mean_pixel_error = atof (optarg);
82 options.max_std_dev_pixel_error = atof (optarg);
90 if (argc <= optind || argc > (optind + 2)) {
95 if (!filesystem::exists (argv[optind])) {
96 cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
100 if (!filesystem::exists (argv[optind + 1])) {
101 cerr << argv[0] << ": DCP " << argv[optind + 1] << " not found.\n";
107 a = new DCP (argv[optind]);
108 list<shared_ptr<DCPReadError> > errors;
109 a->read (keep_going, &errors);
110 for (list<shared_ptr<DCPReadError> >::const_iterator i = errors.begin(); i != errors.end(); ++i) {
111 cerr << (*i)->what() << "\n";
113 } catch (FileError& e) {
114 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << " " << e.filename() << "\n";
120 b = new DCP (argv[optind + 1]);
121 list<shared_ptr<DCPReadError> > errors;
122 b->read (keep_going, &errors);
123 for (list<shared_ptr<DCPReadError> >::const_iterator i = errors.begin(); i != errors.end(); ++i) {
124 cerr << (*i)->what() << "\n";
126 } catch (FileError& e) {
127 cerr << "Could not read DCP " << argv[optind + 1] << "; " << e.what() << " " << e.filename() << "\n";
131 /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */
132 options.max_audio_sample_error = 255;
134 bool const equals = a->equals (*b, options, boost::bind (note, _1, _2));