summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-05-29 21:12:17 +0200
committerCarl Hetherington <cth@carlh.net>2024-05-29 21:12:17 +0200
commit07aa4852acfd908c4e3a92f7bed2c7328cfcf123 (patch)
treebe9642b5202a0342be268f6e4b9f93c684bab347 /src
parentbfac1d7cfec57b225a0257d2fa0172efe7fbd08b (diff)
parent78dc1250feed93df7f519c559949d4fac4cc5b1a (diff)
Merge remote-tracking branch 'origin/main' into v2.17.x
Diffstat (limited to 'src')
-rw-r--r--src/lib/content.cc8
-rw-r--r--src/lib/content.h2
-rw-r--r--src/lib/dcp_content.cc2
-rw-r--r--src/lib/dcp_decoder.cc2
-rw-r--r--src/lib/dcp_examiner.cc3
-rw-r--r--src/lib/ffmpeg_decoder.cc11
-rw-r--r--src/lib/hints.cc2
-rw-r--r--src/lib/player.cc4
-rw-r--r--src/wx/content_timeline.cc2
-rw-r--r--src/wx/content_timeline_audio_view.cc2
10 files changed, 22 insertions, 16 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 6743705d9..496a68a63 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 3753c84d7..d4b99d39e 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<void (ChangeType, std::weak_ptr<Content>, int, bool)> Change;
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index e9afa04cc..465eff706 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -736,7 +736,7 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c
}
auto part = [](shared_ptr<const Content> c) {
- return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty();
+ return c->has_mapped_audio();
};
if (overlaps(film, part)) {
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index e9db479d1..abbaaf15d 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -81,7 +81,7 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
if (content->video) {
video = make_shared<VideoDecoder>(this, content);
}
- if (content->audio && !content->audio->mapping().mapped_output_channels().empty()) {
+ if (content->has_mapped_audio()) {
audio = make_shared<AudioDecoder>(this, content->audio, fast);
}
for (auto i: content->text) {
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc
index 229786868..ae885c140 100644
--- a/src/lib/dcp_examiner.cc
+++ b/src/lib/dcp_examiner.cc
@@ -173,7 +173,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> 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());
@@ -198,6 +198,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> 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/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index e80cb92e5..29ab5aaf8 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -89,7 +89,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp
_pts_offset = {};
}
- if (c->audio && !c->audio->mapping().mapped_output_channels().empty()) {
+ if (c->has_mapped_audio()) {
audio = make_shared<AudioDecoder>(this, c->audio, fast);
}
@@ -830,13 +830,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<vector<sub::Subtitle>>(raw)) {
only_text()->emit_plain_start (from, i);
diff --git a/src/lib/hints.cc b/src/lib/hints.cc
index f9f87221e..e7a393103 100644
--- a/src/lib/hints.cc
+++ b/src/lib/hints.cc
@@ -710,7 +710,7 @@ Hints::check_audio_language ()
auto content = film()->content();
auto mapped_audio =
std::find_if(content.begin(), content.end(), [](shared_ptr<const Content> 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 98f0b027a..ea236db39 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -249,7 +249,7 @@ have_video (shared_ptr<const Content> content)
bool
have_audio (shared_ptr<const Content> content)
{
- return static_cast<bool>(content->audio) && !content->audio->mapping().mapped_output_channels().empty() && content->can_be_played();
+ return content->has_mapped_audio() && content->can_be_played();
}
@@ -367,7 +367,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);
}
diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc
index 663f93030..7200bf076 100644
--- a/src/wx/content_timeline.cc
+++ b/src/wx/content_timeline.cc
@@ -307,7 +307,7 @@ ContentTimeline::recreate_views()
_views.push_back(make_shared<ContentTimelineVideoView>(*this, i));
}
- if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) {
+ if (i->has_mapped_audio()) {
_views.push_back(make_shared<ContentTimelineAudioView>(*this, i));
}
diff --git a/src/wx/content_timeline_audio_view.cc b/src/wx/content_timeline_audio_view.cc
index 600e39057..cff0b5ed5 100644
--- a/src/wx/content_timeline_audio_view.cc
+++ b/src/wx/content_timeline_audio_view.cc
@@ -73,7 +73,7 @@ ContentTimelineAudioView::label () const
s += wxString::Format (_(" advanced by %dms"), -ac->delay());
}
- list<int> mapped = ac->mapping().mapped_output_channels();
+ auto mapped = ac->mapping().mapped_output_channels();
if (!mapped.empty ()) {
s += wxString::FromUTF8(" → ");
for (auto i: mapped) {