#include "lib/examine_content_job.h"
#include "lib/filter.h"
#include "lib/player.h"
+#include "lib/player_video_frame.h"
#include "lib/video_content.h"
#include "lib/video_decoder.h"
#include "lib/timer.h"
-#include "lib/dcp_video.h"
#include "film_viewer.h"
#include "wx_util.h"
, _frame_number (new wxStaticText (this, wxID_ANY, wxT("")))
, _timecode (new wxStaticText (this, wxID_ANY, wxT("")))
, _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
+ , _last_get_accurate (true)
{
#ifndef __WXOSX__
_panel->SetDoubleBuffered (true);
_frame.reset ();
_slider->SetValue (0);
- set_position_text (DCPTime ());
+ set_position_text ();
if (!_film) {
return;
_player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1));
calculate_sizes ();
- get (_position, true);
+ get (_position, _last_get_accurate);
}
void
FilmViewer::get (DCPTime p, bool accurate)
{
- shared_ptr<DCPVideo> dcp_video = _player->get_video (p, accurate);
- if (dcp_video) {
- _frame = dcp_video->image (PIX_FMT_BGRA, true);
+ if (!_player) {
+ return;
+ }
+
+ list<shared_ptr<PlayerVideoFrame> > pvf = _player->get_video (p, accurate);
+ if (!pvf.empty ()) {
+ _frame = pvf.front()->image ();
_frame = _frame->scale (_frame->size(), Scaler::from_id ("fastbilinear"), PIX_FMT_RGB24, false);
} else {
_frame.reset ();
}
- set_position_text (p);
+ _position = p;
+
+ set_position_text ();
_panel->Refresh ();
_panel->Update ();
+
+ _last_get_accurate = accurate;
}
void
FilmViewer::timer ()
{
- if (!_player) {
- return;
- }
-
get (_position + DCPTime::from_frames (1, _film->video_frame_rate ()), true);
DCPTime const len = _film->length ();
void
FilmViewer::slider_moved ()
{
- if (!_film || !_player) {
+ if (!_film) {
return;
}
_panel_size.width = ev.GetSize().GetWidth();
_panel_size.height = ev.GetSize().GetHeight();
calculate_sizes ();
- get (_position, true);
+ get (_position, _last_get_accurate);
}
void
}
void
-FilmViewer::set_position_text (DCPTime t)
+FilmViewer::set_position_text ()
{
if (!_film) {
_frame_number->SetLabel ("0");
double const fps = _film->video_frame_rate ();
/* Count frame number from 1 ... not sure if this is the best idea */
- _frame_number->SetLabel (wxString::Format (wxT("%d"), int (rint (t.seconds() * fps)) + 1));
+ _frame_number->SetLabel (wxString::Format (wxT("%d"), int (rint (_position.seconds() * fps)) + 1));
- double w = t.seconds ();
+ double w = _position.seconds ();
int const h = (w / 3600);
w -= h * 3600;
int const m = (w / 60);
void
FilmViewer::back_clicked ()
{
- if (!_player) {
- return;
- }
-
DCPTime p = _position - DCPTime::from_frames (1, _film->video_frame_rate ());
if (p < DCPTime ()) {
p = DCPTime ();
void
FilmViewer::forward_clicked ()
{
- if (!_player) {
- return;
- }
-
get (_position + DCPTime::from_frames (1, _film->video_frame_rate ()), true);
}
}
calculate_sizes ();
- get (_position, true);
+ get (_position, _last_get_accurate);
}