Try to actually use colour conversion; bump libdcp in cscript.
authorCarl Hetherington <cth@carlh.net>
Sat, 17 Aug 2013 21:21:15 +0000 (22:21 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 17 Aug 2013 21:21:15 +0000 (22:21 +0100)
12 files changed:
cscript
src/lib/dcp_video_frame.cc
src/lib/dcp_video_frame.h
src/lib/encoder.cc
src/lib/encoder.h
src/lib/player.cc
src/lib/player.h
src/lib/server.cc
src/lib/transcoder.cc
src/wx/content_colour_conversion_dialog.cc
src/wx/preset_colour_conversion_dialog.cc
test/client_server_test.cc

diff --git a/cscript b/cscript
index 4004cbdc3a61ae2d7e2d2a3e0501a8d1a00c4584..1f14f2f7766ea44f7e784c704dfcea384bfabc98 100644 (file)
--- a/cscript
+++ b/cscript
@@ -7,7 +7,7 @@ def dependencies(target):
         return ()
     else:
         return (('ffmpeg-cdist', '0d76267f36cbf01acd6a2a96ad2f7497a1843862'),
-                ('libdcp', 'ee5e932cf0afa1ce24ea5eb0f298be8009cd9689'))
+                ('libdcp', '7b8313c73082cc08b4dc42dc86d0c90a578993b1'))
 
 def build(target):
     cmd = './waf configure --prefix=%s' % target.work_dir_cscript()
index 1cb20b61176f2b229aab97380f1fa5e6ecb500ea..cde9f8a328323d030d9fabca906be94acdf14dce 100644 (file)
@@ -77,11 +77,12 @@ using libdcp::Size;
  *  @param l Log to write to.
  */
 DCPVideoFrame::DCPVideoFrame (
-       shared_ptr<const Image> image, int f, Eyes eyes, int dcp_fps, int bw, shared_ptr<Log> l
+       shared_ptr<const Image> image, int f, Eyes eyes, ColourConversion c, int dcp_fps, int bw, shared_ptr<Log> l
        )
        : _image (image)
        , _frame (f)
        , _eyes (eyes)
+       , _conversion (c)
        , _frames_per_second (dcp_fps)
        , _j2k_bandwidth (bw)
        , _log (l)
