Try to fix problems with odd crop values and YUV.
authorCarl Hetherington <cth@carlh.net>
Fri, 23 Aug 2013 14:33:45 +0000 (15:33 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 23 Aug 2013 14:33:45 +0000 (15:33 +0100)
src/lib/image.cc
src/lib/player.cc

index 5c04f70e6ab40f0e4c5ee1afd32f0ff6a14b2a55..f9a42f93b2fc572345fab5d54eef6885361ca869 100644 (file)
@@ -420,7 +420,7 @@ Image::allocate ()
        _stride[0] = _stride[1] = _stride[2] = _stride[3] = 0;
 
        for (int i = 0; i < components(); ++i) {
-               _line_size[i] = _size.width * bytes_per_pixel(i);
+               _line_size[i] = ceil (_size.width * bytes_per_pixel(i));
                _stride[i] = stride_round_up (i, _line_size, _aligned ? 32 : 1);
                _data[i] = (uint8_t *) av_malloc (_stride[i] * lines (i));
        }
index 84589ce39b44c495369367f4597ee4abd3197258..8a37cb835e672d92476468eea7784f5e24aad5cf 100644 (file)
@@ -250,8 +250,11 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image
        if (content->trimmed (relative_time)) {
                return;
        }
-       
-       shared_ptr<Image> work_image = image->crop (content->crop(), true);
+
+       /* Convert to RGB first, as FFmpeg doesn't seem to like handling YUV images with odd widths */
+       shared_ptr<Image> work_image = image->scale (image->size (), _film->scaler(), PIX_FMT_RGB24, true);
+
+       shared_ptr<Image> work_image = work_image->crop (content->crop(), true);
 
        libdcp::Size const image_size = content->ratio()->size (_video_container_size);