Remove required Film from content examine.
authorCarl Hetherington <cth@carlh.net>
Fri, 23 Nov 2018 01:15:37 +0000 (01:15 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 23 Nov 2018 01:15:37 +0000 (01:15 +0000)
21 files changed:
src/lib/atmos_mxf_content.cc
src/lib/atmos_mxf_content.h
src/lib/content.h
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcp_subtitle_content.cc
src/lib/dcp_subtitle_content.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/frame_rate_change.cc
src/lib/frame_rate_change.h
src/lib/image_content.cc
src/lib/image_content.h
src/lib/string_text_file_content.cc
src/lib/string_text_file_content.h
src/lib/video_mxf_content.cc
src/lib/video_mxf_content.h
src/tools/dcpomatic_playlist.cc
src/wx/content_view.cc
src/wx/content_view.h
src/wx/swaroop_controls.cc

index 4835442d5e5f01b3eb973f84ab7e888449d8e9f6..5b97edcfd185fa996ba0a9340326781c37743da7 100644 (file)
@@ -96,3 +96,9 @@ AtmosMXFContent::full_length (shared_ptr<const Film> film) const
        FrameRateChange const frc (film, shared_from_this());
        return DCPTime::from_frames (llrint (_length * frc.factor()), film->video_frame_rate());
 }
+
+DCPTime
+AtmosMXFContent::approximate_length () const
+{
+       return DCPTime::from_frames (_length, 24);
+}
index 854824c67d82d76ca63d6d6da802fadb6291ddef..05f36c21c40683c191012a67d5c6d2c99189ba63 100644 (file)
@@ -38,6 +38,7 @@ public:
        std::string summary () const;
        void as_xml (xmlpp::Node* node, bool with_path) const;
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
 
        static bool valid_mxf (boost::filesystem::path path);
 
index 47f29cb79e3f7626875e7546c628dfef1a375602..552017c64179920d4ad5240a486da088167e5988 100644 (file)
@@ -91,6 +91,7 @@ public:
 
        virtual void as_xml (xmlpp::Node *, bool with_paths) const;
        virtual DCPTime full_length (boost::shared_ptr<const Film>) const = 0;
