Update for libdcp API changes.
authorCarl Hetherington <cth@carlh.net>
Tue, 19 Mar 2019 21:37:19 +0000 (21:37 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 10 May 2019 22:43:42 +0000 (23:43 +0100)
src/lib/dcp_decoder.cc
src/lib/reel_writer.cc
test/vf_test.cc

index 8179ef0096b7c1e4bd8a7852af36119c3cacb28d..98238f6531e7e0c4201f37a1e1aa0ebb6251b4ae 100644 (file)
@@ -124,7 +124,7 @@ DCPDecoder::pass ()
        pass_texts (_next, picture_asset->size());
 
        if ((_mono_reader || _stereo_reader) && (_decode_referenced || !_dcp_content->reference_video())) {
-               int64_t const entry_point = (*_reel)->main_picture()->entry_point ();
+               int64_t const entry_point = (*_reel)->main_picture()->entry_point().get_value_or(0);
                if (_mono_reader) {
                        video->emit (
                                film(),
@@ -170,7 +170,7 @@ DCPDecoder::pass ()
        }
 
        if (_sound_reader && (_decode_referenced || !_dcp_content->reference_audio())) {
-               int64_t const entry_point = (*_reel)->main_sound()->entry_point ();
+               int64_t const entry_point = (*_reel)->main_sound()->entry_point().get_value_or(0);
                shared_ptr<const dcp::SoundFrame> sf = _sound_reader->get_frame (entry_point + frame);
                uint8_t const * from = sf->data ();
 
@@ -210,7 +210,7 @@ DCPDecoder::pass_texts (ContentTime next, dcp::Size size)
                        next,
                        (*_reel)->main_subtitle()->asset(),
                        _dcp_content->reference_text(TEXT_OPEN_SUBTITLE),
-                       (*_reel)->main_subtitle()->entry_point(),
+                       (*_reel)->main_subtitle()->entry_point().get_value_or(0),
                        *decoder,
                        size
                        );
@@ -219,7 +219,7 @@ DCPDecoder::pass_texts (ContentTime next, dcp::Size size)
        BOOST_FOREACH (shared_ptr<dcp::ReelClosedCaptionAsset> i, (*_reel)->closed_captions()) {
                DCPOMATIC_ASSERT (decoder != text.end ());
                pass_texts (
-                       next, i->asset(), _dcp_content->reference_text(TEXT_CLOSED_CAPTION), i->entry_point(), *decoder, size
+                       next, i->asset(), _dcp_content->reference_text(TEXT_CLOSED_CAPTION), i->entry_point().get_value_or(0), *decoder, size
                        );
                ++decoder;
        }
@@ -296,7 +296,7 @@ DCPDecoder::pass_texts (
 void
 DCPDecoder::next_reel ()
 {
-       _offset += (*_reel)->main_picture()->duration();
+       _offset += (*_reel)->main_picture()->actual_duration();
        ++_reel;
        get_readers ();
 }
@@ -359,8 +359,12 @@ DCPDecoder::seek (ContentTime t, bool accurate)
 
        /* Seek to pre-roll position */
 
-       while (_reel != _reels.end() && pre >= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film()))) {
-               ContentTime rd = ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film()));
+       while (
+               _reel != _reels.end() &&
+               pre >= ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film()))
+               ) {
+
+               ContentTime rd = ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film()));
                pre -= rd;
                t -= rd;
                next_reel ();
@@ -376,8 +380,12 @@ DCPDecoder::seek (ContentTime t, bool accurate)
 
        /* Seek to correct position */
 
-       while (_reel != _reels.end() && t >= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film()))) {
-               t -= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film()));
+       while (
+               _reel != _reels.end() &&
+               t >= ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film()))
+               ) {
+
+               t -= ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film()));
                next_reel ();
        }
 
