-bool
-Writer::check_existing_picture_asset_frame (FILE* asset, int f, Eyes eyes)
-{
- /* Read the frame info as written */
- FILE* file = fopen_boost (_film->info_file (), "rb");
- if (!file) {
- LOG_GENERAL ("Existing frame %1 has no info file", f);
- return false;
- }
-
- dcp::FrameInfo info = read_frame_info (file, f, eyes);
- fclose (file);
- if (info.size == 0) {
- LOG_GENERAL ("Existing frame %1 has no info file", f);
- return false;
- }
-
- /* Read the data from the asset and hash it */
- dcpomatic_fseek (asset, info.offset, SEEK_SET);
- Data data (info.size);
- size_t const read = fread (data.data().get(), 1, data.size(), asset);
- if (read != static_cast<size_t> (data.size ())) {
- LOG_GENERAL ("Existing frame %1 is incomplete", f);
- return false;
- }
-
- MD5Digester digester;
- digester.add (data.data().get(), data.size());
- if (digester.get() != info.hash) {
- LOG_GENERAL ("Existing frame %1 failed hash check", f);
- return false;
- }
-
- return true;
-}
-
-void
-Writer::check_existing_picture_asset ()
-{
- /* Try to open the existing asset */
- FILE* asset = fopen_boost (_picture_asset->file(), "rb");
- if (!asset) {
- LOG_GENERAL ("Could not open existing asset at %1 (errno=%2)", _picture_asset->file().string(), errno);
- return;
- }
-
- while (true) {
-
- shared_ptr<Job> job = _job.lock ();
- DCPOMATIC_ASSERT (job);
-
- job->set_progress_unknown ();
-
- if (_film->three_d ()) {
- if (!check_existing_picture_asset_frame (asset, _first_nonexistant_frame, EYES_LEFT)) {
- break;
- }
- if (!check_existing_picture_asset_frame (asset, _first_nonexistant_frame, EYES_RIGHT)) {
- break;
- }
- } else {
- if (!check_existing_picture_asset_frame (asset, _first_nonexistant_frame, EYES_BOTH)) {
- break;
- }
- }
-
- LOG_GENERAL ("Have existing frame %1", _first_nonexistant_frame);
- ++_first_nonexistant_frame;
- }
-
- fclose (asset);
-}
-
-/** @param frame Frame index.