summaryrefslogtreecommitdiffstats
path: root/video/out/vo_corevideo.m
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-25 13:55:09 +0100
committerwm4 <wm4@nowhere>2013-01-13 17:39:32 +0100
commitf4a95058c70d829624146abd64b9b04d59dbc286 (patch)
tree0c86980f54988603ee5a6a55bed0830771b519c6 /video/out/vo_corevideo.m
parentd77d9fb933e0e7dc34de02f3d0c13791ddd80114 (diff)
downloadmpv-f4a95058c70d829624146abd64b9b04d59dbc286.tar.bz2
mpv-f4a95058c70d829624146abd64b9b04d59dbc286.tar.xz
vo_corevideo: correct stride usage
The code assumed mp_image_alloc() would allocate an image large enough for corevideo's stride, which doesn't have to be the case. If corevideo's stride was larger than the stride of mp_image, the memcpy() would write beyond the mp_image allocation. This probably didn't actually happen, but fix the code to be more correct anyway.
Diffstat (limited to 'video/out/vo_corevideo.m')
-rw-r--r--video/out/vo_corevideo.m11
1 files changed, 6 insertions, 5 deletions
diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m
index 292dfea5a5..8c4b021e20 100644
--- a/video/out/vo_corevideo.m
+++ b/video/out/vo_corevideo.m
@@ -367,14 +367,15 @@ static mp_image_t *get_screenshot(struct vo *vo)
size_t width = CVPixelBufferGetWidth(p->pixelBuffer);
size_t height = CVPixelBufferGetHeight(p->pixelBuffer);
size_t stride = CVPixelBufferGetBytesPerRow(p->pixelBuffer);
- size_t image_size = stride * height;
- mp_image_t *image = alloc_mpi(width, height, img_fmt);
- memcpy(image->planes[0], base, image_size);
- image->stride[0] = stride;
+ struct mp_image img = {0};
+ mp_image_setfmt(&img, img_fmt);
+ mp_image_set_size(&img, width, height);
+ img.planes[0] = base;
+ img.stride[0] = stride;
+ struct mp_image *image = mp_image_new_copy(&img);
mp_image_set_display_size(image, vo->aspdat.prew, vo->aspdat.preh);
-
mp_image_set_colorspace_details(image, &p->colorspace);
return image;