Optimise the fetch-same-frame case a bit (#196).
authorCarl Hetherington <cth@carlh.net>
Wed, 16 Oct 2013 10:46:36 +0000 (11:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 16 Oct 2013 10:46:36 +0000 (11:46 +0100)
ChangeLog
src/lib/player.cc
src/lib/player.h
src/wx/film_viewer.cc

index 050c1c424e1251db26c44b6688a5d9d62f6cb8fb..8390a7ee8eca18b7958680ef8b8c73f6167227af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-16  Carl Hetherington  <cth@carlh.net>
+
+       * Speed up response to some settings changes
+       (e.g. crop) (#196).
+
 2013-10-15  Carl Hetherington  <cth@carlh.net>
 
        * Version 1.16 released.
index ff484e749565d5778772503b061ceca76c379342..a235d16229bdd616303eb0df3ea02b07f34b1d65 100644 (file)
@@ -190,6 +190,13 @@ Player::pass ()
 void
 Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image, Eyes eyes, bool same, VideoContent::Frame frame)
 {
+       /* Keep a note of what came in so that we can repeat it if required */
+       _last_process_video.weak_piece = weak_piece;
+       _last_process_video.image = image;
+       _last_process_video.eyes = eyes;
+       _last_process_video.same = same;
+       _last_process_video.frame = frame;
+       
        shared_ptr<Piece> piece = weak_piece.lock ();
        if (!piece) {
                return;
@@ -608,3 +615,20 @@ Player::update_subtitle ()
        _out_subtitle.from = _in_subtitle.from + piece->content->position ();
        _out_subtitle.to = _in_subtitle.to + piece->content->position ();
 }
+
+/** Re-emit the last frame that was emitted, using current settings for crop, ratio, scaler and subtitles */
+void
+Player::repeat_last_video ()
+{
+       if (!_last_process_video.image) {
+               return;
+       }
+
+       process_video (
+               _last_process_video.weak_piece,
+               _last_process_video.image,
+               _last_process_video.eyes,
+               _last_process_video.same,
+               _last_process_video.frame
+               );
+}
index 2261f66eaa6aafb8c09c3c71961e5f152fc5f513..5604d8e0350c967f09cd33bfaf1a66ae77e62c29 100644 (file)
@@ -59,6 +59,8 @@ public:
 
        void set_video_container_size (libdcp::Size);
 
+       void repeat_last_video ();
+
        /** Emitted when a video frame is ready.
         *  First parameter is the video image.
         *  Second parameter is the eye(s) that should see this image.
@@ -138,6 +140,14 @@ private:
 
        bool _last_emit_was_black;
 
+       struct {
+               boost::weak_ptr<Piece> weak_piece;
+               boost::shared_ptr<const Image> image;
+               Eyes eyes;
+               bool same;
+               VideoContent::Frame frame;
+       } _last_process_video;
+
        boost::signals2::scoped_connection _playlist_changed_connection;
        boost::signals2::scoped_connection _playlist_content_changed_connection;
        boost::signals2::scoped_connection _film_changed_connection;
index 69cd276e17a9fa6ac64aef63f0bde2b3003ca9d5..291ab422d82574bf357988d237efaf1b0aed4443 100644 (file)
@@ -135,7 +135,7 @@ FilmViewer::set_film (shared_ptr<Film> f)
        _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1));
 
        calculate_sizes ();
-       fetch_current_frame_again ();
+       fetch_next_frame ();
 }
 
 void
@@ -145,17 +145,14 @@ FilmViewer::fetch_current_frame_again ()
                return;
        }
 
-       /* Player::video_position is the time after the last frame that we received.
-          We want to see it again, so seek back one frame.
+       /* We could do this with a seek and a fetch_next_frame, but this is
+          a shortcut to make it quicker.
        */
 
-       Time p = _player->video_position() - _film->video_frames_to_time (1);
-       if (p < 0) {
-               p = 0;
-       }
-
-       _player->seek (p, true);
-       fetch_next_frame ();
+       _got_frame = false;
+       _player->repeat_last_video ();
+       _panel->Refresh ();
+       _panel->Update ();
 }
 
 void