X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcp_examiner.cc;h=af9e38873f83688c989e55ab226f4ad9cb326e99;hb=a3ef6c08705798ac1cd8b62b77697c35c3506567;hp=8fa41a8a59d536dfe899d9cf0bd54a75a8dfebaa;hpb=8b9888ed8247109dc3c09492302e865fa4731460;p=dcpomatic.git diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 8fa41a8a5..af9e38873 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -65,19 +65,15 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) { shared_ptr cpl; - for (int i = 0; i < static_cast(TextType::COUNT); ++i) { - _text_count[i] = 0; - } - auto cpls = dcp::find_and_resolve_cpls (content->directories(), tolerant); if (content->cpl ()) { - /* Use the CPL that the content was using before */ - for (auto i: cpls) { - if (i->id() == content->cpl().get()) { - cpl = i; - } + /* Use the CPL that was specified, or that the content was using before */ + auto iter = std::find_if(cpls.begin(), cpls.end(), [content](shared_ptr cpl) { return cpl->id() == content->cpl().get(); }); + if (iter == cpls.end()) { + throw CPLNotFoundError(content->cpl().get()); } + cpl = *iter; } else { /* Choose the CPL with the fewest unsatisfied references */ @@ -204,7 +200,7 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) LOG_GENERAL ("Main subtitle %1 of reel %2 found", i->main_subtitle()->id(), i->id()); - _text_count[static_cast(TextType::OPEN_SUBTITLE)] = 1; + _text_count[TextType::OPEN_SUBTITLE] = 1; _open_subtitle_language = try_to_parse_language (i->main_subtitle()->language()); for (auto const& font: i->main_subtitle()->asset()->font_data()) { @@ -222,7 +218,7 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) LOG_GENERAL ("Closed caption %1 of reel %2 found", j->id(), i->id()); - _text_count[static_cast(TextType::CLOSED_CAPTION)]++; + _text_count[TextType::CLOSED_CAPTION]++; _dcp_text_tracks.push_back (DCPTextTrack(j->annotation_text().get_value_or(""), try_to_parse_language(j->language()))); } @@ -252,6 +248,10 @@ DCPExaminer::DCPExaminer (shared_ptr content, bool tolerant) _reel_lengths.push_back (i->atmos()->actual_duration()); } + if (reel_fonts.empty()) { + reel_fonts.push_back(make_shared("")); + } + _fonts.push_back(reel_fonts); }