Rename split-by-video content slightly; fix referencing to multi-reel DCPs.
authorCarl Hetherington <cth@carlh.net>
Mon, 12 Oct 2015 14:05:09 +0000 (15:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 12 Oct 2015 14:05:09 +0000 (15:05 +0100)
15 files changed:
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcpomatic_time.cc
src/lib/dcpomatic_time.h
src/lib/film.cc
src/lib/player.cc
src/lib/player.h
src/lib/transcoder.cc
src/lib/types.h
src/lib/video_content.cc
src/lib/video_content.h
src/lib/writer.cc
src/lib/writer.h
src/wx/dcp_panel.cc
test/data

index cb9dcf53d6dc184caaa47f098fb3954b2a3eec8a..f39b2fb4a221c8070199d01aa3629972fc07a352 100644 (file)
 #include "film.h"
 #include "config.h"
 #include "compose.hpp"
+#include "dcp_decoder.h"
 #include <dcp/dcp.h>
 #include <dcp/exceptions.h>
+#include <dcp/reel_picture_asset.h>
+#include <dcp/reel.h>
 #include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
 #include <iterator>
 #include <iostream>
 
@@ -245,3 +249,20 @@ DCPContent::set_reference_subtitle (bool r)
 
        signal_changed (DCPContentProperty::REFERENCE_SUBTITLE);
 }
+
+list<DCPTime>
+DCPContent::reel_split_points () const
+{
+       list<DCPTime> s;
+       DCPDecoder decoder (shared_from_this(), false);
+       DCPTime t = position();
+
+       shared_ptr<const Film> film = _film.lock ();
+       DCPOMATIC_ASSERT (film);
+       BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder.reels()) {
+               s.push_back (t);
+               t += DCPTime::from_frames (k->main_picture()->duration(), film->video_frame_rate());
+       }
+
+       return s;
+}
index 0f59bdf43e1f6aaee16d3e3835b0098e5b91f65f..be12ba5346eb7f81fa85dd75eec0df625818f8d3 100644 (file)
@@ -52,6 +52,10 @@ public:
                return boost::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
        }
 
+       boost::shared_ptr<const DCPContent> shared_from_this () const {
+               return boost::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
+       }
+
        DCPTime full_length () const;
 
        void examine (boost::shared_ptr<Job>);
@@ -61,6 +65,7 @@ public:
        std::string identifier () const;
 
        void set_default_colour_conversion ();
+       std::list<DCPTime> reel_split_points () const;
 
        /* SubtitleContent */
 
index 49309b1d27a3ca190de2b981f172fb8417f85867..1d965993598c20d6b573ca653d92692b374ff472 100644 (file)
@@ -88,3 +88,10 @@ operator<< (ostream& s, DCPTime t)
        s << "[DCP " << t.get() << " " << t.seconds() << "s]";
        return s;
 }
+
+ostream &
+operator<< (ostream& s, DCPTimePeriod p)
+{
+       s << "[DCP " << p.from.get() << " " << p.from.seconds() << "s -> " << p.to.get() << " " << p.to.seconds() << "s]";
+       return s;
+}
index beea8c8980f52664f27937067aeac3e389d904ca..496f54d8efdb7fbf57a65a0fef0fc2ddc7505a9e 100644 (file)
@@ -272,5 +272,6 @@ ContentTime min (ContentTime a, ContentTime b);
 ContentTime max (ContentTime a, ContentTime b);
 std::ostream& operator<< (std::ostream& s, ContentTime t);
 std::ostream& operator<< (std::ostream& s, DCPTime t);
+std::ostream& operator<< (std::ostream& s, DCPTimePeriod p);
 
 #endif
index 8cf46815020d82eb14e6b419ea3100d1e62e94f5..ace180d1d24bab92eef6fc568e925bed98a2e668 100644 (file)
@@ -1297,16 +1297,18 @@ Film::reels () const
        case REELTYPE_SINGLE:
                p.push_back (DCPTimePeriod (DCPTime (), len));
                break;
