From 2e9744b7c79a0e56193b48bd0760a7b989f06079 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 29 Mar 2019 01:19:44 +0000 Subject: [PATCH] Don't crash when loading DCPs with multiple CCAP assets per reel (part of #1516). --- src/lib/dcp_content.cc | 2 +- src/lib/dcp_examiner.cc | 8 ++++---- src/lib/dcp_examiner.h | 12 ++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 4c4486a28..ef877a17f 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -225,7 +225,7 @@ DCPContent::examine (shared_ptr film, shared_ptr job) boost::mutex::scoped_lock lm (_mutex); _name = examiner->name (); for (int i = 0; i < TEXT_COUNT; ++i) { - if (examiner->has_text(static_cast(i))) { + for (int j = 0; j < examiner->text_count(static_cast(i)); ++j) { text.push_back (shared_ptr(new TextContent(this, static_cast(i), static_cast(i)))); } } diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index dfb47f2eb..c70d8b2db 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -66,7 +66,7 @@ DCPExaminer::DCPExaminer (shared_ptr content) shared_ptr cpl; for (int i = 0; i < TEXT_COUNT; ++i) { - _has_text[i] = false; + _text_count[i] = 0; } if (content->cpl ()) { @@ -170,7 +170,7 @@ DCPExaminer::DCPExaminer (shared_ptr content) return; } - _has_text[TEXT_OPEN_SUBTITLE] = true; + _text_count[TEXT_OPEN_SUBTITLE] = 1; } BOOST_FOREACH (shared_ptr j, i->closed_captions()) { @@ -180,7 +180,7 @@ DCPExaminer::DCPExaminer (shared_ptr content) return; } - _has_text[TEXT_CLOSED_CAPTION] = true; + _text_count[TEXT_CLOSED_CAPTION]++; } if (i->main_picture()) { diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index f54f02c36..199ac3985 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -83,8 +83,11 @@ public: return _audio_frame_rate.get_value_or (48000); } - bool has_text (TextType type) const { - return _has_text[type]; + /** @param type TEXT_OPEN_SUBTITLE or TEXT_CLOSED_CAPTION. + * @return Number of assets of this type in this DCP. + */ + int text_count (TextType type) const { + return _text_count[type]; } bool kdm_valid () const { @@ -123,7 +126,8 @@ private: bool _has_video; /** true if this DCP has audio content (but false if it has unresolved references to audio content) */ bool _has_audio; - bool _has_text[TEXT_COUNT]; + /** number of different assets of each type (OCAP/CCAP) */ + int _text_count[TEXT_COUNT]; bool _encrypted; bool _needs_assets; bool _kdm_valid; -- 2.30.2