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"
27 using namespace boost;
28 using namespace libdcp;
30 static bool verbose = false;
35 cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
36 << " -V, --version show libdcp version\n"
37 << " -h, --help show this help\n"
38 << " -v, --verbose be verbose\n"
39 << " -n, --mxf-names allow differing MXF names\n"
40 << " --cpl-names allow differing CPL names\n"
41 << " -m, --mean-pixel maximum allowed mean pixel error (default 5)\n"
42 << " -s, --std-dev-pixel maximum allowed standard deviation of pixel error (default 5)\n"
44 << "The <DCP>s are the DCP directories to compare.\n"
45 << "Comparison is of metadata and content, ignoring timestamps\n"
46 << "and differing UUIDs.\n";
50 note (NoteType t, string n)
52 if (t == ERROR || verbose) {
53 cout << " " << n << "\n";
58 main (int argc, char* argv[])
60 EqualityOptions options;
61 options.max_mean_pixel_error = 5;
62 options.max_std_dev_pixel_error = 5;
66 static struct option long_options[] = {
67 { "version", no_argument, 0, 'V'},
68 { "help", no_argument, 0, 'h'},
69 { "verbose", no_argument, 0, 'v'},
70 { "mxf-names", no_argument, 0, 'n'},
71 { "mean-pixel", required_argument, 0, 'm'},
72 { "std-dev-pixel", required_argument, 0, 's'},
73 /* From here we're using random capital letters for the short option */
74 { "cpl-names", no_argument, 0, 'A'},
78 int c = getopt_long (argc, argv, "Vhvnm:s:A", long_options, &option_index);
86 cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
95 options.mxf_names_can_differ = true;
98 options.max_mean_pixel_error = atof (optarg);
101 options.max_std_dev_pixel_error = atof (optarg);
104 options.cpl_names_can_differ = true;
109 if (argc <= optind || argc > (optind + 2)) {
114 if (!filesystem::exists (argv[optind])) {
115 cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n";
119 if (!filesystem::exists (argv[optind + 1])) {
120 cerr << argv[0] << ": DCP " << argv[optind + 1] << " not found.\n";
126 a = new DCP (argv[optind]);
128 } catch (FileError& e) {
129 cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << " " << e.filename() << "\n";
135 b = new DCP (argv[optind + 1]);
137 } catch (FileError& e) {
138 cerr << "Could not read DCP " << argv[optind + 1] << "; " << e.what() << " " << e.filename() << "\n";
142 /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */
143 options.max_audio_sample_error = 255;
145 bool const equals = a->equals (*b, options, boost::bind (note, _1, _2));