X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcp_video.cc;h=cacba190f87603dfa5d12a1a27c953229af959a5;hb=b6c780d3107557d452c6612d715d01e2be52dbda;hp=9b1c8c33eae12cf36d214cbd81b84af99e9e7ae8;hpb=1f82930e73679d6aec5223caa255f564339a1a2a;p=dcpomatic.git diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 9b1c8c33e..cacba190f 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -67,7 +66,6 @@ #include "i18n.h" using std::string; -using std::stringstream; using std::cout; using boost::shared_ptr; using boost::lexical_cast; @@ -113,26 +111,33 @@ DCPVideo::DCPVideo (shared_ptr frame, shared_ptr DCPVideo::encode_locally () { - shared_ptr in_lut = dcp::GammaLUT::cache.get ( - 12, _frame->colour_conversion().input_gamma, _frame->colour_conversion().input_gamma_linearised - ); - - /* XXX: libdcp should probably use boost */ - - double matrix[3][3]; - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - matrix[i][j] = _frame->colour_conversion().matrix (i, j); + shared_ptr xyz; + + if (_frame->colour_conversion()) { + ColourConversion conversion = _frame->colour_conversion().get (); + shared_ptr in_lut = dcp::GammaLUT::cache.get ( + 12, conversion.input_gamma, conversion.input_gamma_linearised + ); + + /* XXX: dcp should probably use boost */ + + double matrix[3][3]; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + matrix[i][j] = conversion.matrix (i, j); + } } + + xyz = dcp::rgb_to_xyz ( + _frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles), + in_lut, + dcp::GammaLUT::cache.get (16, 1 / conversion.output_gamma, false), + matrix + ); + } else { + xyz = dcp::xyz_to_xyz (_frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles)); } - shared_ptr xyz = dcp::rgb_to_xyz ( - _frame->image (_burn_subtitles), - in_lut, - dcp::GammaLUT::cache.get (16, 1 / _frame->colour_conversion().output_gamma, false), - matrix - ); - /* Set the max image and component sizes based on frame_rate */ int max_cs_len = ((float) _j2k_bandwidth) / 8 / _frames_per_second; if (_frame->eyes() == EYES_LEFT || _frame->eyes() == EYES_RIGHT) { @@ -282,10 +287,9 @@ DCPVideo::encode_remotely (ServerDescription serv) LOG_GENERAL (N_("Sending frame %1 to remote"), _index); /* Send XML metadata */ - stringstream xml; - doc.write_to_stream (xml, "UTF-8"); - socket->write (xml.str().length() + 1); - socket->write ((uint8_t *) xml.str().c_str(), xml.str().length() + 1); + string xml = doc.write_to_string ("UTF-8"); + socket->write (xml.length() + 1); + socket->write ((uint8_t *) xml.c_str(), xml.length() + 1); /* Send binary data */ _frame->send_binary (socket, _burn_subtitles); @@ -318,3 +322,18 @@ DCPVideo::eyes () const return _frame->eyes (); } +/** @return true if this DCPVideo is definitely the same as another; + * (apart from the frame index), false if it is probably not. + */ +bool +DCPVideo::same (shared_ptr other) const +{ + if (_frames_per_second != other->_frames_per_second || + _j2k_bandwidth != other->_j2k_bandwidth || + _resolution != other->_resolution || + _burn_subtitles != other->_burn_subtitles) { + return false; + } + + return _frame->same (other->_frame); +}