diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-15 13:48:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-15 13:48:22 +0100 |
| commit | 034abb6bb0f1d0382620bdcc43501ce0ba30b03a (patch) | |
| tree | 862347349d48e3afae6190e60fbc2d0cfa88f23c | |
| parent | 6322c72a13d7be2e991a8e0421414c0af8187b88 (diff) | |
Try to give basic progress indication on dcpdiff.
| -rw-r--r-- | src/asset.h | 2 | ||||
| -rw-r--r-- | src/dcp.cc | 16 | ||||
| -rw-r--r-- | src/dcp.h | 4 | ||||
| -rw-r--r-- | src/mxf_asset.cc | 12 | ||||
| -rw-r--r-- | src/mxf_asset.h | 2 | ||||
| -rw-r--r-- | src/picture_asset.cc | 17 | ||||
| -rw-r--r-- | src/picture_asset.h | 8 | ||||
| -rw-r--r-- | src/reel.cc | 8 | ||||
| -rw-r--r-- | src/reel.h | 2 | ||||
| -rw-r--r-- | src/sound_asset.cc | 8 | ||||
| -rw-r--r-- | src/sound_asset.h | 2 | ||||
| -rw-r--r-- | src/subtitle_asset.h | 4 | ||||
| -rw-r--r-- | src/types.h | 5 | ||||
| -rw-r--r-- | tools/dcpdiff.cc | 23 |
14 files changed, 64 insertions, 49 deletions
diff --git a/src/asset.h b/src/asset.h index 527dea7a..1b1bf4c6 100644 --- a/src/asset.h +++ b/src/asset.h @@ -81,7 +81,7 @@ public: _file_name = f; } - virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (std::string)>) const = 0; + virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const = 0; protected: @@ -248,10 +248,10 @@ DCP::read (bool require_mxfs) } bool -DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (string)> note) const +DCP::equals (DCP const & other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { if (_cpls.size() != other._cpls.size()) { - note ("CPL counts differ"); + note (ERROR, "CPL counts differ"); return false; } @@ -516,30 +516,30 @@ CPL::write_to_assetmap (ostream& s) const bool -CPL::equals (CPL const & other, EqualityOptions opt, boost::function<void (string)> note) const +CPL::equals (CPL const & other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { if (_name != other._name) { - note ("names differ"); + note (ERROR, "names differ"); return false; } if (_content_kind != other._content_kind) { - note ("content kinds differ"); + note (ERROR, "content kinds differ"); return false; } if (_fps != other._fps) { - note ("frames per second differ"); + note (ERROR, "frames per second differ"); return false; } if (_length != other._length) { - note ("lengths differ"); + note (ERROR, "lengths differ"); return false; } if (_reels.size() != other._reels.size()) { - note ("reel counts differ"); + note (ERROR, "reel counts differ"); return false; } @@ -84,7 +84,7 @@ public: std::list<boost::shared_ptr<const Asset> > assets () const; - bool equals (CPL const & other, EqualityOptions options, boost::function<void (std::string)> note) const; + bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const; void write_xml () const; void write_to_assetmap (std::ostream& s) const; @@ -144,7 +144,7 @@ public: * @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, boost::function<void (std::string)> note) const; + bool equals (DCP const & other, EqualityOptions options, boost::function<void (NoteType, 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 cf265712..9b491dd7 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, boost::function<void (string)> note) const +MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, boost::function<void (NoteType, string)> note) const { shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other); if (!other_mxf) { - note ("comparing an MXF asset with a non-MXF asset"); + note (ERROR, "comparing an MXF asset with a non-MXF asset"); return false; } if (_file_name != other_mxf->_file_name) { - note ("MXF names differ"); + note (ERROR, "MXF names differ"); return false; } if (_edit_rate != other_mxf->_edit_rate) { - note ("MXF edit rates differ"); + note (ERROR, "MXF edit rates differ"); return false; } if (_intrinsic_duration != other_mxf->_intrinsic_duration) { - note ("MXF intrinsic durations differ"); + note (ERROR, "MXF intrinsic durations differ"); return false; } if (_duration != other_mxf->_duration) { - note ("MXF durations differ"); + note (ERROR, "MXF durations differ"); return false; } diff --git a/src/mxf_asset.h b/src/mxf_asset.h index 0c98f3c6..29b3c1b0 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, boost::function<void (std::string)> note) const; + 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; diff --git a/src/picture_asset.cc b/src/picture_asset.cc index 807564c5..4b775980 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -79,7 +79,7 @@ PictureAsset::write_to_cpl (ostream& s) const } bool -PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const +PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { if (!MXFAsset::equals (other, opt, note)) { return false; @@ -125,7 +125,7 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost: // desc_A.QuantizationDefault != desc_B.QuantizationDefault ) { - note ("video MXF picture descriptors differ"); + note (ERROR, "video MXF picture descriptors differ"); return false; } @@ -248,7 +248,7 @@ MonoPictureAsset::get_frame (int n) const bool -MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const +MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { if (!PictureAsset::equals (other, opt, note)) { return false; @@ -258,6 +258,7 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, bo assert (other_picture); for (int i = 0; i < _intrinsic_duration; ++i) { + note (PROGRESS, "Comparing video frame " + lexical_cast<string> (i) + " of " + lexical_cast<string> (_intrinsic_duration)); shared_ptr<const MonoPictureFrame> frame_A = get_frame (i); shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i); @@ -274,7 +275,7 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, bo } bool -StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const +StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { if (!PictureAsset::equals (other, opt, note)) { return false; @@ -309,7 +310,7 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, bool PictureAsset::frame_buffer_equals ( - int frame, EqualityOptions opt, boost::function<void (string)> note, + int frame, EqualityOptions opt, boost::function<void (NoteType, string)> note, uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B ) const { @@ -325,7 +326,7 @@ PictureAsset::frame_buffer_equals ( /* Compare them */ if (image_A->numcomps != image_B->numcomps) { - note ("image component counts for frame " + lexical_cast<string>(frame) + " differ"); + note (ERROR, "image component counts for frame " + lexical_cast<string>(frame) + " differ"); return false; } @@ -336,7 +337,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) { - note ("image sizes for frame " + lexical_cast<string>(frame) + " differ"); + note (ERROR, "image sizes for frame " + lexical_cast<string>(frame) + " differ"); return false; } @@ -363,7 +364,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) { - note ("mean or standard deviation out of range for " + lexical_cast<string>(frame)); + note (ERROR, "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 f4d4d7a4..c9226b1f 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, boost::function<void (std::string)> note) const; + bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const; Size size () const { return _size; @@ -72,7 +72,7 @@ public: protected: bool frame_buffer_equals ( - int frame, EqualityOptions opt, boost::function<void (std::string)> note, + int frame, EqualityOptions opt, boost::function<void (NoteType, 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, boost::function<void (std::string)> note) const; + bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, 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, boost::function<void (std::string)> note) const; + bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const; }; diff --git a/src/reel.cc b/src/reel.cc index 096acf19..86533ea2 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -50,10 +50,10 @@ Reel::write_to_cpl (ostream& s) const } bool -Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (string)> note) const +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 ("reel has different assets"); + note (ERROR, "reel has different assets"); return false; } @@ -62,7 +62,7 @@ Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::f } if ((_main_sound && !other->_main_sound) || (!_main_sound && other->_main_sound)) { - note ("reel has different assets"); + note (ERROR, "reel has different assets"); return false; } @@ -71,7 +71,7 @@ Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::f } if ((_main_subtitle && !other->_main_subtitle) || (!_main_subtitle && other->_main_subtitle)) { - note ("reel has different assets"); + note (ERROR, "reel has different assets"); return false; } @@ -56,7 +56,7 @@ public: void write_to_cpl (std::ostream & s) const; - bool equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (std::string)> notes) const; + bool equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (NoteType, 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 da6e72bc..6e29aadf 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -222,7 +222,7 @@ SoundAsset::write_to_cpl (ostream& s) const } bool -SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (string)> note) const +SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const { if (!MXFAsset::equals (other, opt, note)) { return false; @@ -260,7 +260,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::f // desc_A.ChannelFormat != desc_B.ChannelFormat || ) { - note ("audio MXF picture descriptors differ"); + note (ERROR, "audio MXF picture descriptors differ"); return false; } @@ -277,7 +277,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::f } if (buffer_A.Size() != buffer_B.Size()) { - note ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ"); + note (ERROR, "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, boost::f 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) { - note ("PCM data difference of " + lexical_cast<string> (d)); + note (ERROR, "PCM data difference of " + lexical_cast<string> (d)); return false; } } diff --git a/src/sound_asset.h b/src/sound_asset.h index dedebac3..9e6e75cf 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, boost::function<void (std::string)> note) const; + bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, 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 b3936dc2..1e31df2b 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, boost::function<void (std::string)> note) const { + virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const { /* XXX */ - note ("subtitle assets not compared yet"); + note (ERROR, "subtitle assets not compared yet"); return true; } diff --git a/src/types.h b/src/types.h index ebcfb838..4c824080 100644 --- a/src/types.h +++ b/src/types.h @@ -107,6 +107,11 @@ struct EqualityOptions { int max_audio_sample_error; }; +enum NoteType { + PROGRESS, + ERROR +}; + /** @class Color * @brief An RGB color (aka colour). */ diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index 6d55586d..7913c533 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -8,12 +8,15 @@ using namespace std; using namespace boost; using namespace libdcp; +static bool verbose = false; + static void help (string n) { cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n" - << " -v, --version show libdcp version\n" + << " -V, --version show libdcp version\n" << " -h, --help show this help\n" + << " -v, --verbose be verbose\n" << "\n" << "The <DCP>s are the DCP directories to compare.\n" << "Comparison is of metadata and content, ignoring timestamps\n" @@ -21,9 +24,11 @@ help (string n) } void -note (string n) +note (NoteType t, string n) { - cout << " " << n << "\n"; + if (t == ERROR || (t == PROGRESS && verbose)) { + cout << " " << n << "\n"; + } } int @@ -34,24 +39,28 @@ main (int argc, char* argv[]) int option_index = 0; while (1) { static struct option long_options[] = { - { "version", no_argument, 0, 'v'}, + { "version", no_argument, 0, 'V'}, { "help", no_argument, 0, 'h'}, + { "verbose", no_argument, 0, 'v'}, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "vh", long_options, &option_index); + int c = getopt_long (argc, argv, "Vhv", long_options, &option_index); if (c == -1) { break; } switch (c) { - case 'v': + case 'V': cout << "dcpdiff version " << LIBDCP_VERSION << "\n"; exit (EXIT_SUCCESS); case 'h': help (argv[0]); exit (EXIT_SUCCESS); + case 'v': + verbose = true; + break; } } @@ -93,7 +102,7 @@ main (int argc, char* argv[]) /* 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; - bool const equals = a->equals (*b, options, boost::bind (note, _1)); + bool const equals = a->equals (*b, options, boost::bind (note, _1, _2)); if (equals) { exit (EXIT_SUCCESS); |
