#include <libavutil/pixdesc.h>
#include <libavutil/frame.h>
}
+#if HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
#include <iostream>
#include "i18n.h"
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 ()
{
testing suggests that it works.
*/
_data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * sample_size(i).height + _extra_pixels * bytes_per_pixel(i) + 32);
+#if HAVE_VALGRIND_MEMCHECK_H
+ /* The data between the end of the line size and the stride is undefined but processed by
+ libswscale, causing lots of valgrind errors. Mark it all defined to quell these errors.
+ */
+ VALGRIND_MAKE_MEM_DEFINED (_data[i], _stride[i] * sample_size(i).height + _extra_pixels * bytes_per_pixel(i) + 32);
+#endif
}
}