Fix crash when alpha-blending subtitles onto YUV420 images.
authorCarl Hetherington <cth@carlh.net>
Wed, 7 Jun 2017 20:27:40 +0000 (21:27 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 7 Jun 2017 20:27:40 +0000 (21:27 +0100)
src/lib/image.cc
src/lib/image.h
src/lib/player_video.cc

index b82cc607249965cfbd8753c48e1421440614588b..03a4d96b4848da8a133828c144195b76033d396c 100644 (file)
@@ -1035,3 +1035,13 @@ Image::fade (float f)
                throw PixelFormatError ("fade()", _pixel_format);
        }
 }
+
+shared_ptr<Image>
+Image::ensure_aligned (shared_ptr<Image> image)
+{
+       if (image->aligned()) {
+               return image;
+       }
+
+       return shared_ptr<Image> (new Image (image, true));
+}
index fd5adb0762ea9071ce1cd831f7aba49c3bef0aab..9a5a7dae8c961c90756ee439beda9fe774ad010c 100644 (file)
@@ -77,6 +77,8 @@ public:
                return _pixel_format;
        }
 
+       static boost::shared_ptr<Image> ensure_aligned (boost::shared_ptr<Image> image);
+
 private:
        friend struct pixel_formats_test;
 
index 2e53a6aa6be0e67a45e58ae3ffb403d597bfe676..6f0977e628091fa3885acfa3324b4910139d12ac 100644 (file)
@@ -135,7 +135,7 @@ PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat
                );
 
        if (_subtitle) {
-               out->alpha_blend (_subtitle->image, _subtitle->position);
+               out->alpha_blend (Image::ensure_aligned (_subtitle->image), _subtitle->position);
        }
 
        if (_fade) {