Merge master.
[dcpomatic.git] / src / lib / writer.cc
index a4c10195c5b156aba190b0ccb4d90560109f58a0..125efd644e857933a2bf59d1157061eec405bde8 100644 (file)
 
 #include <fstream>
 #include <cerrno>
-#include <libdcp/mono_picture_mxf.h>
-#include <libdcp/stereo_picture_mxf.h>
-#include <libdcp/sound_mxf.h>
-#include <libdcp/sound_mxf_writer.h>
-#include <libdcp/reel.h>
-#include <libdcp/reel_mono_picture_asset.h>
-#include <libdcp/reel_stereo_picture_asset.h>
-#include <libdcp/reel_sound_asset.h>
-#include <libdcp/dcp.h>
-#include <libdcp/cpl.h>
+#include <dcp/mono_picture_mxf.h>
+#include <dcp/stereo_picture_mxf.h>
+#include <dcp/sound_mxf.h>
+#include <dcp/sound_mxf_writer.h>
+#include <dcp/reel.h>
+#include <dcp/reel_mono_picture_asset.h>
+#include <dcp/reel_stereo_picture_asset.h>
+#include <dcp/reel_sound_asset.h>
+#include <dcp/dcp.h>
+#include <dcp/cpl.h>
 #include "writer.h"
 #include "compose.hpp"
 #include "film.h"
 #include "config.h"
 #include "job.h"
 #include "cross.h"
+#include "audio_buffers.h"
 
 #include "i18n.h"
 
+/* OS X strikes again */
+#undef set_key
+
 using std::make_pair;
 using std::pair;
 using std::string;
@@ -90,7 +94,7 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j)
                _picture_mxf.reset (new dcp::MonoPictureMXF (dcp::Fraction (_film->video_frame_rate (), 1)));
        }
 
-       _picture_mxf->set_size (fit_ratio_within (_film->container()->ratio(), _film->full_frame ()));
+       _picture_mxf->set_size (_film->frame_size ());
 
        if (_film->encrypted ()) {
                _picture_mxf->set_key (_film->key ());
@@ -291,16 +295,16 @@ try
                        _last_written_frame = qi.frame;
                        _last_written_eyes = qi.eyes;
                        
-                       if (_film->length()) {
-                               shared_ptr<Job> job = _job.lock ();
-                               assert (job);
-                               int total = _film->time_to_video_frames (_film->length ());
-                               if (_film->three_d ()) {
-                                       /* _full_written and so on are incremented for each eye, so we need to double the total
-                                          frames to get the correct progress.
-                                       */
-                                       total *= 2;
-                               }
+                       shared_ptr<Job> job = _job.lock ();
+                       assert (job);
+                       int64_t total = _film->length().frames (_film->video_frame_rate ());
+                       if (_film->three_d ()) {
+                               /* _full_written and so on are incremented for each eye, so we need to double the total
+                                  frames to get the correct progress.
+                               */
+                               total *= 2;
+                       }
+                       if (total) {
                                job->set_progress (float (_full_written + _fake_written + _repeat_written) / total);
                        }
                }