From fd198a9cb1f033773102f54603bd06b98f3c7fb1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 19 May 2024 23:27:34 +0200 Subject: Add and use Content::has_mapped_audio(). --- src/lib/content.cc | 8 ++++++++ src/lib/content.h | 2 ++ src/lib/dcp_content.cc | 2 +- src/lib/dcp_decoder.cc | 2 +- src/lib/ffmpeg_decoder.cc | 2 +- src/lib/hints.cc | 2 +- src/lib/player.cc | 2 +- 7 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/content.cc b/src/lib/content.cc index 6324050ec..f13201b93 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -570,3 +570,11 @@ Content::changed () const return (write_time_changed || calculate_digest() != digest()); } + + +bool +Content::has_mapped_audio() const +{ + return audio && !audio->mapping().mapped_output_channels().empty(); +} + diff --git a/src/lib/content.h b/src/lib/content.h index f2fecddf0..540abdd8a 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -203,6 +203,8 @@ public: return true; } + bool has_mapped_audio() const; + /* ChangeType::PENDING and ChangeType::CANCELLED may be emitted from any thread; ChangeType::DONE always from GUI thread */ boost::signals2::signal, int, bool)> Change; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index bdd5e0e09..6e573c639 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -731,7 +731,7 @@ DCPContent::can_reference_audio (shared_ptr film, string& why_not) c /// TRANSLATORS: this string will follow "Cannot reference this DCP: " return can_reference( film, [](shared_ptr c) { - return static_cast(c->audio) && !c->audio->mapping().mapped_output_channels().empty(); + return c->has_mapped_audio(); }, _("it overlaps other audio content; remove the other content."), why_not diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 17f0e73b5..727dcbf26 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -77,7 +77,7 @@ DCPDecoder::DCPDecoder (shared_ptr film, shared_ptrvideo) { video = make_shared(this, content); } - if (content->audio && !content->audio->mapping().mapped_output_channels().empty()) { + if (content->has_mapped_audio()) { audio = make_shared(this, content->audio, fast); } for (auto i: content->text) { diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index e0d9918b2..019e4f95c 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -89,7 +89,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr film, shared_ptraudio && !c->audio->mapping().mapped_output_channels().empty()) { + if (c->has_mapped_audio()) { audio = make_shared(this, c->audio, fast); } diff --git a/src/lib/hints.cc b/src/lib/hints.cc index bbd5ae5d5..2e2a8fd7b 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -698,7 +698,7 @@ Hints::check_audio_language () auto content = film()->content(); auto mapped_audio = std::find_if(content.begin(), content.end(), [](shared_ptr c) { - return c->audio && !c->audio->mapping().mapped_output_channels().empty(); + return c->has_mapped_audio(); }); if (mapped_audio != content.end() && !film()->audio_language()) { diff --git a/src/lib/player.cc b/src/lib/player.cc index 27c89a2fa..47067af5a 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -251,7 +251,7 @@ have_video (shared_ptr content) bool have_audio (shared_ptr content) { - return static_cast(content->audio) && !content->audio->mapping().mapped_output_channels().empty() && content->can_be_played(); + return content->has_mapped_audio() && content->can_be_played(); } -- cgit v1.2.3 From 0bc6d354b100c44834302c6ac5d0b5099e0f0564 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 19 May 2024 23:46:55 +0200 Subject: Don't make _stream_states for unmapped audio, otherwise we wait for content which will never arrive. --- src/lib/player.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/player.cc b/src/lib/player.cc index 47067af5a..75f6b7919 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -369,7 +369,7 @@ Player::setup_pieces () _stream_states.clear (); for (auto i: _pieces) { - if (i->content->audio) { + if (i->content->has_mapped_audio()) { for (auto j: i->content->audio->streams()) { _stream_states[j] = StreamState(i); } -- cgit v1.2.3 From eeef6e5e41163257145e5e6d4418c28b6970bae2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 May 2024 15:21:51 +0200 Subject: Fix stream length for DCP content (#2688). --- src/lib/dcp_examiner.cc | 3 ++- test/audio_content_test.cc | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 88c9a5b70..ae5f9e9c0 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -167,7 +167,7 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) if (reel->main_sound()) { _has_audio = true; - _audio_length += reel->main_sound()->actual_duration(); + auto const edit_rate = reel->main_sound()->edit_rate(); if (!reel->main_sound()->asset_ref().resolved()) { LOG_GENERAL("Main sound %1 of reel %2 is missing", reel->main_sound()->id(), reel->id()); @@ -192,6 +192,7 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) } _audio_language = try_to_parse_language (asset->language()); + _audio_length += reel->main_sound()->actual_duration() * (asset->sampling_rate() * edit_rate.denominator / edit_rate.numerator); } } diff --git a/test/audio_content_test.cc b/test/audio_content_test.cc index f2c095fab..97f55d53a 100644 --- a/test/audio_content_test.cc +++ b/test/audio_content_test.cc @@ -20,10 +20,14 @@ #include "lib/audio_content.h" +#include "lib/dcp_content.h" #include "lib/content_factory.h" +#include "lib/film.h" #include "lib/maths_util.h" #include "lib/video_content.h" #include "test.h" +#include +#include #include @@ -259,3 +263,27 @@ BOOST_AUTO_TEST_CASE (audio_content_fades_same_as_video) BOOST_CHECK(content->audio->fade_out() == dcpomatic::ContentTime::from_frames(81 * 48000 / 24, 48000)); } + + +BOOST_AUTO_TEST_CASE(fade_out_works_with_dcp_content) +{ + auto dcp = std::make_shared(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV"); + auto film = new_test_film2("fade_out_works_with_dcp_content", { dcp }); + dcp->audio->set_fade_out(dcpomatic::ContentTime::from_seconds(15)); + make_and_verify_dcp(film); + + int32_t max = 0; + dcp::SoundAsset sound(find_file(film->dir(film->dcp_name()), "pcm_")); + auto reader = sound.start_read(); + for (auto i = 0; i < sound.intrinsic_duration(); ++i) { + auto frame = reader->get_frame(i); + for (auto j = 0; j < frame->channels(); ++j) { + for (auto k = 0; k < frame->samples(); ++k) { + max = std::max(max, frame->get(j, k)); + } + } + } + + BOOST_CHECK(max > 2000); +} + -- cgit v1.2.3 From ad5cc13514cb02b523fe1b553fc727e570dac6de Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 May 2024 20:47:56 +0100 Subject: Fix build with newer libsub. --- src/lib/ffmpeg_decoder.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 019e4f95c..45983795b 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -831,13 +831,8 @@ FFmpegDecoder::process_ass_subtitle (string ass, ContentTime from) auto video_size = _ffmpeg_content->video->size(); DCPOMATIC_ASSERT(video_size); - auto raw = sub::SSAReader::parse_line ( - base, - text, - video_size->width, - video_size->height, - sub::Colour(1, 1, 1) - ); + sub::SSAReader::Context context(video_size->width, video_size->height, sub::Colour(1, 1, 1)); + auto const raw = sub::SSAReader::parse_line(base, text, context); for (auto const& i: sub::collect>(raw)) { only_text()->emit_plain_start (from, i); -- cgit v1.2.3