summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-10-21 19:14:58 +0100
committerCarl Hetherington <cth@carlh.net>2014-10-21 19:14:58 +0100
commitcb990adba9c57e5107ef2aa9716cf0a26c1df83d (patch)
treee59571d05db47b6f1070c85331ba351fd2794adf /src/lib
parent8a19e2b56d3b95a18ae8ac9965eab750c28d30ad (diff)
parent5c8599593ee8b3ef05d5c55c5f0885a2d8bfb9d2 (diff)
Merge master.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_video.cc2
-rw-r--r--src/lib/image.cc2
-rw-r--r--src/lib/image_examiner.cc2
-rw-r--r--src/lib/player_video.cc4
-rw-r--r--src/lib/player_video.h5
-rw-r--r--src/lib/player_video_frame.cc148
-rw-r--r--src/lib/util.cc5
7 files changed, 164 insertions, 4 deletions
diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc
index ccfc800c8..f6c671fd1 100644
--- a/src/lib/dcp_video.cc
+++ b/src/lib/dcp_video.cc
@@ -125,7 +125,7 @@ DCPVideo::encode_locally ()
}
shared_ptr<dcp::XYZFrame> xyz = dcp::rgb_to_xyz (
- _frame->image (_burn_subtitles),
+ _frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles),
in_lut,
dcp::GammaLUT::cache.get (16, 1 / _frame->colour_conversion().output_gamma, false),
matrix
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 0da2d1e48..bc64ba3b8 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -322,6 +322,8 @@ Image::make_black ()
case PIX_FMT_ABGR:
case PIX_FMT_BGRA:
case PIX_FMT_RGB555LE:
+ case PIX_FMT_RGB48LE:
+ case PIX_FMT_RGB48BE:
memset (data()[0], 0, lines(0) * stride()[0]);
break;
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
index 004b89e65..75ccb6a3e 100644
--- a/src/lib/image_examiner.cc
+++ b/src/lib/image_examiner.cc
@@ -37,7 +37,9 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
: _film (film)
, _image_content (content)
{
+#ifdef DCPOMATIC_IMAGE_MAGICK
using namespace MagickCore;
+#endif
Magick::Image* image = new Magick::Image (content->path(0).string());
_video_size = dcp::Size (image->columns(), image->rows());
delete image;
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index 2feb52f42..8e6fcd5f3 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -90,7 +90,7 @@ PlayerVideo::set_subtitle (PositionImage image)
}
shared_ptr<Image>
-PlayerVideo::image (bool burn_subtitle) const
+PlayerVideo::image (AVPixelFormat pixel_format, bool burn_subtitle) const
{
shared_ptr<Image> im = _in->image ();
@@ -112,7 +112,7 @@ PlayerVideo::image (bool burn_subtitle) const
break;
}
- shared_ptr<Image> out = im->crop_scale_window (total_crop, _inter_size, _out_size, _scaler, PIX_FMT_RGB24, true);
+ shared_ptr<Image> out = im->crop_scale_window (total_crop, _inter_size, _out_size, _scaler, pixel_format, true);
if (burn_subtitle && _subtitle.image) {
out->alpha_blend (_subtitle.image, _subtitle.position);
diff --git a/src/lib/player_video.h b/src/lib/player_video.h
index 0f5e83b10..e9d260972 100644
--- a/src/lib/player_video.h
+++ b/src/lib/player_video.h
@@ -18,6 +18,9 @@
*/
#include <boost/shared_ptr.hpp>
+extern "C" {
+#include <libavutil/pixfmt.h>
+}
#include "types.h"
#include "position.h"
#include "colour_conversion.h"
@@ -54,7 +57,7 @@ public:
void set_subtitle (PositionImage);
- boost::shared_ptr<Image> image (bool burn_subtitle) const;
+ boost::shared_ptr<Image> image (AVPixelFormat pix_fmt, bool burn_subtitle) 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/player_video_frame.cc b/src/lib/player_video_frame.cc
new file mode 100644
index 000000000..63ddc637b
--- /dev/null
+++ b/src/lib/player_video_frame.cc
@@ -0,0 +1,148 @@
+/*
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <libdcp/raw_convert.h>
+#include "player_video_frame.h"
+#include "image.h"
+#include "image_proxy.h"
+#include "scaler.h"
+
+using std::string;
+using std::cout;
+using boost::shared_ptr;
+using libdcp::raw_convert;
+
+PlayerVideoFrame::PlayerVideoFrame (
+ shared_ptr<const ImageProxy> in,
+ Crop crop,
+ libdcp::Size inter_size,
+ libdcp::Size out_size,
+ Scaler const * scaler,
+ Eyes eyes,
+ Part part,
+ ColourConversion colour_conversion
+ )
+ : _in (in)
+ , _crop (crop)
+ , _inter_size (inter_size)
+ , _out_size (out_size)
+ , _scaler (scaler)
+ , _eyes (eyes)
+ , _part (part)
+ , _colour_conversion (colour_conversion)
+{
+
+}
+
+PlayerVideoFrame::PlayerVideoFrame (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket, shared_ptr<Log> log)
+{
+ _crop = Crop (node);
+
+ _inter_size = libdcp::Size (node->number_child<int> ("InterWidth"), node->number_child<int> ("InterHeight"));
+ _out_size = libdcp::Size (node->number_child<int> ("OutWidth"), node->number_child<int> ("OutHeight"));
+ _scaler = Scaler::from_id (node->string_child ("Scaler"));
+ _eyes = (Eyes) node->number_child<int> ("Eyes");
+ _part = (Part) node->number_child<int> ("Part");
+ _colour_conversion = ColourConversion (node);
+
+ _in = image_proxy_factory (node->node_child ("In"), socket, log);
+
+ if (node->optional_number_child<int> ("SubtitleX")) {
+
+ _subtitle_position = Position<int> (node->number_child<int> ("SubtitleX"), node->number_child<int> ("SubtitleY"));
+
+ shared_ptr<Image> image (
+ new Image (PIX_FMT_RGBA, libdcp::Size (node->number_child<int> ("SubtitleWidth"), node->number_child<int> ("SubtitleHeight")), true)
+ );
+
+ image->read_from_socket (socket);
+ _subtitle_image = image;
+ }
+}
+
+void
+PlayerVideoFrame::set_subtitle (shared_ptr<const Image> image, Position<int> pos)
+{
+ _subtitle_image = image;
+ _subtitle_position = pos;
+}
+
+shared_ptr<Image>
+PlayerVideoFrame::image (AVPixelFormat pixel_format) const
+{
+ shared_ptr<Image> im = _in->image ();
+
+ Crop total_crop = _crop;
+ switch (_part) {
+ case PART_LEFT_HALF:
+ total_crop.right += im->size().width / 2;
+ break;
+ case PART_RIGHT_HALF:
+ total_crop.left += im->size().width / 2;
+ break;
+ case PART_TOP_HALF:
+ total_crop.bottom += im->size().height / 2;
+ break;
+ case PART_BOTTOM_HALF:
+ total_crop.top += im->size().height / 2;
+ break;
+ default:
+ break;
+ }
+
+ shared_ptr<Image> out = im->crop_scale_window (total_crop, _inter_size, _out_size, _scaler, pixel_format, false);
+
+ Position<int> const container_offset ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.width) / 2);
+
+ if (_subtitle_image) {
+ out->alpha_blend (_subtitle_image, _subtitle_position);
+ }
+
+ return out;
+}
+
+void
+PlayerVideoFrame::add_metadata (xmlpp::Node* node) const
+{
+ _crop.as_xml (node);
+ _in->add_metadata (node->add_child ("In"));
+ node->add_child("InterWidth")->add_child_text (raw_convert<string> (_inter_size.width));
+ node->add_child("InterHeight")->add_child_text (raw_convert<string> (_inter_size.height));
+ node->add_child("OutWidth")->add_child_text (raw_convert<string> (_out_size.width));
+ node->add_child("OutHeight")->add_child_text (raw_convert<string> (_out_size.height));
+ node->add_child("Scaler")->add_child_text (_scaler->id ());
+ node->add_child("Eyes")->add_child_text (raw_convert<string> (_eyes));
+ node->add_child("Part")->add_child_text (raw_convert<string> (_part));
+ _colour_conversion.as_xml (node);
+ if (_subtitle_image) {
+ node->add_child ("SubtitleWidth")->add_child_text (raw_convert<string> (_subtitle_image->size().width));
+ node->add_child ("SubtitleHeight")->add_child_text (raw_convert<string> (_subtitle_image->size().height));
+ node->add_child ("SubtitleX")->add_child_text (raw_convert<string> (_subtitle_position.x));
+ node->add_child ("SubtitleY")->add_child_text (raw_convert<string> (_subtitle_position.y));
+ }
+}
+
+void
+PlayerVideoFrame::send_binary (shared_ptr<Socket> socket) const
+{
+ _in->send_binary (socket);
+ if (_subtitle_image) {
+ _subtitle_image->write_to_socket (socket);
+ }
+}
diff --git a/src/lib/util.cc b/src/lib/util.cc
index e0db5de2e..7a0f1a17a 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -44,7 +44,12 @@
#include <glib.h>
#include <openjpeg.h>
#include <pangomm/init.h>
+#ifdef DCPOMATIC_IMAGE_MAGICK
#include <magick/MagickCore.h>
+#else
+#include <magick/common.h>
+#include <magick/magick_config.h>
+#endif
#include <magick/version.h>
#include <dcp/version.h>
#include <dcp/util.h>