diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ab_transcoder.cc | 17 | ||||
| -rw-r--r-- | src/lib/analyse_audio_job.cc | 3 | ||||
| -rw-r--r-- | src/lib/combiner.cc | 2 | ||||
| -rw-r--r-- | src/lib/combiner.h | 2 | ||||
| -rw-r--r-- | src/lib/dcp_video_frame.cc | 4 | ||||
| -rw-r--r-- | src/lib/dcp_video_frame.h | 4 | ||||
| -rw-r--r-- | src/lib/delay_line.cc | 2 | ||||
| -rw-r--r-- | src/lib/delay_line.h | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 51 | ||||
| -rw-r--r-- | src/lib/film.h | 15 | ||||
| -rw-r--r-- | src/lib/gain.cc | 2 | ||||
| -rw-r--r-- | src/lib/gain.h | 2 | ||||
| -rw-r--r-- | src/lib/matcher.cc | 2 | ||||
| -rw-r--r-- | src/lib/matcher.h | 2 | ||||
| -rw-r--r-- | src/lib/processor.h | 10 | ||||
| -rw-r--r-- | src/lib/server.cc | 2 | ||||
| -rw-r--r-- | src/lib/server.h | 4 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 3 | ||||
| -rw-r--r-- | src/lib/transcoder.cc | 1 | ||||
| -rw-r--r-- | src/lib/writer.cc | 12 |
20 files changed, 75 insertions, 67 deletions
diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc index 4ed5d02ca..3a1cd83d7 100644 --- a/src/lib/ab_transcoder.cc +++ b/src/lib/ab_transcoder.cc @@ -40,6 +40,7 @@ using std::string; using boost::shared_ptr; +using boost::dynamic_pointer_cast; /** @param a Film to use for the left half of the screen. * @param b Film to use for the right half of the screen. @@ -54,6 +55,7 @@ ABTranscoder::ABTranscoder ( , _film_b (b) , _job (j) , _encoder (e) + , _combiner (new Combiner (a->log())) { _da = decoder_factory (_film_a, o); _db = decoder_factory (_film_b, o); @@ -92,17 +94,24 @@ void ABTranscoder::go () { _encoder->process_begin (); + + bool done[3] = { false, false, false }; while (1) { - bool const va = _da.video->pass (); - bool const vb = _db.video->pass (); - bool const a = _da.audio->pass (); + done[0] = _da.video->pass (); + done[1] = _db.video->pass (); + + if (!done[2] && _da.audio && dynamic_pointer_cast<Decoder> (_da.audio) != dynamic_pointer_cast<Decoder> (_da.video)) { + done[2] = _da.audio->pass (); + } else { + done[2] = true; + } if (_job) { _da.video->set_progress (_job); } - if (va && vb && a) { + if (done[0] && done[1] && done[2]) { break; } } diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 41f918f34..92c3cdd4e 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -29,6 +29,7 @@ using std::string; using std::max; +using std::min; using std::cout; using boost::shared_ptr; @@ -67,7 +68,7 @@ AnalyseAudioJob::run () decoders.audio->Audio.connect (bind (&AnalyseAudioJob::audio, this, _1)); int64_t total_audio_frames = video_frames_to_audio_frames (_film->length().get(), _film->audio_stream()->sample_rate(), _film->source_frame_rate()); - _samples_per_point = total_audio_frames / _num_points; + _samples_per_point = max (1L, total_audio_frames / _num_points); _current.resize (_film->audio_stream()->channels ()); _analysis.reset (new AudioAnalysis (_film->audio_stream()->channels())); diff --git a/src/lib/combiner.cc b/src/lib/combiner.cc index 68aafd2a2..12ce4a96e 100644 --- a/src/lib/combiner.cc +++ b/src/lib/combiner.cc @@ -22,7 +22,7 @@ using boost::shared_ptr; -Combiner::Combiner (Log* log) +Combiner::Combiner (shared_ptr<Log> log) : VideoProcessor (log) { diff --git a/src/lib/combiner.h b/src/lib/combiner.h index 7fad1aeae..68026eaff 100644 --- a/src/lib/combiner.h +++ b/src/lib/combiner.h @@ -31,7 +31,7 @@ class Combiner : public VideoProcessor { public: - Combiner (Log* log); + Combiner (boost::shared_ptr<Log> log); void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s); void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s); diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 67617c63c..d674393a9 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -70,7 +70,7 @@ using libdcp::Size; * @param out Required size of output, in pixels (including any padding). * @param s Scaler to use. * @param p Number of pixels of padding either side of the image. - * @param f Index of the frame within the DCP's intrinsic duration. + * @param f Index of the frame within the DCP. * @param fps Frames per second of the Film's source. * @param pp FFmpeg post-processing string to use. * @param clut Colour look-up table to use (see Config::colour_lut_index ()) @@ -80,7 +80,7 @@ using libdcp::Size; DCPVideoFrame::DCPVideoFrame ( shared_ptr<const Image> yuv, shared_ptr<Subtitle> sub, Size out, int p, int subtitle_offset, float subtitle_scale, - Scaler const * s, int f, int dcp_fps, string pp, int clut, int bw, Log* l + Scaler const * s, int f, int dcp_fps, string pp, int clut, int bw, shared_ptr<Log> l ) : _input (yuv) , _subtitle (sub) diff --git a/src/lib/dcp_video_frame.h b/src/lib/dcp_video_frame.h index 6794765ac..4ceb07d26 100644 --- a/src/lib/dcp_video_frame.h +++ b/src/lib/dcp_video_frame.h @@ -107,7 +107,7 @@ class DCPVideoFrame public: DCPVideoFrame ( boost::shared_ptr<const Image>, boost::shared_ptr<Subtitle>, libdcp::Size, - int, int, float, Scaler const *, int, int, std::string, int, int, Log * + int, int, float, Scaler const *, int, int, std::string, int, int, boost::shared_ptr<Log> ); virtual ~DCPVideoFrame (); @@ -135,7 +135,7 @@ private: int _colour_lut; ///< Colour look-up table to use int _j2k_bandwidth; ///< J2K bandwidth to use - Log* _log; ///< log + boost::shared_ptr<Log> _log; ///< log opj_image_cmptparm_t _cmptparm[3]; ///< libopenjpeg's opj_image_cmptparm_t opj_image* _image; ///< libopenjpeg's image container diff --git a/src/lib/delay_line.cc b/src/lib/delay_line.cc index 4ad172781..53da9a412 100644 --- a/src/lib/delay_line.cc +++ b/src/lib/delay_line.cc @@ -30,7 +30,7 @@ using boost::shared_ptr; /** @param channels Number of channels of audio. * @param frames Delay in frames, +ve to move audio later. */ -DelayLine::DelayLine (Log* log, int channels, int frames) +DelayLine::DelayLine (shared_ptr<Log> log, int channels, int frames) : AudioProcessor (log) , _negative_delay_remaining (0) , _frames (frames) diff --git a/src/lib/delay_line.h b/src/lib/delay_line.h index 4d6f1313b..c51784f35 100644 --- a/src/lib/delay_line.h +++ b/src/lib/delay_line.h @@ -26,7 +26,7 @@ class AudioBuffers; class DelayLine : public AudioProcessor { public: - DelayLine (Log* log, int channels, int frames); + DelayLine (boost::shared_ptr<Log> log, int channels, int frames); void process_audio (boost::shared_ptr<AudioBuffers>); diff --git a/src/lib/film.cc b/src/lib/film.cc index 8f545952b..77f9828cd 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -144,12 +144,13 @@ Film::Film (string d, bool must_exist) read_metadata (); } - _log = new FileLog (file ("log")); + _log.reset (new FileLog (file ("log"))); } Film::Film (Film const & o) : boost::enable_shared_from_this<Film> (o) - , _log (0) + /* note: the copied film shares the original's log */ + , _log (o._log) , _directory (o._directory) , _name (o._name) , _use_dci_name (o._use_dci_name) @@ -180,7 +181,6 @@ Film::Film (Film const & o) , _dcp_frame_rate (o._dcp_frame_rate) , _size (o._size) , _length (o._length) - , _dcp_intrinsic_duration (o._dcp_intrinsic_duration) , _content_digest (o._content_digest) , _content_audio_streams (o._content_audio_streams) , _external_audio_stream (o._external_audio_stream) @@ -188,12 +188,12 @@ Film::Film (Film const & o) , _source_frame_rate (o._source_frame_rate) , _dirty (o._dirty) { - + } Film::~Film () { - delete _log; + } string @@ -350,9 +350,12 @@ void Film::analyse_audio_finished () { ensure_ui_thread (); - _analyse_audio_job.reset (); - AudioAnalysisFinished (); + if (_analyse_audio_job->finished_ok ()) { + AudioAnalysisSucceeded (); + } + + _analyse_audio_job.reset (); } void @@ -450,7 +453,6 @@ Film::write_metadata () const f << "width " << _size.width << endl; f << "height " << _size.height << endl; f << "length " << _length.get_value_or(0) << endl; - f << "dcp_intrinsic_duration " << _dcp_intrinsic_duration.get_value_or(0) << endl; f << "content_digest " << _content_digest << endl; for (vector<shared_ptr<AudioStream> >::const_iterator i = _content_audio_streams.begin(); i != _content_audio_streams.end(); ++i) { @@ -591,11 +593,6 @@ Film::read_metadata () if (vv) { _length = vv; } - } else if (k == "dcp_intrinsic_duration") { - int const vv = atoi (v.c_str ()); - if (vv) { - _dcp_intrinsic_duration = vv; - } } else if (k == "content_digest") { _content_digest = v; } else if (k == "content_audio_stream" || (!version && k == "audio_stream")) { @@ -1291,16 +1288,6 @@ Film::unset_length () } void -Film::set_dcp_intrinsic_duration (int d) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _dcp_intrinsic_duration = d; - } - signal_changed (DCP_INTRINSIC_DURATION); -} - -void Film::set_content_digest (string d) { { @@ -1434,3 +1421,21 @@ Film::have_dcp () const return true; } + +bool +Film::has_audio () const +{ + if (use_content_audio()) { + return audio_stream(); + } + + vector<string> const e = external_audio (); + for (vector<string>::const_iterator i = e.begin(); i != e.end(); ++i) { + if (!i->empty ()) { + return true; + } + } + + return false; +} + diff --git a/src/lib/film.h b/src/lib/film.h index 9921acbb4..698e7ef46 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -77,7 +77,7 @@ public: /** @return Logger. * It is safe to call this from any thread. */ - Log* log () const { + boost::shared_ptr<Log> log () const { return _log; } @@ -98,10 +98,6 @@ public: std::string dci_name (bool if_created_now) const; std::string dcp_name (bool if_created_now = false) const; - boost::optional<int> dcp_intrinsic_duration () const { - return _dcp_intrinsic_duration; - } - /** @return true if our state has changed since we last saved it */ bool dirty () const { return _dirty; @@ -145,7 +141,6 @@ public: DCI_METADATA, SIZE, LENGTH, - DCP_INTRINSIC_DURATION, CONTENT_AUDIO_STREAMS, SUBTITLE_STREAMS, SOURCE_FRAME_RATE, @@ -327,7 +322,7 @@ public: } boost::shared_ptr<AudioStream> audio_stream () const; - + bool has_audio () const; /* SET */ @@ -365,7 +360,6 @@ public: void set_size (libdcp::Size); void set_length (SourceFrame); void unset_length (); - void set_dcp_intrinsic_duration (int); void set_content_digest (std::string); void set_content_audio_streams (std::vector<boost::shared_ptr<AudioStream> >); void set_subtitle_streams (std::vector<boost::shared_ptr<SubtitleStream> >); @@ -374,7 +368,7 @@ public: /** Emitted when some property has changed */ mutable boost::signals2::signal<void (Property)> Changed; - boost::signals2::signal<void ()> AudioAnalysisFinished; + boost::signals2::signal<void ()> AudioAnalysisSucceeded; /** Current version number of the state file */ static int const state_version; @@ -382,7 +376,7 @@ public: private: /** Log to write to */ - Log* _log; + boost::shared_ptr<Log> _log; /** Any running ExamineContentJob, or 0 */ boost::shared_ptr<ExamineContentJob> _examine_content_job; @@ -477,7 +471,6 @@ private: libdcp::Size _size; /** The length of the source, in video frames (as far as we know) */ boost::optional<SourceFrame> _length; - boost::optional<int> _dcp_intrinsic_duration; /** MD5 digest of our content file */ std::string _content_digest; /** The audio streams in our content */ diff --git a/src/lib/gain.cc b/src/lib/gain.cc index cec3b3c62..df7011d2e 100644 --- a/src/lib/gain.cc +++ b/src/lib/gain.cc @@ -22,7 +22,7 @@ using boost::shared_ptr; /** @param gain gain in dB */ -Gain::Gain (Log* log, float gain) +Gain::Gain (shared_ptr<Log> log, float gain) : AudioProcessor (log) , _gain (gain) { diff --git a/src/lib/gain.h b/src/lib/gain.h index 716ee9b51..d462e5aee 100644 --- a/src/lib/gain.h +++ b/src/lib/gain.h @@ -22,7 +22,7 @@ class Gain : public AudioProcessor { public: - Gain (Log* log, float gain); + Gain (boost::shared_ptr<Log> log, float gain); void process_audio (boost::shared_ptr<AudioBuffers>); diff --git a/src/lib/matcher.cc b/src/lib/matcher.cc index 4cd264338..48f6ed912 100644 --- a/src/lib/matcher.cc +++ b/src/lib/matcher.cc @@ -26,7 +26,7 @@ using std::min; using boost::shared_ptr; -Matcher::Matcher (Log* log, int sample_rate, float frames_per_second) +Matcher::Matcher (shared_ptr<Log> log, int sample_rate, float frames_per_second) : AudioVideoProcessor (log) , _sample_rate (sample_rate) , _frames_per_second (frames_per_second) diff --git a/src/lib/matcher.h b/src/lib/matcher.h index 60bb87432..b1680e131 100644 --- a/src/lib/matcher.h +++ b/src/lib/matcher.h @@ -24,7 +24,7 @@ class Matcher : public AudioVideoProcessor { public: - Matcher (Log* log, int sample_rate, float frames_per_second); + Matcher (boost::shared_ptr<Log> log, int sample_rate, float frames_per_second); void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s); void process_audio (boost::shared_ptr<AudioBuffers>); void process_end (); diff --git a/src/lib/processor.h b/src/lib/processor.h index 19d7c4b0c..1ba396f2f 100644 --- a/src/lib/processor.h +++ b/src/lib/processor.h @@ -40,7 +40,7 @@ public: /** Construct a Processor. * @param log Log to use. */ - Processor (Log* log) + Processor (boost::shared_ptr<Log> log) : _log (log) {} @@ -50,7 +50,7 @@ public: virtual void process_end () {} protected: - Log* _log; ///< log to write to + boost::shared_ptr<Log> _log; ///< log to write to }; /** @class AudioVideoProcessor @@ -62,7 +62,7 @@ public: /** Construct an AudioVideoProcessor. * @param log Log to write to. */ - AudioVideoProcessor (Log* log) + AudioVideoProcessor (boost::shared_ptr<Log> log) : Processor (log) {} }; @@ -76,7 +76,7 @@ public: /** Construct an AudioProcessor. * @param log Log to write to. */ - AudioProcessor (Log* log) + AudioProcessor (boost::shared_ptr<Log> log) : Processor (log) {} }; @@ -90,7 +90,7 @@ public: /** Construct an VideoProcessor. * @param log Log to write to. */ - VideoProcessor (Log* log) + VideoProcessor (boost::shared_ptr<Log> log) : Processor (log) {} }; diff --git a/src/lib/server.cc b/src/lib/server.cc index 76a25bfbb..9c5a77f68 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -77,7 +77,7 @@ ServerDescription::as_metadata () const return s.str (); } -Server::Server (Log* log) +Server::Server (shared_ptr<Log> log) : _log (log) { diff --git a/src/lib/server.h b/src/lib/server.h index 32ba8dc4b..89aeca626 100644 --- a/src/lib/server.h +++ b/src/lib/server.h @@ -76,7 +76,7 @@ private: class Server { public: - Server (Log* log); + Server (boost::shared_ptr<Log> log); void run (int num_threads); @@ -88,5 +88,5 @@ private: std::list<boost::shared_ptr<Socket> > _queue; boost::mutex _worker_mutex; boost::condition _worker_condition; - Log* _log; + boost::shared_ptr<Log> _log; }; diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index f7cc500fe..234ebe051 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -68,10 +68,7 @@ TranscodeJob::run () set_progress (1); set_state (FINISHED_OK); - _film->set_dcp_intrinsic_duration (_encoder->video_frames_out ()); - _film->log()->log (N_("Transcode job completed successfully")); - _film->log()->log (String::compose (N_("DCP intrinsic duration is %1"), _encoder->video_frames_out())); } catch (std::exception& e) { diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index 9720ca56a..e0f3a03a2 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -38,7 +38,6 @@ #include "audio_decoder.h" using std::string; -using std::cout; using boost::shared_ptr; using boost::dynamic_pointer_cast; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 5a2f7c9a9..2d7ee9ba3 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -261,8 +261,6 @@ Writer::finish () int const frames = _last_written_frame + 1; int const duration = frames - _film->trim_start() - _film->trim_end(); - _film->set_dcp_intrinsic_duration (frames); - _picture_asset->set_entry_point (_film->trim_start ()); _picture_asset->set_duration (duration); @@ -275,8 +273,14 @@ Writer::finish () boost::filesystem::path to; to /= _film->dir (_film->dcp_name()); to /= N_("video.mxf"); - - boost::filesystem::create_hard_link (from, to); + + boost::system::error_code ec; + boost::filesystem::create_hard_link (from, to, ec); + if (ec) { + /* hard link failed; copy instead */ + boost::filesystem::copy_file (from, to); + _film->log()->log ("Hard-link failed; fell back to copying"); + } /* And update the asset */ |
