diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-04 11:15:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-04 11:15:35 +0100 |
| commit | fca67f5661c55db6d4206cd17f4cdcf7ede865da (patch) | |
| tree | bd1d4f8fa6fa7befa30c78c646f636e31a6b3e80 | |
| parent | af87bfc82beee0b0600558c84c3843dfd5a252f6 (diff) | |
| parent | a7bf2931ce47b1f3a2e4dbea0cf642d955619ac9 (diff) | |
Merge master.
| -rw-r--r-- | src/asset.cc | 28 | ||||
| -rw-r--r-- | src/asset.h | 40 | ||||
| -rw-r--r-- | src/cpl.cc | 9 | ||||
| -rw-r--r-- | src/mxf_asset.cc | 29 | ||||
| -rw-r--r-- | src/mxf_asset.h | 28 | ||||
| -rw-r--r-- | src/picture_asset.cc | 13 | ||||
| -rw-r--r-- | tools/dcpdiff.cc | 24 | ||||
| -rw-r--r-- | wscript | 2 |
8 files changed, 104 insertions, 69 deletions
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<const Asset> other, EqualityOptions, boost::function<void (NoteType, string)> 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<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const = 0; + void set_duration (int d) { + _duration = d; + } + + void set_intrinsic_duration (int d) { + _intrinsic_duration = d; + } + + virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) 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 */ @@ -103,7 +103,8 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> 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; @@ -111,7 +112,6 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> asset_map, b } } else { - try { picture.reset (new StereoPictureAsset ( _directory, @@ -122,6 +122,7 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> asset_map, b ); picture->set_entry_point (p->entry_point); + picture->set_duration (p->duration); } catch (MXFFileError) { if (require_mxfs) { @@ -141,6 +142,7 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> 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; @@ -155,6 +157,9 @@ CPL::CPL (string directory, string file, shared_ptr<const AssetMap> asset_map, b asset_map->asset_from_id ((*i)->asset_list->main_subtitle->id)->chunks.front()->path ) ); + + subtitle->set_entry_point ((*i)->asset_list->main_subtitle->entry_point); + subtitle->set_duration ((*i)->asset_list->main_subtitle->duration); } _reels.push_back (shared_ptr<Reel> (new Reel (picture, sound, subtitle))); diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc index eb323f59..cfb02c85 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<void (float)>* 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, MXFMeta bool MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { + if (!Asset::equals (other, opt, note)) { + return false; + } + shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other); if (!other_mxf) { note (ERROR, "comparing an MXF asset with a non-MXF asset"); @@ -85,21 +81,6 @@ MXFAsset::equals (shared_ptr<const Asset> 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 f5cee5de..55aa889a 100644 --- a/src/mxf_asset.h +++ b/src/mxf_asset.h @@ -51,27 +51,7 @@ public: */ MXFAsset (std::string directory, std::string file_name, boost::signals2::signal<void (float)>* 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<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> 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. @@ -83,14 +63,6 @@ protected: /** Signal to emit to report progress, or 0 */ boost::signals2::signal<void (float)>* _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; }; } diff --git a/src/picture_asset.cc b/src/picture_asset.cc index d98ef066..788e3dc4 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -368,13 +368,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<string>(frame)); + note (NOTE, "mean difference " + lexical_cast<string> (mean) + ", deviation " + lexical_cast<string> (std_dev)); + + if (mean > opt.max_mean_pixel_error) { + note (ERROR, "mean " + lexical_cast<string>(mean) + " out of range " + lexical_cast<string>(opt.max_mean_pixel_error) + " in frame " + lexical_cast<string>(frame)); + return false; + } + + if (std_dev > opt.max_std_dev_pixel_error) { + note (ERROR, "standard deviation " + lexical_cast<string>(std_dev) + " out of range " + lexical_cast<string>(opt.max_std_dev_pixel_error) + " in frame " + lexical_cast<string>(frame)); return false; } - note (NOTE, "mean difference " + lexical_cast<string> (mean) + ", deviation " + lexical_cast<string> (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] <DCP> <DCP>\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 <DCP>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; @@ -2,7 +2,7 @@ import subprocess import os APPNAME = 'libdcp' -VERSION = '0.48pre' +VERSION = '0.49pre' def options(opt): opt.load('compiler_cxx') |
