diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-15 21:48:02 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-15 21:48:02 +0100 |
| commit | adf17c5e1992186c7f8d63d9cffd087311164ffa (patch) | |
| tree | 90eb0e04e702a0dcb60739ccdd938857dd16742c /src/lib | |
| parent | 040d5792b67e3ac1f3d023acc905b36748ddb85f (diff) | |
| parent | 1bb4bd728a445de0728c897211bf079c714d4f41 (diff) | |
Merge.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 4 | ||||
| -rw-r--r-- | src/lib/job_manager.h | 3 | ||||
| -rw-r--r-- | src/lib/player.cc | 20 | ||||
| -rw-r--r-- | src/lib/player.h | 5 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 31 | ||||
| -rw-r--r-- | src/lib/position.h | 4 | ||||
| -rw-r--r-- | src/lib/rect.h | 4 | ||||
| -rw-r--r-- | src/lib/sndfile_content.h | 4 | ||||
| -rw-r--r-- | src/lib/video_content.h | 3 |
9 files changed, 67 insertions, 11 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 18834c90e..11cea8fb1 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -338,7 +338,7 @@ FFmpegDecoder::seek (VideoContent::Frame frame, bool accurate) _video_position = rint ( (av_frame_get_best_effort_timestamp (_frame) * time_base + _video_pts_offset) * _ffmpeg_content->video_frame_rate() ); - + if (_video_position >= (frame - 1)) { av_free_packet (&_packet); break; @@ -451,6 +451,8 @@ FFmpegDecoder::decode_video_packet () /* This PTS is more than one frame forward in time of where we think we should be; emit a black frame. */ + + /* XXX: I think this should be a copy of the last frame... */ boost::shared_ptr<Image> black ( new Image ( static_cast<AVPixelFormat> (_frame->format), diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index cc1c1d28f..82095a143 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -45,6 +45,9 @@ public: static JobManager* instance (); private: + /* This function is part of the test suite */ + friend void ::wait_for_jobs (); + JobManager (); void scheduler (); diff --git a/src/lib/player.cc b/src/lib/player.cc index 8fd5715d4..6ee8c5029 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -238,6 +238,10 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image work_image = im; } +#ifdef DCPOMATIC_DEBUG + _last_video = piece->content; +#endif + Video (work_image, same, time); time += TIME_HZ / _film->dcp_video_frame_rate(); @@ -348,7 +352,10 @@ Player::flush () } -/** @return true on error */ +/** Seek so that the next pass() will yield (approximately) the requested frame. + * Pass accurate = true to try harder to get close to the request. + * @return true on error + */ void Player::seek (Time t, bool accurate) { @@ -374,11 +381,16 @@ 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()); - VideoContent::Frame f = s * vc->video_frame_rate() / (frc.factor() * TIME_HZ); + /* 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); dynamic_pointer_cast<VideoDecoder>((*i)->decoder)->seek (f, accurate); } _video_position = _audio_position = t; + /* XXX: don't seek audio because we don't need to... */ } @@ -501,6 +513,10 @@ Player::resampler (shared_ptr<AudioContent> c) void Player::emit_black () { +#ifdef DCPOMATIC_DEBUG + _last_video.reset (); +#endif + /* XXX: use same here */ Video (_black_frame, false, _video_position); _video_position += _film->video_frames_to_time (1); diff --git a/src/lib/player.h b/src/lib/player.h index b3eadd7c0..92a358043 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -75,6 +75,7 @@ public: boost::signals2::signal<void ()> Changed; private: + friend class PlayerWrapper; void process_video (boost::weak_ptr<Piece>, boost::shared_ptr<const Image>, bool, VideoContent::Frame); void process_audio (boost::weak_ptr<Piece>, boost::shared_ptr<const AudioBuffers>, AudioContent::Frame); @@ -126,6 +127,10 @@ private: Time from; Time to; } _out_subtitle; + +#ifdef DCPOMATIC_DEBUG + boost::shared_ptr<Content> _last_video; +#endif }; #endif diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index aea6c5f41..028b2b880 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -75,15 +75,40 @@ Playlist::content_changed (weak_ptr<Content> c, int p) if (p == ContentProperty::LENGTH) { maybe_sequence_video (); } +<<<<<<< HEAD ContentChanged (c, p); } +======= + + ContentChanged (c, p); +} + +>>>>>>> 1ea6a456bc2b4a695f6db4720353c35167597b30 void Playlist::maybe_sequence_video () { if (!_sequence_video || _sequencing_video) { return; +<<<<<<< HEAD + } + + _sequencing_video = true; + + ContentList cl = _content; + sort (cl.begin(), cl.end(), ContentSorter ()); + Time last = 0; + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { + if (!dynamic_pointer_cast<VideoContent> (*i)) { + continue; + } + + (*i)->set_start (last); + last = (*i)->end (); + } + +======= } _sequencing_video = true; @@ -100,6 +125,7 @@ Playlist::maybe_sequence_video () last = (*i)->end (); } +>>>>>>> 1ea6a456bc2b4a695f6db4720353c35167597b30 _sequencing_video = false; } @@ -231,7 +257,7 @@ Playlist::best_dcp_frame_rate () const candidates.push_back (FrameRateCandidate (float (*i) * 2, *i)); } - /* Pick the best one, bailing early if we hit an exact match */ + /* Pick the best one */ float error = std::numeric_limits<float>::max (); optional<FrameRateCandidate> best; list<FrameRateCandidate>::iterator i = candidates.begin(); @@ -244,7 +270,8 @@ Playlist::best_dcp_frame_rate () const continue; } - this_error += fabs (i->source - vc->video_frame_rate ()); + /* Use the largest difference between DCP and source as the "error" */ + this_error = max (this_error, float (fabs (i->source - vc->video_frame_rate ()))); } if (this_error < error) { diff --git a/src/lib/position.h b/src/lib/position.h index f904fe661..8768bf5a8 100644 --- a/src/lib/position.h +++ b/src/lib/position.h @@ -17,8 +17,8 @@ */ -#ifndef DVDOMATIC_POSITION_H -#define DVDOMATIC_POSITION_H +#ifndef DCPOMATIC_POSITION_H +#define DCPOMATIC_POSITION_H /** @struct Position * @brief A position. diff --git a/src/lib/rect.h b/src/lib/rect.h index df1869841..6f4709c08 100644 --- a/src/lib/rect.h +++ b/src/lib/rect.h @@ -17,8 +17,8 @@ */ -#ifndef DVDOMATIC_RECT_H -#define DVDOMATIC_RECT_H +#ifndef DCPOMATIC_RECT_H +#define DCPOMATIC_RECT_H #include "position.h" diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h index 3d3f0c36c..e3b775e8b 100644 --- a/src/lib/sndfile_content.h +++ b/src/lib/sndfile_content.h @@ -17,8 +17,8 @@ */ -#ifndef DVDOMATIC_SNDFILE_CONTENT_H -#define DVDOMATIC_SNDFILE_CONTENT_H +#ifndef DCPOMATIC_SNDFILE_CONTENT_H +#define DCPOMATIC_SNDFILE_CONTENT_H extern "C" { #include <libavutil/audioconvert.h> diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 46c8efdeb..697a0ecc3 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -88,6 +88,9 @@ protected: private: friend class ffmpeg_pts_offset_test; + friend class best_dcp_frame_rate_test_single; + friend class best_dcp_frame_rate_test_double; + friend class audio_sampling_rate_test; libdcp::Size _video_size; float _video_frame_rate; |
