From: Carl Hetherington Date: Wed, 7 Jun 2017 20:27:40 +0000 (+0100) Subject: Fix crash when alpha-blending subtitles onto YUV420 images. X-Git-Tag: v2.11.11~19 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=2d9f569c146b391159f362c854457ce1facac1e8 Fix crash when alpha-blending subtitles onto YUV420 images. --- diff --git a/src/lib/image.cc b/src/lib/image.cc index b82cc6072..03a4d96b4 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -1035,3 +1035,13 @@ Image::fade (float f) throw PixelFormatError ("fade()", _pixel_format); } } + +shared_ptr +Image::ensure_aligned (shared_ptr image) +{ + if (image->aligned()) { + return image; + } + + return shared_ptr (new Image (image, true)); +} diff --git a/src/lib/image.h b/src/lib/image.h index fd5adb076..9a5a7dae8 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -77,6 +77,8 @@ public: return _pixel_format; } + static boost::shared_ptr ensure_aligned (boost::shared_ptr image); + private: friend struct pixel_formats_test; diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index 2e53a6aa6..6f0977e62 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -135,7 +135,7 @@ PlayerVideo::image (dcp::NoteHandler note, functionalpha_blend (_subtitle->image, _subtitle->position); + out->alpha_blend (Image::ensure_aligned (_subtitle->image), _subtitle->position); } if (_fade) {