* of images that require encoding.
*/
-#include "film.h"
#include "dcp_video.h"
#include "config.h"
#include "exceptions.h"
* @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 */
* @brief A single frame of video destined for a DCP.
*/
-class Film;
class ServerDescription;
class Scaler;
class Image;
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 {
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 ());
} 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 ());
* @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;
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 */
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)
}
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]));
}
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;
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)
* @brief A very simple logging class.
*/
+#include <dcp/types.h>
#include <boost/thread/mutex.hpp>
#include <boost/filesystem.hpp>
#include <boost/signals2.hpp>
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);
using std::string;
using std::cout;
using boost::shared_ptr;
+using boost::optional;
using boost::dynamic_pointer_cast;
MagickImageProxy::MagickImageProxy (boost::filesystem::path path)
}
shared_ptr<Image>
-MagickImageProxy::image () const
+MagickImageProxy::image (optional<dcp::NoteHandler>) const
{
if (_image) {
return _image;
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;
}
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) {
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;
using std::string;
using boost::shared_ptr;
+using boost::optional;
RawImageProxy::RawImageProxy (shared_ptr<Image> image)
: _image (image)
}
shared_ptr<Image>
-RawImageProxy::image () const
+RawImageProxy::image (optional<dcp::NoteHandler>) const
{
return _image;
}
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;
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);
++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;
* @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;
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 ();
)
);
- 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);
)
);
- 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);