- int const left_size = xml->number_child<int> ("LeftSize");
- int const right_size = xml->number_child<int> ("RightSize");
- shared_ptr<dcp::StereoPictureFrame> f (new dcp::StereoPictureFrame ());
- socket->read (f->left_j2k_data(), left_size);
- socket->read (f->right_j2k_data(), right_size);
- _stereo = f;
+ }
+ _data = Data (xml->number_child<int> ("Size"));
+ /* This only matters when we are using J2KImageProxy for the preview, which
+ will never use this constructor (which is only used for passing data to
+ encode servers). So we can put anything in here. It's a bit of a hack.
+ */
+ _pixel_format = AV_PIX_FMT_XYZ12LE;
+ socket->read (_data.data().get (), _data.size ());
+}
+
+void
+J2KImageProxy::prepare (optional<dcp::Size> target_size) const
+{
+ boost::mutex::scoped_lock lm (_mutex);
+
+ if (_decompressed && target_size == _target_size) {
+ return;
+ }
+
+ int reduce = 0;
+
+ if (_forced_reduction) {
+ reduce = *_forced_reduction;