@@ -95,11 +96,27 @@ DCPVideoFrame::DCPVideoFrame (
 shared_ptr<EncodedData>
 DCPVideoFrame::encode_locally ()
 {
+       shared_ptr<libdcp::LUT> in_lut;
+       if (_conversion.input_gamma_linearised) {
+               in_lut = libdcp::SRGBLinearisedGammaLUT::cache.get (12, _conversion.input_gamma);
+       } else {
+               in_lut = libdcp::GammaLUT::cache.get (12, _conversion.input_gamma);
+       }
+
+       /* 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] = _conversion.matrix (i, j);
+               }
+       }
+       
        shared_ptr<libdcp::XYZFrame> xyz = libdcp::rgb_to_xyz (
                _image,
-               libdcp::SRGBLinearisedGammaLUT::cache.get (12, 2.4),
-               libdcp::GammaLUT::cache.get (16, 1 / 2.6),
-               libdcp::colour_matrix::srgb_to_xyz
+               in_lut,
+               libdcp::GammaLUT::cache.get (16, 1 / _conversion.output_gamma),
+               matrix
                );
                
        /* Set the max image and component sizes based on frame_rate */
@@ -224,6 +241,8 @@ DCPVideoFrame::encode_remotely (ServerDescription serv)
 
        socket->connect (*endpoint_iterator);
 
+       /* XXX: colour conversion! */
+
        stringstream s;
        s << "encode please\n"
          << "width " << _image->size().width << "\n"
index ce6444293c2fedfbf1f587161aa43a7e9bf6330d..9e58b587968588ca2aff335ef70fbd886cdf971b 100644 (file)
@@ -102,7 +102,7 @@ public:
 class DCPVideoFrame : public boost::noncopyable
 {
 public:
-       DCPVideoFrame (boost::shared_ptr<const Image>, int, Eyes, int, int, boost::shared_ptr<Log>);
+       DCPVideoFrame (boost::shared_ptr<const Image>, int, Eyes, ColourConversion, int, int, boost::shared_ptr<Log>);
 
        boost::shared_ptr<EncodedData> encode_locally ();
        boost::shared_ptr<EncodedData> encode_remotely (ServerDescription);
@@ -119,6 +119,7 @@ private:
        boost::shared_ptr<const Image> _image;
        int _frame;                      ///< frame index within the DCP's intrinsic duration
        Eyes _eyes;
+       ColourConversion _conversion;
        int _frames_per_second;          ///< Frames per second that we will use for the DCP
        int _j2k_bandwidth;              ///< J2K bandwidth to use
 
index 29fe64e26c993d6f17336e38669a990945032b45..ea175f1f43cdc30b3e9cdad8ab2429337e6b94fb 100644 (file)
@@ -171,7 +171,7 @@ Encoder::frame_done ()
 }
 
 void
-Encoder::process_video (shared_ptr<const Image> image, Eyes eyes, bool same)
+Encoder::process_video (shared_ptr<const Image> image, Eyes eyes, ColourConversion conversion, bool same)
 {
        boost::mutex::scoped_lock lock (_mutex);
 
@@ -205,7 +205,7 @@ Encoder::process_video (shared_ptr<const Image> image, Eyes eyes, bool same)
                TIMING ("adding to queue of %1", _queue.size ());
                _queue.push_back (shared_ptr<DCPVideoFrame> (
                                          new DCPVideoFrame (
-                                                 image, _video_frames_out, eyes, _film->video_frame_rate(),
+                                                 image, _video_frames_out, eyes, conversion, _film->video_frame_rate(),
                                                  _film->j2k_bandwidth(), _film->log()
                                                  )
                                          ));
index c0ea30fcbb0a051582b24ddceb564d9ceeb873f4..44134e568bf819fabeeb3b3f09a3d72f57eb7e17 100644 (file)
@@ -66,7 +66,7 @@ public:
         *  @param i Video frame image.
         *  @param same true if i is the same as the last time we were called.
         */
-       void process_video (boost::shared_ptr<const Image> i, Eyes eyes, bool same);
+       void process_video (boost::shared_ptr<const Image> i, Eyes eyes, ColourConversion, bool same);
 
        /** Call with some audio data */
        void process_audio (boost::shared_ptr<const AudioBuffers>);
index af2e6216a0f730321c6b3b8cc78f82bcb2d0ccb8..f8ccb0142af5d3a95bdb03f4a965971049f50825 100644 (file)
@@ -276,11 +276,11 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image
        _last_video = piece->content;
 #endif
 
-       Video (work_image, eyes, same, time);
+       Video (work_image, eyes, content->colour_conversion(), same, time);
        time += TIME_HZ / _film->video_frame_rate();
 
        if (frc.repeat) {
-               Video (work_image, eyes, true, time);
+               Video (work_image, eyes, content->colour_conversion(), true, time);
                time += TIME_HZ / _film->video_frame_rate();
        }
 
@@ -549,7 +549,7 @@ Player::emit_black ()
        _last_video.reset ();
 #endif
        
-       Video (_black_frame, EYES_BOTH, _last_emit_was_black, _video_position);
+       Video (_black_frame, EYES_BOTH, ColourConversion(), _last_emit_was_black, _video_position);
        _video_position += _film->video_frames_to_time (1);
        _last_emit_was_black = true;
 }
index 85d750f6fd7ef39a668bd8cbab25f58271d7bd80..2261f66eaa6aafb8c09c3c71961e5f152fc5f513 100644 (file)
@@ -62,10 +62,11 @@ public:
        /** Emitted when a video frame is ready.
         *  First parameter is the video image.
         *  Second parameter is the eye(s) that should see this image.
-        *  Third parameter is true if the image is the same as the last one that was emitted.
-        *  Fourth parameter is the time.
+        *  Third parameter is the colour conversion that should be used for this image.
+        *  Fourth parameter is true if the image is the same as the last one that was emitted.
+        *  Fifth parameter is the time.
         */
-       boost::signals2::signal<void (boost::shared_ptr<const Image>, Eyes, bool, Time)> Video;
+       boost::signals2::signal<void (boost::shared_ptr<const Image>, Eyes, ColourConversion, bool, Time)> Video;
        
        /** Emitted when some audio data is ready */
        boost::signals2::signal<void (boost::shared_ptr<const AudioBuffers>, Time)> Audio;
index de265dca430043fdb174e5f014f5a2ba94c14531..e4c281172eb552ea7ca7e784a73b0fb08d530959 100644 (file)
@@ -112,8 +112,10 @@ Server::process (shared_ptr<Socket> socket)
 
        image->read_from_socket (socket);
 
+       /* XXX: colour conversion... */
+
        DCPVideoFrame dcp_video_frame (
-               image, frame, eyes, frames_per_second, j2k_bandwidth, _log
+               image, frame, eyes, ColourConversion(), frames_per_second, j2k_bandwidth, _log
                );
        
        shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally ();
index 3002ef61c9c0f776d3b714bf326cb14ff7073d97..715a158db20b5b8ffe19473cececdec01235f364 100644 (file)
@@ -40,11 +40,11 @@ using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 
 static void
-video_proxy (weak_ptr<Encoder> encoder, shared_ptr<const Image> image, Eyes eyes, bool same)
+video_proxy (weak_ptr<Encoder> encoder, shared_ptr<const Image> image, Eyes eyes, ColourConversion conversion, bool same)
 {
        shared_ptr<Encoder> e = encoder.lock ();
        if (e) {
-               e->process_video (image, eyes, same);
+               e->process_video (image, eyes, conversion, same);
        }
 }
 
@@ -67,7 +67,7 @@ Transcoder::Transcoder (shared_ptr<const Film> f, shared_ptr<Job> j)
        , _player (f->make_player ())
        , _encoder (new Encoder (f, j))
 {
-       _player->Video.connect (bind (video_proxy, _encoder, _1, _2, _3));
+       _player->Video.connect (bind (video_proxy, _encoder, _1, _2, _3, _4));
        _player->Audio.connect (bind (audio_proxy, _encoder, _1));
 }
 
index 8fca090adac4953db6123ff28a17a2daed279741..d8e768bcd6d16b069ab273ae0eb414a5e8d3bce1 100644 (file)
@@ -44,7 +44,7 @@ ContentColourConversionDialog::ContentColourConversionDialog (wxWindow* parent)
        table->Add (_preset_choice);
 
        overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-       overall_sizer->Add (new wxStaticLine (this, wxID_ANY));
+       overall_sizer->Add (new wxStaticLine (this, wxID_ANY), 0, wxEXPAND);
        overall_sizer->Add (_editor);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
index 8c4a6dbcf792367fb07c14207f15eb7e956f9811..e7f8cf0494cd741813f3a74f19d100c91d911355 100644 (file)
@@ -39,7 +39,7 @@ PresetColourConversionDialog::PresetColourConversionDialog (wxWindow* parent)
        table->Add (_name);
 
        overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-       overall_sizer->Add (new wxStaticLine (this, wxID_ANY));
+       overall_sizer->Add (new wxStaticLine (this, wxID_ANY), 0, wxEXPAND);
        overall_sizer->Add (_editor);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
index 7faf47c4158a72e5c86d88c37051a3b827f0cb12..8662f54e8f6a3fa11f482da25b423c32e0e125cb 100644 (file)
@@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE (client_server_test)
                        image,
                        0,
                        EYES_BOTH,
+                       ColourConversion (),
                        24,
                        200000000,
                        log