summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-15 13:38:14 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-15 13:38:14 +0100
commit6322c72a13d7be2e991a8e0421414c0af8187b88 (patch)
treeb4ca07d1f00016bcd407152202ab408b59f093d4 /src
parent4709841e68d860c4fbee2f2f824e57489c8ad97d (diff)
Use boost::function for making notes during equals operations.
Diffstat (limited to 'src')
-rw-r--r--src/asset.cc1
-rw-r--r--src/asset.h3
-rw-r--r--src/dcp.cc20
-rw-r--r--src/dcp.h7
-rw-r--r--src/mxf_asset.cc12
-rw-r--r--src/mxf_asset.h2
-rw-r--r--src/picture_asset.cc29
-rw-r--r--src/picture_asset.h8
-rw-r--r--src/reel.cc14
-rw-r--r--src/reel.h3
-rw-r--r--src/sound_asset.cc10
-rw-r--r--src/sound_asset.h2
-rw-r--r--src/subtitle_asset.h4
13 files changed, 59 insertions, 56 deletions
diff --git a/src/asset.cc b/src/asset.cc
index 3d2a0e03..305fc9a7 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -24,6 +24,7 @@
#include <iostream>
#include <fstream>
#include <boost/filesystem.hpp>
+#include <boost/function.hpp>
#include "AS_DCP.h"
#include "KM_util.h"
#include "asset.h"
diff --git a/src/asset.h b/src/asset.h
index 436e8b41..527dea7a 100644
--- a/src/asset.h
+++ b/src/asset.h
@@ -27,6 +27,7 @@
#include <string>
#include <list>
#include <boost/filesystem.hpp>
+#include <boost/function.hpp>
#include "types.h"
namespace ASDCP {
@@ -80,7 +81,7 @@ public:
_file_name = f;
}
- virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const = 0;
+ virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)>) const = 0;
protected:
diff --git a/src/dcp.cc b/src/dcp.cc
index d446b205..49d41c70 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -248,10 +248,10 @@ DCP::read (bool require_mxfs)
}
bool
-DCP::equals (DCP const & other, EqualityOptions opt, list<string>& notes) const
+DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (string)> note) const
{
if (_cpls.size() != other._cpls.size()) {
- notes.push_back ("CPL counts differ");
+ note ("CPL counts differ");
return false;
}
@@ -259,7 +259,7 @@ DCP::equals (DCP const & other, EqualityOptions opt, list<string>& notes) const
list<shared_ptr<const CPL> >::const_iterator b = other._cpls.begin ();
while (a != _cpls.end ()) {
- if (!(*a)->equals (*b->get(), opt, notes)) {
+ if (!(*a)->equals (*b->get(), opt, note)) {
return false;
}
++a;
@@ -516,30 +516,30 @@ CPL::write_to_assetmap (ostream& s) const
bool
-CPL::equals (CPL const & other, EqualityOptions opt, list<string>& notes) const
+CPL::equals (CPL const & other, EqualityOptions opt, boost::function<void (string)> note) const
{
if (_name != other._name) {
- notes.push_back ("names differ");
+ note ("names differ");
return false;
}
if (_content_kind != other._content_kind) {
- notes.push_back ("content kinds differ");
+ note ("content kinds differ");
return false;
}
if (_fps != other._fps) {
- notes.push_back ("frames per second differ");
+ note ("frames per second differ");
return false;
}
if (_length != other._length) {
- notes.push_back ("lengths differ");
+ note ("lengths differ");
return false;
}
if (_reels.size() != other._reels.size()) {
- notes.push_back ("reel counts differ");
+ note ("reel counts differ");
return false;
}
@@ -547,7 +547,7 @@ CPL::equals (CPL const & other, EqualityOptions opt, list<string>& notes) const
list<shared_ptr<const Reel> >::const_iterator b = other._reels.begin ();
while (a != _reels.end ()) {
- if (!(*a)->equals (*b, opt, notes)) {
+ if (!(*a)->equals (*b, opt, note)) {
return false;
}
++a;
diff --git a/src/dcp.h b/src/dcp.h
index c5734542..7e9b4edc 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -84,7 +84,7 @@ public:
std::list<boost::shared_ptr<const Asset> > assets () const;
- bool equals (CPL const & other, EqualityOptions options, std::list<std::string>& notes) const;
+ bool equals (CPL const & other, EqualityOptions options, boost::function<void (std::string)> note) const;
void write_xml () const;
void write_to_assetmap (std::ostream& s) const;
@@ -141,11 +141,10 @@ public:
/** Compare this DCP with another, according to various options.
* @param other DCP to compare this one to.
- * @param options Options to define just what "equality" means.
- * @param notes Filled in with notes about differences.
+ * @param options Options to define what "equality" means.
* @return true if the DCPs are equal according to EqualityOptions, otherwise false.
*/
- bool equals (DCP const & other, EqualityOptions options, std::list<std::string>& notes) const;
+ bool equals (DCP const & other, EqualityOptions options, boost::function<void (std::string)> note) const;
/** Add a CPL to this DCP.
* @param cpl CPL to add.
diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc
index 9b4cbf74..cf265712 100644
--- a/src/mxf_asset.cc
+++ b/src/mxf_asset.cc
@@ -71,31 +71,31 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid)
}
bool
-MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, list<string>& notes) const
+MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, boost::function<void (string)> note) const
{
shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other);
if (!other_mxf) {
- notes.push_back ("comparing an MXF asset with a non-MXF asset");
+ note ("comparing an MXF asset with a non-MXF asset");
return false;
}
if (_file_name != other_mxf->_file_name) {
- notes.push_back ("MXF names differ");
+ note ("MXF names differ");
return false;
}
if (_edit_rate != other_mxf->_edit_rate) {
- notes.push_back ("MXF edit rates differ");
+ note ("MXF edit rates differ");
return false;
}
if (_intrinsic_duration != other_mxf->_intrinsic_duration) {
- notes.push_back ("MXF intrinsic durations differ");
+ note ("MXF intrinsic durations differ");
return false;
}
if (_duration != other_mxf->_duration) {
- notes.push_back ("MXF durations differ");
+ note ("MXF durations differ");
return false;
}
diff --git a/src/mxf_asset.h b/src/mxf_asset.h
index 430e9157..0c98f3c6 100644
--- a/src/mxf_asset.h
+++ b/src/mxf_asset.h
@@ -61,7 +61,7 @@ public:
_intrinsic_duration = d;
}
- virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
+ virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)> note) const;
int intrinsic_duration () const {
return _intrinsic_duration;
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index 13253242..807564c5 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -79,9 +79,9 @@ PictureAsset::write_to_cpl (ostream& s) const
}
bool
-PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<string>& notes) const
+PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const
{
- if (!MXFAsset::equals (other, opt, notes)) {
+ if (!MXFAsset::equals (other, opt, note)) {
return false;
}
@@ -125,7 +125,7 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<s
// desc_A.QuantizationDefault != desc_B.QuantizationDefault
) {
- notes.push_back ("video MXF picture descriptors differ");
+ note ("video MXF picture descriptors differ");
return false;
}
@@ -248,9 +248,9 @@ MonoPictureAsset::get_frame (int n) const
bool
-MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<string>& notes) const
+MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const
{
- if (!PictureAsset::equals (other, opt, notes)) {
+ if (!PictureAsset::equals (other, opt, note)) {
return false;
}
@@ -262,7 +262,7 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, li
shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i);
if (!frame_buffer_equals (
- i, opt, notes,
+ i, opt, note,
frame_A->j2k_data(), frame_A->j2k_size(),
frame_B->j2k_data(), frame_B->j2k_size()
)) {
@@ -274,9 +274,9 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, li
}
bool
-StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<string>& notes) const
+StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const
{
- if (!PictureAsset::equals (other, opt, notes)) {
+ if (!PictureAsset::equals (other, opt, note)) {
return false;
}
@@ -288,7 +288,7 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i);
if (!frame_buffer_equals (
- i, opt, notes,
+ i, opt, note,
frame_A->left_j2k_data(), frame_A->left_j2k_size(),
frame_B->left_j2k_data(), frame_B->left_j2k_size()
)) {
@@ -296,7 +296,7 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
}
if (!frame_buffer_equals (
- i, opt, notes,
+ i, opt, note,
frame_A->right_j2k_data(), frame_A->right_j2k_size(),
frame_B->right_j2k_data(), frame_B->right_j2k_size()
)) {
@@ -309,7 +309,8 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
bool
PictureAsset::frame_buffer_equals (
- int frame, EqualityOptions opt, list<string>& notes, uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
+ int frame, EqualityOptions opt, boost::function<void (string)> note,
+ uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
) const
{
if (size_A == size_B && memcmp (data_A, data_B, size_A) == 0) {
@@ -324,7 +325,7 @@ PictureAsset::frame_buffer_equals (
/* Compare them */
if (image_A->numcomps != image_B->numcomps) {
- notes.push_back ("image component counts for frame " + lexical_cast<string>(frame) + " differ");
+ note ("image component counts for frame " + lexical_cast<string>(frame) + " differ");
return false;
}
@@ -335,7 +336,7 @@ PictureAsset::frame_buffer_equals (
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>(frame) + " differ");
+ note ("image sizes for frame " + lexical_cast<string>(frame) + " differ");
return false;
}
@@ -362,7 +363,7 @@ PictureAsset::frame_buffer_equals (
double const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size());
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>(frame));
+ note ("mean or standard deviation out of range for " + lexical_cast<string>(frame));
return false;
}
diff --git a/src/picture_asset.h b/src/picture_asset.h
index d3fabbbd..f4d4d7a4 100644
--- a/src/picture_asset.h
+++ b/src/picture_asset.h
@@ -63,7 +63,7 @@ public:
*/
void write_to_cpl (std::ostream& s) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
+ bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)> note) const;
Size size () const {
return _size;
@@ -72,7 +72,7 @@ public:
protected:
bool frame_buffer_equals (
- int frame, EqualityOptions opt, std::list<std::string>& notes,
+ int frame, EqualityOptions opt, boost::function<void (std::string)> note,
uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
) const;
@@ -210,7 +210,7 @@ public:
boost::shared_ptr<MonoPictureAssetWriter> start_write (bool);
boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
+ bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)> note) const;
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
@@ -224,7 +224,7 @@ public:
StereoPictureAsset (std::string directory, std::string mxf_name, int fps, int intrinsic_duration);
boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
+ bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)> note) const;
};
diff --git a/src/reel.cc b/src/reel.cc
index 8995f874..096acf19 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -50,32 +50,32 @@ Reel::write_to_cpl (ostream& s) const
}
bool
-Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, list<string>& notes) const
+Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (string)> note) const
{
if ((_main_picture && !other->_main_picture) || (!_main_picture && other->_main_picture)) {
- notes.push_back ("reel has different assets");
+ note ("reel has different assets");
return false;
}
- if (_main_picture && !_main_picture->equals (other->_main_picture, opt, notes)) {
+ if (_main_picture && !_main_picture->equals (other->_main_picture, opt, note)) {
return false;
}
if ((_main_sound && !other->_main_sound) || (!_main_sound && other->_main_sound)) {
- notes.push_back ("reel has different assets");
+ note ("reel has different assets");
return false;
}
- if (_main_sound && !_main_sound->equals (other->_main_sound, opt, notes)) {
+ if (_main_sound && !_main_sound->equals (other->_main_sound, opt, note)) {
return false;
}
if ((_main_subtitle && !other->_main_subtitle) || (!_main_subtitle && other->_main_subtitle)) {
- notes.push_back ("reel has different assets");
+ note ("reel has different assets");
return false;
}
- if (_main_subtitle && !_main_subtitle->equals (other->_main_subtitle, opt, notes)) {
+ if (_main_subtitle && !_main_subtitle->equals (other->_main_subtitle, opt, note)) {
return false;
}
diff --git a/src/reel.h b/src/reel.h
index c7d3b164..b0dfc84d 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -19,6 +19,7 @@
#include <list>
#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
#include "types.h"
namespace libdcp {
@@ -55,7 +56,7 @@ public:
void write_to_cpl (std::ostream & s) const;
- bool equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, std::list<std::string>& notes) const;
+ bool equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (std::string)> notes) const;
private:
boost::shared_ptr<const PictureAsset> _main_picture;
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index e18441c6..da6e72bc 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -222,9 +222,9 @@ SoundAsset::write_to_cpl (ostream& s) const
}
bool
-SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<string>& notes) const
+SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const
{
- if (!MXFAsset::equals (other, opt, notes)) {
+ if (!MXFAsset::equals (other, opt, note)) {
return false;
}
@@ -260,7 +260,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str
// desc_A.ChannelFormat != desc_B.ChannelFormat ||
) {
- notes.push_back ("audio MXF picture descriptors differ");
+ note ("audio MXF picture descriptors differ");
return false;
}
@@ -277,7 +277,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str
}
if (buffer_A.Size() != buffer_B.Size()) {
- notes.push_back ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ");
+ note ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ");
return false;
}
@@ -285,7 +285,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str
for (uint32_t i = 0; i < buffer_A.Size(); ++i) {
int const d = abs (buffer_A.RoData()[i] - buffer_B.RoData()[i]);
if (d > opt.max_audio_sample_error) {
- notes.push_back ("PCM data difference of " + lexical_cast<string> (d));
+ note ("PCM data difference of " + lexical_cast<string> (d));
return false;
}
}
diff --git a/src/sound_asset.h b/src/sound_asset.h
index ad350ce5..dedebac3 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -129,7 +129,7 @@ public:
*/
void write_to_cpl (std::ostream& s) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
+ bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)> note) const;
boost::shared_ptr<const SoundFrame> get_frame (int n) const;
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 71ae42fc..b3936dc2 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -184,9 +184,9 @@ public:
SubtitleAsset (std::string directory, std::string movie_title, std::string language);
void write_to_cpl (std::ostream&) const;
- virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, std::list<std::string>& notes) const {
+ virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (std::string)> note) const {
/* XXX */
- notes.push_back ("subtitle assets not compared yet");
+ note ("subtitle assets not compared yet");
return true;
}