Use EnumIndexedVector in DCPExaminer.
authorCarl Hetherington <cth@carlh.net>
Mon, 26 Sep 2022 22:35:42 +0000 (00:35 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 27 Sep 2022 11:46:16 +0000 (13:46 +0200)
src/lib/dcp_examiner.cc
src/lib/dcp_examiner.h

index 0cfe499a3234b982063e7617c4fe98405140c6d0..af9e38873f83688c989e55ab226f4ad9cb326e99 100644 (file)
@@ -65,10 +65,6 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
 {
        shared_ptr<dcp::CPL> cpl;
 
-       for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
-               _text_count[i] = 0;
-       }
-
        auto cpls = dcp::find_and_resolve_cpls (content->directories(), tolerant);
 
        if (content->cpl ()) {
@@ -204,7 +200,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
 
                        LOG_GENERAL ("Main subtitle %1 of reel %2 found", i->main_subtitle()->id(), i->id());
 
-                       _text_count[static_cast<int>(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<const DCPContent> content, bool tolerant)
 
                        LOG_GENERAL ("Closed caption %1 of reel %2 found", j->id(), i->id());
 
-                       _text_count[static_cast<int>(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())));
                }
 
index 6b88a3c0d412d13d2cf636b7ac49854a28dca682..75ea8b68c664176d8aa6072063c272fee74e1da7 100644 (file)
@@ -106,7 +106,7 @@ public:
         *  @return Number of assets of this type in this DCP.
         */
        int text_count (TextType type) const {
-               return _text_count[static_cast<int>(type)];
+               return _text_count[type];
        }
 
        boost::optional<dcp::LanguageTag> open_subtitle_language () const {
@@ -186,7 +186,7 @@ private:
        bool _has_audio = false;
        boost::optional<dcp::LanguageTag> _audio_language;
        /** number of different assets of each type (OCAP/CCAP) */
-       int _text_count[static_cast<int>(TextType::COUNT)];
+       EnumIndexedVector<int, TextType> _text_count;
        boost::optional<dcp::LanguageTag> _open_subtitle_language;
        /** the DCPTextTracks for each of our CCAPs */
        std::vector<DCPTextTrack> _dcp_text_tracks;