+
+ QueueItem qi;
+ qi.type = QueueItem::REPEAT;
+ qi.frame = f;
+
+ _queue.push_back (qi);
+
+ _condition.notify_all ();
+}
+
+
+void
+Writer::check_existing_picture_mxf ()
+{
+ /* Try to open the existing MXF */
+ boost::filesystem::path p;
+ p /= _film->video_mxf_dir ();
+ p /= _film->video_mxf_filename ();
+ FILE* mxf = fopen (p.string().c_str(), N_("rb"));
+ if (!mxf) {
+ return;
+ }
+
+ while (1) {
+
+ /* Read the frame info as written */
+ ifstream ifi (_film->info_path (_first_nonexistant_frame).c_str());
+ libdcp::FrameInfo info (ifi);
+
+ /* Read the data from the MXF and hash it */
+ fseek (mxf, info.offset, SEEK_SET);
+ EncodedData data (info.size);
+ fread (data.data(), 1, data.size(), mxf);
+ string const existing_hash = md5_digest (data.data(), data.size());
+
+ if (existing_hash != info.hash) {
+ _film->log()->log (String::compose (N_("Existing frame %1 failed hash check"), _first_nonexistant_frame));
+ break;
+ }
+
+ _film->log()->log (String::compose (N_("Have existing frame %1"), _first_nonexistant_frame));
+ ++_first_nonexistant_frame;
+ }
+
+ fclose (mxf);
+}
+
+/** @param frame Frame index.
+ * @return true if we can fake-write this frame.
+ */
+bool
+Writer::can_fake_write (int frame) const
+{
+ /* We have to do a proper write of the first frame so that we can set up the JPEG2000
+ parameters in the MXF writer.
+ */
+ return (frame != 0 && frame < _first_nonexistant_frame);
+}
+
+bool
+operator< (QueueItem const & a, QueueItem const & b)
+{
+ return a.frame < b.frame;
+}
+
+bool
+operator== (QueueItem const & a, QueueItem const & b)
+{
+ return a.frame == b.frame;