diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-11-05 08:39:47 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-11-05 08:39:47 +0100 |
| commit | 2cc2a247744ea7e75bffeaba80d78975efef6504 (patch) | |
| tree | 9377f29bc6968876e3a390e8d5a12390b110c354 /src/lib | |
| parent | b4f942ef0b7b9e2f781c0d17b3ad43884750fa7a (diff) | |
| parent | b32d031762bc49d8d076d36c4a8c60fa175a94dc (diff) | |
Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/j2k_image_proxy.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 9893d65a6..d4c7a8716 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -138,7 +138,13 @@ 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); - _image.reset (new Image (_pixel_format, decompressed->size(), true)); + /* 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)); int const shift = 16 - decompressed->precision (0); |
