diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-06-20 23:01:12 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-06-20 23:01:12 +0100 |
| commit | dc1c279211773ad68cb0348eb802cf5c9594d8dd (patch) | |
| tree | d49cd367d1832ce04bbc041b866835b2463d29d7 /src/lib | |
| parent | 4d54b053b6e9565e026554b1dba31d73a1b492ae (diff) | |
Various subtitle UI tweaks.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 20 | ||||
| -rw-r--r-- | src/lib/film.h | 9 | ||||
| -rw-r--r-- | src/lib/player.cc | 9 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 18 | ||||
| -rw-r--r-- | src/lib/playlist.h | 2 | ||||
| -rw-r--r-- | src/lib/subtitle_content.cc | 20 | ||||
| -rw-r--r-- | src/lib/subtitle_content.h | 8 |
8 files changed, 36 insertions, 52 deletions
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index d3e0fa7b2..a12f45a30 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -110,7 +110,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> f, vector<boost::shared_ptr for (size_t i = 0; i < c.size(); ++i) { shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]); - if (f->with_subtitles() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { + if (fc->subtitle_use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { throw JoinError (_("Content to be joined must use the same subtitle stream.")); } diff --git a/src/lib/film.cc b/src/lib/film.cc index 14735d1b1..b01a70b72 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -110,7 +110,6 @@ Film::Film (boost::filesystem::path dir, bool log) , _container (Config::instance()->default_container ()) , _resolution (RESOLUTION_2K) , _scaler (Scaler::from_id ("bicubic")) - , _with_subtitles (false) , _signed (true) , _encrypted (false) , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ()) @@ -187,10 +186,6 @@ Film::video_identifier () const s << "_3D"; } - if (_with_subtitles) { - s << "_WS"; - } - return s.str (); } @@ -370,7 +365,6 @@ Film::metadata () const root->add_child("Resolution")->add_child_text (resolution_to_string (_resolution)); root->add_child("Scaler")->add_child_text (_scaler->id ()); - root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0"); root->add_child("J2KBandwidth")->add_child_text (raw_convert<string> (_j2k_bandwidth)); _isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata")); root->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate)); @@ -442,7 +436,6 @@ Film::read_metadata () _resolution = string_to_resolution (f.string_child ("Resolution")); _scaler = Scaler::from_id (f.string_child ("Scaler")); - _with_subtitles = f.bool_child ("WithSubtitles"); _j2k_bandwidth = f.number_child<int> ("J2KBandwidth"); _video_frame_rate = f.number_child<int> ("VideoFrameRate"); _signed = f.optional_bool_child("Signed").get_value_or (true); @@ -714,13 +707,6 @@ Film::set_scaler (Scaler const * s) } void -Film::set_with_subtitles (bool w) -{ - _with_subtitles = w; - signal_changed (WITH_SUBTITLES); -} - -void Film::set_j2k_bandwidth (int b) { _j2k_bandwidth = b; @@ -969,12 +955,6 @@ Film::length () const return _playlist->length (); } -bool -Film::has_subtitles () const -{ - return _playlist->has_subtitles (); -} - int Film::best_video_frame_rate () const { diff --git a/src/lib/film.h b/src/lib/film.h index 67d00aa54..a44c606d6 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -115,7 +115,6 @@ public: ContentList content () const; DCPTime length () const; - bool has_subtitles () const; int best_video_frame_rate () const; FrameRateChange active_frame_rate_change (DCPTime) const; @@ -155,7 +154,6 @@ public: CONTAINER, RESOLUTION, SCALER, - WITH_SUBTITLES, SIGNED, ENCRYPTED, J2K_BANDWIDTH, @@ -199,10 +197,6 @@ public: return _scaler; } - bool with_subtitles () const { - return _with_subtitles; - } - /* signed is a reserved word */ bool is_signed () const { return _signed; @@ -256,7 +250,6 @@ public: void set_container (Ratio const *); void set_resolution (Resolution); void set_scaler (Scaler const *); - void set_with_subtitles (bool); void set_signed (bool); void set_encrypted (bool); void set_j2k_bandwidth (int); @@ -309,8 +302,6 @@ private: Resolution _resolution; /** Scaler algorithm to use */ Scaler const * _scaler; - /** True if subtitles should be shown for this film */ - bool _with_subtitles; bool _signed; bool _encrypted; /** bandwidth for J2K files in bits per second */ diff --git a/src/lib/player.cc b/src/lib/player.cc index 418f360fe..bb1a4cdeb 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -179,6 +179,7 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent) Changed (frequent); } else if ( + property == SubtitleContentProperty::SUBTITLE_USE || property == SubtitleContentProperty::SUBTITLE_X_OFFSET || property == SubtitleContentProperty::SUBTITLE_Y_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE || @@ -216,7 +217,7 @@ Player::film_changed (Film::Property p) last time we were run. */ - if (p == Film::SCALER || p == Film::WITH_SUBTITLES || p == Film::CONTAINER || p == Film::VIDEO_FRAME_RATE) { + if (p == Film::SCALER || p == Film::CONTAINER || p == Film::VIDEO_FRAME_RATE) { Changed (false); } } @@ -375,8 +376,12 @@ Player::get_video (DCPTime time, bool accurate) list<PositionImage> sub_images; for (list<shared_ptr<Piece> >::const_iterator j = subs.begin(); j != subs.end(); ++j) { - shared_ptr<SubtitleDecoder> subtitle_decoder = dynamic_pointer_cast<SubtitleDecoder> ((*j)->decoder); shared_ptr<SubtitleContent> subtitle_content = dynamic_pointer_cast<SubtitleContent> ((*j)->content); + if (!subtitle_content->subtitle_use ()) { + continue; + } + + shared_ptr<SubtitleDecoder> subtitle_decoder = dynamic_pointer_cast<SubtitleDecoder> ((*j)->decoder); ContentTime const from = dcp_to_content_subtitle (*j, time); /* XXX: this video_frame_rate() should be the rate that the subtitle content has been prepared for */ ContentTime const to = from + ContentTime::from_frames (1, _film->video_frame_rate ()); diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index e555db9ba..1c268ca11 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -186,24 +186,6 @@ Playlist::remove (ContentList c) Changed (); } -bool -Playlist::has_subtitles () const -{ - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i); - if (fc && !fc->subtitle_streams().empty()) { - return true; - } - - shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (*i); - if (sc) { - return true; - } - } - - return false; -} - class FrameRateCandidate { public: diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 7c29b8588..3e5093aca 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -63,8 +63,6 @@ public: void move_earlier (boost::shared_ptr<Content>); void move_later (boost::shared_ptr<Content>); - bool has_subtitles () const; - ContentList content () const; std::string video_identifier () const; diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index 068bf7516..f839a56d0 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -35,9 +35,11 @@ using dcp::raw_convert; int const SubtitleContentProperty::SUBTITLE_X_OFFSET = 500; int const SubtitleContentProperty::SUBTITLE_Y_OFFSET = 501; int const SubtitleContentProperty::SUBTITLE_SCALE = 502; +int const SubtitleContentProperty::SUBTITLE_USE = 503; SubtitleContent::SubtitleContent (shared_ptr<const Film> f, boost::filesystem::path p) : Content (f, p) + , _subtitle_use (false) , _subtitle_x_offset (0) , _subtitle_y_offset (0) , _subtitle_scale (1) @@ -47,11 +49,13 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, boost::filesystem::p SubtitleContent::SubtitleContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version) : Content (f, node) + , _subtitle_use (false) , _subtitle_x_offset (0) , _subtitle_y_offset (0) , _subtitle_scale (1) { if (version >= 7) { + _subtitle_use = node->bool_child ("SubtitleUse"); _subtitle_x_offset = node->number_child<float> ("SubtitleXOffset"); _subtitle_y_offset = node->number_child<float> ("SubtitleYOffset"); } else { @@ -70,6 +74,10 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Co for (size_t i = 0; i < c.size(); ++i) { shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c[i]); + if (sc->subtitle_use() != ref->subtitle_use()) { + throw JoinError (_("Content to be joined must have the same 'use subtitles' setting.")); + } + if (sc->subtitle_x_offset() != ref->subtitle_x_offset()) { throw JoinError (_("Content to be joined must have the same subtitle X offset.")); } @@ -83,6 +91,7 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Co } } + _subtitle_use = ref->subtitle_use (); _subtitle_x_offset = ref->subtitle_x_offset (); _subtitle_y_offset = ref->subtitle_y_offset (); _subtitle_scale = ref->subtitle_scale (); @@ -91,12 +100,23 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Co void SubtitleContent::as_xml (xmlpp::Node* root) const { + root->add_child("SubtitleUse")->add_child_text (raw_convert<string> (_subtitle_use)); root->add_child("SubtitleXOffset")->add_child_text (raw_convert<string> (_subtitle_x_offset)); root->add_child("SubtitleYOffset")->add_child_text (raw_convert<string> (_subtitle_y_offset)); root->add_child("SubtitleScale")->add_child_text (raw_convert<string> (_subtitle_scale)); } void +SubtitleContent::set_subtitle_use (bool u) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _subtitle_use = u; + } + signal_changed (SubtitleContentProperty::SUBTITLE_USE); +} + +void SubtitleContent::set_subtitle_x_offset (double o) { { diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h index 7d4a385c9..b73119bdb 100644 --- a/src/lib/subtitle_content.h +++ b/src/lib/subtitle_content.h @@ -28,6 +28,7 @@ public: static int const SUBTITLE_X_OFFSET; static int const SUBTITLE_Y_OFFSET; static int const SUBTITLE_SCALE; + static int const SUBTITLE_USE; }; class SubtitleContent : public virtual Content @@ -39,10 +40,16 @@ public: void as_xml (xmlpp::Node *) const; + void set_subtitle_use (bool); void set_subtitle_x_offset (double); void set_subtitle_y_offset (double); void set_subtitle_scale (double); + bool subtitle_use () const { + boost::mutex::scoped_lock lm (_mutex); + return _subtitle_use; + } + double subtitle_x_offset () const { boost::mutex::scoped_lock lm (_mutex); return _subtitle_x_offset; @@ -61,6 +68,7 @@ public: private: friend class ffmpeg_pts_offset_test; + bool _subtitle_use; /** x offset for placing subtitles, as a proportion of the container width; * +ve is further right, -ve is further left. */ |
