diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-15 16:36:28 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-15 16:36:28 +0000 |
| commit | 4e5d5c7dcc6470b8dc918d03a00e30c07df60efe (patch) | |
| tree | c167419e927f260348b468aae5036815a6a640a5 /src/lib | |
| parent | e8204f55c981493b99814f71a50b3c3d62601032 (diff) | |
| parent | f71a23109d774dc65e4262e5dba41360732cf342 (diff) | |
Merge master.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/encoder.cc | 3 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 7 | ||||
| -rw-r--r-- | src/lib/ffmpeg_examiner.cc | 1 | ||||
| -rw-r--r-- | src/lib/film.cc | 8 | ||||
| -rw-r--r-- | src/lib/player.cc | 15 | ||||
| -rw-r--r-- | src/lib/po/de_DE.po | 4 | ||||
| -rw-r--r-- | src/lib/ratio.cc | 6 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 9 | ||||
| -rw-r--r-- | src/lib/writer.cc | 72 | ||||
| -rw-r--r-- | src/lib/writer.h | 8 |
10 files changed, 94 insertions, 39 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index ca9134c04..d26f77614 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -68,9 +68,6 @@ Encoder::Encoder (shared_ptr<const Film> f, weak_ptr<Job> j) Encoder::~Encoder () { terminate_threads (); - if (_writer) { - _writer->finish (); - } } /** Add a worker thread for a each thread on a remote server. Caller must hold diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 8742c48ec..52afe2a27 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -160,8 +160,6 @@ FFmpegDecoder::pass () return true; } - avcodec_get_frame_defaults (_frame); - shared_ptr<const Film> film = _film.lock (); assert (film); @@ -561,8 +559,13 @@ FFmpegDecoder::decode_subtitle_packet () /* Subtitle PTS in seconds (within the source, not taking into account any of the source that we may have chopped off for the DCP) */ +<<<<<<< HEAD double const packet_time = (static_cast<double> (sub.pts ) / AV_TIME_BASE) + _pts_offset; +======= + double const packet_time = (static_cast<double> (sub.pts ) / AV_TIME_BASE) + _video_pts_offset; + +>>>>>>> master /* hence start time for this sub */ ContentTime const from = (packet_time + (double (sub.start_display_time) / 1e3)) * TIME_HZ; ContentTime const to = (packet_time + (double (sub.end_display_time) / 1e3)) * TIME_HZ; diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index e86a82fad..38dd678bb 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -70,7 +70,6 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c) } int frame_finished; - avcodec_get_frame_defaults (_frame); AVCodecContext* context = _format_context->streams[_packet.stream_index]->codec; diff --git a/src/lib/film.cc b/src/lib/film.cc index 57d23ec4e..099bacfdc 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -265,6 +265,14 @@ Film::make_dcp () #else log()->log ("libdcp built in optimised mode."); #endif + +#ifdef DCPOMATIC_WINDOWS + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof (info); + GetVersionEx (&info); + log()->log (String::compose ("Windows version %1.%2.%3 SP %4", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber, info.szCSDVersion)); +#endif + log()->log (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency ())); list<pair<string, string> > const m = mount_info (); for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) { diff --git a/src/lib/player.cc b/src/lib/player.cc index 260476242..77630f0e3 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -291,6 +291,7 @@ Player::emit_video (weak_ptr<Piece> weak_piece, shared_ptr<DecodedVideo> video) pi->set_subtitle (_out_subtitle.image, _out_subtitle.position + container_offset); } + #ifdef DCPOMATIC_DEBUG _last_video = piece->content; @@ -661,8 +662,22 @@ Player::update_subtitle () true ); +<<<<<<< HEAD _out_subtitle.from = _in_subtitle.subtitle->dcp_time; _out_subtitle.to = _in_subtitle.subtitle->dcp_time_to; +======= + /* XXX: hack */ + Time from = _in_subtitle.from; + Time to = _in_subtitle.to; + shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (piece->content); + if (vc) { + from = rint (from * vc->video_frame_rate() / _film->video_frame_rate()); + to = rint (to * vc->video_frame_rate() / _film->video_frame_rate()); + } + + _out_subtitle.from = from * piece->content->position (); + _out_subtitle.to = to + piece->content->position (); +>>>>>>> master } /** Re-emit the last frame that was emitted, using current settings for crop, ratio, scaler and subtitles. diff --git a/src/lib/po/de_DE.po b/src/lib/po/de_DE.po index 3d8a26f66..acb666099 100644 --- a/src/lib/po/de_DE.po +++ b/src/lib/po/de_DE.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-01-07 20:01+0000\n" -"PO-Revision-Date: 2014-01-05 23:06+0100\n" +"PO-Revision-Date: 2014-01-14 19:45+0100\n" "Last-Translator: \n" "Language-Team: LANGUAGE <LL@li.org>\n" "Language: de\n" @@ -603,7 +603,7 @@ msgstr "Bild-Decoder nicht gefunden" #: src/lib/writer.cc:387 msgid "could not move audio MXF into the DCP (%1)" -msgstr "" +msgstr "Ton MXF kann nicht in das DCP verschoben werden (%1)" #: src/lib/sndfile_decoder.cc:45 msgid "could not open audio file for reading" diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index 41abbb760..a47b2101e 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -32,11 +32,11 @@ vector<Ratio const *> Ratio::_ratios; void Ratio::setup_ratios () { - _ratios.push_back (new Ratio (float(1285) / 1080, "119", _("1.19"), "F")); - _ratios.push_back (new Ratio (float(1436) / 1080, "133", _("4:3"), "F")); + _ratios.push_back (new Ratio (float(1290) / 1080, "119", _("1.19"), "F")); + _ratios.push_back (new Ratio (float(1440) / 1080, "133", _("4:3"), "F")); _ratios.push_back (new Ratio (float(1480) / 1080, "137", _("Academy"), "F")); _ratios.push_back (new Ratio (float(1485) / 1080, "138", _("1.375"), "F")); - _ratios.push_back (new Ratio (float(1793) / 1080, "166", _("1.66"), "F")); + _ratios.push_back (new Ratio (float(1800) / 1080, "166", _("1.66"), "F")); _ratios.push_back (new Ratio (float(1920) / 1080, "178", _("16:9"), "F")); _ratios.push_back (new Ratio (float(1998) / 1080, "185", _("Flat"), "F")); _ratios.push_back (new Ratio (float(2048) / 858, "239", _("Scope"), "S")); diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index fe07ba2f6..882072689 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -64,12 +64,11 @@ TranscodeJob::run () _film->log()->log (N_("Transcode job completed successfully")); - } catch (std::exception& e) { - + } catch (...) { set_progress (1); set_state (FINISHED_ERROR); - _film->log()->log (String::compose (N_("Transcode job failed (%1)"), e.what())); - + _film->log()->log (N_("Transcode job failed or cancelled")); + _transcoder.reset (); throw; } } @@ -78,7 +77,7 @@ string TranscodeJob::status () const { if (!_transcoder) { - return _("0%"); + return Job::status (); } float const fps = _transcoder->current_encoding_rate (); diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 320528682..c2a6c981b 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -45,6 +45,7 @@ using std::pair; using std::string; using std::list; using std::cout; +using std::stringstream; using boost::shared_ptr; using boost::weak_ptr; @@ -86,6 +87,7 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j) _picture_asset->set_edit_rate (_film->video_frame_rate ()); _picture_asset->set_size (fit_ratio_within (_film->container()->ratio(), _film->full_frame ())); + _picture_asset->set_interop (_film->interop ()); if (_film->encrypted ()) { _picture_asset->set_key (_film->key ()); @@ -93,25 +95,19 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j) _picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0); - /* Write the sound asset into the film directory so that we leave the creation - of the DCP directory until the last minute. Some versions of windows inexplicably - don't like overwriting existing files here, so try to remove it using boost. - */ - boost::system::error_code ec; - boost::filesystem::remove (_film->file (_film->audio_mxf_filename ()), ec); - if (ec) { - _film->log()->log (String::compose ("Could not remove existing audio MXF file (%1)", ec.value ())); - } - _sound_asset.reset (new libdcp::SoundAsset (_film->directory (), _film->audio_mxf_filename ())); _sound_asset->set_edit_rate (_film->video_frame_rate ()); _sound_asset->set_channels (_film->audio_channels ()); _sound_asset->set_sampling_rate (_film->audio_frame_rate ()); + _sound_asset->set_interop (_film->interop ()); if (_film->encrypted ()) { _sound_asset->set_key (_film->key ()); } + /* Write the sound asset into the film directory so that we leave the creation + of the DCP directory until the last minute. + */ _sound_asset_writer = _sound_asset->start_write (); _thread = new boost::thread (boost::bind (&Writer::thread, this)); @@ -119,11 +115,20 @@ Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j) job->sub (_("Encoding image data")); } +Writer::~Writer () +{ + terminate_thread (false); +} + void Writer::write (shared_ptr<const EncodedData> encoded, int frame, Eyes eyes) { boost::mutex::scoped_lock lock (_mutex); + while (_queued_full_in_memory > _maximum_frames_in_memory) { + _full_condition.wait (lock); + } + QueueItem qi; qi.type = QueueItem::FULL; qi.encoded = encoded; @@ -143,7 +148,7 @@ Writer::write (shared_ptr<const EncodedData> encoded, int frame, Eyes eyes) ++_queued_full_in_memory; } - _condition.notify_all (); + _empty_condition.notify_all (); } void @@ -151,6 +156,10 @@ Writer::fake_write (int frame, Eyes eyes) { boost::mutex::scoped_lock lock (_mutex); + while (_queued_full_in_memory > _maximum_frames_in_memory) { + _full_condition.wait (lock); + } + FILE* ifi = fopen_boost (_film->info_path (frame, eyes), "r"); libdcp::FrameInfo info (ifi); fclose (ifi); @@ -169,7 +178,7 @@ Writer::fake_write (int frame, Eyes eyes) _queue.push_back (qi); } - _condition.notify_all (); + _empty_condition.notify_all (); } /** This method is not thread safe */ @@ -224,7 +233,7 @@ try } TIMING (N_("writer sleeps with a queue of %1"), _queue.size()); - _condition.wait (lock); + _empty_condition.wait (lock); TIMING (N_("writer wakes with a queue of %1"), _queue.size()); } @@ -324,6 +333,8 @@ try qi.encoded.reset (); --_queued_full_in_memory; } + + _full_condition.notify_all (); } } catch (...) @@ -332,22 +343,35 @@ catch (...) } void -Writer::finish () +Writer::terminate_thread (bool can_throw) { - if (!_thread) { + boost::mutex::scoped_lock lock (_mutex); + if (_thread == 0) { return; } - boost::mutex::scoped_lock lock (_mutex); _finish = true; - _condition.notify_all (); + _empty_condition.notify_all (); + _full_condition.notify_all (); lock.unlock (); - _thread->join (); - rethrow (); + _thread->join (); + if (can_throw) { + rethrow (); + } delete _thread; _thread = 0; +} + +void +Writer::finish () +{ + if (!_thread) { + return; + } + + terminate_thread (true); _picture_asset_writer->finalize (); _sound_asset_writer->finalize (); @@ -428,7 +452,9 @@ Writer::finish () meta.set_issue_date_now (); dcp.write_xml (_film->interop (), meta, _film->is_signed() ? make_signer () : shared_ptr<const libdcp::Signer> ()); - _film->log()->log (String::compose (N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT; %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk)); + _film->log()->log ( + String::compose (N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT; %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk) + ); } /** Tell the writer that frame `f' should be a repeat of the frame before it */ @@ -437,6 +463,10 @@ Writer::repeat (int f, Eyes e) { boost::mutex::scoped_lock lock (_mutex); + while (_queued_full_in_memory > _maximum_frames_in_memory) { + _full_condition.wait (lock); + } + QueueItem qi; qi.type = QueueItem::REPEAT; qi.frame = f; @@ -450,7 +480,7 @@ Writer::repeat (int f, Eyes e) _queue.push_back (qi); } - _condition.notify_all (); + _empty_condition.notify_all (); } bool diff --git a/src/lib/writer.h b/src/lib/writer.h index 842d6a55d..7af79a417 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -71,6 +71,7 @@ class Writer : public ExceptionStore, public boost::noncopyable { public: Writer (boost::shared_ptr<const Film>, boost::weak_ptr<Job>); + ~Writer (); bool can_fake_write (int) const; @@ -83,6 +84,7 @@ public: private: void thread (); + void terminate_thread (bool); void check_existing_picture_mxf (); bool check_existing_picture_mxf_frame (FILE *, int, Eyes); bool have_sequenced_image_at_queue_head (); @@ -103,8 +105,10 @@ private: int _queued_full_in_memory; /** mutex for thread state */ mutable boost::mutex _mutex; - /** condition to manage thread wakeups */ - boost::condition _condition; + /** condition to manage thread wakeups when we have nothing to do */ + boost::condition _empty_condition; + /** condition to manage thread wakeups when we have too much to do */ + boost::condition _full_condition; /** the data of the last written frame, or 0 if there isn't one */ boost::shared_ptr<const EncodedData> _last_written[EYES_COUNT]; /** the index of the last written frame */ |
