From 568d433830710baa7b0c64a5b7491758beb95b1c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 2 May 2013 17:20:04 +0100 Subject: Move edit rate / durations / entry point etc. into Asset from MXFAsset. --- src/asset.cc | 28 +++++++++++++++++++++++++++- src/asset.h | 40 ++++++++++++++++++++++++++++++++++++++-- src/dcp.cc | 5 ++++- src/mxf_asset.cc | 29 +++++------------------------ src/mxf_asset.h | 28 ---------------------------- 5 files changed, 74 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/asset.cc b/src/asset.cc index 305fc9a7..58c821a7 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -35,10 +35,14 @@ using namespace std; using namespace boost; using namespace libdcp; -Asset::Asset (string directory, string file_name) +Asset::Asset (string directory, string file_name, int edit_rate, int intrinsic_duration) : _directory (directory) , _file_name (file_name) , _uuid (make_uuid ()) + , _edit_rate (edit_rate) + , _entry_point (0) + , _intrinsic_duration (intrinsic_duration) + , _duration (intrinsic_duration) { if (_file_name.empty ()) { _file_name = _uuid + ".xml"; @@ -91,3 +95,25 @@ Asset::digest () const return _digest; } + + +bool +Asset::equals (shared_ptr other, EqualityOptions, boost::function note) const +{ + if (_edit_rate != other->_edit_rate) { + note (ERROR, "MXF edit rates differ"); + return false; + } + + if (_intrinsic_duration != other->_intrinsic_duration) { + note (ERROR, "MXF intrinsic durations differ"); + return false; + } + + if (_duration != other->_duration) { + note (ERROR, "MXF durations differ"); + return false; + } + + return true; +} diff --git a/src/asset.h b/src/asset.h index 1b1bf4c6..06c66356 100644 --- a/src/asset.h +++ b/src/asset.h @@ -48,7 +48,7 @@ public: * @param directory Directory where our XML or MXF file is. * @param file_name Name of our file within directory, or empty to make one up based on UUID. */ - Asset (std::string directory, std::string file_name = ""); + Asset (std::string directory, std::string file_name = "", int edit_rate = 0, int intrinsic_duration = 0); virtual ~Asset() {} @@ -80,8 +80,36 @@ public: void set_file_name (std::string f) { _file_name = f; } + + int entry_point () const { + return _entry_point; + } + + int duration () const { + return _duration; + } + + int intrinsic_duration () const { + return _intrinsic_duration; + } + + int edit_rate () const { + return _edit_rate; + } + + void set_entry_point (int e) { + _entry_point = e; + } - virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function) const = 0; + void set_duration (int d) { + _duration = d; + } + + void set_intrinsic_duration (int d) { + _intrinsic_duration = d; + } + + virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function) const; protected: @@ -93,6 +121,14 @@ protected: std::string _file_name; /** Our UUID */ std::string _uuid; + /** The edit rate; this is normally equal to the number of video frames per second */ + int _edit_rate; + /** Start point to present in frames */ + int _entry_point; + /** Total length in frames */ + int _intrinsic_duration; + /** Length to present in frames */ + int _duration; private: /** Digest of our MXF or XML file */ diff --git a/src/dcp.cc b/src/dcp.cc index bac266ab..3fe69e40 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -365,7 +365,8 @@ CPL::CPL (string directory, string file, shared_ptr asset_map, b ) ); - picture->set_entry_point ((*i)->asset_list->main_picture->entry_point); + picture->set_entry_point (p->entry_point); + picture->set_duration (p->duration); } catch (MXFFileError) { if (require_mxfs) { throw; @@ -384,6 +385,7 @@ CPL::CPL (string directory, string file, shared_ptr asset_map, b ); picture->set_entry_point (p->entry_point); + picture->set_duration (p->duration); } catch (MXFFileError) { if (require_mxfs) { @@ -403,6 +405,7 @@ CPL::CPL (string directory, string file, shared_ptr asset_map, b ); sound->set_entry_point ((*i)->asset_list->main_sound->entry_point); + sound->set_duration ((*i)->asset_list->main_sound->duration); } catch (MXFFileError) { if (require_mxfs) { throw; diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc index 144532f8..229c332f 100644 --- a/src/mxf_asset.cc +++ b/src/mxf_asset.cc @@ -39,21 +39,13 @@ using namespace libdcp; MXFAsset::MXFAsset (string directory, string file_name) : Asset (directory, file_name) , _progress (0) - , _edit_rate (0) - , _entry_point (0) - , _intrinsic_duration (0) - , _duration (0) { } MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal* progress, int edit_rate, int intrinsic_duration) - : Asset (directory, file_name) + : Asset (directory, file_name, edit_rate, intrinsic_duration) , _progress (progress) - , _edit_rate (edit_rate) - , _entry_point (0) - , _intrinsic_duration (intrinsic_duration) - , _duration (intrinsic_duration) { } @@ -73,6 +65,10 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid) bool MXFAsset::equals (shared_ptr other, EqualityOptions opt, boost::function note) const { + if (!Asset::equals (other, opt, note)) { + return false; + } + shared_ptr other_mxf = dynamic_pointer_cast (other); if (!other_mxf) { note (ERROR, "comparing an MXF asset with a non-MXF asset"); @@ -85,21 +81,6 @@ MXFAsset::equals (shared_ptr other, EqualityOptions opt, boost::fun return false; } } - - if (_edit_rate != other_mxf->_edit_rate) { - note (ERROR, "MXF edit rates differ"); - return false; - } - - if (_intrinsic_duration != other_mxf->_intrinsic_duration) { - note (ERROR, "MXF intrinsic durations differ"); - return false; - } - - if (_duration != other_mxf->_duration) { - note (ERROR, "MXF durations differ"); - return false; - } return true; } diff --git a/src/mxf_asset.h b/src/mxf_asset.h index 29b3c1b0..5815fd90 100644 --- a/src/mxf_asset.h +++ b/src/mxf_asset.h @@ -49,27 +49,7 @@ public: */ MXFAsset (std::string directory, std::string file_name, boost::signals2::signal* progress, int edit_rate, int intrinsic_duration); - void set_entry_point (int e) { - _entry_point = e; - } - - void set_duration (int d) { - _duration = d; - } - - void set_intrinsic_duration (int d) { - _intrinsic_duration = d; - } - virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; - - int intrinsic_duration () const { - return _intrinsic_duration; - } - - int edit_rate () const { - return _edit_rate; - } /** Fill in a ADSCP::WriteInfo struct. * @param w struct to fill in. @@ -81,14 +61,6 @@ protected: /** Signal to emit to report progress, or 0 */ boost::signals2::signal* _progress; - /** The edit rate; this is normally equal to the number of video frames per second */ - int _edit_rate; - /** Start point to present in frames */ - int _entry_point; - /** Total length in frames */ - int _intrinsic_duration; - /** Length to present in frames */ - int _duration; }; } -- cgit v1.2.3 From 8c7829cd20778082a7a5ea612639c313f3006faa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 3 May 2013 16:12:50 +0100 Subject: A few tweaks to dcpdiff. --- src/picture_asset.cc | 13 +++++++++---- tools/dcpdiff.cc | 24 +++++++++++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/picture_asset.cc b/src/picture_asset.cc index f2982b47..a505dc63 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -364,13 +364,18 @@ 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) { - note (ERROR, "mean or standard deviation out of range for " + lexical_cast(frame)); + note (NOTE, "mean difference " + lexical_cast (mean) + ", deviation " + lexical_cast (std_dev)); + + if (mean > opt.max_mean_pixel_error) { + note (ERROR, "mean " + lexical_cast(mean) + " out of range " + lexical_cast(opt.max_mean_pixel_error) + " in frame " + lexical_cast(frame)); + return false; + } + + if (std_dev > opt.max_std_dev_pixel_error) { + note (ERROR, "standard deviation " + lexical_cast(std_dev) + " out of range " + lexical_cast(opt.max_std_dev_pixel_error) + " in frame " + lexical_cast(frame)); return false; } - note (NOTE, "mean difference " + lexical_cast (mean) + ", deviation " + lexical_cast (std_dev)); - opj_image_destroy (image_A); opj_image_destroy (image_B); diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index 490059aa..b361b93a 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -14,10 +14,12 @@ static void help (string n) { cerr << "Syntax: " << n << " [OPTION] \n" - << " -V, --version show libdcp version\n" - << " -h, --help show this help\n" - << " -v, --verbose be verbose\n" - << " -n, --names allow differing MXF names\n" + << " -V, --version show libdcp version\n" + << " -h, --help show this help\n" + << " -v, --verbose be verbose\n" + << " -n, --names allow differing MXF names\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" << "\n" << "The s are the DCP directories to compare.\n" << "Comparison is of metadata and content, ignoring timestamps\n" @@ -36,6 +38,8 @@ int main (int argc, char* argv[]) { EqualityOptions options; + options.max_mean_pixel_error = 5; + options.max_std_dev_pixel_error = 5; int option_index = 0; while (1) { @@ -44,10 +48,12 @@ main (int argc, char* argv[]) { "help", no_argument, 0, 'h'}, { "verbose", no_argument, 0, 'v'}, { "names", no_argument, 0, 'n'}, + { "mean-pixel", required_argument, 0, 'm'}, + { "std-dev-pixel", required_argument, 0, 's'}, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "Vhvn", long_options, &option_index); + int c = getopt_long (argc, argv, "Vhvnm:s:", long_options, &option_index); if (c == -1) { break; @@ -66,6 +72,12 @@ main (int argc, char* argv[]) case 'n': options.mxf_names_can_differ = true; break; + case 'm': + options.max_mean_pixel_error = atof (optarg); + break; + case 's': + options.max_std_dev_pixel_error = atof (optarg); + break; } } @@ -102,8 +114,6 @@ main (int argc, char* argv[]) exit (EXIT_FAILURE); } - options.max_mean_pixel_error = 5; - options.max_std_dev_pixel_error = 5; /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */ options.max_audio_sample_error = 255; -- cgit v1.2.3