From 49fc9b8c4282d0e973ac1f4e31357735cf6be218 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 29 Jul 2016 23:15:26 +0100 Subject: [PATCH] Add reel index/count to DCP filename format. --- cscript | 2 +- src/lib/reel_writer.cc | 17 ++++++++++------- src/lib/reel_writer.h | 6 +++++- src/lib/util.cc | 8 ++++++-- src/lib/util.h | 4 ++-- src/lib/writer.cc | 6 ++++-- src/wx/config_dialog.cc | 4 ++++ src/wx/name_format_editor.h | 2 +- 8 files changed, 33 insertions(+), 16 deletions(-) diff --git a/cscript b/cscript index 2ce672385..5d0c949e8 100644 --- a/cscript +++ b/cscript @@ -237,7 +237,7 @@ def dependencies(target): ffmpeg_options = {} return (('ffmpeg-cdist', '1d4a1a4', ffmpeg_options), - ('libdcp', '7e9ad08'), + ('libdcp', 'f3fb557'), ('libsub', '067c21c')) def configure_options(target): diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index d576eb2a0..b712ac3c5 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This file is part of DCP-o-matic. @@ -60,13 +60,15 @@ using dcp::Data; int const ReelWriter::_info_size = 48; -ReelWriter::ReelWriter (shared_ptr film, DCPTimePeriod period, shared_ptr job) +ReelWriter::ReelWriter (shared_ptr film, DCPTimePeriod period, shared_ptr job, int reel_index, int reel_count) : _film (film) , _period (period) , _first_nonexistant_frame (0) , _last_written_video_frame (-1) , _last_written_eyes (EYES_RIGHT) , _total_written_audio_frames (0) + , _reel_index (reel_index) + , _reel_count (reel_count) { /* Create our picture asset in a subdirectory, named according to those film's parameters which affect the video output. We will hard-link @@ -111,7 +113,7 @@ ReelWriter::ReelWriter (shared_ptr film, DCPTimePeriod period, share of the DCP directory until the last minute. */ _sound_asset_writer = _sound_asset->start_write ( - _film->directory() / audio_asset_filename (_sound_asset), + _film->directory() / audio_asset_filename (_sound_asset, _reel_index, _reel_count), _film->interop() ? dcp::INTEROP : dcp::SMPTE ); } @@ -266,7 +268,7 @@ ReelWriter::finish () boost::filesystem::path video_from = _picture_asset->file (); boost::filesystem::path video_to; video_to /= _film->dir (_film->dcp_name()); - video_to /= video_asset_filename (_picture_asset); + video_to /= video_asset_filename (_picture_asset, _reel_index, _reel_count); boost::system::error_code ec; boost::filesystem::create_hard_link (video_from, video_to, ec); @@ -286,13 +288,14 @@ ReelWriter::finish () if (_sound_asset) { boost::filesystem::path audio_to; audio_to /= _film->dir (_film->dcp_name ()); - audio_to /= audio_asset_filename (_sound_asset); + string const aaf = audio_asset_filename (_sound_asset, _reel_index, _reel_count); + audio_to /= aaf; boost::system::error_code ec; - boost::filesystem::rename (_film->file (audio_asset_filename (_sound_asset)), audio_to, ec); + boost::filesystem::rename (_film->file (aaf), audio_to, ec); if (ec) { throw FileError ( - String::compose (_("could not move audio asset into the DCP (%1)"), ec.value ()), audio_asset_filename (_sound_asset) + String::compose (_("could not move audio asset into the DCP (%1)"), ec.value ()), aaf ); } diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 9dc740171..a80f51dc2 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -47,7 +47,7 @@ namespace dcp { class ReelWriter { public: - ReelWriter (boost::shared_ptr film, DCPTimePeriod period, boost::shared_ptr job); + ReelWriter (boost::shared_ptr film, DCPTimePeriod period, boost::shared_ptr job, int reel_index, int reel_count); void write (boost::optional encoded, Frame frame, Eyes eyes); void fake_write (Frame frame, Eyes eyes, int size); @@ -102,6 +102,10 @@ private: Eyes _last_written_eyes; /** the number of audio frames that have been written to the reel */ int _total_written_audio_frames; + /** index of this reel within the DCP (starting from 0) */ + int _reel_index; + /** number of reels in the DCP */ + int _reel_count; boost::shared_ptr _picture_asset; boost::shared_ptr _picture_asset_writer; diff --git a/src/lib/util.cc b/src/lib/util.cc index 59974c24c..c8d0561be 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -617,20 +617,24 @@ split_get_request (string url) } string -video_asset_filename (shared_ptr asset) +video_asset_filename (shared_ptr asset, int reel_index, int reel_count) { dcp::NameFormat::Map values; values['t'] = "j2c"; values['i'] = asset->id(); + values['r'] = raw_convert (reel_index + 1); + values['n'] = raw_convert (reel_count); return Config::instance()->dcp_filename_format().get(values) + ".mxf"; } string -audio_asset_filename (shared_ptr asset) +audio_asset_filename (shared_ptr asset, int reel_index, int reel_count) { dcp::NameFormat::Map values; values['t'] = "pcm"; values['i'] = asset->id(); + values['r'] = raw_convert (reel_index + 1); + values['n'] = raw_convert (reel_count); return Config::instance()->dcp_filename_format().get(values) + ".mxf"; } diff --git a/src/lib/util.h b/src/lib/util.h index c94d0fc9f..b3621bb13 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -74,8 +74,8 @@ extern int stride_round_up (int, int const *, int); extern void* wrapped_av_malloc (size_t); extern void set_backtrace_file (boost::filesystem::path); extern std::map split_get_request (std::string url); -extern std::string video_asset_filename (boost::shared_ptr asset); -extern std::string audio_asset_filename (boost::shared_ptr asset); +extern std::string video_asset_filename (boost::shared_ptr asset, int reel_index, int reel_count); +extern std::string audio_asset_filename (boost::shared_ptr asset, int reel_index, int reel_count); extern float relaxed_string_to_float (std::string); extern bool string_not_empty (std::string); diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 00dfcdcbe..9aee7d92f 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -84,8 +84,10 @@ Writer::Writer (shared_ptr film, weak_ptr j) shared_ptr job = _job.lock (); DCPOMATIC_ASSERT (job); - BOOST_FOREACH (DCPTimePeriod p, _film->reels ()) { - _reels.push_back (ReelWriter (film, p, job)); + int reel_index = 0; + list const reels = _film->reels (); + BOOST_FOREACH (DCPTimePeriod p, reels) { + _reels.push_back (ReelWriter (film, p, job, reel_index++, reels.size())); } /* We can keep track of the current audio and subtitle reels easily because audio diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index a68f4576d..10ee7c79a 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -1413,9 +1413,13 @@ private: dcp::NameFormat::Map titles; titles['t'] = "type (j2c/pcm/sub/cpl/pkl)"; titles['i'] = "unique ID"; + titles['r'] = "reel number"; + titles['n'] = "number of reels"; dcp::NameFormat::Map examples; examples['t'] = "j2c"; examples['i'] = "eb1c112c-ca3c-4ae6-9263-c6714ff05d64"; + examples['r'] = "1"; + examples['n'] = "4"; _dcp_filename_format = new NameFormatEditor (_panel, Config::instance()->dcp_filename_format(), titles, examples); table->Add (_dcp_filename_format->panel(), 1, wxEXPAND | wxALL); diff --git a/src/wx/name_format_editor.h b/src/wx/name_format_editor.h index 0f4682127..71295807f 100644 --- a/src/wx/name_format_editor.h +++ b/src/wx/name_format_editor.h @@ -83,7 +83,7 @@ private: wxString example = wxString::Format (_("e.g. %s"), _name.get (_examples)); wxString wrapped; for (size_t i = 0; i < example.Length(); ++i) { - if (i > 0 && (i % 30) == 0) { + if (i > 0 && (i % 40) == 0) { wrapped += "\n"; } wrapped += example[i]; -- 2.30.2