-       case REELTYPE_ONE_PER_VIDEO:
+       case REELTYPE_BY_VIDEO_CONTENT:
        {
                optional<DCPTime> last;
                BOOST_FOREACH (shared_ptr<Content> c, content ()) {
                        shared_ptr<VideoContent> v = dynamic_pointer_cast<VideoContent> (c);
                        if (v) {
-                               if (last) {
-                                       p.push_back (DCPTimePeriod (last.get(), v->position ()));
+                               BOOST_FOREACH (DCPTime t, v->reel_split_points()) {
+                                       if (last) {
+                                               p.push_back (DCPTimePeriod (last.get(), t));
+                                       }
+                                       last = t;
                                }
-                               last = v->position ();
                        }
                }
                if (last) {
@@ -1330,4 +1332,3 @@ Film::reels () const
 
        return p;
 }
-
index 0606a9340c9d1d6e51cd3f4e0d2ac906a090edf5..c484ecc9a2de03243ebf2bbd3e091615ee4751a0 100644 (file)
@@ -46,6 +46,7 @@
 #include "dcp_subtitle_decoder.h"
 #include "audio_processor.h"
 #include "playlist.h"
+#include "referenced_reel_asset.h"
 #include <dcp/reel.h>
 #include <dcp/reel_sound_asset.h>
 #include <dcp/reel_subtitle_asset.h>
@@ -741,26 +742,49 @@ Player::set_play_referenced ()
        _have_valid_pieces = false;
 }
 
-list<shared_ptr<dcp::ReelAsset> >
+list<ReferencedReelAsset>
 Player::get_reel_assets ()
 {
-       list<shared_ptr<dcp::ReelAsset> > a;
+       list<ReferencedReelAsset> a;
 
        BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) {
                shared_ptr<DCPContent> j = dynamic_pointer_cast<DCPContent> (i);
                if (!j) {
                        continue;
                }
-               /* XXX: hack hack hack */
                DCPDecoder decoder (j, false);
-               if (j->reference_video ()) {
-                       a.push_back (decoder.reels().front()->main_picture ());
-               }
-               if (j->reference_audio ()) {
-                       a.push_back (decoder.reels().front()->main_sound ());
-               }
-               if (j->reference_subtitle ()) {
-                       a.push_back (decoder.reels().front()->main_subtitle ());
+               int64_t offset = 0;
+               BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder.reels()) {
+                       DCPTime const from = i->position() + DCPTime::from_frames (offset, _film->video_frame_rate());
+                       if (j->reference_video ()) {
+                               a.push_back (
+                                       ReferencedReelAsset (
+                                               k->main_picture (),
+                                               DCPTimePeriod (from, from + DCPTime::from_frames (k->main_picture()->duration(), _film->video_frame_rate()))
+                                               )
+                                       );
+                       }
+
+                       if (j->reference_audio ()) {
+                               a.push_back (
+                                       ReferencedReelAsset (
+                                               k->main_sound (),
+                                               DCPTimePeriod (from, from + DCPTime::from_frames (k->main_sound()->duration(), _film->video_frame_rate()))
+                                               )
+                                       );
+                       }
+
+                       if (j->reference_subtitle ()) {
+                               a.push_back (
+                                       ReferencedReelAsset (
+                                               k->main_subtitle (),
+                                               DCPTimePeriod (from, from + DCPTime::from_frames (k->main_subtitle()->duration(), _film->video_frame_rate()))
+                                               )
+                                       );
+                       }
+
+                       /* Assume that main picture duration is the length of the reel */
+                       offset += k->main_picture()->duration ();
                }
        }
 
index 9bb84a11cac03ad86da1b41684f5e73677869bff..cd1423e9f89fd71d0a34a2cd745fcf2baab9ad2c 100644 (file)
@@ -37,6 +37,7 @@ class PlayerVideo;
 class Playlist;
 class Font;
 class AudioBuffers;
+class ReferencedReelAsset;
 
 /** @class Player
  *  @brief A class which can `play' a Playlist.
@@ -50,7 +51,7 @@ public:
        boost::shared_ptr<AudioBuffers> get_audio (DCPTime time, DCPTime length, bool accurate);
        PlayerSubtitles get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt);
        std::list<boost::shared_ptr<Font> > get_subtitle_fonts ();
-       std::list<boost::shared_ptr<dcp::ReelAsset> > get_reel_assets ();
+       std::list<ReferencedReelAsset> get_reel_assets ();
 
        void set_video_container_size (dcp::Size);
        void set_ignore_video ();
index 49742f98d551b12b6168f0d54d0b8f1c937a679b..20185e8c9073aa1081440de839124fd3f75ff320 100644 (file)
@@ -33,6 +33,7 @@
 #include "job.h"
 #include "writer.h"
 #include "compose.hpp"
+#include "referenced_reel_asset.h"
 #include "subtitle_content.h"
 #include <boost/signals2.hpp>
 #include <boost/foreach.hpp>
@@ -101,8 +102,7 @@ Transcoder::go ()
                }
        }
 
-       /* XXX: we should be passing through details of positions, at least... */
-       BOOST_FOREACH (shared_ptr<dcp::ReelAsset> i, _player->get_reel_assets ()) {
+       BOOST_FOREACH (ReferencedReelAsset i, _player->get_reel_assets ()) {
                _writer->write (i);
        }
 
index 5486f8612279c5a310be54ad2b85020f3d588008..105432f83508cd43be07cf7f430f8c66f76fbf4c 100644 (file)
@@ -87,7 +87,7 @@ enum Part
 enum ReelType
 {
        REELTYPE_SINGLE,
-       REELTYPE_ONE_PER_VIDEO,
+       REELTYPE_BY_VIDEO_CONTENT,
        REELTYPE_BY_LENGTH
 };
 
index ff54c40142b06c2fb702e6211990dc1a1d359f87..a9b28631504a98e2ec82058cf18dab65b62c7fc1 100644 (file)
@@ -579,3 +579,11 @@ VideoContent::add_properties (list<pair<string, string> >& p) const
        p.push_back (make_pair (_("Video size"), raw_convert<string> (video_size().width) + "x" + raw_convert<string> (video_size().height)));
        p.push_back (make_pair (_("Video frame rate"), raw_convert<string> (video_frame_rate()) + " " + _("frames per second")));
 }
+
+list<DCPTime>
+VideoContent::reel_split_points () const
+{
+       list<DCPTime> t;
+       t.push_back (position ());
+       return t;
+}
index f7689763ff363216486ae6d567a2174bba64614d..c0a609a6ac90ae7891ca9d1cea1d421fb7b30401 100644 (file)
@@ -55,6 +55,11 @@ public:
 
        virtual void set_default_colour_conversion ();
 
+       /** @return points at which to split this content when
+        *  REELTYPE_BY_VIDEO_CONTENT is in use.
+        */
+       virtual std::list<DCPTime> reel_split_points () const;
+
        Frame video_length () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _video_length;
index 53c4cc370564d8eb671564e4ccbd3ceeaebc4242..736dba78e0cb3841c32ad015b246da244b71eda1 100644 (file)
@@ -34,6 +34,7 @@
 #include "version.h"
 #include "font.h"
 #include "util.h"
+#include "referenced_reel_asset.h"
 #include <dcp/mono_picture_asset.h>
 #include <dcp/stereo_picture_asset.h>
 #include <dcp/sound_asset.h>
@@ -602,11 +603,10 @@ Writer::finish ()
                                reel_picture_asset.reset (new dcp::ReelStereoPictureAsset (stereo, 0));
                        }
                } else {
-                       /* We don't have a picture asset of our own; maybe we need to reference one */
-                       /* XXX: this is all a hack */
-                       BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
-                               shared_ptr<dcp::ReelPictureAsset> k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j);
-                               if (k) {
+                       /* We don't have a picture asset of our own; hopefully we have one to reference */
+                       BOOST_FOREACH (ReferencedReelAsset j, _reel_assets) {
+                               shared_ptr<dcp::ReelPictureAsset> k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j.asset);
+                               if (k && j.period == i.period) {
                                        reel_picture_asset = k;
                                }
                        }
