diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-10-26 09:37:29 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-10-26 09:37:29 +0000 |
| commit | 2e62b2c0de47fc8e5bcb5466b2876f9b23d2ae84 (patch) | |
| tree | dd6ec559cfb77bc16a510aebbe1021b114a53748 /src | |
| parent | 526fd6de4c80a7ac9614a1cb0209efff7b171cd5 (diff) | |
Reinstate subtitle speed-up patch 526fd6de4c80a7ac9614a1cb0209efff7b171cd5 but only for preview.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/audio_decoder_stream.cc | 4 | ||||
| -rw-r--r-- | src/lib/dcp_decoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/dcp_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/decoder.h | 8 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/image_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/image_decoder.h | 3 | ||||
| -rw-r--r-- | src/lib/player.cc | 8 | ||||
| -rw-r--r-- | src/lib/player.h | 2 | ||||
| -rw-r--r-- | src/lib/sndfile_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/sndfile_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/subrip_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/subrip_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.cc | 12 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.h | 6 | ||||
| -rw-r--r-- | src/lib/transcoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 4 | ||||
| -rw-r--r-- | src/wx/subtitle_view.cc | 3 |
21 files changed, 43 insertions, 39 deletions
diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc index 274bf2d54..4fedf9291 100644 --- a/src/lib/audio_decoder_stream.cc +++ b/src/lib/audio_decoder_stream.cc @@ -87,7 +87,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) /* Keep stuffing data into _decoded until we have enough data, or the subclass does not want to give us any more */ while ( (_decoded.frame > frame || (_decoded.frame + _decoded.audio->frames()) < end) && - !_decoder->pass () + !_decoder->pass (Decoder::PASS_REASON_AUDIO, accurate) ) {} @@ -95,7 +95,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) } else { while ( _decoded.audio->frames() < length && - !_decoder->pass () + !_decoder->pass (Decoder::PASS_REASON_AUDIO, accurate) ) {} diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 21eb2f7ea..04fffb981 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -59,7 +59,7 @@ DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, bool fast) } bool -DCPDecoder::pass () +DCPDecoder::pass (PassReason reason, bool) { if (_reel == _reels.end () || !_dcp_content->can_be_played ()) { return true; @@ -68,7 +68,7 @@ DCPDecoder::pass () double const vfr = _dcp_content->video_frame_rate (); int64_t const frame = _next.frames_round (vfr); - if ((*_reel)->main_picture ()) { + if ((*_reel)->main_picture () && reason != PASS_REASON_SUBTITLE) { shared_ptr<dcp::PictureAsset> asset = (*_reel)->main_picture()->asset (); shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset); shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (asset); @@ -88,7 +88,7 @@ DCPDecoder::pass () } } - if ((*_reel)->main_sound ()) { + if ((*_reel)->main_sound () && reason != PASS_REASON_SUBTITLE) { int64_t const entry_point = (*_reel)->main_sound()->entry_point (); shared_ptr<const dcp::SoundFrame> sf = (*_reel)->main_sound()->asset()->get_frame (entry_point + frame); uint8_t const * from = sf->data (); diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h index 6fdbd946a..0db707160 100644 --- a/src/lib/dcp_decoder.h +++ b/src/lib/dcp_decoder.h @@ -44,7 +44,7 @@ public: private: friend struct dcp_subtitle_within_dcp_test; - bool pass (); + bool pass (PassReason, bool accurate); void seek (ContentTime t, bool accurate); std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 1c6b973d6..1bcc7fcf1 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -47,7 +47,7 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate) } bool -DCPSubtitleDecoder::pass () +DCPSubtitleDecoder::pass (PassReason, bool) { if (_next == _subtitles.end ()) { return true; diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index fb2213fa2..1f5377622 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -28,7 +28,7 @@ public: DCPSubtitleDecoder (boost::shared_ptr<const DCPSubtitleContent>); protected: - bool pass (); + bool pass (PassReason, bool accurate); void seek (ContentTime time, bool accurate); private: diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 8378373c6..9867b79b0 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -51,7 +51,13 @@ protected: */ virtual void seek (ContentTime time, bool accurate) = 0; - virtual bool pass () = 0; + enum PassReason { + PASS_REASON_VIDEO, + PASS_REASON_AUDIO, + PASS_REASON_SUBTITLE + }; + + virtual bool pass (PassReason, bool accurate) = 0; }; #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 72a3d02b4..cc4bd34d4 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -89,7 +89,7 @@ FFmpegDecoder::flush () } bool -FFmpegDecoder::pass () +FFmpegDecoder::pass (PassReason reason, bool accurate) { int r = av_read_frame (_format_context, &_packet); @@ -112,11 +112,11 @@ FFmpegDecoder::pass () int const si = _packet.stream_index; shared_ptr<const FFmpegContent> fc = _ffmpeg_content; - if (si == _video_stream && !_ignore_video) { + if (si == _video_stream && !_ignore_video && (accurate || reason != PASS_REASON_SUBTITLE)) { decode_video_packet (); } else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index (_format_context, si)) { decode_subtitle_packet (); - } else { + } else if (reason != PASS_REASON_SUBTITLE) { decode_audio_packet (); } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 5475be612..dc0270cd0 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -49,7 +49,7 @@ public: private: friend struct ::ffmpeg_pts_offset_test; - bool pass (); + bool pass (PassReason, bool accurate); void seek (ContentTime time, bool); void flush (); diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index db7c5401f..2291daecd 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -43,7 +43,7 @@ ImageDecoder::ImageDecoder (shared_ptr<const ImageContent> c) } bool -ImageDecoder::pass () +ImageDecoder::pass (PassReason, bool) { if (_video_position >= _image_content->video_length()) { return true; diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index 4d96306a8..e2de56acb 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -31,11 +31,10 @@ public: } private: - bool pass (); + bool pass (PassReason, bool); void seek (ContentTime, bool); boost::shared_ptr<const ImageContent> _image_content; boost::shared_ptr<ImageProxy> _image; Frame _video_position; }; - diff --git a/src/lib/player.cc b/src/lib/player.cc index 116410046..b8eadf793 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -357,7 +357,7 @@ Player::get_video (DCPTime time, bool accurate) /* Find subtitles for possible burn-in */ - PlayerSubtitles ps = get_subtitles (time, DCPTime::from_frames (1, _film->video_frame_rate ()), false, true); + PlayerSubtitles ps = get_subtitles (time, DCPTime::from_frames (1, _film->video_frame_rate ()), false, true, accurate); list<PositionImage> sub_images; @@ -619,7 +619,7 @@ Player::content_subtitle_to_dcp (shared_ptr<const Piece> piece, ContentTime t) c * _always_burn_subtitles is true; in this case, all subtitles will be returned. */ PlayerSubtitles -Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt) +Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt, bool accurate) { list<shared_ptr<Piece> > subs = overlaps<SubtitleContent> (time, time + length); @@ -641,7 +641,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt) /* 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 ()); - list<ContentImageSubtitle> image = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to), starting); + list<ContentImageSubtitle> image = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to), starting, accurate); for (list<ContentImageSubtitle>::iterator i = image.begin(); i != image.end(); ++i) { /* Apply content's subtitle offsets */ @@ -659,7 +659,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt) ps.image.push_back (i->sub); } - list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting); + list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting, accurate); BOOST_FOREACH (ContentTextSubtitle& ts, text) { BOOST_FOREACH (dcp::SubtitleString s, ts.subs) { s.set_h_position (s.h_position() + subtitle_content->subtitle_x_offset ()); diff --git a/src/lib/player.h b/src/lib/player.h index 3106a3477..bfb21abba 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -49,7 +49,7 @@ public: std::list<boost::shared_ptr<PlayerVideo> > get_video (DCPTime time, bool accurate); boost::shared_ptr<AudioBuffers> get_audio (DCPTime time, DCPTime length, bool accurate); - PlayerSubtitles get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt); + PlayerSubtitles get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt, bool accurate); std::list<boost::shared_ptr<Font> > get_subtitle_fonts (); std::list<ReferencedReelAsset> get_reel_assets (); diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 49633dd1f..ac01e0da8 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -48,7 +48,7 @@ SndfileDecoder::~SndfileDecoder () } bool -SndfileDecoder::pass () +SndfileDecoder::pass (PassReason, bool) { if (_remaining == 0) { return true; diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index da9016ee0..844d1cdc4 100644 --- a/src/lib/sndfile_decoder.h +++ b/src/lib/sndfile_decoder.h @@ -29,7 +29,7 @@ public: ~SndfileDecoder (); private: - bool pass (); + bool pass (PassReason, bool); void seek (ContentTime, bool); int64_t _done; diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index 32d50d86b..26a7ebcae 100644 --- a/src/lib/subrip_decoder.cc +++ b/src/lib/subrip_decoder.cc @@ -49,7 +49,7 @@ SubRipDecoder::seek (ContentTime time, bool accurate) } bool -SubRipDecoder::pass () +SubRipDecoder::pass (PassReason, bool) { if (_next >= _subtitles.size ()) { return true; diff --git a/src/lib/subrip_decoder.h b/src/lib/subrip_decoder.h index db8374c5c..f76d04aeb 100644 --- a/src/lib/subrip_decoder.h +++ b/src/lib/subrip_decoder.h @@ -32,7 +32,7 @@ public: protected: void seek (ContentTime time, bool accurate); - bool pass (); + bool pass (PassReason, bool accurate); private: std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const; diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index a7da626b7..454243b52 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -56,7 +56,7 @@ SubtitleDecoder::text_subtitle (ContentTimePeriod period, list<dcp::SubtitleStri /** @param sp Full periods of subtitles that are showing or starting during the specified period */ template <class T> list<T> -SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting) +SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting, bool accurate) { if (sp.empty ()) { /* Nothing in this period */ @@ -72,7 +72,7 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, * (a) give us what we want, or * (b) hit the end of the decoder. */ - while (!pass () && (subs.empty() || (subs.back().period().to < sp.back().to))) {} + while (!pass(PASS_REASON_SUBTITLE, accurate) && (subs.empty() || (subs.back().period().to < sp.back().to))) {} /* Now look for what we wanted in the data we have collected */ /* XXX: inefficient */ @@ -105,15 +105,15 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, } list<ContentTextSubtitle> -SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting) +SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate) { - return get<ContentTextSubtitle> (_decoded_text_subtitles, text_subtitles_during (period, starting), period, starting); + return get<ContentTextSubtitle> (_decoded_text_subtitles, text_subtitles_during (period, starting), period, starting, accurate); } list<ContentImageSubtitle> -SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting) +SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate) { - return get<ContentImageSubtitle> (_decoded_image_subtitles, image_subtitles_during (period, starting), period, starting); + return get<ContentImageSubtitle> (_decoded_image_subtitles, image_subtitles_during (period, starting), period, starting, accurate); } void diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index d01c4e45b..dd9c024e6 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -33,8 +33,8 @@ class SubtitleDecoder : public virtual Decoder public: SubtitleDecoder (boost::shared_ptr<const SubtitleContent>); - std::list<ContentImageSubtitle> get_image_subtitles (ContentTimePeriod period, bool starting); - std::list<ContentTextSubtitle> get_text_subtitles (ContentTimePeriod period, bool starting); + std::list<ContentImageSubtitle> get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate); + std::list<ContentTextSubtitle> get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate); protected: void seek (ContentTime, bool); @@ -47,7 +47,7 @@ protected: private: template <class T> - std::list<T> get (std::list<T> const & subs, std::list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting); + std::list<T> get (std::list<T> const & subs, std::list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting, bool accurate); /** @param starting true if we want only subtitles that start during the period, otherwise * we want subtitles that overlap the period. diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index acff9c896..7eb3883ff 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -91,7 +91,7 @@ Transcoder::go () _writer->write (_player->get_audio (t, frame, true)); if (non_burnt_subtitles) { - _writer->write (_player->get_subtitles (t, frame, true, false)); + _writer->write (_player->get_subtitles (t, frame, true, false, true)); } } diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 1c9a6374f..fd5779a65 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -98,7 +98,7 @@ VideoDecoder::get_video (Frame frame, bool accurate) break; } - if (pass ()) { + if (pass (PASS_REASON_VIDEO, accurate)) { /* The decoder has nothing more for us */ break; } @@ -115,7 +115,7 @@ VideoDecoder::get_video (Frame frame, bool accurate) dec = decoded_video (frame); } else { /* Any frame will do: use the first one that comes out of pass() */ - while (_decoded_video.empty() && !pass ()) {} + while (_decoded_video.empty() && !pass (PASS_REASON_VIDEO, accurate)) {} if (!_decoded_video.empty ()) { dec.push_back (_decoded_video.front ()); } diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc index 33ef7cfda..632b209ed 100644 --- a/src/wx/subtitle_view.cc +++ b/src/wx/subtitle_view.cc @@ -65,7 +65,7 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr< sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - list<ContentTextSubtitle> subs = decoder->get_text_subtitles (ContentTimePeriod (ContentTime(), ContentTime::max ()), true); + list<ContentTextSubtitle> subs = decoder->get_text_subtitles (ContentTimePeriod (ContentTime(), ContentTime::max ()), true, true); FrameRateChange const frc = film->active_frame_rate_change (position); int n = 0; for (list<ContentTextSubtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) { @@ -83,4 +83,3 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr< SetSizerAndFit (sizer); } - |
