diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-11-04 16:38:14 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-11-16 22:46:39 +0100 |
| commit | ed4fc06db6957b2b63b2400a737f47c18a1003be (patch) | |
| tree | e429ffc3df79e141dacb870ffe9d232e8b72efd4 /src/lib/j2k_image_proxy.cc | |
| parent | 81e40e7b915a55f8e5aa2db34ad809552b1534e3 (diff) | |
Fix incorrect images when cropping without stretch.
Always overallocate images so that Image::crop_scale_window is always
safe from over-reading buffers. Relates to #1654 and probably #1653.
Backported from 7b0372776ac4da6a8e4ff29f41a4f08b9b4de506 in v2.15.x.
Diffstat (limited to 'src/lib/j2k_image_proxy.cc')
| -rw-r--r-- | src/lib/j2k_image_proxy.cc | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index d4c7a8716..31fda2510 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -137,14 +137,7 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const } shared_ptr<dcp::OpenJPEGImage> decompressed = dcp::decompress_j2k (const_cast<uint8_t*> (_data.data().get()), _data.size (), reduce); - - /* When scaling JPEG2000 images (using AV_PIX_FMT_XYZ12LE) ffmpeg will call xyz12ToRgb48 which reads data - from the whole of the image stride. If we are cropping, Image::crop_scale_window munges the - start addresses of each image row (to do the crop) but keeps the stride the same. This means - that under crop we will read over the end of the image by the amount of the crop. To allow this - to happen without invalid memory access we need to overallocate by one whole stride's worth of pixels. - */ - _image.reset (new Image (_pixel_format, decompressed->size(), true, decompressed->size().width)); + _image.reset (new Image (_pixel_format, decompressed->size(), true)); int const shift = 16 - decompressed->precision (0); |
