diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/make_dcp_job.cc | 160 | ||||
| -rw-r--r-- | src/lib/make_dcp_job.h | 46 |
2 files changed, 0 insertions, 206 deletions
diff --git a/src/lib/make_dcp_job.cc b/src/lib/make_dcp_job.cc deleted file mode 100644 index 705521626..000000000 --- a/src/lib/make_dcp_job.cc +++ /dev/null @@ -1,160 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -/** @file src/make_dcp_job.cc - * @brief A job to create DCPs. - */ - -#include <iostream> -#include <boost/filesystem.hpp> -#include <libdcp/dcp.h> -#include <libdcp/picture_asset.h> -#include <libdcp/sound_asset.h> -#include <libdcp/reel.h> -extern "C" { -#include <libavutil/pixdesc.h> -} -#include "make_dcp_job.h" -#include "dcp_content_type.h" -#include "exceptions.h" -#include "options.h" -#include "imagemagick_decoder.h" -#include "film.h" - -using std::string; -using std::cout; -using boost::shared_ptr; - -/** @param f Film we are making the DCP for. - * @param o Options. - */ -MakeDCPJob::MakeDCPJob (shared_ptr<Film> f, shared_ptr<const EncodeOptions> o, shared_ptr<Job> req) - : Job (f, req) - , _opt (o) -{ - -} - -string -MakeDCPJob::name () const -{ - return String::compose ("Make DCP for %1", _film->name()); -} - -/** @param f DCP frame index */ -string -MakeDCPJob::j2c_path (int f) const -{ - SourceFrame const s = (f * 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 _opt->multichannel_audio_out_path (int (c), false); -} - -void -MakeDCPJob::run () -{ - if (!_film->dcp_length()) { - throw EncodeError ("cannot make a DCP when the source length is not known"); - } - - descend (0.9); - - string const dcp_path = _film->dir (_film->dcp_name()); - - /* Remove any old DCP */ - boost::filesystem::remove_all (dcp_path); - - 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() / dfr.skip; - break; - case STILL: - frames = _film->still_duration() * 24; - break; - } - - libdcp::DCP dcp (_film->dir (_film->dcp_name())); - dcp.Progress.connect (boost::bind (&MakeDCPJob::dcp_progress, this, _1)); - - shared_ptr<libdcp::CPL> cpl ( - new libdcp::CPL (_film->dir (_film->dcp_name()), _film->dcp_name(), _film->dcp_content_type()->libdcp_kind (), frames, dfr.frames_per_second) - ); - - dcp.add_cpl (cpl); - - descend (0.8); - - shared_ptr<libdcp::MonoPictureAsset> pa ( - new libdcp::MonoPictureAsset ( - boost::bind (&MakeDCPJob::j2c_path, this, _1), - _film->dir (_film->dcp_name()), - "video.mxf", - &dcp.Progress, - dfr.frames_per_second, - frames, - _opt->out_size - ) - ); - - ascend (); - - shared_ptr<libdcp::SoundAsset> sa; - - if (_film->audio_channels() > 0) { - descend (0.1); - sa.reset ( - new libdcp::SoundAsset ( - boost::bind (&MakeDCPJob::wav_path, this, _1), - _film->dir (_film->dcp_name()), - "audio.mxf", - &dcp.Progress, - dfr.frames_per_second, - frames, - dcp_audio_channels (_film->audio_channels()) - ) - ); - ascend (); - } - - descend (0.05); - cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (pa, sa, shared_ptr<libdcp::SubtitleAsset> ()))); - ascend (); - - descend (0.05); - dcp.write_xml (); - ascend (); - - set_progress (1); - set_state (FINISHED_OK); -} - -void -MakeDCPJob::dcp_progress (float p) -{ - set_progress (p); -} diff --git a/src/lib/make_dcp_job.h b/src/lib/make_dcp_job.h deleted file mode 100644 index 1aa906b0a..000000000 --- a/src/lib/make_dcp_job.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -/** @file src/make_dcp_job.h - * @brief A job to create DCPs. - */ - -#include "job.h" - -class EncodeOptions; - -/** @class MakeDCPJob - * @brief A job to create DCPs - */ -class MakeDCPJob : public Job -{ -public: - MakeDCPJob (boost::shared_ptr<Film>, boost::shared_ptr<const EncodeOptions>, boost::shared_ptr<Job> req); - - std::string name () const; - void run (); - -private: - void dcp_progress (float); - std::string j2c_path (int) const; - std::string wav_path (libdcp::Channel) const; - - boost::shared_ptr<const EncodeOptions> _opt; -}; - |
