Some boost::filesystem::path cleanups; tweak for changes to libdcp.
[dcpomatic.git] / src / lib / make_dcp_job.cc
index fcb10069dabbca86bbfe0e3d1aa80160357375dc..37c9ca6206429d2a864e1f21e11c0c1f48805905 100644 (file)
@@ -36,7 +36,6 @@ extern "C" {
 #include "options.h"
 #include "imagemagick_decoder.h"
 #include "film.h"
-#include "format.h"
 
 using std::string;
 using std::cout;
@@ -45,8 +44,9 @@ using boost::shared_ptr;
 /** @param f Film we are making the DCP for.
  *  @param o Options.
  */
-MakeDCPJob::MakeDCPJob (shared_ptr<Film> f, shared_ptr<Job> req)
+MakeDCPJob::MakeDCPJob (shared_ptr<Film> f, shared_ptr<const EncodeOptions> o, shared_ptr<Job> req)
        : Job (f, req)
+       , _opt (o)
 {
        
 }
@@ -61,16 +61,14 @@ MakeDCPJob::name () const
 string
 MakeDCPJob::j2c_path (int f, int offset) const
 {
-       DCPFrameRate dfr (_film->frames_per_second());
-       int const mult = dfr.skip ? 2 : 1;
-       SourceFrame const s = ((f + offset) * mult) + _film->trim_start();
-       return _film->frame_out_path (s, false);
+       SourceFrame const s = ((f + offset) * dcp_frame_rate(_film->frames_per_second()).skip) + _film->dcp_trim_start();
+       return _opt->frame_out_path (s, false);
 }
 
 string
 MakeDCPJob::wav_path (libdcp::Channel c) const
 {
-       return _film->multichannel_audio_out_path (int (c), false);
+       return _opt->multichannel_audio_out_path (int (c), false);
 }
 
 void
@@ -87,16 +85,13 @@ MakeDCPJob::run ()
        /* Remove any old DCP */
        boost::filesystem::remove_all (dcp_path);
 
-       DCPFrameRate const dfr (_film->frames_per_second ());
+       DCPFrameRate const dfr = dcp_frame_rate (_film->frames_per_second ());
 
        int frames = 0;
        switch (_film->content_type ()) {
        case VIDEO:
                /* Source frames -> DCP frames */
-               frames = _film->dcp_length().get();
-               if (dfr.skip) {
-                       frames /= 2;
-               }
+               frames = _film->dcp_length().get() / dfr.skip;
                break;
        case STILL:
                frames = _film->still_duration() * 24;
@@ -138,8 +133,9 @@ MakeDCPJob::run ()
                                &dcp.Progress,
                                dfr.frames_per_second,
                                this_time,
-                               _film->format()->dcp_size().width,
-                               _film->format()->dcp_size().height
+                               _opt->out_size.width,
+                               _opt->out_size.height,
+                               _film->encrypted()
                                )
                        );
        
@@ -158,7 +154,8 @@ MakeDCPJob::run ()
                                        dfr.frames_per_second,
                                        this_time,
                                        frames_done,
-                                       dcp_audio_channels (_film->audio_channels())
+                                       dcp_audio_channels (_film->audio_channels()),
+                                       _film->encrypted()
                                        )
                                );
                        ascend ();