2 Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <boost/filesystem.hpp>
24 #include "exceptions.h"
28 using namespace boost;
31 static bool verbose = false;
36 cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
37 << " -V, --version show libdcp version\n"
38 << " -h, --help show this help\n"
39 << " -v, --verbose be verbose\n"
40 << " -n, --mxf-names allow differing MXF names\n"
41 << " --cpl-annotation-texts allow differing CPL annotation texts\n"
42 << " -m, --mean-pixel maximum allowed mean pixel error (default 5)\n"
43 << " -s, --std-dev-pixel maximum allowed standard deviation of pixel error (default 5)\n"
44 << " -k, --keep-going carry on in the event of errors, if possible\n"
45 << " --ignore-missing-assets ignore missing asset files\n"
47 << "The <DCP>s are the DCP directories to compare.\n"
48 << "Comparison is of metadata and content, ignoring timestamps\n"
49 << "and differing UUIDs.\n";
53 note (NoteType t, string n)
55 if (t == DCP_ERROR || verbose) {
56 cout << " " << n << "\n";
61 load_dcp (boost::filesystem::path path, bool keep_going, bool ignore_missing_assets)
66 DCP::ReadErrors errors;
67 dcp->read (keep_going, &errors);
68 filter_errors (errors, ignore_missing_assets);
69 for (DCP::ReadErrors::const_iterator i = errors.begin(); i != errors.end(); ++i) {
70 cerr << (*i)->what() << "\n";
72 } catch (FileError& e) {
73 cerr << "Could not read DCP " << path.string() << "; " << e.what() << " " << e.filename() << "\n";
81 main (int argc, char* argv[])
83 EqualityOptions options;
84 options.max_mean_pixel_error = 5;
85 options.max_std_dev_pixel_error = 5;
86 options.reel_hashes_can_differ = true;
87 bool keep_going = false;
88 bool ignore_missing_assets = false;
92 static struct option long_options[] = {
93 { "version", no_argument, 0, 'V'},
94 { "help", no_argument, 0, 'h'},
95 { "verbose", no_argument, 0, 'v'},
96 { "mxf-names", no_argument, 0, 'n'},
97 { "mean-pixel", required_argument, 0, 'm'},
98 { "std-dev-pixel", required_argument, 0, 's'},
99 { "keep-going", no_argument, 0, 'k'},
100 /* From here we're using random capital letters for the short option */
101 { "ignore-missing-assets", no_argument, 0, 'A'},
102 { "cpl-annotation-texts", no_argument, 0, 'C'},
106 int c = getopt_long (argc, argv, "Vhvnm:s:kA", long_options, &option_index);
114 cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
123 options.mxf_names_can_differ = true;
126 options.max_mean_pixel_error = atof (optarg);
129 options.max_std_dev_pixel_error = atof (optarg);
135 ignore_missing_assets = true;
139 options.cpl_annotation_texts_can_differ = true;
144 if (argc <= optind || argc > (optind + 2)) {
149 if (!filesystem::exists (argv[optind])) {
150 cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
154 if (!filesystem::exists (argv[optind + 1])) {
155 cerr << argv[0] << ": DCP " << argv[optind + 1] << " not found.\n";
159 DCP* a = load_dcp (argv[optind], keep_going, ignore_missing_assets);
160 DCP* b = load_dcp (argv[optind + 1], keep_going, ignore_missing_assets);
162 /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */
163 options.max_audio_sample_error = 255;
165 bool const equals = a->equals (*b, options, boost::bind (note, _1, _2));
167 exit (equals ? EXIT_SUCCESS : EXIT_FAILURE);