}
list<string>
-Asset::equals (shared_ptr<const Asset> other, EqualityFlags flags) const
+Asset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double, double) const
{
list<string> notes;
*/
void write_to_assetmap (std::ostream& s) const;
- virtual std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags) const;
+ virtual std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const;
protected:
friend class PictureAsset;
}
list<string>
-DCP::equals (DCP const & other, EqualityFlags flags) const
+DCP::equals (DCP const & other, EqualityFlags flags, double max_mean, double max_std_dev) const
{
list<string> notes;
list<shared_ptr<Asset> >::const_iterator b = other._assets.begin ();
while (a != _assets.end ()) {
- list<string> n = (*a)->equals (*b, flags);
+ list<string> n = (*a)->equals (*b, flags, max_mean, max_std_dev);
notes.merge (n);
++a;
++b;
return _length;
}
- std::list<std::string> equals (DCP const & other, EqualityFlags flags) const;
+ std::list<std::string> equals (DCP const & other, EqualityFlags flags, double max_mean, double max_std_dev) const;
/** Emitted with a parameter between 0 and 1 to indicate progress
* for long jobs.
#include <stdexcept>
#include <iostream>
#include <sstream>
+#include <fstream>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <openjpeg.h>
}
list<string>
-PictureAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags) const
+PictureAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const
{
- list<string> notes = Asset::equals (other, flags);
+ list<string> notes = Asset::equals (other, flags, max_mean, max_std_dev);
if (flags & MXF_INSPECT) {
ASDCP::JP2K::MXFReader reader_A;
if (buffer_A.Size() != buffer_B.Size()) {
notes.push_back ("sizes of video data for frame " + lexical_cast<string>(i) + " differ");
j2k_same = false;
- continue;
- }
-
- if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) {
+ } else if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) {
notes.push_back ("J2K data for frame " + lexical_cast<string>(i) + " differ");
j2k_same = false;
- continue;
}
if (!j2k_same) {
notes.push_back ("image component counts for frame " + lexical_cast<string>(i) + " differ");
}
+ vector<int> abs_diffs (image_A->comps[0].w * image_A->comps[0].h * image_A->numcomps);
+ int d = 0;
+
for (int c = 0; c < image_A->numcomps; ++c) {
+
if (image_A->comps[c].w != image_B->comps[c].w || image_A->comps[c].h != image_B->comps[c].h) {
notes.push_back ("image sizes for frame " + lexical_cast<string>(i) + " differ");
}
-
- cout << "comp " << c << " of " << image_A->numcomps << "\n";
- cout << "bpp " << image_A->comps[c].bpp << "\n";
-
- for (int x = 0; x < image_A->comps[c].w; ++x) {
- for (int y = 0; y < image_A->comps[c].h; ++y) {
-
- }
+
+ int const pixels = image_A->comps[c].w * image_A->comps[c].h;
+ for (int j = 0; j < pixels; ++j) {
+ abs_diffs[d++] = abs (image_A->comps[c].data[j] - image_B->comps[c].data[j]);
}
}
-
+
+ uint64_t total = 0;
+ for (vector<int>::iterator j = abs_diffs.begin(); j != abs_diffs.end(); ++j) {
+ total += *j;
+ }
+
+ double const mean = double (total) / abs_diffs.size ();
+
+ uint64_t total_squared_deviation = 0;
+ for (vector<int>::iterator j = abs_diffs.begin(); j != abs_diffs.end(); ++j) {
+ total_squared_deviation += pow (*j - mean, 2);
+ }
+
+ double const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size());
+
+ if (mean > max_mean || std_dev > max_std_dev) {
+ notes.push_back ("mean or standard deviation out of range for " + lexical_cast<string>(i));
+ }
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) const;
+ std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) 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) const
+SoundAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const
{
- list<string> notes = Asset::equals (other, flags);
+ list<string> notes = Asset::equals (other, flags, max_mean, max_std_dev);
if (flags & MXF_INSPECT) {
ASDCP::PCM::MXFReader reader_A;
*/
void write_to_cpl (std::ostream& s) const;
- std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags) const;
+ std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags, double max_mean, double max_std_dev) const;
private:
void construct (sigc::slot<std::string, Channel> get_path);
flags = EqualityFlags (flags | MXF_BITWISE);
}
- list<string> notes = a->equals (*b, flags);
+ list<string> notes = a->equals (*b, flags, 5, 5);
if (notes.empty ()) {
cout << "DCPs identical\n";
exit (EXIT_SUCCESS);