Updated cs_CZ translation from Tomáš Begeni.
[dcpomatic.git] / src / lib / dcp_decoder.cc
index e72573ebc085352aa751cd82c4cdc39268f251cf..165b5bfb55a2b3ee70521f55fd3a15815722cc65 100644 (file)
@@ -23,6 +23,7 @@
 #include "audio_content.h"
 #include "audio_decoder.h"
 #include "config.h"
+#include "constants.h"
 #include "dcp_content.h"
 #include "dcp_decoder.h"
 #include "digester.h"
@@ -104,7 +105,6 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
        if (old && old->lazy_digest() == _lazy_digest) {
                _reels = old->_reels;
        } else {
-
                auto cpl_list = dcp::find_and_resolve_cpls(content->directories(), tolerant);
 
                if (cpl_list.empty()) {
@@ -136,6 +136,9 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
 
        _reel = _reels.begin ();
        get_readers ();
+
+       _font_id_allocator.add_fonts_from_reels(_reels);
+       _font_id_allocator.allocate();
 }
 
 
@@ -310,7 +313,11 @@ DCPDecoder::pass_texts (
                                }
 
                                dcp::SubtitleString is_copy = *is;
-                               is_copy.set_font(id_for_font_in_reel(is_copy.font().get_value_or(""), _reel - _reels.begin()));
+                               if (is_copy.font()) {
+                                       is_copy.set_font(_font_id_allocator.font_id(_reel - _reels.begin(), asset->id(), is_copy.font().get()));
+                               } else {
+                                       is_copy.set_font(_font_id_allocator.default_font_id());
+                               }
                                strings.push_back(is_copy);
                        }
 
@@ -368,8 +375,7 @@ DCPDecoder::get_readers ()
                return;
        }
 
-       DCPOMATIC_ASSERT(video);
-       if (!video->ignore() && (*_reel)->main_picture()) {
+       if (video && !video->ignore() && (*_reel)->main_picture()) {
                auto asset = (*_reel)->main_picture()->asset ();
                auto mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset);
                auto stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (asset);
@@ -388,8 +394,7 @@ DCPDecoder::get_readers ()
                _stereo_reader.reset ();
        }
 
-       DCPOMATIC_ASSERT(audio);
-       if (!audio->ignore() && (*_reel)->main_sound()) {
+       if (audio && !audio->ignore() && (*_reel)->main_sound()) {
                _sound_reader = (*_reel)->main_sound()->asset()->start_read ();
                _sound_reader->set_check_hmac (false);
        } else {
@@ -445,10 +450,12 @@ DCPDecoder::seek (ContentTime t, bool accurate)
 
        /* Pass texts in the pre-roll */
 
-       auto const vfr = _dcp_content->active_video_frame_rate (film());
-       for (int i = 0; i < pre_roll_seconds * vfr; ++i) {
-               pass_texts (pre, (*_reel)->main_picture()->asset()->size());
-               pre += ContentTime::from_frames (1, vfr);
+       if (_reel != _reels.end()) {
+               auto const vfr = _dcp_content->active_video_frame_rate (film());
+               for (int i = 0; i < pre_roll_seconds * vfr; ++i) {
+                       pass_texts (pre, (*_reel)->main_picture()->asset()->size());
+                       pre += ContentTime::from_frames (1, vfr);
+               }
        }
 
        /* Seek to correct position */