index 9be4ce57155d23fd2bbc318b58a80e156e8e9170..f5fe872487601f0b0f48d2ad043fdd5a9beb0a4d 100644 (file)
@@ -408,10 +408,10 @@ maybe_add_text (
        }
 
        if (reel_asset) {
-               if (reel_asset->duration() != period_duration) {
+               if (reel_asset->actual_duration() != period_duration) {
                        throw ProgrammingError (
                                __FILE__, __LINE__,
-                               String::compose ("%1 vs %2", reel_asset->duration(), period_duration)
+                               String::compose ("%1 vs %2", reel_asset->actual_duration(), period_duration)
                                );
                }
                reel->add (reel_asset);
@@ -460,7 +460,7 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
        if (reel_picture_asset->duration() != period_duration) {
                throw ProgrammingError (
                        __FILE__, __LINE__,
-                       String::compose ("%1 vs %2", reel_picture_asset->duration(), period_duration)
+                       String::compose ("%1 vs %2", reel_picture_asset->actual_duration(), period_duration)
                        );
        }
        reel->add (reel_picture_asset);
@@ -490,26 +490,26 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
        }
 
        DCPOMATIC_ASSERT (reel_sound_asset);
-       if (reel_sound_asset->duration() != period_duration) {
+       if (reel_sound_asset->actual_duration() != period_duration) {
                LOG_ERROR (
                        "Reel sound asset has length %1 but reel period is %2",
-                       reel_sound_asset->duration(),
+                       reel_sound_asset->actual_duration(),
                        period_duration
                        );
-               if (reel_sound_asset->duration() != period_duration) {
+               if (reel_sound_asset->actual_duration() != period_duration) {
                        throw ProgrammingError (
                                __FILE__, __LINE__,
-                               String::compose ("%1 vs %2", reel_sound_asset->duration(), period_duration)
+                               String::compose ("%1 vs %2", reel_sound_asset->actual_duration(), period_duration)
                                );
                }
 
        }
        reel->add (reel_sound_asset);
 
-       maybe_add_text<dcp::ReelSubtitleAsset> (_subtitle_asset, reel_picture_asset->duration(), reel, refs, fonts, _film, _period);
+       maybe_add_text<dcp::ReelSubtitleAsset> (_subtitle_asset, reel_picture_asset->actual_duration(), reel, refs, fonts, _film, _period);
        for (map<DCPTextTrack, shared_ptr<dcp::SubtitleAsset> >::const_iterator i = _closed_caption_assets.begin(); i != _closed_caption_assets.end(); ++i) {
                shared_ptr<dcp::ReelClosedCaptionAsset> a = maybe_add_text<dcp::ReelClosedCaptionAsset> (
-                       i->second, reel_picture_asset->duration(), reel, refs, fonts, _film, _period
+                       i->second, reel_picture_asset->actual_duration(), reel, refs, fonts, _film, _period
                        );
                a->set_annotation_text (i->first.name);
                a->set_language (i->first.language);
index b82c3c8897c96e5265a39d82c16c699cb17d7dde..6862a12043fa9a497f4ee79f99006a31dc8ef541 100644 (file)
@@ -188,11 +188,11 @@ BOOST_AUTO_TEST_CASE (vf_test3)
        BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1);
        BOOST_REQUIRE_EQUAL (vf_c.cpls().front()->reels().size(), 1);
        BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_picture());
-       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->entry_point(), 24);
-       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->duration(), 72);
+       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->entry_point().get_value_or(0), 24);
+       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_picture()->actual_duration(), 72);
        BOOST_REQUIRE (vf_c.cpls().front()->reels().front()->main_sound());
-       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->entry_point(), 24);
-       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->duration(), 72);
+       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->entry_point().get_value_or(0), 24);
+       BOOST_CHECK_EQUAL (vf_c.cpls().front()->reels().front()->main_sound()->actual_duration(), 72);
 }
 
 /** Make a OV with video and audio and a VF referencing the OV and adding some more video */