}
list<string>
-Asset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double, double) const
+Asset::equals (shared_ptr<const Asset> other, EqualityOptions opt) const
{
list<string> notes;
- if (flags & LIBDCP_METADATA) {
+ if (opt.flags & LIBDCP_METADATA) {
if (_mxf_name != other->_mxf_name) {
notes.push_back ("MXF names differ");
}
}
}
- if (flags & MXF_BITWISE) {
+ if (opt.flags & MXF_BITWISE) {
if (digest() != other->digest()) {
notes.push_back ("MXF digests differ");
*/
void write_to_assetmap (std::ostream& s) const;
- virtual std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const;
+ virtual std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
protected:
friend class PictureAsset;
}
list<string>
-DCP::equals (DCP const & other, EqualityFlags flags, double max_mean, double max_std_dev) const
+DCP::equals (DCP const & other, EqualityOptions opt) const
{
list<string> notes;
- if (flags & LIBDCP_METADATA) {
+ if (opt.flags & LIBDCP_METADATA) {
if (_name != other._name) {
notes.push_back ("names differ");
}
list<shared_ptr<Asset> >::const_iterator b = other._assets.begin ();
while (a != _assets.end ()) {
- list<string> n = (*a)->equals (*b, flags, max_mean, max_std_dev);
+ list<string> n = (*a)->equals (*b, opt);
notes.merge (n);
++a;
++b;
return _length;
}
- std::list<std::string> equals (DCP const & other, EqualityFlags flags, double max_mean, double max_std_dev) const;
+ std::list<std::string> equals (DCP const & other, EqualityOptions options) const;
/** Emitted with a parameter between 0 and 1 to indicate progress
* for long jobs.
}
list<string>
-PictureAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const
+PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt) const
{
- list<string> notes = Asset::equals (other, flags, max_mean, max_std_dev);
+ list<string> notes = Asset::equals (other, opt);
- if (flags & MXF_INSPECT) {
+ if (opt.flags & MXF_INSPECT) {
ASDCP::JP2K::MXFReader reader_A;
if (ASDCP_FAILURE (reader_A.OpenRead (mxf_path().string().c_str()))) {
throw FileError ("could not open MXF file for reading", mxf_path().string());
}
if (!j2k_same) {
+
+ if (opt.verbose) {
+ cout << "J2K images for " << i << " differ; checking by pixel\n";
+ }
+
/* Decompress the images to bitmaps */
opj_image_t* image_A = decompress_j2k (const_cast<uint8_t*> (buffer_A.RoData()), buffer_A.Size ());
opj_image_t* image_B = decompress_j2k (const_cast<uint8_t*> (buffer_B.RoData()), buffer_B.Size ());
double const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size());
- if (mean > max_mean || std_dev > max_std_dev) {
+ if (mean > opt.max_mean_pixel_error || std_dev > opt.max_std_dev_pixel_error) {
notes.push_back ("mean or standard deviation out of range for " + lexical_cast<string>(i));
}
+ if (opt.verbose) {
+ cout << "\tmean pixel error " << mean << ", standard deviation " << std_dev << "\n";
+ }
+
opj_image_destroy (image_A);
opj_image_destroy (image_B);
}
*/
void write_to_cpl (std::ostream& s) const;
- std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const;
+ std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
}
list<string>
-SoundAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const
+SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt) const
{
- list<string> notes = Asset::equals (other, flags, max_mean, max_std_dev);
+ list<string> notes = Asset::equals (other, opt);
- if (flags & MXF_INSPECT) {
+ if (opt.flags & MXF_INSPECT) {
ASDCP::PCM::MXFReader reader_A;
if (ASDCP_FAILURE (reader_A.OpenRead (mxf_path().string().c_str()))) {
cout << "failed " << mxf_path() << "\n";
*/
void write_to_cpl (std::ostream& s) const;
- std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const;
+ std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityOptions opt) const;
private:
void construct (sigc::slot<std::string, Channel> get_path);
MXF_INSPECT = 0x4
};
+struct EqualityOptions {
+ EqualityFlags flags;
+ bool verbose;
+ double max_mean_pixel_error;
+ double max_std_dev_pixel_error;
+};
+
+
}
#endif
cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
<< " -b, --bitwise bitwise check\n"
<< " -v, --version show libdcp version\n"
+ << " -d, --verbose be verbose\n"
<< " -h, --help show this help\n"
<< "\n"
<< "The <DCP>s are the DCP directories to compare.\n"
int
main (int argc, char* argv[])
{
- bool bitwise = false;
+ EqualityOptions options;
+ options.flags = EqualityFlags (LIBDCP_METADATA | MXF_INSPECT);
+ options.verbose = false;
int option_index = 0;
while (1) {
{ "bitwise", no_argument, 0, 'b'},
{ "version", no_argument, 0, 'v'},
{ "help", no_argument, 0, 'h'},
+ { "verbose", no_argument, 0, 'd'},
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "bvh", long_options, &option_index);
+ int c = getopt_long (argc, argv, "bvhd", long_options, &option_index);
if (c == -1) {
break;
switch (c) {
case 'b':
- bitwise = true;
+ options.flags = EqualityFlags (options.flags | MXF_BITWISE);
break;
case 'v':
cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
case 'h':
help (argv[0]);
exit (EXIT_SUCCESS);
+ case 'd':
+ options.verbose = true;
+ break;
}
}
exit (EXIT_FAILURE);
}
- EqualityFlags flags = EqualityFlags (LIBDCP_METADATA | MXF_INSPECT);
- if (bitwise) {
- flags = EqualityFlags (flags | MXF_BITWISE);
- }
+ options.max_mean_pixel_error = 5;
+ options.max_std_dev_pixel_error = 5;
- list<string> notes = a->equals (*b, flags, 5, 5);
+ list<string> notes = a->equals (*b, options);
if (notes.empty ()) {
- cout << "DCPs identical\n";
+ cout << "DCPs equal\n";
exit (EXIT_SUCCESS);
}