Make a note in the log when XYZ values are clamped by libdcp on XYZ -> RGB conversion.
authorCarl Hetherington <cth@carlh.net>
Wed, 7 Jan 2015 12:12:15 +0000 (12:12 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 7 Jan 2015 12:12:15 +0000 (12:12 +0000)
18 files changed:
src/lib/dcp_video.cc
src/lib/dcp_video.h
src/lib/encoder.cc
src/lib/image_proxy.h
src/lib/j2k_image_proxy.cc
src/lib/j2k_image_proxy.h
src/lib/log.cc
src/lib/log.h
src/lib/magick_image_proxy.cc
src/lib/magick_image_proxy.h
src/lib/player_video.cc
src/lib/player_video.h
src/lib/raw_image_proxy.cc
src/lib/raw_image_proxy.h
src/lib/server.cc
src/tools/server_test.cc
src/wx/film_viewer.cc
test/client_server_test.cc

index cca199b05f793d56e3ba6001856421e0ddf72995..559aef7c6105ac47ec8f4f43c90c2deb9c99ed47 100644 (file)
@@ -28,7 +28,6 @@
  *  of images that require encoding.
  */
 
-#include "film.h"
 #include "dcp_video.h"
 #include "config.h"
 #include "exceptions.h"
@@ -108,17 +107,17 @@ DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml::
  *  @return Encoded data.
  */
 shared_ptr<EncodedData>
-DCPVideo::encode_locally ()
+DCPVideo::encode_locally (dcp::NoteHandler note)
 {
        shared_ptr<dcp::XYZFrame> xyz;
 
        if (_frame->colour_conversion()) {
                xyz = dcp::rgb_to_xyz (
-                       _frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles),
+                       _frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles, note),
                        _frame->colour_conversion().get()
                        );
        } else {
-               xyz = dcp::xyz_to_xyz (_frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles));
+               xyz = dcp::xyz_to_xyz (_frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles, note));
        }
 
        /* Set the max image and component sizes based on frame_rate */
index 9a6ae8d914b9e798d282de87e298ebac42dc231f..af4712b2b1cd2ff2e4ba262c646ce95ea5991fed 100644 (file)
@@ -26,7 +26,6 @@
  *  @brief A single frame of video destined for a DCP.
  */
 
-class Film;
 class ServerDescription;
 class Scaler;
 class Image;
@@ -50,7 +49,7 @@ public:
        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 ();
