Revert "Avoid decoding other packets when looking for subs."
[dcpomatic.git] / src / lib / video_decoder.cc
index 5754cb1caf712ae3314eeb4124d247011a0c1cd5..1c9a6374fa9dad584ee6c49abf53545b993fc7e4 100644 (file)
@@ -23,6 +23,7 @@
 #include "film.h"
 #include "log.h"
 #include "compose.hpp"
+#include <iostream>
 
 #include "i18n.h"
 
@@ -43,7 +44,7 @@ VideoDecoder::VideoDecoder (shared_ptr<const VideoContent> c)
        , _last_seek_accurate (true)
        , _ignore_video (false)
 {
-       _black_image.reset (new Image (PIX_FMT_RGB24, _video_content->video_size(), true));
+       _black_image.reset (new Image (AV_PIX_FMT_RGB24, _video_content->video_size(), true));
        _black_image->make_black ();
 }
 
@@ -74,7 +75,7 @@ VideoDecoder::get_video (Frame frame, bool accurate)
           one after the end of _decoded_video we need to seek.
        */
 
-       _video_content->film()->log()->log (String::compose ("VD has request for %1", frame), Log::TYPE_DEBUG_DECODE);
+       _video_content->film()->log()->log (String::compose ("VD has request for %1", frame), LogEntry::TYPE_DEBUG_DECODE);
 
        if (_decoded_video.empty() || frame < _decoded_video.front().frame || frame > (_decoded_video.back().frame + 1)) {
                seek (ContentTime::from_frames (frame, _video_content->video_frame_rate()), accurate);
@@ -239,7 +240,7 @@ VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame)
                return;
        }
 
-       _video_content->film()->log()->log (String::compose ("VD receives %1", frame), Log::TYPE_DEBUG_DECODE);
+       _video_content->film()->log()->log (String::compose ("VD receives %1", frame), LogEntry::TYPE_DEBUG_DECODE);
 
        /* We may receive the same frame index twice for 3D, and we need to know
           when that happens.
@@ -317,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