+       virtual DCPTime approximate_length () const = 0;
        virtual std::string identifier () const;
        /** @return points at which to split this content when
         *  REELTYPE_BY_VIDEO_CONTENT is in use.
index c89eadc3c97d89a49f6b133ea28462b3777c16e1..ac9f828996d286c20b15f849ff378dd5e5921035 100644 (file)
@@ -212,7 +212,7 @@ DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
                AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels()));
                audio->set_stream (as);
                AudioMapping m = as->mapping ();
-               m.make_default (film->audio_processor());
+               m.make_default (film ? film->audio_processor() : 0);
                as->set_mapping (m);
        }
 
@@ -345,6 +345,15 @@ DCPContent::full_length (shared_ptr<const Film> film) const
        return DCPTime::from_frames (llrint(video->length() * frc.factor()), film->video_frame_rate());
 }
 
+DCPTime
+DCPContent::approximate_length () const
+{
+       if (!video) {
+               return DCPTime();
+       }
+       return DCPTime::from_frames (video->length(), 24);
+}
+
 string
 DCPContent::identifier () const
 {
index 874e1ee318f447914e4a6fdbb464b27dccbe6eed..656c96897177448aa37aad8bbf58cef988e83030 100644 (file)
@@ -62,6 +62,7 @@ public:
        }
 
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
 
        void examine (boost::shared_ptr<const Film> film, boost::shared_ptr<Job>);
        std::string summary () const;
index d25e06188b95de79ab189e9cbc03b1a8af5adad2..54bd631cb6586a03dc7ee15c9831193e78c78e56 100644 (file)
@@ -88,6 +88,12 @@ DCPSubtitleContent::full_length (shared_ptr<const Film> film) const
        return DCPTime (_length, frc);
 }
 
+DCPTime
+DCPSubtitleContent::approximate_length () const
+{
+       return DCPTime (_length, FrameRateChange());
+}
+
 string
 DCPSubtitleContent::summary () const
 {
index 5eaad0d2fc677efc04b7a7896695d11997284155..f5f375eee3570673d62ba97128829e6a1e802512 100644 (file)
@@ -32,6 +32,7 @@ public:
        std::string technical_summary () const;
        void as_xml (xmlpp::Node *, bool with_paths) const;
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
 
 private:
        ContentTime _length;
index 9192006796aefeda43d64a7a763f7beece3e98dc..f4e4beba923cf4aed67b634831dc334c97ca74d2 100644 (file)
@@ -307,7 +307,7 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
 
                        AudioStreamPtr as = audio->streams().front();
                        AudioMapping m = as->mapping ();
-                       m.make_default (film->audio_processor(), first_path);
+                       m.make_default (film ? film->audio_processor() : 0, first_path);
                        as->set_mapping (m);
                }
 
@@ -415,6 +415,23 @@ FFmpegContent::full_length (shared_ptr<const Film> film) const
        return longest;
 }
 
+DCPTime
+FFmpegContent::approximate_length () const
+{
+       if (video) {
+               return DCPTime::from_frames (video->length_after_3d_combine(), 24);
+       }
+
+       DCPOMATIC_ASSERT (audio);
+
+       Frame longest = 0;
+       BOOST_FOREACH (AudioStreamPtr i, audio->streams ()) {
+               longest = max (longest, Frame(llrint(i->length())));
+       }
+
+       return DCPTime::from_frames (longest, 24);
+}
+
 void
 FFmpegContent::set_filters (vector<Filter const *> const & filters)
 {
index b7685bf0937c56f92b1cfea4e65aea1c2f114785..4c612cd3ee00eb62720fc35fe1759f5fd2cf1451 100644 (file)
@@ -64,6 +64,7 @@ public:
        std::string technical_summary () const;
        void as_xml (xmlpp::Node *, bool with_paths) const;
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
 
        std::string identifier () const;
 
index 456b4151e1a11accef6e1d6b481955c65e71a4c2..7b43ccdbc0ae9c45ce3ab2c9547b6e8855499282 100644 (file)
@@ -36,6 +36,17 @@ about_equal (double a, double b)
        return (fabs (a - b) < VIDEO_FRAME_RATE_EPSILON);
 }
 
+FrameRateChange::FrameRateChange ()
+       : skip (false)
+       , repeat (1)
+       , change_speed (false)
+       , source (24)
+       , dcp (24)
+       , speed_up (1)
+{
+
+}
+
 FrameRateChange::FrameRateChange (double source_, int dcp_)
        : skip (false)
        , repeat (1)
index 05660ce826f07edfc1cada2eb5ca56a06ad731b2..acb75c0b5764e91257ef21d86ff6474b99134ee0 100644 (file)
@@ -30,6 +30,7 @@ class Content;
 class FrameRateChange
 {
 public:
+       FrameRateChange ();
        FrameRateChange (double, int);
        FrameRateChange (boost::shared_ptr<const Film> film, boost::shared_ptr<const Content> content);
        FrameRateChange (boost::shared_ptr<const Film> film, Content const * content);
index c84ba7d29019c3f0575170678254c4649f27c97d..8902798a4c4f1d4187d1cc6a6fa095b71ef28de2 100644 (file)
@@ -139,6 +139,12 @@ ImageContent::full_length (shared_ptr<const Film> film) const
        return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
 }
 
+DCPTime
+ImageContent::approximate_length () const
+{
+       return DCPTime::from_frames (video->length_after_3d_combine(), 24);
+}
+
 string
 ImageContent::identifier () const
 {
index 6a450ef8f33721b5903179118c809ce41b88b9fb..e2a2ec36623b40faa6a7b69baca72e698d0a01d5 100644 (file)
@@ -42,6 +42,7 @@ public:
        std::string technical_summary () const;
        void as_xml (xmlpp::Node *, bool with_paths) const;
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
 
        std::string identifier () const;
 
index 8b740546e82004c47299b514650e5384f11fe197..b4362a7d0e7bb9e4b40ef97e6b7f779170ff991a 100644 (file)
@@ -94,3 +94,9 @@ StringTextFileContent::full_length (shared_ptr<const Film> film) const
        FrameRateChange const frc (film, shared_from_this());
        return DCPTime (_length, frc);
 }
+
+DCPTime
+StringTextFileContent::approximate_length () const
+{
+       return DCPTime (_length, FrameRateChange());
+}
index 4932f2a72dbc5feaa52a9ab54d21a18877cb591a..936e894d8a567e663edfb1c3602b3229b56c656d 100644 (file)
@@ -44,6 +44,7 @@ public:
        std::string technical_summary () const;
        void as_xml (xmlpp::Node *, bool with_paths) const;
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
 
 private:
        ContentTime _length;
index def58c5ebb3a5a7bc0e69dcccc2df31be1ed82b0..9d2af1a32923c966e08c1b85343de6b24af17276 100644 (file)
@@ -123,6 +123,12 @@ VideoMXFContent::full_length (shared_ptr<const Film> film) const
        return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
 }
 
+DCPTime
+VideoMXFContent::approximate_length () const
+{
+       return DCPTime::from_frames (video->length_after_3d_combine(), 24);
+}
+
 void
 VideoMXFContent::add_properties (list<UserProperty>& p) const
 {
index 6236568b1cad89837627c98ad5f68531e9173d2f..25da0def4976e605258ea83f16e33843a55cfc7e 100644 (file)
@@ -40,6 +40,7 @@ public:
        std::string identifier () const;
        void as_xml (xmlpp::Node* node, bool with_paths) const;
        DCPTime full_length (boost::shared_ptr<const Film> film) const;
+       DCPTime approximate_length () const;
        void add_properties (std::list<UserProperty>& p) const;
 
        static bool valid_mxf (boost::filesystem::path path);
index 2c575af366f3fe922eedb5b108f3f461c389f712..2bb9ec2a70408df5d1f5fe84bf28e54773e9d281 100644 (file)
@@ -46,7 +46,7 @@ class ContentDialog : public wxDialog, public ContentStore
 public:
        ContentDialog (wxWindow* parent, weak_ptr<Film> film)
                : wxDialog (parent, wxID_ANY, _("Add content"), wxDefaultPosition, wxSize(800, 640))
-               , _content_view (new ContentView(this, film))
+               , _content_view (new ContentView(this))
        {
                _content_view->update ();
 
index fdc7afcabaea19e30b45b59a28a68dee0bff0e45..035118245fc150017b45dae8fa46b4ec2d988c28 100644 (file)
@@ -40,9 +40,8 @@ using boost::weak_ptr;
 using boost::optional;
 using boost::dynamic_pointer_cast;
 
-ContentView::ContentView (wxWindow* parent, weak_ptr<Film> film)
+ContentView::ContentView (wxWindow* parent)
        : wxListCtrl (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER)
-       , _film (film)
 {
        AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 80);
        /* type */
