diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-25 01:21:17 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-25 01:21:17 +0000 |
| commit | 494b6ee180e531358bab39e72f6123e90f9314e5 (patch) | |
| tree | cabae95d5a0a6b2bfdfad7a9e590a2780f38426d /src/lib | |
| parent | cd21997cc5d7e6bc16c6c6e767e61cddfc7f6add (diff) | |
Basics of checking video MXFs.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/writer.cc | 40 | ||||
| -rw-r--r-- | src/lib/writer.h | 2 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 33a7f42af..3ec88860a 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -17,8 +17,10 @@ */ +#include <fstream> #include <libdcp/picture_asset.h> #include <libdcp/sound_asset.h> +#include <libdcp/picture_frame.h> #include <libdcp/reel.h> #include "writer.h" #include "compose.hpp" @@ -29,16 +31,22 @@ using std::make_pair; using std::pair; +using std::string; +using std::ifstream; +using std::cout; using boost::shared_ptr; unsigned int const Writer::_maximum_frames_in_memory = 8; Writer::Writer (shared_ptr<Film> f) : _film (f) + , _first_nonexistant_frame (0) , _thread (0) , _finish (false) , _last_written_frame (-1) { + check_existing_picture_mxf (); + /* Create our picture asset in a subdirectory, named according to the film's parameters which affect the video output. We will hard-link it into the DCP later. @@ -260,3 +268,35 @@ Writer::repeat (int f) boost::mutex::scoped_lock lock (_mutex); _queue.push_back (make_pair (shared_ptr<const EncodedData> (), f)); } + +void +Writer::check_existing_picture_mxf () +{ + boost::filesystem::path p; + p /= _film->video_mxf_dir (); + p /= _film->video_mxf_filename (); + if (!boost::filesystem::exists (p)) { + return; + } + + libdcp::MonoPictureAsset existing (_film->video_mxf_dir(), _film->video_mxf_filename()); + + while (_first_nonexistant_frame < existing.intrinsic_duration()) { + + shared_ptr<const libdcp::MonoPictureFrame> f = existing.get_frame (_first_nonexistant_frame); + string const existing_hash = md5_digest (f->j2k_data(), f->j2k_size()); + + ifstream hf (_film->hash_path (_first_nonexistant_frame).c_str ()); + string reference_hash; + hf >> reference_hash; + + if (existing_hash != reference_hash) { + cout << "frame " << _first_nonexistant_frame << " failed hash check.\n"; + break; + } + + cout << "frame " << _first_nonexistant_frame << " ok.\n"; + ++_first_nonexistant_frame; + } +} + diff --git a/src/lib/writer.h b/src/lib/writer.h index 1aaea4d9d..768d63448 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -46,8 +46,10 @@ public: private: void thread (); + void check_existing_picture_mxf (); boost::shared_ptr<Film> _film; + int _first_nonexistant_frame; boost::thread* _thread; bool _finish; |
