Don't expand all cinemas on opening KDM dialogs (#779).
[dcpomatic.git] / src / wx / film_viewer.cc
index 27c8d23b61710d4478c3a96008c52176bceeec66..5ca147b747b932be49c035c51b6e9477bffac12e 100644 (file)
@@ -37,6 +37,9 @@
 #include "lib/log.h"
 #include "film_viewer.h"
 #include "wx_util.h"
+extern "C" {
+#include <libavutil/pixfmt.h>
+}
 #include <dcp/exceptions.h>
 #include <wx/tglbtn.h>
 #include <iostream>
@@ -67,6 +70,8 @@ FilmViewer::FilmViewer (wxWindow* p)
        , _frame_number (new wxStaticText (this, wxID_ANY, wxT("")))
        , _timecode (new wxStaticText (this, wxID_ANY, wxT("")))
        , _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
+       , _coalesce_player_changes (false)
+       , _pending_player_change (false)
        , _last_get_accurate (true)
 {
 #ifndef __WXOSX__
@@ -186,7 +191,11 @@ FilmViewer::get (DCPTime p, bool accurate)
 
        if (!pvf.empty ()) {
                try {
-                       _frame = pvf.front()->image (PIX_FMT_RGB24, boost::bind (&Log::dcp_log, _film->log().get(), _1, _2));
+                       /* XXX: this could now give us a 48-bit image, which is a bit wasteful,
+                          or a XYZ image, which the code below will currently rely on FFmpeg
+                          to colourspace-convert.
+                       */
+                       _frame = pvf.front()->image (boost::bind (&Log::dcp_log, _film->log().get(), _1, _2));
                        ImageChanged (pvf.front ());
 
                        dcp::YUVToRGB yuv_to_rgb = dcp::YUV_TO_RGB_REC601;
@@ -194,7 +203,7 @@ FilmViewer::get (DCPTime p, bool accurate)
                                yuv_to_rgb = pvf.front()->colour_conversion().get().yuv_to_rgb();
                        }
 
-                       _frame = _frame->scale (_frame->size(), yuv_to_rgb, PIX_FMT_RGB24, false);
+                       _frame = _frame->scale (_frame->size(), yuv_to_rgb, AV_PIX_FMT_RGB24, false);
                        _position = pvf.front()->time ();
                        _inter_position = pvf.front()->inter_position ();
                        _inter_size = pvf.front()->inter_size ();
@@ -428,6 +437,11 @@ FilmViewer::player_changed (bool frequent)
                return;
        }
 
+       if (_coalesce_player_changes) {
+               _pending_player_change = true;
+               return;
+       }
+
        calculate_sizes ();
        refresh ();
        update_position_label ();
@@ -462,3 +476,26 @@ FilmViewer::refresh ()
 {
        get (_position, _last_get_accurate);
 }
+
+void
+FilmViewer::set_position (DCPTime p)
+{
+       _position = p;
+       get (_position, true);
+       update_position_label ();
+       update_position_slider ();
+}
+
+void
+FilmViewer::set_coalesce_player_changes (bool c)
+{
+       _coalesce_player_changes = c;
+
+       if (c) {
+               _pending_player_change = false;
+       } else {
+               if (_pending_player_change) {
+                       player_changed (false);
+               }
+       }
+}