X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=f90cf32f5c3f228a35726017837de3c08a40492e;hb=8e866d15e16f41d96dbbc1aa00c95d5b85f4286e;hp=f5212f8d016f34e727fcc81d11c3354445884f47;hpb=91273da19c689e44f3baa368d4b4efbe75cd8fe5;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index f5212f8d0..f90cf32f5 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -22,8 +22,8 @@ #include "film.h" #include "ffmpeg_decoder.h" #include "ffmpeg_content.h" -#include "imagemagick_decoder.h" -#include "imagemagick_content.h" +#include "still_image_decoder.h" +#include "still_image_content.h" #include "sndfile_decoder.h" #include "sndfile_content.h" #include "subtitle_content.h" @@ -32,6 +32,7 @@ #include "image.h" #include "ratio.h" #include "resampler.h" +#include "log.h" #include "scaler.h" using std::list; @@ -45,7 +46,7 @@ using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; -#define DEBUG_PLAYER 1 +//#define DEBUG_PLAYER 1 class Piece { @@ -74,8 +75,8 @@ std::ostream& operator<<(std::ostream& s, Piece const & p) { if (dynamic_pointer_cast (p.content)) { s << "\tffmpeg "; - } else if (dynamic_pointer_cast (p.content)) { - s << "\timagemagick"; + } else if (dynamic_pointer_cast (p.content)) { + s << "\tstill image"; } else if (dynamic_pointer_cast (p.content)) { s << "\tsndfile "; } @@ -94,7 +95,7 @@ Player::Player (shared_ptr f, shared_ptr p) , _have_valid_pieces (false) , _video_position (0) , _audio_position (0) - , _audio_buffers (f->dcp_audio_channels(), 0) + , _audio_buffers (f->audio_channels(), 0) { _playlist->Changed.connect (bind (&Player::playlist_changed, this)); _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3)); @@ -202,7 +203,7 @@ Player::pass () } void -Player::process_video (weak_ptr weak_piece, shared_ptr image, bool same, VideoContent::Frame frame) +Player::process_video (weak_ptr weak_piece, shared_ptr image, Eyes eyes, bool same, VideoContent::Frame frame) { shared_ptr piece = weak_piece.lock (); if (!piece) { @@ -212,7 +213,7 @@ Player::process_video (weak_ptr weak_piece, shared_ptr image shared_ptr content = dynamic_pointer_cast (piece->content); assert (content); - FrameRateConversion frc (content->video_frame_rate(), _film->dcp_video_frame_rate()); + FrameRateConversion frc (content->video_frame_rate(), _film->video_frame_rate()); if (frc.skip && (frame % 2) == 1) { return; } @@ -223,7 +224,7 @@ Player::process_video (weak_ptr weak_piece, shared_ptr image work_image = work_image->scale_and_convert_to_rgb (image_size, _film->scaler(), true); - Time time = content->start() + (frame * frc.factor() * TIME_HZ / _film->dcp_video_frame_rate()); + Time time = content->start() + (frame * frc.factor() * TIME_HZ / _film->video_frame_rate()); if (_film->with_subtitles () && _out_subtitle.image && time >= _out_subtitle.from && time <= _out_subtitle.to) { work_image->alpha_blend (_out_subtitle.image, _out_subtitle.position); @@ -240,14 +241,14 @@ Player::process_video (weak_ptr weak_piece, shared_ptr image #ifdef DCPOMATIC_DEBUG _last_video = piece->content; -#endif +#endif - Video (work_image, same, time); - time += TIME_HZ / _film->dcp_video_frame_rate(); + Video (work_image, eyes, same, time); + time += TIME_HZ / _film->video_frame_rate(); if (frc.repeat) { - Video (work_image, true, time); - time += TIME_HZ / _film->dcp_video_frame_rate(); + Video (work_image, eyes, true, time); + time += TIME_HZ / _film->video_frame_rate(); } _video_position = piece->video_position = time; @@ -271,7 +272,7 @@ Player::process_audio (weak_ptr weak_piece, shared_ptr dcp_mapped (new AudioBuffers (_film->dcp_audio_channels(), audio->frames())); + shared_ptr dcp_mapped (new AudioBuffers (_film->audio_channels(), audio->frames())); dcp_mapped->make_silent (); list > map = content->audio_mapping().content_to_dcp (); for (list >::iterator i = map.begin(); i != map.end(); ++i) { @@ -282,11 +283,11 @@ Player::process_audio (weak_ptr weak_piece, shared_ptrstart() + (frame * TIME_HZ / _film->dcp_audio_frame_rate()) + (content->audio_delay() * TIME_HZ / 1000); + Time time = content->start() + (frame * TIME_HZ / _film->audio_frame_rate()) + (content->audio_delay() * TIME_HZ / 1000); /* We must cut off anything that comes before the start of all time */ if (time < 0) { - int const frames = - time * _film->dcp_audio_frame_rate() / TIME_HZ; + int const frames = - time * _film->audio_frame_rate() / TIME_HZ; if (frames >= audio->frames ()) { return; } @@ -380,12 +381,12 @@ Player::seek (Time t, bool accurate) (*i)->video_position = (*i)->audio_position = vc->start() + s; - FrameRateConversion frc (vc->video_frame_rate(), _film->dcp_video_frame_rate()); + FrameRateConversion frc (vc->video_frame_rate(), _film->video_frame_rate()); /* Here we are converting from time (in the DCP) to a frame number in the content. Hence we need to use the DCP's frame rate and the double/skip correction, not the source's rate. */ - VideoContent::Frame f = s * _film->dcp_video_frame_rate() / (frc.factor() * TIME_HZ); + VideoContent::Frame f = s * _film->video_frame_rate() / (frc.factor() * TIME_HZ); dynamic_pointer_cast((*i)->decoder)->seek (f, accurate); } @@ -401,10 +402,10 @@ Player::setup_pieces () _pieces.clear (); - Playlist::ContentList content = _playlist->content_with_loop (); + ContentList content = _playlist->content (); sort (content.begin(), content.end(), ContentSorter ()); - for (Playlist::ContentList::iterator i = content.begin(); i != content.end(); ++i) { + for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { shared_ptr piece (new Piece (*i)); @@ -414,28 +415,28 @@ Player::setup_pieces () if (fc) { shared_ptr fd (new FFmpegDecoder (_film, fc, _video, _audio)); - fd->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3)); + fd->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3, _4)); fd->Audio.connect (bind (&Player::process_audio, this, piece, _1, _2)); fd->Subtitle.connect (bind (&Player::process_subtitle, this, piece, _1, _2, _3, _4)); piece->decoder = fd; } - shared_ptr ic = dynamic_pointer_cast (*i); + shared_ptr ic = dynamic_pointer_cast (*i); if (ic) { - shared_ptr id; + shared_ptr id; - /* See if we can re-use an old ImageMagickDecoder */ + /* See if we can re-use an old StillImageDecoder */ for (list >::const_iterator j = old_pieces.begin(); j != old_pieces.end(); ++j) { - shared_ptr imd = dynamic_pointer_cast ((*j)->decoder); + shared_ptr imd = dynamic_pointer_cast ((*j)->decoder); if (imd && imd->content() == ic) { id = imd; } } if (!id) { - id.reset (new ImageMagickDecoder (_film, ic)); - id->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3)); + id.reset (new StillImageDecoder (_film, ic)); + id->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3, _4)); } piece->decoder = id; @@ -479,6 +480,8 @@ Player::content_changed (weak_ptr w, int property, bool frequent) } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE) { update_subtitle (); Changed (frequent); + } else if (property == VideoContentProperty::VIDEO_FRAME_TYPE) { + Changed (frequent); } } @@ -518,15 +521,15 @@ Player::emit_black () #endif /* XXX: use same here */ - Video (_black_frame, false, _video_position); + Video (_black_frame, EYES_BOTH, false, _video_position); _video_position += _film->video_frames_to_time (1); } void Player::emit_silence (OutputAudioFrame most) { - OutputAudioFrame N = min (most, _film->dcp_audio_frame_rate() / 2); - shared_ptr silence (new AudioBuffers (_film->dcp_audio_channels(), N)); + OutputAudioFrame N = min (most, _film->audio_frame_rate() / 2); + shared_ptr silence (new AudioBuffers (_film->audio_channels(), N)); silence->make_silent (); Audio (silence, _audio_position); _audio_position += _film->audio_frames_to_time (N);