Merge master.
[dcpomatic.git] / src / lib / dcp_video_frame.cc
index 5cd6a118e6256987646734b0a2d47b4187872ac3..1aae64ac7aafd98fa40e59316dcb73872fc421b0 100644 (file)
 #include <boost/array.hpp>
 #include <boost/asio.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
 #include <openssl/md5.h>
-#include <libdcp/rec709_linearised_gamma_lut.h>
-#include <libdcp/srgb_linearised_gamma_lut.h>
-#include <libdcp/gamma_lut.h>
-#include <libdcp/xyz_frame.h>
-#include <libdcp/rgb_xyz.h>
-#include <libdcp/colour_matrix.h>
-#include <libdcp/raw_convert.h>
+#include <dcp/gamma_lut.h>
+#include <dcp/xyz_frame.h>
+#include <dcp/rgb_xyz.h>
+#include <dcp/colour_matrix.h>
+#include <dcp/raw_convert.h>
 #include <libcxml/cxml.h>
 #include "film.h"
 #include "dcp_video_frame.h"
 #include "cross.h"
 #include "player_video_frame.h"
 
+#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
+
 #include "i18n.h"
 
 using std::string;
 using std::stringstream;
 using std::cout;
 using boost::shared_ptr;
-using libdcp::Size;
-using libdcp::raw_convert;
+using boost::lexical_cast;
+using dcp::Size;
+using dcp::raw_convert;
 
 #define DCI_COEFFICENT (48.0 / 52.37)
 
@@ -109,13 +111,10 @@ DCPVideoFrame::DCPVideoFrame (shared_ptr<const PlayerVideoFrame> frame, shared_p
 shared_ptr<EncodedData>
 DCPVideoFrame::encode_locally ()
 {
-       shared_ptr<libdcp::LUT> in_lut;
-       if (_frame->colour_conversion().input_gamma_linearised) {
-               in_lut = libdcp::SRGBLinearisedGammaLUT::cache.get (12, _frame->colour_conversion().input_gamma);
-       } else {
-               in_lut = libdcp::GammaLUT::cache.get (12, _frame->colour_conversion().input_gamma);
-       }
-
+       shared_ptr<dcp::GammaLUT> 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];
@@ -125,10 +124,10 @@ DCPVideoFrame::encode_locally ()
                }
        }
 
-       shared_ptr<libdcp::XYZFrame> xyz = libdcp::rgb_to_xyz (
+       shared_ptr<dcp::XYZFrame> xyz = dcp::rgb_to_xyz (
                _frame->image(),
                in_lut,
-               libdcp::GammaLUT::cache.get (16, 1 / _frame->colour_conversion().output_gamma),
+               dcp::GammaLUT::cache.get (16, 1 / _frame->colour_conversion().output_gamma, false),
                matrix
                );
 
@@ -250,13 +249,13 @@ DCPVideoFrame::encode_locally ()
 
        switch (_frame->eyes()) {
        case EYES_BOTH:
-               _log->log (String::compose (N_("Finished locally-encoded frame %1 for mono"), _index));
+               LOG_GENERAL (N_("Finished locally-encoded frame %1 for mono"), _index);
                break;
        case EYES_LEFT:
-               _log->log (String::compose (N_("Finished locally-encoded frame %1 for L"), _index));
+               LOG_GENERAL (N_("Finished locally-encoded frame %1 for L"), _index);
                break;
        case EYES_RIGHT:
-               _log->log (String::compose (N_("Finished locally-encoded frame %1 for R"), _index));
+               LOG_GENERAL (N_("Finished locally-encoded frame %1 for R"), _index);
                break;
        default:
                break;
@@ -293,7 +292,7 @@ DCPVideoFrame::encode_remotely (ServerDescription serv)
        root->add_child("Version")->add_child_text (raw_convert<string> (SERVER_LINK_VERSION));
        add_metadata (root);
 
-       _log->log (String::compose (N_("Sending frame %1 to remote"), _index));
+       LOG_GENERAL (N_("Sending frame %1 to remote"), _index);
        
        /* Send XML metadata */
        stringstream xml;
@@ -310,7 +309,7 @@ DCPVideoFrame::encode_remotely (ServerDescription serv)
        shared_ptr<EncodedData> e (new RemotelyEncodedData (socket->read_uint32 ()));
        socket->read (e->data(), e->size());
 
-       _log->log (String::compose (N_("Finished remotely-encoded frame %1"), _index));
+       LOG_GENERAL (N_("Finished remotely-encoded frame %1"), _index);
        
        return e;
 }
@@ -388,7 +387,7 @@ EncodedData::write (shared_ptr<const Film> film, int frame, Eyes eyes) const
 }
 
 void
-EncodedData::write_info (shared_ptr<const Film> film, int frame, Eyes eyes, libdcp::FrameInfo fin) const
+EncodedData::write_info (shared_ptr<const Film> film, int frame, Eyes eyes, dcp::FrameInfo fin) const
 {
        boost::filesystem::path const info = film->info_path (frame, eyes);
        FILE* h = fopen_boost (info, "w");