- if (!_player_video.first) {
- _frame.reset ();
- refresh_panel ();
- return;
- }
-
- if (_playing && (time() - _player_video.second) > one_video_frame()) {
- /* Too late; just drop this frame before we try to get its image (which will be the time-consuming
- part if this frame is J2K).
- */
- _video_position = _player_video.second;
- ++_dropped;
- return;
- }
-
- /* In an ideal world, what we would do here is:
- *
- * 1. convert to XYZ exactly as we do in the DCP creation path.
- * 2. convert back to RGB for the preview display, compensating
- * for the monitor etc. etc.
- *
- * but this is inefficient if the source is RGB. Since we don't
- * (currently) care too much about the precise accuracy of the preview's
- * colour mapping (and we care more about its speed) we try to short-
- * circuit this "ideal" situation in some cases.
- *
- * The content's specified colour conversion indicates the colourspace
- * which the content is in (according to the user).
- *
- * PlayerVideo::image (bound to PlayerVideo::always_rgb) will take the source
- * image and convert it (from whatever the user has said it is) to RGB.
- */
-
- _frame = _player_video.first->image (
- bind (&Log::dcp_log, _film->log().get(), _1, _2),
- bind (&PlayerVideo::always_rgb, _1),
- false, true
- );
-
- ImageChanged (_player_video.first);
-
- _video_position = _player_video.second;
- _inter_position = _player_video.first->inter_position ();
- _inter_size = _player_video.first->inter_size ();
-
- refresh_panel ();
-
- _closed_captions_dialog->update (time());
-}
-
-void
-FilmViewer::timer ()
-{
- if (!_film || !_playing) {
- return;
- }
-
- get ();
- update_position_label ();
- update_position_slider ();
- DCPTime const next = _video_position + one_video_frame();
-
- if (next >= _film->length()) {
- stop ();
- }
-
- _timer.Start (max ((next.seconds() - time().seconds()) * 1000, 1.0), wxTIMER_ONE_SHOT);
-
- if (_butler) {
- _butler->rethrow ();
- }
-}
-
-void
-FilmViewer::paint_panel ()
-{
- wxPaintDC dc (_panel);
-
- if (!_frame || !_film || !_out_size.width || !_out_size.height || _out_size != _frame->size()) {
- dc.Clear ();
- return;
- }
-
- wxImage frame (_out_size.width, _out_size.height, _frame->data()[0], true);
- wxBitmap frame_bitmap (frame);
- dc.DrawBitmap (frame_bitmap, 0, 0);
-
- if (_out_size.width < _panel_size.width) {
- wxPen p (GetBackgroundColour ());
- wxBrush b (GetBackgroundColour ());
- dc.SetPen (p);
- dc.SetBrush (b);
- dc.DrawRectangle (_out_size.width, 0, _panel_size.width - _out_size.width, _panel_size.height);
- }
-
- if (_out_size.height < _panel_size.height) {
- wxPen p (GetBackgroundColour ());
- wxBrush b (GetBackgroundColour ());
- dc.SetPen (p);
- dc.SetBrush (b);
- dc.DrawRectangle (0, _out_size.height, _panel_size.width, _panel_size.height - _out_size.height);
- }
-
- if (_outline_content && _outline_content->GetValue ()) {
- wxPen p (wxColour (255, 0, 0), 2);
- dc.SetPen (p);
- dc.SetBrush (*wxTRANSPARENT_BRUSH);
- dc.DrawRectangle (_inter_position.x, _inter_position.y, _inter_size.width, _inter_size.height);
- }
-}
-
-/** @param page true if this was a PAGEUP/PAGEDOWN event for which we won't receive a THUMBRELEASE */
-void
-FilmViewer::slider_moved (bool page)
-{
- if (!_film) {
- return;
- }
-
- if (!page && !_slider_being_moved) {
- /* This is the first event of a drag; stop playback for the duration of the drag */
- _was_running_before_slider = stop ();
- _slider_being_moved = true;
- }
-
- DCPTime t (_slider->GetValue() * _film->length().get() / 4096);
- t = t.round (_film->video_frame_rate());
- /* Ensure that we hit the end of the film at the end of the slider */
- if (t >= _film->length ()) {
- t = _film->length() - one_video_frame();
- }
- seek (t, false);
- update_position_label ();
-}
-
-void
-FilmViewer::slider_released ()
-{
- if (_was_running_before_slider) {
- /* Restart after a drag */
- start ();
- }
- _slider_being_moved = false;