Asset::equals (boost::shared_ptr<const Asset> other, EqualityOptions, function<void (NoteType, string)> note) const
{
if (_hash != other->_hash) {
- note (DCP_ERROR, "Asset hashes differ");
+ note (DCP_ERROR, "Asset: hashes differ");
return false;
}
{
}
-
-bool
-Content::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
-{
- if (!Asset::equals (other, opt, note)) {
- return false;
- }
-
- return true;
-}
*/
Content (boost::filesystem::path file);
- bool equals (
- boost::shared_ptr<const Asset> other,
- EqualityOptions opt,
- boost::function<void (NoteType, std::string)>
- ) const;
-
protected:
virtual std::string asdcp_kind () const = 0;
};
using std::list;
using std::pair;
using std::make_pair;
+using std::cout;
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
if (_annotation_text != other_cpl->_annotation_text && !opt.cpl_annotation_texts_can_differ) {
stringstream s;
- s << "annotation texts differ: " << _annotation_text << " vs " << other_cpl->_annotation_text << "\n";
+ s << "CPL: annotation texts differ: " << _annotation_text << " vs " << other_cpl->_annotation_text << "\n";
note (DCP_ERROR, s.str ());
return false;
}
if (_content_kind != other_cpl->_content_kind) {
- note (DCP_ERROR, "content kinds differ");
+ note (DCP_ERROR, "CPL: content kinds differ");
return false;
}
if (_reels.size() != other_cpl->_reels.size()) {
- note (DCP_ERROR, String::compose ("reel counts differ (%1 vs %2)", _reels.size(), other_cpl->_reels.size()));
+ note (DCP_ERROR, String::compose ("CPL: reel counts differ (%1 vs %2)", _reels.size(), other_cpl->_reels.size()));
return false;
}
using std::string;
using std::list;
+using std::cout;
using std::stringstream;
using std::ostream;
using std::make_pair;
bool
DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
- if (_assets.size() != other._assets.size()) {
- note (DCP_ERROR, String::compose ("Asset counts differ: %1 vs %2", _assets.size(), other._assets.size()));
+ list<shared_ptr<CPL> > a = cpls ();
+ list<shared_ptr<CPL> > b = other.cpls ();
+
+ if (a.size() != b.size()) {
+ note (DCP_ERROR, String::compose ("CPL counts differ: %1 vs %2", a.size(), b.size()));
return false;
}
- list<shared_ptr<Asset> >::const_iterator a = _assets.begin ();
- list<shared_ptr<Asset> >::const_iterator b = other._assets.begin ();
+ bool r = true;
+
+ for (list<shared_ptr<CPL> >::const_iterator i = a.begin(); i != a.end(); ++i) {
+ list<shared_ptr<CPL> >::const_iterator j = b.begin ();
+ while (j != b.end() && !(*j)->equals (*i, opt, note)) {
+ ++j;
+ }
- while (a != _assets.end ()) {
- if (!(*a)->equals (*b, opt, note)) {
- return false;
+ if (j == b.end ()) {
+ r = false;
}
- ++a;
- ++b;
}
- return true;
+ return r;
}
void
using std::string;
using std::vector;
+using std::cout;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using namespace dcp;
bool
MonoPictureMXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
+ if (!dynamic_pointer_cast<const MonoPictureMXF> (other)) {
+ return false;
+ }
+
if (!MXF::equals (other, opt, note)) {
return false;
}
shared_ptr<const MXF> other_mxf = dynamic_pointer_cast<const MXF> (other);
if (!other_mxf) {
- note (DCP_ERROR, "comparing an MXF asset with a non-MXF asset");
return false;
}
if (_edit_rate != other_mxf->_edit_rate) {
- note (DCP_ERROR, "content edit rates differ");
+ note (DCP_ERROR, "MXF: edit rates differ");
return false;
}
if (_intrinsic_duration != other_mxf->_intrinsic_duration) {
- note (DCP_ERROR, "asset intrinsic durations differ");
+ note (DCP_ERROR, String::compose ("MXF: intrinsic durations differ (%1 vs %2)", _intrinsic_duration, other_mxf->_intrinsic_duration));
return false;
}
if (_file != other_mxf->file ()) {
- note (DCP_ERROR, "MXF names differ");
+ note (DCP_ERROR, "MXF: names differ");
if (!opt.mxf_names_can_differ) {
return false;
}
Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
if ((_main_picture && !other->_main_picture) || (!_main_picture && other->_main_picture)) {
- note (DCP_ERROR, "reel has different assets");
+ note (DCP_ERROR, "Reel: assets differ");
return false;
}
}
if ((_main_sound && !other->_main_sound) || (!_main_sound && other->_main_sound)) {
- note (DCP_ERROR, "reel has different assets");
+ note (DCP_ERROR, "Reel: assets differ");
return false;
}
}
if ((_main_subtitle && !other->_main_subtitle) || (!_main_subtitle && other->_main_subtitle)) {
- note (DCP_ERROR, "reel has different assets");
+ note (DCP_ERROR, "Reel: assets differ");
return false;
}
using std::pair;
using std::string;
+using std::stringstream;
using std::make_pair;
using boost::shared_ptr;
using namespace dcp;
{
return make_pair ("", "");
}
+
+bool
+ReelAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const
+{
+ if (_annotation_text != other->_annotation_text) {
+ stringstream s;
+ s << "Reel: annotation texts differ (" << _annotation_text << " vs " << other->_annotation_text << ")\n";
+ note (DCP_ERROR, s.str ());
+ return false;
+ }
+
+ if (_edit_rate != other->_edit_rate) {
+ note (DCP_ERROR, "Reel: edit rates differ");
+ return false;
+ }
+
+ if (_intrinsic_duration != other->_intrinsic_duration) {
+ note (DCP_ERROR, "Reel: intrinsic durations differ");
+ return false;
+ }
+
+ if (_entry_point != other->_entry_point) {
+ note (DCP_ERROR, "Reel: entry points differ");
+ return false;
+ }
+
+ if (_duration != other->_duration) {
+ note (DCP_ERROR, "Reel: durations differ");
+ return false;
+ }
+
+ if (_hash != other->_hash) {
+ if (!opt.reel_hashes_can_differ) {
+ note (DCP_ERROR, "Reel: hashes differ");
+ return false;
+ } else {
+ note (DCP_NOTE, "Reel: hashes differ");
+ }
+ }
+
+ if (_content.resolved () && other->_content.resolved ()) {
+ return _content->equals (other->_content.object (), opt, note);
+ }
+
+ return true;
+}
ReelAsset (boost::shared_ptr<const cxml::Node>);
virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
-
- virtual bool equals (
- boost::shared_ptr<const ReelAsset>,
- EqualityOptions,
- boost::function<void (NoteType, std::string)>)
- const {
-
- return false;
- }
+ virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, boost::function<void (NoteType, std::string)>) const;
/** @return a Ref to our actual content */
Ref<Content>& content () {
using std::string;
using std::stringstream;
using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
using namespace dcp;
ReelPictureAsset::ReelPictureAsset ()
{
return "MDIK";
}
+
+bool
+ReelPictureAsset::equals (shared_ptr<const ReelAsset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const
+{
+ if (!ReelAsset::equals (other, opt, note)) {
+ return false;
+ }
+
+ shared_ptr<const ReelPictureAsset> rpa = dynamic_pointer_cast<const ReelPictureAsset> (other);
+ if (!rpa) {
+ return false;
+ }
+
+ if (_frame_rate != rpa->_frame_rate) {
+ note (DCP_ERROR, "frame rates differ in reel");
+ return false;
+ }
+
+ if (_screen_aspect_ratio != rpa->_screen_aspect_ratio) {
+ note (DCP_ERROR, "screen aspect ratios differ in reel");
+ return false;
+ }
+
+ return true;
+}
ReelPictureAsset (boost::shared_ptr<const cxml::Node>);
virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+ virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, boost::function<void (NoteType, std::string)>) const;
boost::shared_ptr<PictureMXF> mxf () {
return boost::dynamic_pointer_cast<PictureMXF> (_content.object ());
, max_audio_sample_error (0)
, cpl_annotation_texts_can_differ (false)
, mxf_names_can_differ (false)
+ , reel_hashes_can_differ (false)
{}
/** The maximum allowable mean difference in pixel value between two images */
bool cpl_annotation_texts_can_differ;
/** true if MXF filenames are allowed to differ */
bool mxf_names_can_differ;
+ /** true if <Hash>es in Reels can differ */
+ bool reel_hashes_can_differ;
};
/* I've been unable to make mingw happy with ERROR as a symbol, so
<< " -h, --help show this help\n"
<< " -v, --verbose be verbose\n"
<< " -n, --names allow differing MXF names\n"
- << " --cpl-names allow differing CPL annotation texts (backwards compatible)\n"
<< " --cpl-annotation-texts allow differing CPL annotation texts\n"
<< " -m, --mean-pixel maximum allowed mean pixel error (default 5)\n"
<< " -s, --std-dev-pixel maximum allowed standard deviation of pixel error (default 5)\n"
EqualityOptions options;
options.max_mean_pixel_error = 5;
options.max_std_dev_pixel_error = 5;
+ options.reel_hashes_can_differ = true;
bool keep_going = false;
bool ignore_missing_assets = false;
{ "keep-going", no_argument, 0, 'k'},
/* From here we're using random capital letters for the short option */
{ "ignore-missing-assets", no_argument, 0, 'A'},
- { "cpl-names", no_argument, 0, 'B'},
{ "cpl-annotation-texts", no_argument, 0, 'C'},
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "Vhvnm:s:kAB", long_options, &option_index);
+ int c = getopt_long (argc, argv, "Vhvnm:s:kA", long_options, &option_index);
if (c == -1) {
break;
bool const equals = a->equals (*b, options, boost::bind (note, _1, _2));
- if (equals) {
- exit (EXIT_SUCCESS);
- }
-
- exit (EXIT_FAILURE);
+ exit (equals ? EXIT_SUCCESS : EXIT_FAILURE);
}