Partial conversion of PlayerSubtitles -> PlayerText and SubtitleString -> PlainText.
authorCarl Hetherington <cth@carlh.net>
Thu, 19 Jul 2018 18:58:30 +0000 (19:58 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 19 Jul 2018 22:45:23 +0000 (23:45 +0100)
19 files changed:
src/lib/active_subtitles.cc
src/lib/active_subtitles.h
src/lib/dcp_encoder.cc
src/lib/dcp_encoder.h
src/lib/encoder.h
src/lib/ffmpeg_encoder.cc
src/lib/ffmpeg_encoder.h
src/lib/plain_text.h [new file with mode: 0644]
src/lib/player.cc
src/lib/player.h
src/lib/player_subtitles.cc [deleted file]
src/lib/player_subtitles.h [deleted file]
src/lib/player_text.cc [new file with mode: 0644]
src/lib/player_text.h [new file with mode: 0644]
src/lib/render_text.h
src/lib/subtitle_string.h [deleted file]
src/lib/writer.cc
src/lib/writer.h
src/lib/wscript

index f1d20179882948796130c6e8a728f9a4a6364d5f..f309ba1e05d1ee5e630035563745bd6858a32e46 100644 (file)
@@ -35,10 +35,10 @@ using boost::optional;
  *  @param period Period of interest.
  *  @param always_burn_subtitles Always burn subtitles even if their content is not set to burn.
  */
-list<PlayerSubtitles>
+list<PlayerText>
 ActiveSubtitles::get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const
 {
-       list<PlayerSubtitles> ps;
+       list<PlayerText> ps;
 
        for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) {
 
@@ -91,7 +91,7 @@ ActiveSubtitles::clear_before (DCPTime time)
  *  @param from From time for these subtitles.
  */
 void
-ActiveSubtitles::add_from (weak_ptr<Piece> piece, PlayerSubtitles ps, DCPTime from)
+ActiveSubtitles::add_from (weak_ptr<Piece> piece, PlayerText ps, DCPTime from)
 {
        if (_data.find(piece) == _data.end()) {
                _data[piece] = list<Period>();
@@ -104,14 +104,14 @@ ActiveSubtitles::add_from (weak_ptr<Piece> piece, PlayerSubtitles ps, DCPTime fr
  *  @param to To time for the last subtitle submitted to add_from for this piece.
  *  @return Return the corresponding subtitles and their from time.
  */
-pair<PlayerSubtitles, DCPTime>
+pair<PlayerText, DCPTime>
 ActiveSubtitles::add_to (weak_ptr<Piece> piece, DCPTime to)
 {
        DCPOMATIC_ASSERT (_data.find(piece) != _data.end());
 
        _data[piece].back().to = to;
 
-       BOOST_FOREACH (SubtitleString& i, _data[piece].back().subs.text) {
+       BOOST_FOREACH (PlainText& i, _data[piece].back().subs.text) {
                i.set_out (dcp::Time(to.seconds(), 1000));
        }
 
index 1496bc5d26b3870196bdcdbf9979ee51ac4dc813..2dd0a4b16e31964a0e781b1361d0f97959e143d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2017-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -23,7 +23,7 @@
  */
 
 #include "dcpomatic_time.h"
-#include "player_subtitles.h"
+#include "player_text.h"
 #include <boost/noncopyable.hpp>
 #include <list>
 #include <map>
@@ -36,11 +36,11 @@ class Piece;
 class ActiveSubtitles : public boost::noncopyable
 {
 public:
-       std::list<PlayerSubtitles> get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const;
+       std::list<PlayerText> get_burnt (DCPTimePeriod period, bool always_burn_subtitles) const;
        void clear_before (DCPTime time);
        void clear ();
-       void add_from (boost::weak_ptr<Piece> piece, PlayerSubtitles ps, DCPTime from);
-       std::pair<PlayerSubtitles, DCPTime> add_to (boost::weak_ptr<Piece> piece, DCPTime to);
+       void add_from (boost::weak_ptr<Piece> piece, PlayerText ps, DCPTime from);
+       std::pair<PlayerText, DCPTime> add_to (boost::weak_ptr<Piece> piece, DCPTime to);
        bool have (boost::weak_ptr<Piece> piece) const;
 
 private:
@@ -49,12 +49,12 @@ private:
        public:
                Period () {}
 
-               Period (PlayerSubtitles s, DCPTime f)
+               Period (PlayerText s, DCPTime f)
                        : subs (s)
                        , from (f)
                {}
 
-               PlayerSubtitles subs;
+               PlayerText subs;
                DCPTime from;
                boost::optional<DCPTime> to;
        };
index 9121e9d53243551db4a5530cd27760221dcb155e..c38d73276066e44e6204fc2ba7437bc2a687c1ff 100644 (file)
@@ -141,7 +141,7 @@ DCPEncoder::audio (shared_ptr<AudioBuffers> data, DCPTime time)
 }
 
 void
-DCPEncoder::subtitle (PlayerSubtitles data, DCPTimePeriod period)
+DCPEncoder::subtitle (PlayerText data, DCPTimePeriod period)
 {
        if (_non_burnt_subtitles) {
                _writer->write (data, period);
index 15f3dbc64ba2ff68b798dae682942426a4b5b4b6..7fbb076f3d313cceb550fd5c3104e26ce5ca4092 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -19,7 +19,7 @@
 */
 
 #include "types.h"
-#include "player_subtitles.h"
+#include "player_text.h"
 #include "encoder.h"
 #include <boost/weak_ptr.hpp>
 
@@ -52,7 +52,7 @@ private:
 
        void video (boost::shared_ptr<PlayerVideo>, DCPTime);
        void audio (boost::shared_ptr<AudioBuffers>, DCPTime);
-       void subtitle (PlayerSubtitles, DCPTimePeriod);
+       void subtitle (PlayerText, DCPTimePeriod);
 
        boost::shared_ptr<Writer> _writer;
        boost::shared_ptr<J2KEncoder> _j2k_encoder;
index 4907ed7c5a906f7a3dcc3ca2c31339139fbc9219..f4116c50c5888172dc3191e79562979fa7178054 100644 (file)
@@ -22,7 +22,7 @@
 #define DCPOMATIC_ENCODER_H
 
 #include "types.h"
-#include "player_subtitles.h"
+#include "player_text.h"
 #include <boost/weak_ptr.hpp>
 #include <boost/signals2.hpp>
 
index e55622abf8220246b1bc45b9623c5c3c26005cec..e9d872c8f782e590c8c856460c0fcefca7a234d3 100644 (file)
@@ -411,7 +411,7 @@ FFmpegEncoder::audio_frame (int size)
 }
 
 void
-FFmpegEncoder::subtitle (PlayerSubtitles, DCPTimePeriod)
+FFmpegEncoder::subtitle (PlayerText, DCPTimePeriod)
 {
 
 }
index ca1aa6fbca893f479f19df04b8c7c49f2afc6a39..b1d07eb7f65bdeff0ebaf414be6a29afbffcf6ac 100644 (file)
@@ -54,7 +54,7 @@ public:
 private:
        void video (boost::shared_ptr<PlayerVideo>, DCPTime);
        void audio (boost::shared_ptr<AudioBuffers>);
-       void subtitle (PlayerSubtitles, DCPTimePeriod);
+       void subtitle (PlayerText, DCPTimePeriod);
 
        void setup_video ();
        void setup_audio ();
diff --git a/src/lib/plain_text.h b/src/lib/plain_text.h
new file mode 100644 (file)
index 0000000..05a95ae
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+    Copyright (C) 2016-2018 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_PLAIN_TEXT_H
+#define DCPOMATIC_PLAIN_TEXT_H
+
+#include <dcp/subtitle_string.h>
+
+/** A wrapper for SubtitleString which allows us to include settings that are not
+ *  applicable to true DCP subtitles.  For example, we can set outline width for burn-in
+ *  but this cannot be specified in DCP XML.
+ */
+class PlainText : public dcp::SubtitleString
+{
+public:
+       explicit PlainText (dcp::SubtitleString dcp_)
+               : dcp::SubtitleString (dcp_)
+               , outline_width (2)
+       {}
+
+       PlainText (dcp::SubtitleString dcp_, int outline_width_)
+               : dcp::SubtitleString (dcp_)
+               , outline_width (outline_width_)
+       {}
+
+       int outline_width;
+};
+
+#endif
index 4c9e216e1ecb2e30ccc4ce72e495bc8afc3f39c0..32c2dfdfde2bd0d49f07d0d994d9849b60439d3d 100644 (file)
@@ -663,7 +663,7 @@ Player::subtitles_for_frame (DCPTime time) const
 
        int const vfr = _film->video_frame_rate();
 
-       BOOST_FOREACH (PlayerSubtitles i, _active_subtitles.get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) {
+       BOOST_FOREACH (PlayerText i, _active_subtitles.get_burnt (DCPTimePeriod(time, time + DCPTime::from_frames(1, vfr)), _always_burn_subtitles)) {
 
                /* Image subtitles */
                list<PositionImage> c = transform_bitmap_texts (i.image);
@@ -858,7 +858,7 @@ Player::bitmap_text_start (weak_ptr<Piece> wp, ContentBitmapText subtitle)
        subtitle.sub.rectangle.width *= piece->content->subtitle->x_scale ();
        subtitle.sub.rectangle.height *= piece->content->subtitle->y_scale ();
 
-       PlayerSubtitles ps;
+       PlayerText ps;
        ps.image.push_back (subtitle.sub);
        DCPTime from (content_time_to_dcp (piece, subtitle.from()));
 
@@ -873,7 +873,7 @@ Player::plain_text_start (weak_ptr<Piece> wp, ContentPlainText subtitle)
                return;
        }
 
-       PlayerSubtitles ps;
+       PlayerText ps;
        DCPTime const from (content_time_to_dcp (piece, subtitle.from()));
 
        if (from > piece->content->end()) {
@@ -926,7 +926,7 @@ Player::subtitle_stop (weak_ptr<Piece> wp, ContentTime to)
                return;
        }
 
-       pair<PlayerSubtitles, DCPTime> from = _active_subtitles.add_to (wp, dcp_to);
+       pair<PlayerText, DCPTime> from = _active_subtitles.add_to (wp, dcp_to);
 
        if (piece->content->subtitle->use() && !_always_burn_subtitles && !piece->content->subtitle->burn()) {
                Subtitle (from.first, DCPTimePeriod (from.second, dcp_to));
index abc06721a6c7f0f7818ca1537a15034fe695d905..2f1baa53c1659e296af43da5c5522114869b50db 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef DCPOMATIC_PLAYER_H
 #define DCPOMATIC_PLAYER_H
 
-#include "player_subtitles.h"
+#include "player_text.h"
 #include "active_subtitles.h"
 #include "content_text.h"
 #include "film.h"
@@ -101,7 +101,7 @@ public:
        /** Emitted when a subtitle is ready.  This signal may be emitted considerably
         *  after the corresponding Video.
         */
-       boost::signals2::signal<void (PlayerSubtitles, DCPTimePeriod)> Subtitle;
+       boost::signals2::signal<void (PlayerText, DCPTimePeriod)> Subtitle;
 
 private:
        friend class PlayerWrapper;
diff --git a/src/lib/player_subtitles.cc b/src/lib/player_subtitles.cc
deleted file mode 100644 (file)
index 10bacde..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "player_subtitles.h"
-#include "font.h"
-#include <boost/foreach.hpp>
-
-using std::list;
-using boost::shared_ptr;
-
-void
-PlayerSubtitles::add_fonts (list<shared_ptr<Font> > fonts_)
-{
-       BOOST_FOREACH (shared_ptr<Font> i, fonts_) {
-               bool got = false;
-               BOOST_FOREACH (shared_ptr<Font> j, fonts) {
-                       if (*i == *j) {
-                               got = true;
-                       }
-               }
-               if (!got) {
-                       fonts.push_back (i);
-               }
-       }
-}
diff --git a/src/lib/player_subtitles.h b/src/lib/player_subtitles.h
deleted file mode 100644 (file)
index 4e3a739..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef DCPOMATIC_PLAYER_SUBTITLES_H
-#define DCPOMATIC_PLAYER_SUBTITLES_H
-
-#include "bitmap_text.h"
-#include "dcpomatic_time.h"
-#include "subtitle_string.h"
-
-class Font;
-
-/** A set of subtitles which span the same time period */
-class PlayerSubtitles
-{
-public:
-       void add_fonts (std::list<boost::shared_ptr<Font> > fonts_);
-       std::list<boost::shared_ptr<Font> > fonts;
-
-       /** BitmapTexts, with their rectangles transformed as specified by their content */
-       std::list<BitmapText> image;
-       std::list<SubtitleString> text;
-};
-
-#endif
diff --git a/src/lib/player_text.cc b/src/lib/player_text.cc
new file mode 100644 (file)
index 0000000..588e4ef
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "player_text.h"
+#include "font.h"
+#include <boost/foreach.hpp>
+
+using std::list;
+using boost::shared_ptr;
+
+void
+PlayerSubtitles::add_fonts (list<shared_ptr<Font> > fonts_)
+{
+       BOOST_FOREACH (shared_ptr<Font> i, fonts_) {
+               bool got = false;
+               BOOST_FOREACH (shared_ptr<Font> j, fonts) {
+                       if (*i == *j) {
+                               got = true;
+                       }
+               }
+               if (!got) {
+                       fonts.push_back (i);
+               }
+       }
+}
diff --git a/src/lib/player_text.h b/src/lib/player_text.h
new file mode 100644 (file)
index 0000000..93b6cd9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef DCPOMATIC_PLAYER_TEXT_H
+#define DCPOMATIC_PLAYER_TEXT_H
+
+#include "bitmap_text.h"
+#include "dcpomatic_time.h"
+#include "plain_text.h"
+
+class Font;
+
+/** A set of text (subtitle/CCAP) which span the same time period */
+class PlayerText
+{
+public:
+       void add_fonts (std::list<boost::shared_ptr<Font> > fonts_);
+       std::list<boost::shared_ptr<Font> > fonts;
+
+       /** BitmapTexts, with their rectangles transformed as specified by their content */
+       std::list<BitmapText> image;
+       std::list<PlainText> text;
+};
+
+#endif
index 0f3a31e211277c78fbb8d9e349f7d1d58338555f..496967f31713dcf5b194df3ce27efba0892b7d8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -20,7 +20,7 @@
 
 #include "position_image.h"
 #include "dcpomatic_time.h"
-#include "subtitle_string.h"
+#include "plain_text.h"
 #include <dcp/util.h>
 
 class Font;
diff --git a/src/lib/subtitle_string.h b/src/lib/subtitle_string.h
deleted file mode 100644 (file)
index 81ebc27..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef DCPOMATIC_SUBTITLE_STRING_H
-#define DCPOMATIC_SUBTITLE_STRING_H
-
-#include <dcp/subtitle_string.h>
-
-/** A wrapper for SubtitleString which allows us to include settings that are not
- *  applicable to true DCP subtitles.  For example, we can set outline width for burn-in
- *  but this cannot be specified in DCP XML.
- */
-class SubtitleString : public dcp::SubtitleString
-{
-public:
-       explicit SubtitleString (dcp::SubtitleString dcp_)
-               : dcp::SubtitleString (dcp_)
-               , outline_width (2)
-       {}
-
-       SubtitleString (dcp::SubtitleString dcp_, int outline_width_)
-               : dcp::SubtitleString (dcp_)
-               , outline_width (outline_width_)
-       {}
-
-       int outline_width;
-};
-
-#endif
index 2eec8110e3112c1a2548eb125b541c743af61c2d..a5e8cd9d225850694ccaa49d16e61619ce014e1e 100644 (file)
@@ -663,7 +663,7 @@ Writer::can_fake_write (Frame frame) const
 }
 
 void
-Writer::write (PlayerSubtitles subs, DCPTimePeriod period)
+Writer::write (PlayerText subs, DCPTimePeriod period)
 {
        while (_subtitle_reel->period().to <= period.from) {
                ++_subtitle_reel;
index 0e1c0e02f3e66dc5b5db6d16b9ec7c98bd5274f3..c8d1888349809d2bb4b2d52c14cca8862aa0d8ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -23,7 +23,7 @@
  */
 
 #include "types.h"
-#include "player_subtitles.h"
+#include "player_text.h"
 #include "exception_store.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
@@ -104,7 +104,7 @@ public:
        bool can_repeat (Frame) const;
        void repeat (Frame, Eyes);
        void write (boost::shared_ptr<const AudioBuffers>, DCPTime time);
-       void write (PlayerSubtitles subs, DCPTimePeriod period);
+       void write (PlayerText subs, DCPTimePeriod period);
        void write (std::list<boost::shared_ptr<Font> > fonts);
        void write (ReferencedReelAsset asset);
        void finish ();
index 9e2d07d7c97da0204d47fecdda28182ed5f4c9f9..ee5a583ac11e3e9eb0cc29994e4ab45df0bf78fe 100644 (file)
@@ -112,7 +112,7 @@ sources = """
           mid_side_decoder.cc
           overlaps.cc
           player.cc
-          player_subtitles.cc
+          player_text.cc
           player_video.cc
           playlist.cc
           position_image.cc