diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-02-23 00:57:04 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-02-23 00:57:04 +0000 |
| commit | c8d104aa221bdccb0a11524c038b5f4c7c070554 (patch) | |
| tree | 9b4a62e03df9dc8ccf0ac381d6b8eb141e8d63c3 /src | |
| parent | 5a03c6b8e5d088126378b2dd3aef93fbc0216d06 (diff) | |
Fix implementation of delay in 7758260; it needs to apply to
anything passed to emit_video(), not just things that come from
decoders.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/delay.cc | 41 | ||||
| -rw-r--r-- | src/lib/delay.h | 43 | ||||
| -rw-r--r-- | src/lib/player.cc | 37 | ||||
| -rw-r--r-- | src/lib/player.h | 4 | ||||
| -rw-r--r-- | src/lib/shuffler.cc | 10 | ||||
| -rw-r--r-- | src/lib/shuffler.h | 10 | ||||
| -rw-r--r-- | src/lib/video_adjuster.cc | 37 | ||||
| -rw-r--r-- | src/lib/video_adjuster.h | 48 | ||||
| -rw-r--r-- | src/lib/wscript | 2 |
9 files changed, 40 insertions, 192 deletions
diff --git a/src/lib/delay.cc b/src/lib/delay.cc deleted file mode 100644 index 6f98b3ba0..000000000 --- a/src/lib/delay.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "delay.h" -#include "content_video.h" -#include "dcpomatic_assert.h" -#include <boost/foreach.hpp> -#include <iostream> - -using std::make_pair; -using boost::weak_ptr; -using boost::shared_ptr; -using boost::optional; - -void -Delay::video (weak_ptr<Piece> weak_piece, ContentVideo video) -{ - _store.push_back (make_pair (weak_piece, video)); - /* Delay by 2 frames */ - while (_store.size() > 2) { - Video (_store.front().first, _store.front().second); - _store.pop_front (); - } -} diff --git a/src/lib/delay.h b/src/lib/delay.h deleted file mode 100644 index fa08b0558..000000000 --- a/src/lib/delay.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifndef DCPOMATIC_DELAY_H -#define DCPOMATIC_DELAY_H - -#include "types.h" -#include "video_adjuster.h" -#include "content_video.h" -#include <boost/signals2.hpp> - -class Piece; - -/** A class which `delays' received video by 2 frames; i.e. when it receives - * a video frame it emits the last-but-one it received. - */ -class Delay : public VideoAdjuster -{ -public: - void video (boost::weak_ptr<Piece>, ContentVideo video); - -private: - boost::optional<ContentVideo> _last; -}; - -#endif diff --git a/src/lib/player.cc b/src/lib/player.cc index a8a72a229..87a294042 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -49,7 +49,6 @@ #include "image_decoder.h" #include "compose.hpp" #include "shuffler.h" -#include "delay.h" #include <dcp/reel.h> #include <dcp/reel_sound_asset.h> #include <dcp/reel_subtitle_asset.h> @@ -90,7 +89,6 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist , _play_referenced (false) , _audio_merger (_film->audio_frame_rate()) , _shuffler (0) - , _delay (0) { _film_changed_connection = _film->Changed.connect (bind (&Player::film_changed, this, _1)); _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this)); @@ -105,7 +103,6 @@ Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist Player::~Player () { delete _shuffler; - delete _delay; } void @@ -117,10 +114,6 @@ Player::setup_pieces () _shuffler = new Shuffler(); _shuffler->Video.connect(bind(&Player::video, this, _1, _2)); - delete _delay; - _delay = new Delay(); - _delay->Video.connect(bind(&Player::video, this, _1, _2)); - BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) { if (!i->paths_valid ()) { @@ -159,10 +152,7 @@ Player::setup_pieces () /* We need a Shuffler to cope with 3D L/R video data arriving out of sequence */ decoder->video->Data.connect (bind (&Shuffler::video, _shuffler, weak_ptr<Piece>(piece), _1)); } else { - /* We need a Delay to give a little wiggle room to ensure that relevent subtitles arrive at the - player before the video that requires them. - */ - decoder->video->Data.connect (bind (&Delay::video, _delay, weak_ptr<Piece>(piece), _1)); + decoder->video->Data.connect (bind (&Player::video, this, weak_ptr<Piece>(piece), _1)); } } @@ -660,8 +650,11 @@ Player::pass () if (done) { _shuffler->flush (); - _delay->flush (); + for (list<pair<shared_ptr<PlayerVideo>, DCPTime> >::const_iterator i = _delay.begin(); i != _delay.end(); ++i) { + do_emit_video(i->first, i->second); + } } + return done; } @@ -943,9 +936,7 @@ Player::seek (DCPTime time, bool accurate) _shuffler->clear (); } - if (_delay) { - _delay->clear (); - } + _delay.clear (); if (_audio_processor) { _audio_processor->flush (); @@ -988,6 +979,22 @@ Player::seek (DCPTime time, bool accurate) void Player::emit_video (shared_ptr<PlayerVideo> pv, DCPTime time) { + /* We need a delay to give a little wiggle room to ensure that relevent subtitles arrive at the + player before the video that requires them. + */ + _delay.push_back (make_pair (pv, time)); + if (_delay.size() < 2) { + return; + } + + pair<shared_ptr<PlayerVideo>, DCPTime> to_do = _delay.front(); + _delay.pop_front(); + do_emit_video (to_do.first, to_do.second); +} + +void +Player::do_emit_video (shared_ptr<PlayerVideo> pv, DCPTime time) +{ optional<PositionImage> subtitles = subtitles_for_frame (time); if (subtitles) { pv->set_subtitle (subtitles.get ()); diff --git a/src/lib/player.h b/src/lib/player.h index 58ed4e369..8142f8e7f 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -33,7 +33,6 @@ #include "audio_stream.h" #include "audio_merger.h" #include "empty.h" -#include "delay.h" #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <list> @@ -121,6 +120,7 @@ private: ) const; boost::optional<PositionImage> subtitles_for_frame (DCPTime time) const; void emit_video (boost::shared_ptr<PlayerVideo> pv, DCPTime time); + void do_emit_video (boost::shared_ptr<PlayerVideo> pv, DCPTime time); void emit_audio (boost::shared_ptr<AudioBuffers> data, DCPTime time); boost::shared_ptr<const Film> _film; @@ -160,7 +160,7 @@ private: AudioMerger _audio_merger; Shuffler* _shuffler; - Delay* _delay; + std::list<std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> > _delay; class StreamState { diff --git a/src/lib/shuffler.cc b/src/lib/shuffler.cc index 4b8474ab3..0ec4daf5a 100644 --- a/src/lib/shuffler.cc +++ b/src/lib/shuffler.cc @@ -78,6 +78,14 @@ Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) void Shuffler::clear () { - VideoAdjuster::clear (); + _store.clear (); _last = optional<ContentVideo>(); } + +void +Shuffler::flush () +{ + BOOST_FOREACH (Store i, _store) { + Video (i.first, i.second); + } +} diff --git a/src/lib/shuffler.h b/src/lib/shuffler.h index 2c1d0677f..3eed3e4f0 100644 --- a/src/lib/shuffler.h +++ b/src/lib/shuffler.h @@ -20,18 +20,22 @@ #include "types.h" #include "content_video.h" -#include "video_adjuster.h" #include <boost/signals2.hpp> class Piece; -class Shuffler : public VideoAdjuster +class Shuffler { public: void clear (); - + void flush (); void video (boost::weak_ptr<Piece>, ContentVideo video); + boost::signals2::signal<void (boost::weak_ptr<Piece>, ContentVideo)> Video; + + typedef std::pair<boost::weak_ptr<Piece>, ContentVideo> Store; + private: + std::list<Store> _store; boost::optional<ContentVideo> _last; }; diff --git a/src/lib/video_adjuster.cc b/src/lib/video_adjuster.cc deleted file mode 100644 index c945c6668..000000000 --- a/src/lib/video_adjuster.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "video_adjuster.h" -#include "content_video.h" -#include <boost/foreach.hpp> - -void -VideoAdjuster::flush () -{ - BOOST_FOREACH (Store i, _store) { - Video (i.first, i.second); - } -} - -void -VideoAdjuster::clear () -{ - _store.clear (); -} diff --git a/src/lib/video_adjuster.h b/src/lib/video_adjuster.h deleted file mode 100644 index 6fde2baad..000000000 --- a/src/lib/video_adjuster.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifndef DCPOMATIC_VIDEO_ADJUSTER_H -#define DCPOMATIC_VIDEO_ADJUSTER_H - -#include <boost/signals2.hpp> - -class Piece; -class ContentVideo; - -/** Parent class for short delays of video content done by the Player - * to work around various problems. - */ -class VideoAdjuster -{ -public: - virtual ~VideoAdjuster() {} - - virtual void clear (); - void flush (); - - boost::signals2::signal<void (boost::weak_ptr<Piece>, ContentVideo)> Video; - - typedef std::pair<boost::weak_ptr<Piece>, ContentVideo> Store; - -protected: - std::list<Store> _store; -}; - -#endif diff --git a/src/lib/wscript b/src/lib/wscript index 46ced80ab..ae8ab30cb 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -63,7 +63,6 @@ sources = """ decoder.cc decoder_factory.cc decoder_part.cc - delay.cc digester.cc dkdm_wrapper.cc dolby_cp750.cc @@ -147,7 +146,6 @@ sources = """ upmixer_a.cc upmixer_b.cc util.cc - video_adjuster.cc video_content.cc video_content_scale.cc video_decoder.cc |