+       boost::shared_ptr<EncodedData> encode_locally (dcp::NoteHandler note);
        boost::shared_ptr<EncodedData> encode_remotely (ServerDescription);
 
        int index () const {
index da6c969052f4a4d8e59f37043263b2c3fa258851..6b520571a7430efd7f9a21636cf3d8402af2f827 100644 (file)
@@ -127,7 +127,11 @@ Encoder::end ()
        for (list<shared_ptr<DCPVideo> >::iterator i = _queue.begin(); i != _queue.end(); ++i) {
                LOG_GENERAL (N_("Encode left-over frame %1"), (*i)->index ());
                try {
-                       _writer->write ((*i)->encode_locally(), (*i)->index (), (*i)->eyes ());
+                       _writer->write (
+                               (*i)->encode_locally (boost::bind (&Log::dcp_log, _film->log().get(), _1, _2)),
+                               (*i)->index (),
+                               (*i)->eyes ()
+                               );
                        frame_done ();
                } catch (std::exception& e) {
                        LOG_ERROR (N_("Local encode failed (%1)"), e.what ());
@@ -322,7 +326,7 @@ try
                        } else {
                                try {
                                        LOG_TIMING ("[%1] encoder thread begins local encode of %2", boost::this_thread::get_id(), vf->index());
-                                       encoded = vf->encode_locally ();
+                                       encoded = vf->encode_locally (boost::bind (&Log::dcp_log, _film->log().get(), _1, _2));
                                        LOG_TIMING ("[%1] encoder thread finishes local encode of %2", boost::this_thread::get_id(), vf->index());
                                } catch (std::exception& e) {
                                        LOG_ERROR (N_("Local encode failed (%1)"), e.what ());
index e2d86b8a7ca05a31f3815f183d885c7c5f376730..39cbda27d85e4572c99480b0b921064775e10099 100644 (file)
  *  @brief ImageProxy and subclasses.
  */
 
+#include <dcp/types.h>
 #include <Magick++.h>
 #include <libxml++/libxml++.h>
 #include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
 #include <boost/filesystem.hpp>
 
 class Image;
@@ -58,7 +60,7 @@ public:
        virtual ~ImageProxy () {}
 
        /** @return Image (which must be aligned) */
-       virtual boost::shared_ptr<Image> image () const = 0;
+       virtual boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const = 0;
        virtual void add_metadata (xmlpp::Node *) const = 0;
        virtual void send_binary (boost::shared_ptr<Socket>) const = 0;
        /** @return true if our image is definitely the same as another, false if it is probably not */
index 20bf70cf17eb92eb710905a2aad5250d8502d052..175f4c796e6afc039cd6f216da68a608257463dd 100644 (file)
@@ -30,6 +30,7 @@
 
 using std::string;
 using boost::shared_ptr;
+using boost::optional;
 
 /** Construct a J2KImageProxy from a JPEG2000 file */
 J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size)
@@ -74,12 +75,12 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
 }
 
 shared_ptr<Image>
-J2KImageProxy::image () const
+J2KImageProxy::image (optional<dcp::NoteHandler> note) const
 {
        shared_ptr<Image> image (new Image (PIX_FMT_RGB48LE, _size, false));
 
        if (_mono) {
-               _mono->rgb_frame (reinterpret_cast<uint16_t*> (image->data()[0]));
+               _mono->rgb_frame (reinterpret_cast<uint16_t*> (image->data()[0]), note);
        } else {
                _stereo->rgb_frame (_eye, reinterpret_cast<uint16_t*> (image->data()[0]));
        }
index 7790f617b0f95789d1e6275074e0617d28d76d27..c2f04e1768e8bbaee0482b8b248667068f2aecce 100644 (file)
@@ -30,7 +30,7 @@ public:
        J2KImageProxy (boost::shared_ptr<const dcp::StereoPictureFrame> frame, dcp::Size, dcp::Eye);
        J2KImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
 
-       boost::shared_ptr<Image> image () const;
+       boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
        void add_metadata (xmlpp::Node *) const;
        void send_binary (boost::shared_ptr<Socket>) const;
 
index e0ba3aaaaba87f9458c8cc365e12986dfde176ee..efea9f6b55bc704535d07d64d7c7dd48030826c1 100644 (file)
@@ -95,7 +95,23 @@ Log::microsecond_log (string m, int t)
        SafeStringStream s;
        s << tv.tv_sec << N_(":") << tv.tv_usec << N_(" ") << m;
        do_log (s.str ());
-}      
+}
+
+void
+Log::dcp_log (dcp::NoteType type, string m)
+{
+       switch (type) {
+       case dcp::DCP_PROGRESS:
+               log (m, TYPE_GENERAL);
+               break;
+       case dcp::DCP_ERROR:
+               log (m, TYPE_ERROR);
+               break;
+       case dcp::DCP_NOTE:
+               log (m, TYPE_WARNING);
+               break;
+       }
+}
 
 void
 Log::set_types (int t)
index f14adc26fd054034893c589941498b887700df42..f83c6a90204ef675c93a89f7b0100f760c7efe01 100644 (file)
@@ -24,6 +24,7 @@
  *  @brief A very simple logging class.
  */
 
+#include <dcp/types.h>
 #include <boost/thread/mutex.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/signals2.hpp>
@@ -46,6 +47,7 @@ public:
 
        void log (std::string message, int type);
        void microsecond_log (std::string message, int type);
+       void dcp_log (dcp::NoteType type, std::string message);
 
        void set_types (int types);
 
index e71ee4284f041d5c1acb2154e8896dcaf885b7f7..c9cddd8997fc71ae1d3d4c58f037d4c289b807c0 100644 (file)
@@ -29,6 +29,7 @@
 using std::string;
 using std::cout;
 using boost::shared_ptr;
+using boost::optional;
 using boost::dynamic_pointer_cast;
 
 MagickImageProxy::MagickImageProxy (boost::filesystem::path path)
@@ -62,7 +63,7 @@ MagickImageProxy::MagickImageProxy (shared_ptr<cxml::Node>, shared_ptr<Socket> s
 }
 
 shared_ptr<Image>
-MagickImageProxy::image () const
+MagickImageProxy::image (optional<dcp::NoteHandler>) const
 {
        if (_image) {
                return _image;
index 632fde8c79c2fc0a468d6d1647640b04c4544149..7d2251aebb491408aa3096eef8a8bb227943f62c 100644 (file)
@@ -25,7 +25,7 @@ public:
        MagickImageProxy (boost::filesystem::path);
        MagickImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
 
-       boost::shared_ptr<Image> image () const;
+       boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
        void add_metadata (xmlpp::Node *) const;
        void send_binary (boost::shared_ptr<Socket>) const;
        bool same (boost::shared_ptr<const ImageProxy> other) const;
index 94e6f3f2acd87afc357a06a99fcad7de357a4f11..ccd52ea677acda1bbdcd754996c321b43934a2dd 100644 (file)
@@ -94,9 +94,9 @@ PlayerVideo::set_subtitle (PositionImage image)
 }
 
 shared_ptr<Image>
-PlayerVideo::image (AVPixelFormat pixel_format, bool burn_subtitle) const
+PlayerVideo::image (AVPixelFormat pixel_format, bool burn_subtitle, dcp::NoteHandler note) const
 {
-       shared_ptr<Image> im = _in->image ();
+       shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note));
        
        Crop total_crop = _crop;
        switch (_part) {
index 1468b78637e23f1fd753a51c4eccec7baf16dc45..6762ea8d1b219665066964cbc941ba5ae6927397 100644 (file)
@@ -56,7 +56,7 @@ public:
 
        void set_subtitle (PositionImage);
        
-       boost::shared_ptr<Image> image (AVPixelFormat pix_fmt, bool burn_subtitle) const;
+       boost::shared_ptr<Image> image (AVPixelFormat pix_fmt, bool burn_subtitle, dcp::NoteHandler note) const;
 
        void add_metadata (xmlpp::Node* node, bool send_subtitles) const;
        void send_binary (boost::shared_ptr<Socket> socket, bool send_subtitles) const;
index 8e8bf88248be5bf2b70e2a2f1055283850e6b9b5..8f05f54558301e45f895a338b5e74738e48e006e 100644 (file)
@@ -30,6 +30,7 @@ extern "C" {
 
 using std::string;
 using boost::shared_ptr;
+using boost::optional;
 
 RawImageProxy::RawImageProxy (shared_ptr<Image> image)
        : _image (image)
@@ -48,7 +49,7 @@ RawImageProxy::RawImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
 }
 
 shared_ptr<Image>
-RawImageProxy::image () const
+RawImageProxy::image (optional<dcp::NoteHandler>) const
 {
        return _image;
 }
index a6f777eb3d251c1bcafa5a0f59e4a9990cc8ce8d..51ffd4e9865eeafe4c9e9bd3742b37970c51d3eb 100644 (file)
@@ -28,7 +28,7 @@ public:
        RawImageProxy (boost::shared_ptr<Image>);
        RawImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
 
-       boost::shared_ptr<Image> image () const;
+       boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
        void add_metadata (xmlpp::Node *) const;
        void send_binary (boost::shared_ptr<Socket>) const;
        
index 3583a19c09d447e04e4e73dc7085757c832f53b0..0212356f3ea90e6537af41544757c8248df52c82 100644 (file)
@@ -118,7 +118,7 @@ Server::process (shared_ptr<Socket> socket, struct timeval& after_read, struct t
 
        gettimeofday (&after_read, 0);
        
-       shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally ();
+       shared_ptr<EncodedData> encoded = dcp_video_frame.encode_locally (boost::bind (&Log::dcp_log, _log.get(), _1, _2));
 
        gettimeofday (&after_encode, 0);
        
index 9223efb3eb6642592e1fa36af82a0a266bca774f..5cb1123b14bd9ff5c209c763f162bb0e6100abfa 100644 (file)
@@ -59,7 +59,7 @@ process_video (shared_ptr<PlayerVideo> pvf)
 
        ++frame_count;
 
-       shared_ptr<EncodedData> local_encoded = local->encode_locally ();
+       shared_ptr<EncodedData> local_encoded = local->encode_locally (boost::bind (&Log::dcp_log, log_.get(), _1, _2));
        shared_ptr<EncodedData> remote_encoded;
 
        string remote_error;
index de12564d7756b61730b5ad5f9a54d90f529fbbeb..21d4ae1fe1938e1da5d45de9e4b3e9a8bb0d07a7 100644 (file)
  *  @brief A wx widget to view a preview of a Film.
  */
 
-#include <iostream>
-#include <iomanip>
-#include <wx/tglbtn.h>
-#include <dcp/exceptions.h>
 #include "lib/film.h"
 #include "lib/ratio.h"
 #include "lib/util.h"
 #include "lib/video_content.h"
 #include "lib/video_decoder.h"
 #include "lib/timer.h"
+#include "lib/log.h"
 #include "film_viewer.h"
 #include "wx_util.h"
+#include <dcp/exceptions.h>
+#include <wx/tglbtn.h>
+#include <iostream>
+#include <iomanip>
 
 using std::string;
 using std::pair;
@@ -179,7 +180,7 @@ FilmViewer::get (DCPTime p, bool accurate)
        
        if (!pvf.empty ()) {
                try {
-                       _frame = pvf.front()->image (PIX_FMT_RGB24, true);
+                       _frame = pvf.front()->image (PIX_FMT_RGB24, true, boost::bind (&Log::dcp_log, _film->log().get(), _1, _2));
                        _frame = _frame->scale (_frame->size(), Scaler::from_id ("fastbilinear"), PIX_FMT_RGB24, false);
                        _position = pvf.front()->time ();
                        _inter_position = pvf.front()->inter_position ();
index 0cd728165199e0a9c1a604352681c50617dc99e6..daa1fa20f37ba469a3f99f26eb315095a115276e 100644 (file)
@@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
                        )
                );
 
-       shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
+       shared_ptr<EncodedData> locally_encoded = frame->encode_locally (boost::bind (&Log::dcp_log, log.get(), _1, _2));
        BOOST_ASSERT (locally_encoded);
        
        Server* server = new Server (log, true);
@@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
                        )
                );
 
-       shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
+       shared_ptr<EncodedData> locally_encoded = frame->encode_locally (boost::bind (&Log::dcp_log, log.get(), _1, _2));
        BOOST_ASSERT (locally_encoded);
        
        Server* server = new Server (log, true);