summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-07 12:12:15 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-07 12:12:15 +0000
commit77f7f3be256f81d2977bccdb236582e18a625ba7 (patch)
tree2b3880043171559a2d6b938c3c1746ba6ea5874c /src/lib
parent48073ddb0a9a6e9c9dd81b04b196230f4372447b (diff)
Make a note in the log when XYZ values are clamped by libdcp on XYZ -> RGB conversion.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_video.cc7
-rw-r--r--src/lib/dcp_video.h3
-rw-r--r--src/lib/encoder.cc8
-rw-r--r--src/lib/image_proxy.h4
-rw-r--r--src/lib/j2k_image_proxy.cc5
-rw-r--r--src/lib/j2k_image_proxy.h2
-rw-r--r--src/lib/log.cc18
-rw-r--r--src/lib/log.h2
-rw-r--r--src/lib/magick_image_proxy.cc3
-rw-r--r--src/lib/magick_image_proxy.h2
-rw-r--r--src/lib/player_video.cc4
-rw-r--r--src/lib/player_video.h2
-rw-r--r--src/lib/raw_image_proxy.cc3
-rw-r--r--src/lib/raw_image_proxy.h2
-rw-r--r--src/lib/server.cc2
15 files changed, 46 insertions, 21 deletions
diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc
index cca199b05..559aef7c6 100644
--- a/src/lib/dcp_video.cc
+++ b/src/lib/dcp_video.cc
@@ -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 */
diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h
index 9a6ae8d91..af4712b2b 100644
--- a/src/lib/dcp_video.h
+++ b/src/lib/dcp_video.h
@@ -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 {
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index da6c96905..6b520571a 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -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 ());
diff --git a/src/lib/image_proxy.h b/src/lib/image_proxy.h
index e2d86b8a7..39cbda27d 100644
--- a/src/lib/image_proxy.h
+++ b/src/lib/image_proxy.h
@@ -24,9 +24,11 @@
* @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 */
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc
index 20bf70cf1..175f4c796 100644
--- a/src/lib/j2k_image_proxy.cc
+++ b/src/lib/j2k_image_proxy.cc
@@ -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]));
}
diff --git a/src/lib/j2k_image_proxy.h b/src/lib/j2k_image_proxy.h
index 7790f617b..c2f04e176 100644
--- a/src/lib/j2k_image_proxy.h
+++ b/src/lib/j2k_image_proxy.h
@@ -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;
diff --git a/src/lib/log.cc b/src/lib/log.cc
index e0ba3aaaa..efea9f6b5 100644
--- a/src/lib/log.cc
+++ b/src/lib/log.cc
@@ -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)
diff --git a/src/lib/log.h b/src/lib/log.h
index f14adc26f..f83c6a902 100644
--- a/src/lib/log.h
+++ b/src/lib/log.h
@@ -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);
diff --git a/src/lib/magick_image_proxy.cc b/src/lib/magick_image_proxy.cc
index e71ee4284..c9cddd899 100644
--- a/src/lib/magick_image_proxy.cc
+++ b/src/lib/magick_image_proxy.cc
@@ -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;
diff --git a/src/lib/magick_image_proxy.h b/src/lib/magick_image_proxy.h
index 632fde8c7..7d2251aeb 100644
--- a/src/lib/magick_image_proxy.h
+++ b/src/lib/magick_image_proxy.h
@@ -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;
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index 94e6f3f2a..ccd52ea67 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -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) {
diff --git a/src/lib/player_video.h b/src/lib/player_video.h
index 1468b7863..6762ea8d1 100644
--- a/src/lib/player_video.h
+++ b/src/lib/player_video.h
@@ -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;
diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc
index 8e8bf8824..8f05f5455 100644
--- a/src/lib/raw_image_proxy.cc
+++ b/src/lib/raw_image_proxy.cc
@@ -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;
}
diff --git a/src/lib/raw_image_proxy.h b/src/lib/raw_image_proxy.h
index a6f777eb3..51ffd4e98 100644
--- a/src/lib/raw_image_proxy.h
+++ b/src/lib/raw_image_proxy.h
@@ -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;
diff --git a/src/lib/server.cc b/src/lib/server.cc
index 3583a19c0..0212356f3 100644
--- a/src/lib/server.cc
+++ b/src/lib/server.cc
@@ -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);