From: Carl Hetherington Date: Tue, 1 Jul 2014 16:03:16 +0000 (+0100) Subject: Only burn subtitles if it is turned on. X-Git-Tag: v2.0.48~758 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=096660d2cc3e65ae5e13a69e7ace19ff0d48b39a Only burn subtitles if it is turned on. --- diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 8d4a5925f..b6b7ab296 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -82,13 +82,14 @@ using dcp::raw_convert; * @param l Log to write to. */ DCPVideo::DCPVideo ( - shared_ptr frame, int index, int dcp_fps, int bw, Resolution r, shared_ptr l + shared_ptr frame, int index, int dcp_fps, int bw, Resolution r, bool b, shared_ptr 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 frame, shared_ptrnumber_child ("FramesPerSecond"); _j2k_bandwidth = node->number_child ("J2KBandwidth"); _resolution = Resolution (node->optional_number_child("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 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 (_frames_per_second)); el->add_child("J2KBandwidth")->add_child_text (raw_convert (_j2k_bandwidth)); el->add_child("Resolution")->add_child_text (raw_convert (int (_resolution))); - _frame->add_metadata (el); + el->add_child("BurnSubtitles")->add_child_text (_burn_subtitles ? "1" : "0"); + _frame->add_metadata (el, _burn_subtitles); } Eyes diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index 7b01966bd..05a0b4ce3 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -101,7 +101,7 @@ public: class DCPVideo : public boost::noncopyable { public: - DCPVideo (boost::shared_ptr, int, int, int, Resolution, boost::shared_ptr); + DCPVideo (boost::shared_ptr, int, int, int, Resolution, bool b, boost::shared_ptr); DCPVideo (boost::shared_ptr, cxml::ConstNodePtr, boost::shared_ptr); boost::shared_ptr 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 }; diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 2b1f1d9b3..591523570 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -220,6 +220,7 @@ Encoder::process_video (shared_ptr pvf) _film->video_frame_rate(), _film->j2k_bandwidth(), _film->resolution(), + _film->burn_subtitles(), _film->log() ) )); diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index 3c513848a..d1b394933 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -85,7 +85,7 @@ PlayerVideo::set_subtitle (PositionImage image) } shared_ptr -PlayerVideo::image () const +PlayerVideo::image (bool burn_subtitle) const { shared_ptr im = _in->image (); @@ -111,7 +111,7 @@ PlayerVideo::image () const Position 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 (_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 (_eyes)); node->add_child("Part")->add_child_text (raw_convert (_part)); _colour_conversion.as_xml (node); - if (_subtitle.image) { + if (send_subtitles && _subtitle.image) { node->add_child ("SubtitleWidth")->add_child_text (raw_convert (_subtitle.image->size().width)); node->add_child ("SubtitleHeight")->add_child_text (raw_convert (_subtitle.image->size().height)); node->add_child ("SubtitleX")->add_child_text (raw_convert (_subtitle.position.x)); @@ -141,10 +141,10 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const } void -PlayerVideo::send_binary (shared_ptr socket) const +PlayerVideo::send_binary (shared_ptr socket, bool send_subtitles) const { _in->send_binary (socket); - if (_subtitle.image) { + if (send_subtitles && _subtitle.image) { _subtitle.image->write_to_socket (socket); } } diff --git a/src/lib/player_video.h b/src/lib/player_video.h index 7d2787783..e06e5f45e 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -41,10 +41,10 @@ public: void set_subtitle (PositionImage); - boost::shared_ptr image () const; + boost::shared_ptr image (bool burn_subtitle) const; - void add_metadata (xmlpp::Node* node) const; - void send_binary (boost::shared_ptr socket) const; + void add_metadata (xmlpp::Node* node, bool send_subtitles) const; + void send_binary (boost::shared_ptr socket, bool send_subtitles) const; DCPTime time () const { return _time; diff --git a/src/tools/server_test.cc b/src/tools/server_test.cc index acafa4a81..0e19a36ac 100644 --- a/src/tools/server_test.cc +++ b/src/tools/server_test.cc @@ -50,8 +50,8 @@ static int frame_count = 0; void process_video (shared_ptr pvf) { - shared_ptr local (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_)); - shared_ptr remote (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_)); + shared_ptr local (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, true, log_)); + shared_ptr remote (new DCPVideo (pvf, frame_count, film->video_frame_rate(), 250000000, RESOLUTION_2K, true, log_)); cout << "Frame " << frame_count << ": "; cout.flush (); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 6499aa409..74e3b81ed 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -153,7 +153,7 @@ FilmViewer::get (DCPTime p, bool accurate) list > 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 { diff --git a/test/client_server_test.cc b/test/client_server_test.cc index 148f5ae64..19c827c2f 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -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 ) );