From 526fd6de4c80a7ac9614a1cb0209efff7b171cd5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 23 Oct 2015 16:12:14 +0100 Subject: [PATCH] Revert "Avoid decoding other packets when looking for subs." This reverts commit 9e025d3f85f9d6d855b3d5e6c90bca0eac3a3d49. It causes corruption in prophet_clip.xml for reasons that are not yet known. --- src/lib/audio_decoder_stream.cc | 4 ++-- src/lib/dcp_decoder.cc | 6 +++--- src/lib/dcp_decoder.h | 2 +- src/lib/dcp_subtitle_decoder.cc | 2 +- src/lib/dcp_subtitle_decoder.h | 2 +- src/lib/decoder.h | 8 +------- src/lib/ffmpeg_decoder.cc | 6 +++--- src/lib/ffmpeg_decoder.h | 2 +- src/lib/image_decoder.cc | 2 +- src/lib/image_decoder.h | 2 +- src/lib/sndfile_decoder.cc | 2 +- src/lib/sndfile_decoder.h | 2 +- src/lib/subrip_decoder.cc | 2 +- src/lib/subrip_decoder.h | 2 +- src/lib/subtitle_decoder.cc | 2 +- src/lib/video_decoder.cc | 4 ++-- test/audio_decoder_test.cc | 2 +- 17 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc index 4d1a5e4c5..274bf2d54 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_REASON_AUDIO) + !_decoder->pass () ) {} @@ -95,7 +95,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) } else { while ( _decoded.audio->frames() < length && - !_decoder->pass (Decoder::PASS_REASON_AUDIO) + !_decoder->pass () ) {} diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index ada0d01d1..21eb2f7ea 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -59,7 +59,7 @@ DCPDecoder::DCPDecoder (shared_ptr c, bool fast) } bool -DCPDecoder::pass (PassReason reason) +DCPDecoder::pass () { if (_reel == _reels.end () || !_dcp_content->can_be_played ()) { return true; @@ -68,7 +68,7 @@ DCPDecoder::pass (PassReason reason) double const vfr = _dcp_content->video_frame_rate (); int64_t const frame = _next.frames_round (vfr); - if ((*_reel)->main_picture () && reason != PASS_REASON_SUBTITLE) { + if ((*_reel)->main_picture ()) { shared_ptr asset = (*_reel)->main_picture()->asset (); shared_ptr mono = dynamic_pointer_cast (asset); shared_ptr stereo = dynamic_pointer_cast (asset); @@ -88,7 +88,7 @@ DCPDecoder::pass (PassReason reason) } } - if ((*_reel)->main_sound () && reason != PASS_REASON_SUBTITLE) { + if ((*_reel)->main_sound ()) { int64_t const entry_point = (*_reel)->main_sound()->entry_point (); shared_ptr 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 8ec80c2af..6fdbd946a 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 (PassReason); + bool pass (); void seek (ContentTime t, bool accurate); std::list image_subtitles_during (ContentTimePeriod, bool starting) const; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 0f1cda209..1c6b973d6 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 (PassReason) +DCPSubtitleDecoder::pass () { if (_next == _subtitles.end ()) { return true; diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index 30bb896e0..fb2213fa2 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -28,7 +28,7 @@ public: DCPSubtitleDecoder (boost::shared_ptr); protected: - bool pass (PassReason); + bool pass (); void seek (ContentTime time, bool accurate); private: diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 9e5573662..8378373c6 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -51,13 +51,7 @@ protected: */ virtual void seek (ContentTime time, bool accurate) = 0; - enum PassReason { - PASS_REASON_VIDEO, - PASS_REASON_AUDIO, - PASS_REASON_SUBTITLE - }; - - virtual bool pass (PassReason) = 0; + virtual bool pass () = 0; }; #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index ee9d9eecb..72a3d02b4 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -89,7 +89,7 @@ FFmpegDecoder::flush () } bool -FFmpegDecoder::pass (PassReason reason) +FFmpegDecoder::pass () { int r = av_read_frame (_format_context, &_packet); @@ -112,11 +112,11 @@ FFmpegDecoder::pass (PassReason reason) int const si = _packet.stream_index; shared_ptr fc = _ffmpeg_content; - if (si == _video_stream && !_ignore_video && reason != PASS_REASON_SUBTITLE) { + if (si == _video_stream && !_ignore_video) { decode_video_packet (); } else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index (_format_context, si)) { decode_subtitle_packet (); - } else if (reason != PASS_REASON_SUBTITLE) { + } else { decode_audio_packet (); } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index ce5267936..5475be612 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 (PassReason); + bool pass (); void seek (ContentTime time, bool); void flush (); diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 94c0dfd45..db7c5401f 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -43,7 +43,7 @@ ImageDecoder::ImageDecoder (shared_ptr c) } bool -ImageDecoder::pass (PassReason) +ImageDecoder::pass () { if (_video_position >= _image_content->video_length()) { return true; diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index 4ce75a20d..4d96306a8 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -31,7 +31,7 @@ public: } private: - bool pass (PassReason); + bool pass (); void seek (ContentTime, bool); boost::shared_ptr _image_content; diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 7986e3c73..49633dd1f 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -48,7 +48,7 @@ SndfileDecoder::~SndfileDecoder () } bool -SndfileDecoder::pass (PassReason) +SndfileDecoder::pass () { if (_remaining == 0) { return true; diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index a9d2935b6..da9016ee0 100644 --- a/src/lib/sndfile_decoder.h +++ b/src/lib/sndfile_decoder.h @@ -29,7 +29,7 @@ public: ~SndfileDecoder (); private: - bool pass (PassReason); + bool pass (); void seek (ContentTime, bool); int64_t _done; diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index 3c93292a1..32d50d86b 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 (PassReason) +SubRipDecoder::pass () { if (_next >= _subtitles.size ()) { return true; diff --git a/src/lib/subrip_decoder.h b/src/lib/subrip_decoder.h index b899b5dd8..db8374c5c 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 (PassReason); + bool pass (); private: std::list image_subtitles_during (ContentTimePeriod, bool starting) const; diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index 85b814d58..a7da626b7 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -72,7 +72,7 @@ SubtitleDecoder::get (list const & subs, list const & sp, * (a) give us what we want, or * (b) hit the end of the decoder. */ - while (!pass(PASS_REASON_SUBTITLE) && (subs.empty() || (subs.back().period().to < sp.back().to))) {} + while (!pass () && (subs.empty() || (subs.back().period().to < sp.back().to))) {} /* Now look for what we wanted in the data we have collected */ /* XXX: inefficient */ diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index efc0ecf11..1c9a6374f 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 (PASS_REASON_VIDEO)) { + if (pass ()) { /* 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 (PASS_REASON_VIDEO)) {} + while (_decoded_video.empty() && !pass ()) {} if (!_decoded_video.empty ()) { dec.push_back (_decoded_video.front ()); } diff --git a/test/audio_decoder_test.cc b/test/audio_decoder_test.cc index 48118c1b7..44d0d60f4 100644 --- a/test/audio_decoder_test.cc +++ b/test/audio_decoder_test.cc @@ -65,7 +65,7 @@ public: , _position (0) {} - bool pass (PassReason) + bool pass () { Frame const N = min ( Frame (2000), -- 2.30.2