@@ -618,11 +618,11 @@ Writer::finish ()
                        /* We have made a sound asset of our own.  Put it into the reel */
                        reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (i.sound_asset, 0)));
                } else {
-                       /* We don't have a sound asset of our own; maybe we need to reference one */
-                       /* XXX: this is all a hack */
-                       BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
-                               if (dynamic_pointer_cast<dcp::ReelSoundAsset> (j)) {
-                                       reel->add (j);
+                       /* We don't have a sound asset of our own; hopefully we have one to reference */
+                       BOOST_FOREACH (ReferencedReelAsset j, _reel_assets) {
+                               shared_ptr<dcp::ReelSoundAsset> k = dynamic_pointer_cast<dcp::ReelSoundAsset> (j.asset);
+                               if (k && j.period == i.period) {
+                                       reel->add (k);
                                }
                        }
                }
@@ -668,11 +668,11 @@ Writer::finish ()
                                                   )
                                           ));
                } else {
-                       /* We don't have a subtitle asset of our own; maybe we need to reference one */
-                       /* XXX: this is all a hack */
-                       BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
-                               if (dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j)) {
-                                       reel->add (j);
+                       /* We don't have a subtitle asset of our own; hopefully we have one to reference */
+                       BOOST_FOREACH (ReferencedReelAsset j, _reel_assets) {
+                               shared_ptr<dcp::ReelSubtitleAsset> k = dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j.asset);
+                               if (k && j.period == i.period) {
+                                       reel->add (k);
                                }
                        }
                }
