summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-08-02 12:25:15 +0100
committerCarl Hetherington <cth@carlh.net>2012-08-02 12:25:15 +0100
commit8d94e57248b7957d62350083a93aa479457f9385 (patch)
treea3e899ab0d007b540bf4ef9fc5d3650c7df925be /src
parent4f6b9809ed4c9291e2577ee8e0f3bebf15ca2629 (diff)
Tidy up equality options slightly.
Diffstat (limited to 'src')
-rw-r--r--src/asset.cc6
-rw-r--r--src/asset.h2
-rw-r--r--src/dcp.cc6
-rw-r--r--src/dcp.h2
-rw-r--r--src/picture_asset.cc17
-rw-r--r--src/picture_asset.h2
-rw-r--r--src/sound_asset.cc6
-rw-r--r--src/sound_asset.h2
-rw-r--r--src/types.h8
9 files changed, 34 insertions, 17 deletions
diff --git a/src/asset.cc b/src/asset.cc
index 38617e85..78686a17 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -96,11 +96,11 @@ Asset::mxf_path () const
}
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");
}
@@ -112,7 +112,7 @@ Asset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double, doubl
}
}
- if (flags & MXF_BITWISE) {
+ if (opt.flags & MXF_BITWISE) {
if (digest() != other->digest()) {
notes.push_back ("MXF digests differ");
diff --git a/src/asset.h b/src/asset.h
index 51e5dc54..6c0a9803 100644
--- a/src/asset.h
+++ b/src/asset.h
@@ -66,7 +66,7 @@ public:
*/
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;
diff --git a/src/dcp.cc b/src/dcp.cc
index cf37579f..53d6b55d 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -334,11 +334,11 @@ DCP::DCP (string directory)
}
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");
}
@@ -361,7 +361,7 @@ DCP::equals (DCP const & other, EqualityFlags flags, double max_mean, double max
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;
diff --git a/src/dcp.h b/src/dcp.h
index 1ad56efc..477c1901 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -106,7 +106,7 @@ public:
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.
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index 3386d6d4..f5c10ce3 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -143,11 +143,11 @@ PictureAsset::write_to_cpl (ostream& s) const
}
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());
@@ -221,6 +221,11 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double
}
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 ());
@@ -260,10 +265,14 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double
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);
}
diff --git a/src/picture_asset.h b/src/picture_asset.h
index 8a697f2c..41b09b58 100644
--- a/src/picture_asset.h
+++ b/src/picture_asset.h
@@ -82,7 +82,7 @@ public:
*/
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;
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index 2d834957..71d1d9ff 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -177,11 +177,11 @@ SoundAsset::write_to_cpl (ostream& s) 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";
diff --git a/src/sound_asset.h b/src/sound_asset.h
index 4b7c0967..e9faeb8b 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -84,7 +84,7 @@ public:
*/
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);
diff --git a/src/types.h b/src/types.h
index ee3edaef..8c584579 100644
--- a/src/types.h
+++ b/src/types.h
@@ -68,6 +68,14 @@ enum EqualityFlags {
MXF_INSPECT = 0x4
};
+struct EqualityOptions {
+ EqualityFlags flags;
+ bool verbose;
+ double max_mean_pixel_error;
+ double max_std_dev_pixel_error;
+};
+
+
}
#endif