summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-10-12 00:46:00 +0100
committerCarl Hetherington <cth@carlh.net>2018-10-12 00:46:00 +0100
commit72b11d5eb036651b6ff68edf3ed270e8fc52960f (patch)
treec6b88de5c86696f186c93322d50fd954d09c9349 /src/lib
parentc4ac1ba47652884a647103ec49b2de4c0b6e60a9 (diff)
Change MagickImageProxy to FFmpegImageProxy and make it use FFmpeg
to decode images. Hence remove {Image,Graphics}Magick.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_decoder.cc4
-rw-r--r--src/lib/environment_info.cc18
-rw-r--r--src/lib/ffmpeg_image_proxy.cc214
-rw-r--r--src/lib/ffmpeg_image_proxy.h (renamed from src/lib/magick_image_proxy.h)18
-rw-r--r--src/lib/image.cc61
-rw-r--r--src/lib/image.h1
-rw-r--r--src/lib/image_decoder.cc5
-rw-r--r--src/lib/image_examiner.cc8
-rw-r--r--src/lib/image_proxy.cc6
-rw-r--r--src/lib/image_proxy.h1
-rw-r--r--src/lib/j2k_image_proxy.cc1
-rw-r--r--src/lib/j2k_image_proxy.h3
-rw-r--r--src/lib/magick_image_proxy.cc192
-rw-r--r--src/lib/player_video.cc2
-rw-r--r--src/lib/raw_image_proxy.cc6
-rw-r--r--src/lib/raw_image_proxy.h1
-rw-r--r--src/lib/util.cc7
-rw-r--r--src/lib/wscript4
18 files changed, 241 insertions, 311 deletions
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index 4e595da43..72db5369c 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -25,6 +25,7 @@
#include "audio_decoder.h"
#include "j2k_image_proxy.h"
#include "text_decoder.h"
+#include "ffmpeg_image_proxy.h"
#include "image.h"
#include "config.h"
#include <dcp/dcp.h>
@@ -243,7 +244,8 @@ DCPDecoder::pass_texts (ContentTime next, shared_ptr<dcp::SubtitleAsset> asset,
shared_ptr<dcp::SubtitleImage> ii = dynamic_pointer_cast<dcp::SubtitleImage> (i);
if (ii) {
- shared_ptr<Image> image(new Image(ii->png_image()));
+ FFmpegImageProxy proxy (ii->png_image());
+ shared_ptr<Image> image = proxy.image().first;
/* set up rect with height and width */
dcpomatic::Rect<double> rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height));
diff --git a/src/lib/environment_info.cc b/src/lib/environment_info.cc
index 6fb75a037..68496f996 100644
--- a/src/lib/environment_info.cc
+++ b/src/lib/environment_info.cc
@@ -24,21 +24,6 @@
#include "cross.h"
#include <dcp/version.h>
#include <libssh/libssh.h>
-#ifdef DCPOMATIC_IMAGE_MAGICK
-/* ImageMagick */
-#ifdef DCPOMATIC_MAGICKCORE_MAGICK
-#include <magick/MagickCore.h>
-#include <magick/version.h>
-#else
-#include <MagickCore/MagickCore.h>
-#include <MagickCore/version.h>
-#endif
-#else
-/* GraphicsMagick */
-#include <magick/common.h>
-#include <magick/magick_config.h>
-#include <magick/version.h>
-#endif
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
@@ -77,13 +62,12 @@ dependency_version_summary ()
{
char buffer[512];
snprintf (
- buffer, sizeof(buffer), "libavcodec %s, libavfilter %s, libavformat %s, libavutil %s, libswscale %s, %s, libssh %s, libdcp %s git %s",
+ buffer, sizeof(buffer), "libavcodec %s, libavfilter %s, libavformat %s, libavutil %s, libswscale %s, libssh %s, libdcp %s git %s",
ffmpeg_version_to_string(avcodec_version()).c_str(),
ffmpeg_version_to_string(avfilter_version()).c_str(),
ffmpeg_version_to_string(avformat_version()).c_str(),
ffmpeg_version_to_string(avutil_version()).c_str(),
ffmpeg_version_to_string(swscale_version()).c_str(),
- MagickVersion,
ssh_version(0),
dcp::version, dcp::git_commit
);
diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc
new file mode 100644
index 000000000..c83bebcb5
--- /dev/null
+++ b/src/lib/ffmpeg_image_proxy.cc
@@ -0,0 +1,214 @@
+/*
+ Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "ffmpeg_image_proxy.h"
+#include "cross.h"
+#include "exceptions.h"
+#include "dcpomatic_socket.h"
+#include "image.h"
+#include "compose.hpp"
+#include "util.h"
+#include <dcp/raw_convert.h>
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+}
+#include <libxml++/libxml++.h>
+#include <iostream>
+
+#include "i18n.h"
+
+using std::string;
+using std::cout;
+using std::pair;
+using std::min;
+using std::make_pair;
+using boost::shared_ptr;
+using boost::optional;
+using boost::dynamic_pointer_cast;
+using dcp::raw_convert;
+
+FFmpegImageProxy::FFmpegImageProxy (boost::filesystem::path path)
+ : _data (path)
+ , _pos (0)
+ , _path (path)
+{
+
+}
+
+FFmpegImageProxy::FFmpegImageProxy (dcp::Data data)
+ : _data (data)
+ , _pos (0)
+{
+
+}
+
+FFmpegImageProxy::FFmpegImageProxy (shared_ptr<cxml::Node>, shared_ptr<Socket> socket)
+ : _pos (0)
+{
+ uint32_t const size = socket->read_uint32 ();
+ _data = dcp::Data (size);
+ socket->read (_data.data().get(), size);
+}
+
+static int
+avio_read_wrapper (void* data, uint8_t* buffer, int amount)
+{
+ return reinterpret_cast<FFmpegImageProxy*>(data)->avio_read (buffer, amount);
+}
+
+static int64_t
+avio_seek_wrapper (void* data, int64_t offset, int whence)
+{
+ return reinterpret_cast<FFmpegImageProxy*>(data)->avio_seek (offset, whence);
+}
+
+int
+FFmpegImageProxy::avio_read (uint8_t* buffer, int const amount)
+{
+ int const to_do = min(int64_t(amount), _data.size() - _pos);
+ memcpy (buffer, _data.data().get() + _pos, to_do);
+ _pos += to_do;
+ return to_do;
+}
+
+int64_t
+FFmpegImageProxy::avio_seek (int64_t const pos, int whence)
+{
+ switch (whence) {
+ case AVSEEK_SIZE:
+ return _data.size();
+ case SEEK_CUR:
+ _pos += pos;
+ break;
+ case SEEK_SET:
+ _pos = pos;
+ break;
+ case SEEK_END:
+ _pos = _data.size() - pos;
+ break;
+ }
+
+ return _pos;
+}
+
+pair<shared_ptr<Image>, int>
+FFmpegImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size>) const
+{
+ boost::mutex::scoped_lock lm (_mutex);
+
+ if (_image) {
+ return make_pair (_image, 0);
+ }
+
+ uint8_t* avio_buffer = static_cast<uint8_t*> (wrapped_av_malloc(4096));
+ AVIOContext* avio_context = avio_alloc_context (avio_buffer, 4096, 0, const_cast<FFmpegImageProxy*>(this), avio_read_wrapper, 0, avio_seek_wrapper);
+ AVFormatContext* format_context = avformat_alloc_context ();
+ format_context->pb = avio_context;
+
+ AVDictionary* options = 0;
+ /* These durations are in microseconds, and represent how far into the content file
+ we will look for streams.
+ */
+ av_dict_set (&options, "analyzeduration", raw_convert<string>(5 * 60 * 1000000).c_str(), 0);
+ av_dict_set (&options, "probesize", raw_convert<string>(5 * 60 * 1000000).c_str(), 0);
+
+ int e = avformat_open_input (&format_context, 0, 0, &options);
+ if (e < 0) {
+ throw OpenFileError (_path->string(), e, true);
+ }
+
+ if (avformat_find_stream_info(format_context, 0) < 0) {
+ throw DecodeError (_("could not find stream information"));
+ }
+
+ DCPOMATIC_ASSERT (format_context->nb_streams == 1);
+
+ AVFrame* frame = av_frame_alloc ();
+ if (!frame) {
+ throw DecodeError (N_("could not allocate frame"));
+ }
+
+ AVCodecContext* codec_context = format_context->streams[0]->codec;
+ AVCodec* codec = avcodec_find_decoder (codec_context->codec_id);
+ DCPOMATIC_ASSERT (codec);
+
+ if (avcodec_open2 (codec_context, codec, 0) < 0) {
+ throw DecodeError (N_("could not open decoder"));
+ }
+
+ AVPacket packet;
+ int r = av_read_frame (format_context, &packet);
+ if (r < 0) {
+ throw DecodeError (N_("could not read frame"));
+ }
+
+ int frame_finished;
+ if (avcodec_decode_video2(codec_context, frame, &frame_finished, &packet) < 0 || !frame_finished) {
+ throw DecodeError (N_("could not decode video"));
+ }
+
+ _image.reset (new Image (frame));
+
+ av_frame_free (&frame);
+ avformat_close_input (&format_context);
+ av_free (avio_context->buffer);
+ av_free (avio_context);
+
+ return make_pair (_image, 0);
+}
+
+void
+FFmpegImageProxy::add_metadata (xmlpp::Node* node) const
+{
+ node->add_child("Type")->add_child_text (N_("FFmpeg"));
+}
+
+void
+FFmpegImageProxy::send_binary (shared_ptr<Socket> socket) const
+{
+ socket->write (_data.size());
+ socket->write (_data.data().get(), _data.size());
+}
+
+bool
+FFmpegImageProxy::same (shared_ptr<const ImageProxy> other) const
+{
+ shared_ptr<const FFmpegImageProxy> mp = dynamic_pointer_cast<const FFmpegImageProxy> (other);
+ if (!mp) {
+ return false;
+ }
+
+ if (_data.size() != mp->_data.size()) {
+ return false;
+ }
+
+ return memcmp (_data.data().get(), mp->_data.data().get(), _data.size()) == 0;
+}
+
+size_t
+FFmpegImageProxy::memory_used () const
+{
+ size_t m = _data.size();
+ if (_image) {
+ m += _image->memory_used();
+ }
+ return m;
+}
diff --git a/src/lib/magick_image_proxy.h b/src/lib/ffmpeg_image_proxy.h
index 62f3afa2e..0fa8774b8 100644
--- a/src/lib/magick_image_proxy.h
+++ b/src/lib/ffmpeg_image_proxy.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -19,15 +19,16 @@
*/
#include "image_proxy.h"
-#include <Magick++.h>
+#include <dcp/data.h>
#include <boost/thread/mutex.hpp>
#include <boost/filesystem.hpp>
-class MagickImageProxy : public ImageProxy
+class FFmpegImageProxy : public ImageProxy
{
public:
- explicit MagickImageProxy (boost::filesystem::path);
- MagickImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
+ explicit FFmpegImageProxy (boost::filesystem::path);
+ explicit FFmpegImageProxy (dcp::Data);
+ FFmpegImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
std::pair<boost::shared_ptr<Image>, int> image (
boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> (),
@@ -37,11 +38,14 @@ public:
void add_metadata (xmlpp::Node *) const;
void send_binary (boost::shared_ptr<Socket>) const;
bool same (boost::shared_ptr<const ImageProxy> other) const;
- AVPixelFormat pixel_format () const;
size_t memory_used () const;
+ int avio_read (uint8_t* buffer, int const amount);
+ int64_t avio_seek (int64_t const pos, int whence);
+
private:
- Magick::Blob _blob;
+ dcp::Data _data;
+ mutable int64_t _pos;
/** Path of a file that this image came from, if applicable; stored so that
failed-decode errors can give more detail.
*/
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 75345cb06..0590a4e78 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -30,7 +30,6 @@
#include "dcpomatic_socket.h"
#include <dcp/rgb_xyz.h>
#include <dcp/transfer_function.h>
-#include <Magick++.h>
extern "C" {
#include <libswscale/swscale.h>
#include <libavutil/pixfmt.h>
@@ -794,34 +793,6 @@ Image::Image (AVPixelFormat p, dcp::Size s, bool aligned, int extra_pixels)
allocate ();
}
-/** Construct an Image from some PNG data */
-Image::Image (dcp::Data png)
-{
- Magick::Blob blob;
- blob.update (png.data().get(), png.size());
- Magick::Image* magick_image = new Magick::Image (blob);
- _size = dcp::Size(magick_image->columns(), magick_image->rows());
- _pixel_format = AV_PIX_FMT_BGRA;
- _aligned = true;
- _extra_pixels = 0;
- allocate ();
-
- /* Write line-by-line here as _image must be aligned, and write() cannot be told about strides */
- uint8_t* p = data()[0];
- for (int i = 0; i < _size.height; ++i) {
-#ifdef DCPOMATIC_HAVE_MAGICKCORE_NAMESPACE
- using namespace MagickCore;
-#endif
-#ifdef DCPOMATIC_HAVE_MAGICKLIB_NAMESPACE
- using namespace MagickLib;
-#endif
- magick_image->write (0, i, _size.width, 1, "BGRA", CharPixel, p);
- p += stride()[0];
- }
-
- delete magick_image;
-}
-
void
Image::allocate ()
{
@@ -1187,34 +1158,6 @@ Image::memory_used () const
dcp::Data
Image::as_png () const
{
-#ifdef DCPOMATIC_IMAGE_MAGICK
- using namespace MagickCore;
-#else
- using namespace MagickLib;
-#endif
-
- string format;
- switch (_pixel_format) {
- case AV_PIX_FMT_RGB24:
- format = "RGB";
- break;
- case AV_PIX_FMT_BGRA:
- format = "BGRA";
- break;
- default:
- DCPOMATIC_ASSERT (false);
- break;
- }
-
- shared_ptr<const Image> use;
- if (aligned()) {
- use.reset (new Image(shared_from_this(), false));
- }
-
- Magick::Image m (size().width, size().height, format, CharPixel, (void *) use->data()[0]);
- m.magick ("PNG");
- Magick::Blob blob;
- m.write (&blob);
- /* XXX: could use a subclass of Data here (storing its data in a Blob) */
- return dcp::Data (static_cast<const uint8_t*>(blob.data()), blob.length());
+ /* XXX */
+ return dcp::Data();
}
diff --git a/src/lib/image.h b/src/lib/image.h
index 1869ca828..73f2313c1 100644
--- a/src/lib/image.h
+++ b/src/lib/image.h
@@ -44,7 +44,6 @@ public:
Image (AVPixelFormat p, dcp::Size s, bool aligned, int extra_pixels = 0);
explicit Image (AVFrame *);
explicit Image (Image const &);
- explicit Image (dcp::Data);
Image (boost::shared_ptr<const Image>, bool);
Image& operator= (Image const &);
~Image ();
diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc
index fd51c1ba3..e06f6023d 100644
--- a/src/lib/image_decoder.cc
+++ b/src/lib/image_decoder.cc
@@ -22,12 +22,11 @@
#include "image_decoder.h"
#include "video_decoder.h"
#include "image.h"
-#include "magick_image_proxy.h"
+#include "ffmpeg_image_proxy.h"
#include "j2k_image_proxy.h"
#include "film.h"
#include "exceptions.h"
#include "video_content.h"
-#include <Magick++.h>
#include <boost/filesystem.hpp>
#include <iostream>
@@ -68,7 +67,7 @@ ImageDecoder::pass ()
*/
_image.reset (new J2KImageProxy (path, _image_content->video->size(), pf));
} else {
- _image.reset (new MagickImageProxy (path));
+ _image.reset (new FFmpegImageProxy (path));
}
}
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
index 71f0ca41c..26beeb363 100644
--- a/src/lib/image_examiner.cc
+++ b/src/lib/image_examiner.cc
@@ -26,12 +26,11 @@
#include "config.h"
#include "cross.h"
#include "compose.hpp"
-#include "magick_image_proxy.h"
+#include "ffmpeg_image_proxy.h"
#include "image.h"
#include <dcp/openjpeg_image.h>
#include <dcp/exceptions.h>
#include <dcp/j2k.h>
-#include <Magick++.h>
#include <iostream>
#include "i18n.h"
@@ -46,9 +45,6 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
: _film (film)
, _image_content (content)
{
-#ifdef DCPOMATIC_HAVE_MAGICKCORE_NAMESPACE
- using namespace MagickCore;
-#endif
boost::filesystem::path path = content->path(0).string ();
if (valid_j2k_file (path)) {
boost::uintmax_t size = boost::filesystem::file_size (path);
@@ -67,7 +63,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
}
delete[] buffer;
} else {
- MagickImageProxy proxy(content->path(0));
+ FFmpegImageProxy proxy(content->path(0));
_video_size = proxy.image().first->size();
}
diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc
index 3a09cb8e8..e16fab063 100644
--- a/src/lib/image_proxy.cc
+++ b/src/lib/image_proxy.cc
@@ -20,7 +20,7 @@
#include "image_proxy.h"
#include "raw_image_proxy.h"
-#include "magick_image_proxy.h"
+#include "ffmpeg_image_proxy.h"
#include "j2k_image_proxy.h"
#include "image.h"
#include "exceptions.h"
@@ -40,8 +40,8 @@ image_proxy_factory (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket)
{
if (xml->string_child("Type") == N_("Raw")) {
return shared_ptr<ImageProxy> (new RawImageProxy (xml, socket));
- } else if (xml->string_child("Type") == N_("Magick")) {
- return shared_ptr<MagickImageProxy> (new MagickImageProxy (xml, socket));
+ } else if (xml->string_child("Type") == N_("FFmpeg")) {
+ return shared_ptr<FFmpegImageProxy> (new FFmpegImageProxy(xml, socket));
} else if (xml->string_child("Type") == N_("J2K")) {
return shared_ptr<J2KImageProxy> (new J2KImageProxy (xml, socket));
}
diff --git a/src/lib/image_proxy.h b/src/lib/image_proxy.h
index b377d5362..be053eed5 100644
--- a/src/lib/image_proxy.h
+++ b/src/lib/image_proxy.h
@@ -81,7 +81,6 @@ public:
* @return log2 of any scaling down that will be applied to the image.
*/
virtual int prepare (boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const { return 0; }
- virtual AVPixelFormat pixel_format () const = 0;
virtual size_t memory_used () const = 0;
};
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc
index a46cda13c..52b6f34f0 100644
--- a/src/lib/j2k_image_proxy.cc
+++ b/src/lib/j2k_image_proxy.cc
@@ -31,7 +31,6 @@
#include <dcp/j2k.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
-#include <Magick++.h>
#include <iostream>
#include "i18n.h"
diff --git a/src/lib/j2k_image_proxy.h b/src/lib/j2k_image_proxy.h
index 77d53a9e5..a67cc24de 100644
--- a/src/lib/j2k_image_proxy.h
+++ b/src/lib/j2k_image_proxy.h
@@ -60,9 +60,6 @@ public:
/** @return true if our image is definitely the same as another, false if it is probably not */
bool same (boost::shared_ptr<const ImageProxy>) const;
int prepare (boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const;
- AVPixelFormat pixel_format () const {
- return _pixel_format;
- }
dcp::Data j2k () const {
return _data;
diff --git a/src/lib/magick_image_proxy.cc b/src/lib/magick_image_proxy.cc
deleted file mode 100644
index cd5749bb6..000000000
--- a/src/lib/magick_image_proxy.cc
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "magick_image_proxy.h"
-#include "cross.h"
-#include "exceptions.h"
-#include "dcpomatic_socket.h"
-#include "image.h"
-#include "compose.hpp"
-#include <Magick++.h>
-#include <libxml++/libxml++.h>
-#include <iostream>
-
-#include "i18n.h"
-
-using std::string;
-using std::cout;
-using std::pair;
-using std::make_pair;
-using boost::shared_ptr;
-using boost::optional;
-using boost::dynamic_pointer_cast;
-
-MagickImageProxy::MagickImageProxy (boost::filesystem::path path)
- : _path (path)
-{
- /* Read the file into a Blob */
-
- boost::uintmax_t const size = boost::filesystem::file_size (path);
- FILE* f = fopen_boost (path, "rb");
- if (!f) {
- throw OpenFileError (path, errno, true);
- }
-
- uint8_t* data = new uint8_t[size];
- if (fread (data, 1, size, f) != size) {
- delete[] data;
- throw ReadFileError (path);
- }
-
- fclose (f);
- _blob.update (data, size);
- delete[] data;
-}
-
-MagickImageProxy::MagickImageProxy (shared_ptr<cxml::Node>, shared_ptr<Socket> socket)
-{
- uint32_t const size = socket->read_uint32 ();
- uint8_t* data = new uint8_t[size];
- socket->read (data, size);
- _blob.update (data, size);
- delete[] data;
-}
-
-pair<shared_ptr<Image>, int>
-MagickImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size>) const
-{
- boost::mutex::scoped_lock lm (_mutex);
-
- if (_image) {
- return make_pair (_image, 0);
- }
-
- Magick::Image* magick_image = 0;
- string error;
- try {
- magick_image = new Magick::Image (_blob);
- } catch (Magick::Exception& e) {
- error = e.what ();
- }
-
- if (!magick_image) {
- /* ImageMagick cannot auto-detect Targa files, it seems, so try here with an
- explicit format. I can't find it documented that passing a (0, 0) geometry
- is allowed, but it seems to work.
- */
- try {
- magick_image = new Magick::Image (_blob, Magick::Geometry (0, 0), "TGA");
- } catch (...) {
-
- }
- }
-
- if (!magick_image) {
- /* If we failed both an auto-detect and a forced-Targa we give the error from
- the auto-detect.
- */
- if (_path) {
- throw DecodeError (String::compose (_("Could not decode image file %1 (%2)"), _path->string(), error));
- } else {
- throw DecodeError (String::compose (_("Could not decode image file (%1)"), error));
- }
- }
-
- unsigned char const * data = static_cast<unsigned char const *>(_blob.data());
- if (data[801] == 1 || magick_image->image()->colorspace == Magick::sRGBColorspace) {
- /* Either:
- 1. The transfer characteristic in this file is "printing density"; in this case ImageMagick sets the colour space
- to LogColorspace, or
- 2. The file is sRGB.
-
- Empirically we find that in these cases if we subsequently call colorSpace(Magick::RGBColorspace) the colours
- are very wrong. To prevent this, set the image colour space to RGB to stop the ::colorSpace call below doing
- anything. See #1123 and others.
- */
- magick_image->image()->colorspace = Magick::RGBColorspace;
- }
-
- magick_image->colorSpace(Magick::RGBColorspace);
-
- dcp::Size size (magick_image->columns(), magick_image->rows());
-
- _image.reset (new Image (AV_PIX_FMT_RGB24, size, true));
-
- /* Write line-by-line here as _image must be aligned, and write() cannot be told about strides */
- uint8_t* p = _image->data()[0];
- for (int i = 0; i < size.height; ++i) {
-#ifdef DCPOMATIC_HAVE_MAGICKCORE_NAMESPACE
- using namespace MagickCore;
-#endif
-#ifdef DCPOMATIC_HAVE_MAGICKLIB_NAMESPACE
- using namespace MagickLib;
-#endif
- magick_image->write (0, i, size.width, 1, "RGB", CharPixel, p);
- p += _image->stride()[0];
- }
-
- delete magick_image;
-
- return make_pair (_image, 0);
-}
-
-void
-MagickImageProxy::add_metadata (xmlpp::Node* node) const
-{
- node->add_child("Type")->add_child_text (N_("Magick"));
-}
-
-void
-MagickImageProxy::send_binary (shared_ptr<Socket> socket) const
-{
- socket->write (_blob.length ());
- socket->write ((uint8_t *) _blob.data (), _blob.length ());
-}
-
-bool
-MagickImageProxy::same (shared_ptr<const ImageProxy> other) const
-{
- shared_ptr<const MagickImageProxy> mp = dynamic_pointer_cast<const MagickImageProxy> (other);
- if (!mp) {
- return false;
- }
-
- if (_blob.length() != mp->_blob.length()) {
- return false;
- }
-
- return memcmp (_blob.data(), mp->_blob.data(), _blob.length()) == 0;
-}
-
-AVPixelFormat
-MagickImageProxy::pixel_format () const
-{
- return AV_PIX_FMT_RGB24;
-}
-
-size_t
-MagickImageProxy::memory_used () const
-{
- size_t m = _blob.length();
- if (_image) {
- m += _image->memory_used();
- }
- return m;
-}
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index 02c85be12..12ec96a32 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -150,7 +150,7 @@ PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat
}
shared_ptr<Image> out = im->crop_scale_window (
- total_crop, _inter_size, _out_size, yuv_to_rgb, pixel_format (_in->pixel_format()), aligned, fast
+ total_crop, _inter_size, _out_size, yuv_to_rgb, pixel_format (im->pixel_format()), aligned, fast
);
if (_text) {
diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc
index c3b565f3c..084f515ed 100644
--- a/src/lib/raw_image_proxy.cc
+++ b/src/lib/raw_image_proxy.cc
@@ -86,12 +86,6 @@ RawImageProxy::same (shared_ptr<const ImageProxy> other) const
return (*_image.get()) == (*rp->image().first.get());
}
-AVPixelFormat
-RawImageProxy::pixel_format () const
-{
- return _image->pixel_format ();
-}
-
size_t
RawImageProxy::memory_used () const
{
diff --git a/src/lib/raw_image_proxy.h b/src/lib/raw_image_proxy.h
index 78b7db0c7..5711b54f2 100644
--- a/src/lib/raw_image_proxy.h
+++ b/src/lib/raw_image_proxy.h
@@ -37,7 +37,6 @@ public:
void add_metadata (xmlpp::Node *) const;
void send_binary (boost::shared_ptr<Socket>) const;
bool same (boost::shared_ptr<const ImageProxy>) const;
- AVPixelFormat pixel_format () const;
size_t memory_used () const;
private:
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 909a93ba8..051a4bb25 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -49,9 +49,6 @@ extern "C" {
#include <libavcodec/avcodec.h>
}
#include <curl/curl.h>
-#ifdef DCPOMATIC_GRAPHICS_MAGICK
-#include <Magick++.h>
-#endif
#include <glib.h>
#include <pangomm/init.h>
#include <boost/algorithm/string.hpp>
@@ -372,10 +369,6 @@ dcpomatic_setup ()
curl_global_init (CURL_GLOBAL_ALL);
-#ifdef DCPOMATIC_GRAPHICS_MAGICK
- Magick::InitializeMagick (0);
-#endif
-
ui_thread = boost::this_thread::get_id ();
}
diff --git a/src/lib/wscript b/src/lib/wscript
index 768c27f92..75e122e28 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -95,6 +95,7 @@ sources = """
ffmpeg_subtitle_stream.cc
film.cc
filter.cc
+ ffmpeg_image_proxy.cc
font.cc
font_files.cc
frame_rate_change.cc
@@ -114,7 +115,6 @@ sources = """
json_server.cc
log.cc
log_entry.cc
- magick_image_proxy.cc
mid_side_decoder.cc
monitor_checker.cc
overlaps.cc
@@ -177,7 +177,7 @@ def build(bld):
obj.uselib = """
AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE
BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 BOOST_REGEX
- SAMPLERATE POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++
+ SAMPLERATE POSTPROC TIFF SSH DCP CXML GLIB LZMA XML++
CURL ZIP FONTCONFIG PANGOMM CAIROMM XMLSEC SUB ICU NETTLE
"""