--- /dev/null
+/*
+ Copyright (C) 2013-2021 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 "content.h"
+#include "dcpomatic_time.h"
+#include "video_content.h"
+#include <iostream>
+#include <string>
+
+
+class BlackContent : public Content
+{
+public:
+ BlackContent (dcpomatic::DCPTimePeriod period, Eyes eyes)
+ : Content(period.from)
+ , _length(period.duration())
+ {
+ video = std::make_shared<VideoContent>(this);
+ if (eyes == Eyes::BOTH) {
+ video->set_frame_type(VideoFrameType::TWO_D);
+ } else if (eyes == Eyes::LEFT) {
+ video->set_frame_type(VideoFrameType::THREE_D_LEFT);
+ } else if (eyes == Eyes::RIGHT) {
+ video->set_frame_type(VideoFrameType::THREE_D_RIGHT);
+ }
+ }
+
+ std::string summary () const override {
+ return "black";
+ }
+
+ dcpomatic::DCPTime full_length (std::shared_ptr<const Film>) const override {
+ return _length;
+ }
+
+ dcpomatic::DCPTime approximate_length () const override {
+ return _length;
+ }
+
+private:
+ dcpomatic::DCPTime _length;
+};
+
#include "audio_content.h"
#include "audio_decoder.h"
#include "audio_processor.h"
+#include "black_content.h"
+#include "black_decoder.h"
#include "compose.hpp"
#include "config.h"
#include "content_audio.h"
}
+void
+Player::add_black_pieces ()
+{
+ list<DCPTimePeriod> full_left;
+ list<DCPTimePeriod> full_right;
+ list<DCPTimePeriod> full_both;
+ for (auto i: playlist()->content()) {
+ if (i->video && i->video->use() && i->can_be_played() && i->paths_valid()) {
+ auto period = DCPTimePeriod(i->position(), i->end(_film));
+ if (i->video->frame_type() == VideoFrameType::THREE_D_LEFT) {
+ full_left.push_back (period);
+ } else if (i->video->frame_type() == VideoFrameType::THREE_D_RIGHT) {
+ full_right.push_back (period);
+ } else {
+ full_both.push_back (period);
+ }
+ }
+ }
+
+ auto const whole = DCPTimePeriod(DCPTime(), _playback_length);
+
+ auto empty_both = subtract(subtract(subtract({whole}, full_left), full_right), full_both);
+ auto empty_left = subtract(subtract(subtract({whole}, full_left), full_both), empty_both);
+ auto empty_right = subtract(subtract(subtract({whole}, full_right), full_both), empty_both);
+
+ list<pair<DCPTimePeriod, Eyes>> periods;
+
+ for (auto left: empty_left) {
+ periods.push_back (make_pair(left, Eyes::LEFT));
+ }
+
+ for (auto right: empty_right) {
+ periods.push_back (make_pair(right, Eyes::RIGHT));
+ }
+
+ for (auto both: empty_both) {
+ periods.push_back (make_pair(both, Eyes::BOTH));
+ }
+
+ periods.sort([](std::pair<DCPTimePeriod, Eyes> const& a, std::pair<DCPTimePeriod, Eyes> const& b) {
+ return a.first < b.first;
+ });
+
+ for (auto period: periods) {
+ LOG_DEBUG_PLAYER("BlackContent in period %1", to_string(period.first));
+ auto content = make_shared<BlackContent>(period.first, period.second);
+ auto decoder = make_shared<BlackDecoder>(_film, content);
+ _pieces.push_back(make_shared<Piece>(content, decoder, FrameRateChange(_film->video_frame_rate(), _film->video_frame_rate())));
+ }
+}
+
+
void
Player::setup_pieces_unlocked ()
{
auto piece = make_shared<Piece>(i, decoder, frc);
_pieces.push_back (piece);
+ }
+
+
+ add_black_pieces ();
- if (decoder->video) {
+ for (auto piece: _pieces) {
+ if (piece->decoder->video) {
if (have_threed) {
/* We need a Shuffler to cope with 3D L/R video data arriving out of sequence */
- decoder->video->Data.connect (bind(&Shuffler::video, &_shuffler.get(), weak_ptr<Piece>(piece), _1));
+ piece->decoder->video->Data.connect(bind(&Shuffler::video, &_shuffler.get(), weak_ptr<Piece>(piece), _1));
} else {
- decoder->video->Data.connect (bind(&Player::video, this, weak_ptr<Piece>(piece), _1));
+ piece->decoder->video->Data.connect(bind(&Player::video, this, weak_ptr<Piece>(piece), _1));
}
}
- if (decoder->audio) {
- decoder->audio->Data.connect (bind (&Player::audio, this, weak_ptr<Piece> (piece), _1, _2));
+ if (piece->decoder->audio) {
+ piece->decoder->audio->Data.connect(bind(&Player::audio, this, weak_ptr<Piece>(piece), _1, _2));
}
- auto j = decoder->text.begin();
-
- while (j != decoder->text.end()) {
- (*j)->BitmapStart.connect (
- bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
+ for (auto j: piece->decoder->text) {
+ j->BitmapStart.connect (
+ bind(&Player::bitmap_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>(j->content()), _1)
);
- (*j)->PlainStart.connect (
- bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
+ j->PlainStart.connect (
+ bind(&Player::plain_text_start, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>(j->content()), _1)
);
- (*j)->Stop.connect (
- bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>((*j)->content()), _1)
+ j->Stop.connect (
+ bind(&Player::subtitle_stop, this, weak_ptr<Piece>(piece), weak_ptr<const TextContent>(j->content()), _1)
);
-
- ++j;
}
- if (decoder->atmos) {
- decoder->atmos->Data.connect (bind(&Player::atmos, this, weak_ptr<Piece>(piece), _1));
+ if (piece->decoder->atmos) {
+ piece->decoder->atmos->Data.connect(bind(&Player::atmos, this, weak_ptr<Piece>(piece), _1));
}
}
}
}
- _black = EmptyVideo (_film, playlist(), _playback_length);
_silent = EmptyAudio (_film, playlist(), _playback_length);
_next_video_time = boost::none;
enum {
NONE,
CONTENT,
- BLACK,
SILENT
} which = NONE;
which = CONTENT;
}
- if (!_black.done() && !_ignore_video && (!earliest_time || _black.position() < *earliest_time)) {
- earliest_time = _black.position ();
- which = BLACK;
- }
-
if (!_silent.done() && !_ignore_audio && (!earliest_time || _silent.position() < *earliest_time)) {
earliest_time = _silent.position ();
which = SILENT;
switch (which) {
case CONTENT:
{
- LOG_DEBUG_PLAYER ("Calling pass() on %1", earliest_content->content->path(0));
+ if (earliest_content->content->number_of_paths()) {
+ LOG_DEBUG_PLAYER ("Calling pass() on %1", earliest_content->content->path(0));
+ }
earliest_content->done = earliest_content->decoder->pass ();
auto dcp = dynamic_pointer_cast<DCPContent>(earliest_content->content);
if (dcp && !_play_referenced && dcp->reference_audio()) {
}
break;
}
- case BLACK:
- {
- LOG_DEBUG_PLAYER ("Emit black for gap at %1", to_string(_black.position()));
- auto period = _black.period_at_position();
- emit_video (black_player_video_frame(period.second), _black.position());
- _black.set_position (_black.position() + one_video_frame());
- break;
- }
case SILENT:
{
LOG_DEBUG_PLAYER ("Emit silence for gap at %1", to_string(_silent.position()));
_next_audio_time = boost::none;
}
- _black.set_position (time);
_silent.set_position (time);
_last_video.clear ();
#include "lib/audio_buffers.h"
+#include "lib/black_content.h"
#include "lib/butler.h"
#include "lib/compose.hpp"
#include "lib/content_factory.h"
#include "lib/ffmpeg_content.h"
#include "lib/film.h"
#include "lib/image_content.h"
+#include "lib/piece.h"
#include "lib/player.h"
#include "lib/ratio.h"
#include "lib/string_text_file_content.h"
using std::cout;
+using std::dynamic_pointer_cast;
using std::list;
using std::shared_ptr;
using std::make_shared;
BOOST_CHECK (film->length() == DCPTime::from_frames(3 * 24 + 1, 24));
auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT);
+
player->setup_pieces ();
- BOOST_REQUIRE_EQUAL (player->_black._periods.size(), 1U);
- BOOST_CHECK (player->_black._periods.front().first == DCPTimePeriod(DCPTime::from_frames(3 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24)));
+ list<std::shared_ptr<Piece>> black;
+ std::copy_if(
+ player->_pieces.begin(),
+ player->_pieces.end(),
+ std::back_inserter(black),
+ [](shared_ptr<Piece> piece) {
+ return static_cast<bool>(dynamic_pointer_cast<BlackContent>(piece->content));
+ });
+ BOOST_REQUIRE_EQUAL (black.size(), 1U);
+ BOOST_CHECK (black.front()->content->position() == DCPTime::from_frames(3 * 24, 24));
+ BOOST_CHECK (black.front()->content->full_length(film) == DCPTime::from_frames(1, 24));
+
BOOST_REQUIRE_EQUAL (player->_silent._periods.size(), 1U);
BOOST_CHECK (player->_silent._periods.front() == DCPTimePeriod(DCPTime(289920), DCPTime::from_frames(3 * 24 + 1, 24)));
}