From 9e025d3f85f9d6d855b3d5e6c90bca0eac3a3d49 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 16 Oct 2015 14:38:44 +0100 Subject: Avoid decoding other packets when looking for subs. The "accumulation" of, for example, video data when we are looking for audio data is an *optimisation* to reduce the number of seeks. It should not be necessary for correctness (the output should be right even if we never kept anything except what we were looking for). Doing this accumulation is not always an optimisation; sometimes not doing it is better. Avoiding it when going back for subtitles is one of these cases. --- src/lib/video_decoder.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/video_decoder.cc') diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 02f8fa0ac..4b9272413 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 ()); } -- cgit v1.2.3 From f09e6545efa4c5ca816e89e28a287bc6ab1ee50b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 16 Oct 2015 15:08:48 +0100 Subject: Remove the dreaded _decoded_video size assertion. I am reasonably convinced that the accumulation of _decoded_video is an optimisation rather than being required for correctness, so it's no problem to throw frames away as the code will just get them back again if and when it needs them. --- src/lib/video_decoder.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/lib/video_decoder.cc') diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 4b9272413..efc0ecf11 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -318,10 +318,14 @@ VideoDecoder::video (shared_ptr 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 -- cgit v1.2.3