diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-12-22 01:20:39 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-12-22 01:20:39 +0000 |
| commit | e1df859a04d65acaceb032fdb53a6408b84bd972 (patch) | |
| tree | f82fcb0368571ea9a1715a0df0a046261fb7d042 | |
| parent | 7d67f4a38bf7de1b901facf5390a730d307de671 (diff) | |
Various test / seek fixes.
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 14 | ||||
| -rw-r--r-- | src/lib/player.cc | 7 | ||||
| -rw-r--r-- | test/ffmpeg_audio_test.cc | 4 | ||||
| -rw-r--r-- | test/skip_frame_test.cc | 1 | ||||
| -rw-r--r-- | test/test.cc | 1 |
5 files changed, 19 insertions, 8 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 80c3d9906..c6e4217b6 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -367,13 +367,19 @@ FFmpegDecoder::seek_final_finished (int n, int done) const void FFmpegDecoder::seek_and_flush (ContentTime t) { - int64_t const initial_v = ((double (t) / TIME_HZ) - _video_pts_offset) / + int64_t s = ((double (t) / TIME_HZ) - _video_pts_offset) / av_q2d (_format_context->streams[_video_stream]->time_base); - int64_t const initial_a = ((double (t) / TIME_HZ) - _audio_pts_offset) / - av_q2d (_ffmpeg_content->audio_stream()->stream(_format_context)->time_base); + if (_ffmpeg_content->audio_stream ()) { + s = min ( + s, int64_t ( + ((double (t) / TIME_HZ) - _audio_pts_offset) / + av_q2d (_ffmpeg_content->audio_stream()->stream(_format_context)->time_base) + ) + ); + } - av_seek_frame (_format_context, _video_stream, min (initial_v, initial_a), AVSEEK_FLAG_BACKWARD); + av_seek_frame (_format_context, _video_stream, s, AVSEEK_FLAG_BACKWARD); avcodec_flush_buffers (video_codec_context()); if (audio_codec_context ()) { diff --git a/src/lib/player.cc b/src/lib/player.cc index 17b44cdb8..9757040d4 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -142,8 +142,8 @@ Player::pass () shared_ptr<DecodedSubtitle> ds = dynamic_pointer_cast<DecodedSubtitle> (earliest_decoded); if (dv && _video) { - DCPTime const frame = TIME_HZ / _film->video_frame_rate (); - if (!_just_did_inaccurate_seek && earliest_time > (_video_position + frame)) { + DCPTime const half_frame = TIME_HZ / (2 * _film->video_frame_rate ()); + if (!_just_did_inaccurate_seek && earliest_time > (_video_position + half_frame)) { /* See if we're inside some video content */ list<shared_ptr<Piece> >::iterator i = _pieces.begin(); @@ -243,7 +243,7 @@ Player::emit_video (weak_ptr<Piece> weak_piece, shared_ptr<DecodedVideo> video) #endif Video (pi, video->eyes, content->colour_conversion(), video->same, video->dcp_time); - + _last_emit_was_black = false; _video_position = rint (video->dcp_time + TIME_HZ / _film->video_frame_rate()); } @@ -520,6 +520,7 @@ Player::emit_silence (DCPTime most) shared_ptr<AudioBuffers> silence (new AudioBuffers (_film->audio_channels(), t * _film->audio_frame_rate() / TIME_HZ)); silence->make_silent (); Audio (silence, _audio_position); + _audio_position += t; } diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index 65c29325c..bba05ae9b 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -17,6 +17,10 @@ */ +/** @file test/ffmpeg_audio_test.cc + * @brief A simple test of reading audio from an FFmpeg file. + */ + #include <boost/test/unit_test.hpp> #include <libdcp/cpl.h> #include <libdcp/dcp.h> diff --git a/test/skip_frame_test.cc b/test/skip_frame_test.cc index 442047594..4ac5192f2 100644 --- a/test/skip_frame_test.cc +++ b/test/skip_frame_test.cc @@ -46,7 +46,6 @@ BOOST_AUTO_TEST_CASE (skip_frame_test) film->make_dcp (); wait_for_jobs (); - std::cout << film->dir (film->dcp_name ()) << "\n"; check_dcp ("test/data/skip_frame_test", film->dir (film->dcp_name ())); } diff --git a/test/test.cc b/test/test.cc index df2cb1c4b..c0f732c46 100644 --- a/test/test.cc +++ b/test/test.cc @@ -62,6 +62,7 @@ struct TestConfig Config::instance()->set_default_dci_metadata (DCIMetadata ()); Config::instance()->set_default_container (static_cast<Ratio*> (0)); Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0)); + Config::instance()->set_default_audio_delay (0); ServerFinder::instance()->disable (); |
