From 54c0378137091de604b8c0d6d98959b55b0cddb6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 19 Jan 2015 00:26:27 +0000 Subject: [PATCH] Fix audio analysis; make sure we don't decode video and let it pile up unwanted. --- src/lib/analyse_audio_job.cc | 1 + src/lib/ffmpeg_decoder.cc | 2 +- src/lib/player.cc | 13 +++++++++++++ src/lib/player.h | 3 +++ src/lib/video_decoder.cc | 12 ++++++++++++ src/lib/video_decoder.h | 5 +++++ 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 60b10e7b6..74c0125f3 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -60,6 +60,7 @@ AnalyseAudioJob::run () shared_ptr playlist (new Playlist); playlist->add (content); shared_ptr player (new Player (_film, playlist)); + player->set_ignore_video (); int64_t const len = _film->length().frames (_film->audio_frame_rate()); _samples_per_point = max (int64_t (1), len / _num_points); diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index ec4e33a6e..7c846349f 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -154,7 +154,7 @@ FFmpegDecoder::pass () int const si = _packet.stream_index; - if (si == _video_stream) { + if (si == _video_stream && !_ignore_video) { decode_video_packet (); } else if (_ffmpeg_content->audio_stream() && _ffmpeg_content->audio_stream()->uses_index (_format_context, si)) { decode_audio_packet (); diff --git a/src/lib/player.cc b/src/lib/player.cc index 4c9042743..9c7c6471d 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -73,6 +73,7 @@ Player::Player (shared_ptr f, shared_ptr p) , _playlist (p) , _have_valid_pieces (false) , _approximate_size (false) + , _ignore_video (false) { _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this)); _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3)); @@ -173,6 +174,11 @@ Player::setup_pieces () frc = best_overlap_frc; } + shared_ptr vd = dynamic_pointer_cast (decoder); + if (vd && _ignore_video) { + vd->set_ignore_video (); + } + _pieces.push_back (shared_ptr (new Piece (*i, decoder, frc.get ()))); } @@ -608,3 +614,10 @@ Player::get_subtitle_fonts () return fonts; } + +/** Set this player never to produce any video data */ +void +Player::set_ignore_video () +{ + _ignore_video = true; +} diff --git a/src/lib/player.h b/src/lib/player.h index b283481e2..01439a26f 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -93,6 +93,7 @@ public: void set_video_container_size (dcp::Size); void set_approximate_size (); + void set_ignore_video (); PlayerStatistics const & statistics () const; @@ -157,6 +158,8 @@ private: boost::shared_ptr _black_image; bool _approximate_size; + /** true if the player should ignore all video; i.e. never produce any */ + bool _ignore_video; PlayerStatistics _statistics; diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index cac5f2795..b7cf1641b 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -42,6 +42,7 @@ VideoDecoder::VideoDecoder (shared_ptr c) : _video_content (c) #endif , _last_seek_accurate (true) + , _ignore_video (false) { _black_image.reset (new Image (PIX_FMT_RGB24, _video_content->video_size(), true)); _black_image->make_black (); @@ -233,6 +234,10 @@ VideoDecoder::fill_3d (VideoFrame from, VideoFrame to, Eyes eye) void VideoDecoder::video (shared_ptr image, VideoFrame frame) { + if (_ignore_video) { + return; + } + /* We may receive the same frame index twice for 3D, and we need to know when that happens. */ @@ -315,3 +320,10 @@ VideoDecoder::seek (ContentTime s, bool accurate) _last_seek_time = s; _last_seek_accurate = accurate; } + +/** Set this player never to produce any video data */ +void +VideoDecoder::set_ignore_video () +{ + _ignore_video = true; +} diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index 4948cd8a0..5381fb21e 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -49,6 +49,8 @@ public: return _video_content; } + void set_ignore_video (); + #ifdef DCPOMATIC_DEBUG int test_gaps; #endif @@ -68,6 +70,9 @@ protected: boost::shared_ptr _black_image; boost::optional _last_seek_time; bool _last_seek_accurate; + + /** true if this decoder should ignore all video; i.e. never produce any */ + bool _ignore_video; }; #endif -- 2.30.2