@@ -66,11 +65,6 @@ ContentView::selected () const
 void
 ContentView::update ()
 {
-       shared_ptr<Film> film = _film.lock ();
-       if (!film) {
-               return;
-       }
-
        using namespace boost::filesystem;
 
        DeleteAllItems ();
@@ -95,7 +89,7 @@ ContentView::update ()
                        }
 
                        if (content) {
-                               shared_ptr<ExamineContentJob> job(new ExamineContentJob(film, content));
+                               shared_ptr<ExamineContentJob> job(new ExamineContentJob(shared_ptr<Film>(), content));
                                jm->add (job);
                                jobs.push_back (job);
                        }
@@ -133,13 +127,10 @@ ContentView::add (shared_ptr<Content> content)
 {
        int const N = GetItemCount();
 
-       shared_ptr<Film> film = _film.lock ();
-       DCPOMATIC_ASSERT (film);
-
        wxListItem it;
        it.SetId(N);
        it.SetColumn(0);
-       DCPTime length = content->length_after_trim (film);
+       DCPTime length = content->approximate_length ();
        int h, m, s, f;
        length.split (24, h, m, s, f);
        it.SetText(wxString::Format("%02d:%02d:%02d", h, m, s));
@@ -170,14 +161,3 @@ ContentView::get (string digest) const
 
        return shared_ptr<Content>();
 }
-
-void
-ContentView::set_film (weak_ptr<Film> film)
-{
-       if (_film.lock() == film.lock()) {
-               return;
-       }
-
-       _film = film;
-       update ();
-}
index d27638c05099f89bc3ebe0555e46177676796663..334e9bb68202449a8053324cf5d6b854239a9085 100644 (file)
@@ -30,13 +30,12 @@ class Film;
 class ContentView : public wxListCtrl, public ContentStore
 {
 public:
-       ContentView (wxWindow* parent, boost::weak_ptr<Film> film);
+       ContentView (wxWindow* parent);
 
        boost::shared_ptr<Content> selected () const;
        void update ();
 
        boost::shared_ptr<Content> get (std::string digest) const;
-       void set_film (boost::weak_ptr<Film> film);
 
 private:
        void add (boost::shared_ptr<Content> content);
index 538d349425f4b61dee7a965a0df4f39d7ac67b90..dc65f1b85f7635f14672106d94ec70cce87ccd11 100644 (file)
@@ -51,7 +51,7 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
 
        left_sizer->Add (_spl_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
 
-       _content_view = new ContentView (this, _film);
+       _content_view = new ContentView (this);
        left_sizer->Add (_content_view, 1, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
 
        _current_spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
@@ -240,9 +240,6 @@ void
 SwaroopControls::set_film (shared_ptr<Film> film)
 {
        Controls::set_film (film);
-
-       _content_view->set_film (film);
        update_playlist_directory ();
-
        setup_sensitivity ();
 }