@@ -911,7 +911,7 @@ Writer::read_frame_info (FILE* file, int frame, Eyes eyes) const
 }
 
 void
-Writer::write (shared_ptr<dcp::ReelAsset> asset)
+Writer::write (ReferencedReelAsset asset)
 {
        _reel_assets.push_back (asset);
 }
index 23596cefc88c5dc9cfbcb5e5bfeed69c7fe5ec7a..8f1e7127852116665e8f2e33b20b0029f3861052 100644 (file)
@@ -37,6 +37,7 @@ class Data;
 class AudioBuffers;
 class Job;
 class Font;
+class ReferencedReelAsset;
 
 namespace dcp {
        class MonoPictureAsset;
@@ -108,7 +109,7 @@ public:
        void write (boost::shared_ptr<const AudioBuffers>);
        void write (PlayerSubtitles subs);
        void write (std::list<boost::shared_ptr<Font> > fonts);
-       void write (boost::shared_ptr<dcp::ReelAsset> reel_asset);
+       void write (ReferencedReelAsset asset);
        void finish ();
 
        void set_encoder_threads (int threads);
@@ -182,7 +183,7 @@ private:
        */
        int _pushed_to_disk;
 
-       std::list<boost::shared_ptr<dcp::ReelAsset> > _reel_assets;
+       std::list<ReferencedReelAsset> _reel_assets;
 
        std::list<boost::shared_ptr<Font> > _fonts;
 
index b0cbd89416b9d22d9acc473e75b1105989f3fd53..4190526d72f86496ceaf1efe203579dfef52105e 100644 (file)
@@ -171,7 +171,7 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> film)
        }
 
        _reel_type->Append (_("Single reel"));
-       _reel_type->Append (_("One per video content"));
+       _reel_type->Append (_("Split by video content"));
        _reel_type->Append (_("Custom"));
 
        _reel_length->SetRange (1, 64);
index 4af76b996ec91ea4db61f001a6f1b676907dc3a4..ecadd276b6af06022a0cb2a35bd1330eaa025c11 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit 4af76b996ec91ea4db61f001a6f1b676907dc3a4
+Subproject commit ecadd276b6af06022a0cb2a35bd1330eaa025c11