Remove caching of old ImageDecoder objects.
authorCarl Hetherington <cth@carlh.net>
Mon, 13 Jun 2016 13:38:12 +0000 (14:38 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 13 Jun 2016 13:38:12 +0000 (14:38 +0100)
This breaks things when there is a 3D ImageContent.  When
you change the video frame type on this content the view
does not update because the re-used ImageDecoder recycles
the same video without noticing that the frame type has changed.

I guess this is sort of `because' the video frame type is used
in VideoDecoder::give, which sets up the cache.

Unfortunately I can't remember the case which the caching
of ImageDecoders was meant to speed up.  Maybe this will
now become apparent.

src/lib/decoder_factory.cc
src/lib/decoder_factory.h
src/lib/player.cc
src/wx/subtitle_panel.cc

index 7f53c9a4b0b8a34a62d12ed8cd012b3f772dd000..dc01a043a56cf49aa1df7c0baf311be1aa6e9301 100644 (file)
@@ -37,7 +37,7 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 
 shared_ptr<Decoder>
-decoder_factory (shared_ptr<const Content> content, list<shared_ptr<ImageDecoder> > old_image_decoders, shared_ptr<Log> log, bool fast)
+decoder_factory (shared_ptr<const Content> content, shared_ptr<Log> log, bool fast)
 {
        shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (content);
        if (fc) {
@@ -51,20 +51,7 @@ decoder_factory (shared_ptr<const Content> content, list<shared_ptr<ImageDecoder
 
        shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (content);
        if (ic) {
-               shared_ptr<Decoder> decoder;
-
-               /* See if we can re-use an old ImageDecoder */
-               BOOST_FOREACH (shared_ptr<ImageDecoder> i, old_image_decoders) {
-                       if (i->content() == ic) {
-                               decoder = i;
-                       }
-               }
-
-               if (!decoder) {
-                       decoder.reset (new ImageDecoder (ic, log));
-               }
-
-               return decoder;
+               return shared_ptr<Decoder> (new ImageDecoder (ic, log));
        }
 
        shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (content);
index 6a4e55ef12d955f35c7807bdbdfacdfaa92ba8f9..52a53afd2b34f129fb250087a429e5a149ddd5b8 100644 (file)
@@ -22,7 +22,6 @@ class ImageDecoder;
 
 extern boost::shared_ptr<Decoder> decoder_factory (
        boost::shared_ptr<const Content> content,
-       std::list<boost::shared_ptr<ImageDecoder> > old_image_decoders,
        boost::shared_ptr<Log> log,
        bool fast
        );
index d437d5b1bf964e99cc3c3130b0035c26a95907ca..f22a6480f224f678dc803b08fdd9844e647e9b1a 100644 (file)
@@ -115,14 +115,6 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist
 void
 Player::setup_pieces ()
 {
-       list<shared_ptr<ImageDecoder> > old_image_decoders;
-       BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
-               shared_ptr<ImageDecoder> imd = dynamic_pointer_cast<ImageDecoder> (i->decoder);
-               if (imd) {
-                       old_image_decoders.push_back (imd);
-               }
-       }
-
        _pieces.clear ();
 
        BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) {
@@ -131,7 +123,7 @@ Player::setup_pieces ()
                        continue;
                }
 
-               shared_ptr<Decoder> decoder = decoder_factory (i, old_image_decoders, _film->log(), _fast);
+               shared_ptr<Decoder> decoder = decoder_factory (i, _film->log(), _fast);
                FrameRateChange frc (i->active_video_frame_rate(), _film->video_frame_rate());
 
                if (!decoder) {
index 840d3dad57c058ae8e8d993481b2b395d69c8235..4efc4eee426f6be0916751dac236ba95c724b5a6 100644 (file)
@@ -386,8 +386,7 @@ SubtitlePanel::subtitle_view_clicked ()
        ContentList c = _parent->selected_subtitle ();
        DCPOMATIC_ASSERT (c.size() == 1);
 
-       list<shared_ptr<ImageDecoder> > image_decoders;
-       shared_ptr<Decoder> decoder = decoder_factory (c.front(), image_decoders, _parent->film()->log(), false);
+       shared_ptr<Decoder> decoder = decoder_factory (c.front(), _parent->film()->log(), false);
 
        if (decoder) {
                _subtitle_view = new SubtitleView (this, _parent->film(), decoder, c.front()->position ());