diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-06-16 15:52:32 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-06-16 15:52:32 +0100 |
| commit | 6e52f83418c64d5cbd0e613a5fc96ea32881d4d9 (patch) | |
| tree | 722da0c3f985bb0e0d38077ca4992e4580546356 /src/lib | |
| parent | 739a52b20895622a1caf48d3597ae49e6ec0aeeb (diff) | |
Fix subtitle controls in the viewer.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 5 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 3 | ||||
| -rw-r--r-- | src/lib/player.cc | 15 | ||||
| -rw-r--r-- | src/lib/player.h | 2 | ||||
| -rw-r--r-- | src/lib/transcoder.cc | 4 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 30 |
7 files changed, 27 insertions, 34 deletions
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 7a67ee5b8..4a1534887 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -132,7 +132,7 @@ FFmpegContent::examine (shared_ptr<Job> job) shared_ptr<const Film> film = _film.lock (); assert (film); - shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), true, false, false)); + shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), true, false)); ContentVideoFrame video_length = 0; video_length = decoder->video_length (); diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 2f890c0cd..7ebb31084 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -63,7 +63,7 @@ using libdcp::Size; boost::mutex FFmpegDecoder::_mutex; -FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio, bool subtitles) +FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio) : Decoder (f) , VideoDecoder (f, c) , AudioDecoder (f, c) @@ -79,7 +79,6 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegC , _subtitle_codec (0) , _decode_video (video) , _decode_audio (audio) - , _decode_subtitles (subtitles) { setup_general (); setup_video (); @@ -259,7 +258,7 @@ FFmpegDecoder::pass () decode_video_packet (); } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _decode_audio) { decode_audio_packet (); - } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _decode_subtitles) { + } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id) { int got_subtitle; AVSubtitle sub; diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 2d295db7b..3cfb54e09 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -59,7 +59,7 @@ class Film; class FFmpegDecoder : public VideoDecoder, public AudioDecoder { public: - FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const FFmpegContent>, bool video, bool audio, bool subtitles); + FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const FFmpegContent>, bool video, bool audio); ~FFmpegDecoder (); /* Decoder */ @@ -139,7 +139,6 @@ private: bool _decode_video; bool _decode_audio; - bool _decode_subtitles; /* It would appear (though not completely verified) that one must have a mutex around calls to avcodec_open* and avcodec_close... and here diff --git a/src/lib/player.cc b/src/lib/player.cc index 1931ec0f5..6d7c3cfbd 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -58,7 +58,6 @@ Player::Player (shared_ptr<const Film> f, shared_ptr<const Playlist> p) , _playlist (p) , _video (true) , _audio (true) - , _subtitles (true) , _have_valid_pieces (false) , _position (0) , _audio_buffers (f->dcp_audio_channels(), 0) @@ -80,12 +79,6 @@ Player::disable_audio () _audio = false; } -void -Player::disable_subtitles () -{ - _subtitles = false; -} - bool Player::pass () { @@ -291,10 +284,13 @@ Player::setup_pieces () shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i); if (fc) { - shared_ptr<FFmpegDecoder> fd (new FFmpegDecoder (_film, fc, _video, _audio, _subtitles)); + shared_ptr<FFmpegDecoder> fd (new FFmpegDecoder (_film, fc, _video, _audio)); fd->Video.connect (bind (&Player::process_video, this, *i, _1, _2, _3)); fd->Audio.connect (bind (&Player::process_audio, this, *i, _1, _2)); + if (_video_container_size) { + fd->set_video_container_size (_video_container_size.get ()); + } decoder = fd; cout << "\tFFmpeg @ " << fc->start() << " -- " << fc->end() << "\n"; @@ -315,6 +311,9 @@ Player::setup_pieces () if (!id) { id.reset (new ImageMagickDecoder (_film, ic)); id->Video.connect (bind (&Player::process_video, this, *i, _1, _2, _3)); + if (_video_container_size) { + id->set_video_container_size (_video_container_size.get ()); + } } decoder = id; diff --git a/src/lib/player.h b/src/lib/player.h index 95f419b5e..60cf88422 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -49,7 +49,6 @@ public: void disable_video (); void disable_audio (); - void disable_subtitles (); bool pass (); void seek (Time); @@ -80,7 +79,6 @@ private: bool _video; bool _audio; - bool _subtitles; /** Our pieces are ready to go; if this is false the pieces must be (re-)created before they are used */ bool _have_valid_pieces; diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index d4c5210dc..847be2f1c 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -48,10 +48,6 @@ Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<Job> j) , _player (f->player ()) , _encoder (new Encoder (f, j)) { - if (!f->with_subtitles ()) { - _player->disable_subtitles (); - } - _player->connect_video (_encoder); _player->connect_audio (_encoder); } diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 58aceb407..54d14e2c6 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -61,20 +61,22 @@ VideoDecoder::video (shared_ptr<Image> image, bool same, Time t) shared_ptr<Image> out = image->scale_and_convert_to_rgb (image_size, film->scaler(), true); - shared_ptr<Subtitle> sub; - if (_timed_subtitle && _timed_subtitle->displayed_at (t)) { - sub = _timed_subtitle->subtitle (); - } - - if (sub) { - dcpomatic::Rect const tx = subtitle_transformed_area ( - float (image_size.width) / video_size().width, - float (image_size.height) / video_size().height, - sub->area(), film->subtitle_offset(), film->subtitle_scale() - ); - - shared_ptr<Image> im = sub->image()->scale (tx.size(), film->scaler(), true); - out->alpha_blend (im, tx.position()); + if (film->with_subtitles ()) { + shared_ptr<Subtitle> sub; + if (_timed_subtitle && _timed_subtitle->displayed_at (t)) { + sub = _timed_subtitle->subtitle (); + } + + if (sub) { + dcpomatic::Rect const tx = subtitle_transformed_area ( + float (image_size.width) / video_size().width, + float (image_size.height) / video_size().height, + sub->area(), film->subtitle_offset(), film->subtitle_scale() + ); + + shared_ptr<Image> im = sub->image()->scale (tx.size(), film->scaler(), true); + out->alpha_blend (im, tx.position()); + } } if (image_size != container_size) { |
