Only burn subtitles if it is turned on.
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Jul 2014 16:03:16 +0000 (17:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Jul 2014 16:03:16 +0000 (17:03 +0100)
src/lib/dcp_video.cc
src/lib/dcp_video.h
src/lib/encoder.cc
src/lib/player_video.cc
src/lib/player_video.h
src/tools/server_test.cc
src/wx/film_viewer.cc
test/client_server_test.cc

index 8d4a5925f826d6641b57397ae2cdb46b638e14e5..b6b7ab296c2aa6fc5fff7b6b8cd50c25a59e571c 100644 (file)
@@ -82,13 +82,14 @@ using dcp::raw_convert;
  *  @param l Log to write to.
  */
 DCPVideo::DCPVideo (
-       shared_ptr<const PlayerVideo> frame, int index, int dcp_fps, int bw, Resolution r, shared_ptr<Log> l
+       shared_ptr<const PlayerVideo> frame, int index, int dcp_fps, int bw, Resolution r, bool b, shared_ptr<Log> l
        )
        : _frame (frame)
        , _index (index)
        , _frames_per_second (dcp_fps)
        , _j2k_bandwidth (bw)
        , _resolution (r)
+       , _burn_subtitles (b)
        , _log (l)
 {
        
@@ -102,6 +103,7 @@ DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml::
        _frames_per_second = node->number_child<int> ("FramesPerSecond");
        _j2k_bandwidth = node->number_child<int> ("J2KBandwidth");
        _resolution = Resolution (node->optional_number_child<int>("Resolution").get_value_or (RESOLUTION_2K));
+       _burn_subtitles = node->bool_child ("BurnSubtitles");
 }
 
 /** J2K-encode this frame on the local host.
@@ -124,7 +126,7 @@ DCPVideo::encode_locally ()
        }
 
        shared_ptr<dcp::XYZFrame> xyz = dcp::rgb_to_xyz (
-               _frame->image(),
+               _frame->image (_burn_subtitles),
                in_lut,
                dcp::GammaLUT::cache.get (16, 1 / _frame->colour_conversion().output_gamma, false),
                matrix
@@ -285,7 +287,7 @@ DCPVideo::encode_remotely (ServerDescription serv)
        socket->write ((uint8_t *) xml.str().c_str(), xml.str().length() + 1);
 
        /* Send binary data */
-       _frame->send_binary (socket);
+       _frame->send_binary (socket, _burn_subtitles);
 
        /* Read the response (JPEG2000-encoded data); this blocks until the data
           is ready and sent back.
@@ -305,7 +307,8 @@ DCPVideo::add_metadata (xmlpp::Element* el) const
        el->add_child("FramesPerSecond")->add_child_text (raw_convert<string> (_frames_per_second));
        el->add_child("J2KBandwidth")->add_child_text (raw_convert<string> (_j2k_bandwidth));
        el->add_child("Resolution")->add_child_text (raw_convert<string> (int (_resolution)));
-       _frame->add_metadata (el);
+       el->add_child("BurnSubtitles")->add_child_text (_burn_subtitles ? "1" : "0");
+       _frame->add_metadata (el, _burn_subtitles);
 }
 
 Eyes
index 7b01966bd25f04e0cee162d843d8da788c5e0ddc..05a0b4ce32f70ec02afe45953968f4eded79068b 100644 (file)
@@ -101,7 +101,7 @@ public:
 class DCPVideo : public boost::noncopyable
 {
 public:
-       DCPVideo (boost::shared_ptr<const PlayerVideo>, int, int, int, Resolution, boost::shared_ptr<Log>);
+       DCPVideo (boost::shared_ptr<const PlayerVideo>, int, int, int, Resolution, bool b, boost::shared_ptr<Log>);
        DCPVideo (boost::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr, boost::shared_ptr<Log>);
 
        boost::shared_ptr<EncodedData> encode_locally ();
@@ -122,6 +122,7 @@ private:
        int _frames_per_second;          ///< Frames per second that we will use for the DCP
        int _j2k_bandwidth;              ///< J2K bandwidth to use
        Resolution _resolution;          ///< Resolution (2K or 4K)
+       bool _burn_subtitles;            ///< true to burn subtitles into the image
 
        boost::shared_ptr<Log> _log; ///< log
 };
index 2b1f1d9b3bab37236f1bb69462d658e598216540..591523570271d8ff95bae5dc9bbece6fd7ca7f72 100644 (file)
@@ -220,6 +220,7 @@ Encoder::process_video (shared_ptr<PlayerVideo> pvf)
                                                  _film->video_frame_rate(),
                                                  _film->j2k_bandwidth(),
                                                  _film->resolution(),
+                                                 _film->burn_subtitles(),
                                                  _film->log()
                                                  )
                                          ));
index 3c513848ac8ab82188f17ade5fbb9ddae3b0372e..d1b394933b67dc6e9fe70c278d06d6a8be9d5610 100644 (file)
@@ -85,7 +85,7 @@ PlayerVideo::set_subtitle (PositionImage image)
 }
 
 shared_ptr<Image>
-PlayerVideo::image () const
+PlayerVideo::image (bool burn_subtitle) const
 {
        shared_ptr<Image> im = _in->image ();
        
@@ -111,7 +111,7 @@ PlayerVideo::image () const
 
        Position<int> const container_offset ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.width) / 2);
 
-       if (_subtitle.image) {
+       if (burn_subtitle && _subtitle.image) {
                out->alpha_blend (_subtitle.image, _subtitle.position);
        }
 
@@ -119,7 +119,7 @@ PlayerVideo::image () const
 }
 
 void
-PlayerVideo::add_metadata (xmlpp::Node* node) const
+PlayerVideo::add_metadata (xmlpp::Node* node, bool send_subtitles) const
 {
        node->add_child("Time")->add_child_text (raw_convert<string> (_time.get ()));
        _crop.as_xml (node);
@@ -132,7 +132,7 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const
        node->add_child("Eyes")->add_child_text (raw_convert<string> (_eyes));
        node->add_child("Part")->add_child_text (raw_convert<string> (_part));
        _colour_conversion.as_xml (node);
-       if (_subtitle.image) {
+       if (send_subtitles && _subtitle.image) {
                node->add_child ("SubtitleWidth")->add_child_text (raw_convert<string> (_subtitle.image->size().width));
                node->add_child ("SubtitleHeight")->add_child_text (raw_convert<string> (_subtitle.image->size().height));
                node->add_child ("SubtitleX")->add_child_text (raw_convert<string> (_subtitle.position.x));
@@ -141,10 +141,10 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const
 }
 
 void
-PlayerVideo::send_binary (shared_ptr<Socket> socket) const
+PlayerVideo::send_binary (shared_ptr<Socket> socket, bool send_subtitles) const
 {
        _in->send_binary (socket);
-       if (_subtitle.image) {
+       if (send_subtitles && _subtitle.image) {
                _subtitle.image->write_to_socket (socket);
        }
 }
index 7d27877837bc835ef0bba256ed7cd24bde4d6e0f..e06e5f45e183f1cad603a7b14f4fc38e03c4cae7 100644 (file)
@@ -41,10 +41,10 @@ public:
 
        void set_subtitle (PositionImage);
        
-       boost::shared_ptr<Image> image () const;
+       boost::shared_ptr<Image> image (bool burn_subtitle) const;
 
-       void add_metadata (xmlpp::Node* node) const;
-       void send_binary (boost::shared_ptr<Socket> socket) const;
+       void add_metadata (xmlpp::Node* node, bool send_subtitles) const;
+       void send_binary (boost::shared_ptr<Socket> socket, bool send_subtitles) const;
 
        DCPTime time () const {
                return _time;
index acafa4a8133eadd03d4b106c69dd93d887d69ace..0e19a36ac8a9308a2bc76b3ac0528f2876948e46 100644 (file)
@@ -50,8 +50,8 @@ static int frame_count = 0;
 void
 process_video (shared_ptr<PlayerVideo> pvf)
 {
-       shared_ptr<DCPVideo> local  (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_));
-       shared_ptr<DCPVideo> remote (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_));
+       shared_ptr<DCPVideo> local  (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, true, log_));
+       shared_ptr<DCPVideo> remote (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, true, log_));
 
        cout << "Frame " << frame_count << ": ";
        cout.flush ();
index 6499aa4099b10b5c580e89da457c5d473aa2c95b..74e3b81ed82df4126c5ea1b5bee202b2feb3621b 100644 (file)
@@ -153,7 +153,7 @@ FilmViewer::get (DCPTime p, bool accurate)
 
        list<shared_ptr<PlayerVideo> > pvf = _player->get_video (p, accurate);
        if (!pvf.empty ()) {
-               _frame = pvf.front()->image ();
+               _frame = pvf.front()->image (true);
                _frame = _frame->scale (_frame->size(), Scaler::from_id ("fastbilinear"), PIX_FMT_RGB24, false);
                _position = pvf.front()->time ();
        } else {
index 148f5ae6496a5853c6e6ff88d5043181a956663a..19c827c2f91cc0be69da5f5757769655460d7702 100644 (file)
@@ -103,6 +103,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
                        24,
                        200000000,
                        RESOLUTION_2K,
+                       true,
                        log
                        )
                );
@@ -185,6 +186,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
                        24,
                        200000000,
                        RESOLUTION_2K,
+                       true,
                        log
                        )
                );