diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-10-16 17:19:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-10-16 17:19:30 +0100 |
| commit | bd709c1e98e7653dafe7dff302440a7890140c7d (patch) | |
| tree | 5ed050d67e30195e665f5475322d27d7790c2b23 /src/lib | |
| parent | f0da433894308ed72b0dbdd116a30a8d659c33cc (diff) | |
| parent | f09e6545efa4c5ca816e89e28a287bc6ab1ee50b (diff) | |
Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
Diffstat (limited to 'src/lib')
| -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 | 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 | 11 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 14 |
16 files changed, 36 insertions, 33 deletions
diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc index 274bf2d54..4d1a5e4c5 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) ) {} @@ -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) ) {} diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 21eb2f7ea..ada0d01d1 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) { 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..8ec80c2af 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); 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..0f1cda209 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) { if (_next == _subtitles.end ()) { return true; diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index fb2213fa2..30bb896e0 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); void seek (ContentTime time, bool accurate); private: diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 8378373c6..9e5573662 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) = 0; }; #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 72a3d02b4..ee9d9eecb 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) { 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 && 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..ce5267936 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); void seek (ContentTime time, bool); void flush (); diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index db7c5401f..94c0dfd45 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) { 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..4ce75a20d 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -31,7 +31,7 @@ public: } private: - bool pass (); + bool pass (PassReason); void seek (ContentTime, bool); boost::shared_ptr<const ImageContent> _image_content; diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 49633dd1f..7986e3c73 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) { if (_remaining == 0) { return true; diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index da9016ee0..a9d2935b6 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); void seek (ContentTime, bool); int64_t _done; diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index 32d50d86b..3c93292a1 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) { if (_next >= _subtitles.size ()) { return true; diff --git a/src/lib/subrip_decoder.h b/src/lib/subrip_decoder.h index db8374c5c..b899b5dd8 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); 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 a95964f47..85b814d58 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -63,14 +63,7 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, return list<T> (); } - /* Seek if what we want is before what we have, or a more than a little bit after. - Be careful with the length of this `little bit'; consider the case where the last - subs were just less than this little bit B ago. Then we will not seek, but instead - pass() for nearly B seconds; if we are a FFmpegDecoder then this will generate B's - worth of video which will stack up. If B + the pre-roll is bigger than the maximum - number of frames that the VideoDecoder will keep then we will get an assertion - failure in VideoDecoder. - */ + /* Seek if what we want is before what we have, or a more than a little bit after */ if (subs.empty() || sp.back().to < subs.front().period().from || sp.front().from > (subs.back().period().to + ContentTime::from_seconds (1))) { seek (sp.front().from, true); } @@ -79,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) && (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 02f8fa0ac..efc0ecf11 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)) { /* 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)) {} if (!_decoded_video.empty ()) { dec.push_back (_decoded_video.front ()); } @@ -318,10 +318,14 @@ VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame) copy (to_push.begin(), to_push.end(), back_inserter (_decoded_video)); - /* We can't let this build up too much or we will run out of memory. We need to allow - the most frames that can exist between blocks of sound in a multiplexed file. + /* We can't let this build up too much or we will run out of memory. There is a + `best' value for the allowed size of _decoded_video which balances memory use + with decoding efficiency (lack of seeks). Throwing away video frames here + is not a problem for correctness, so do it. */ - DCPOMATIC_ASSERT (_decoded_video.size() <= 96); + while (_decoded_video.size() > 96) { + _decoded_video.pop_back (); + } } void |
