+2016-11-26 Carl Hetherington <cth@carlh.net>
+
+ * Speed up preview of exisiting DCPs when the preview size
+ is less than half the full DCP size (#986).
+
2016-11-25 Carl Hetherington <cth@carlh.net>
* Allow multi-edit of content timing details (#1010).
ffmpeg_options = {}
return (('ffmpeg-cdist', 'c7df8d5', ffmpeg_options),
- ('libdcp', 'v1.4.4'),
+ ('libdcp', '71f5d09'),
('libsub', 'v1.2.4'))
def configure_options(target):
public:
virtual ~ImageProxy () {}
- /** @return Image (which must be aligned) */
- virtual boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const = 0;
+ /** @param note Handler for any notes that occur.
+ * @param size Size that the returned image will be scaled to, in case this
+ * can be used as an optimisation.
+ * @return Image (which must be aligned)
+ */
+ virtual boost::shared_ptr<Image> image (
+ boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> (),
+ boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
+ ) 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 */
#include <dcp/j2k.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
+#include <Magick++.h>
#include <iostream>
#include "i18n.h"
using std::string;
using std::cout;
+using std::max;
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
socket->read (_data.data().get (), _data.size ());
}
-void
-J2KImageProxy::ensure_j2k () const
-{
- if (!_j2k) {
- _j2k = dcp::decompress_j2k (const_cast<uint8_t*> (_data.data().get()), _data.size (), 0);
- }
-}
-
shared_ptr<Image>
-J2KImageProxy::image (optional<dcp::NoteHandler>) const
+J2KImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size> target_size) const
{
- ensure_j2k ();
-
- if (_j2k->precision(0) < 12) {
- int const shift = 12 - _j2k->precision (0);
- for (int c = 0; c < 3; ++c) {
- int* p = _j2k->data (c);
- for (int y = 0; y < _j2k->size().height; ++y) {
- for (int x = 0; x < _j2k->size().width; ++x) {
- *p++ <<= shift;
+ if (!_j2k || target_size != _j2k_target_size) {
+ int reduce = 0;
+
+ while (target_size && (_size.width / pow(2, reduce)) > target_size->width && (_size.height / pow(2, reduce)) > target_size->height) {
+ ++reduce;
+ }
+
+ --reduce;
+ reduce = max (0, reduce);
+ _j2k = dcp::decompress_j2k (const_cast<uint8_t*> (_data.data().get()), _data.size (), reduce);
+
+ if (_j2k->precision(0) < 12) {
+ int const shift = 12 - _j2k->precision (0);
+ for (int c = 0; c < 3; ++c) {
+ int* p = _j2k->data (c);
+ for (int y = 0; y < _j2k->size().height; ++y) {
+ for (int x = 0; x < _j2k->size().width; ++x) {
+ *p++ <<= shift;
+ }
}
}
}
+
+ _j2k_target_size = target_size;
}
- shared_ptr<Image> image (new Image (_pixel_format, _size, true));
+ shared_ptr<Image> image (new Image (_pixel_format, _j2k->size(), true));
/* Copy data in whatever format (sRGB or XYZ) into our Image; I'm assuming
the data is 12-bit either way.
*/
+ int const width = _j2k->size().width;
+
int p = 0;
for (int y = 0; y < _j2k->size().height; ++y) {
uint16_t* q = (uint16_t *) (image->data()[0] + y * image->stride()[0]);
- for (int x = 0; x < _j2k->size().width; ++x) {
+ for (int x = 0; x < width; ++x) {
for (int c = 0; c < 3; ++c) {
*q++ = _j2k->data(c)[p] << 4;
}
++p;
}
+ p += _j2k->factor(0) * width;
}
return image;
J2KImageProxy (boost::shared_ptr<const dcp::StereoPictureFrame> frame, dcp::Size, dcp::Eye, AVPixelFormat pixel_format);
J2KImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
- boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
+ boost::shared_ptr<Image> image (
+ boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> (),
+ boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
+ ) const;
+
void add_metadata (xmlpp::Node *) const;
void send_binary (boost::shared_ptr<Socket>) const;
/** @return true if our image is definitely the same as another, false if it is probably not */
/* For tests */
J2KImageProxy (dcp::Data data, dcp::Size size, AVPixelFormat pixel_format);
- void ensure_j2k () const;
dcp::Data _data;
dcp::Size _size;
boost::optional<dcp::Eye> _eye;
mutable boost::shared_ptr<dcp::OpenJPEGImage> _j2k;
+ mutable boost::optional<dcp::Size> _j2k_target_size;
AVPixelFormat _pixel_format;
};
}
shared_ptr<Image>
-MagickImageProxy::image (optional<dcp::NoteHandler>) const
+MagickImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size>) const
{
boost::mutex::scoped_lock lm (_mutex);
MagickImageProxy (boost::filesystem::path);
MagickImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
- boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
+ boost::shared_ptr<Image> image (
+ boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> (),
+ boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
+ ) 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 (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const
{
- shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note));
+ shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note), _inter_size);
Crop total_crop = _crop;
switch (_part) {
}
shared_ptr<Image>
-RawImageProxy::image (optional<dcp::NoteHandler>) const
+RawImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size>) 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 (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
+ boost::shared_ptr<Image> image (
+ boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> (),
+ boost::optional<dcp::Size> size = boost::optional<dcp::Size> ()
+ ) const;
+
void add_metadata (xmlpp::Node *) const;
void send_binary (boost::shared_ptr<Socket>) const;
bool same (boost::shared_ptr<const ImageProxy>) const;