summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-05 00:18:57 +0200
committerwm4 <wm4@nowhere>2014-08-05 00:18:57 +0200
commitd634f7b01a255b22962b0b44f20f052cfc34b240 (patch)
tree9130918d8491bf3627acf6a65cf2dc25231660d2 /video
parentee6df2f76c7c8a7c26d905444529dc3b755d8548 (diff)
downloadmpv-d634f7b01a255b22962b0b44f20f052cfc34b240.tar.bz2
mpv-d634f7b01a255b22962b0b44f20f052cfc34b240.tar.xz
vdpau: don't crash on flipped images
It seems the vdpau API does not support these. Do a semi-expensive emulation of it. On the other hand, it's not like this is a commonly-used feature. (It might be better to make --vf=flip always copy instead of flipping it via pointer tricks - but everything allows flipped images, and even decoders or libavfilter filters could output them.)
Diffstat (limited to 'video')
-rw-r--r--video/vdpau.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/video/vdpau.c b/video/vdpau.c
index 90aba50e63..e03d2b7817 100644
--- a/video/vdpau.c
+++ b/video/vdpau.c
@@ -409,22 +409,29 @@ struct mp_image *mp_vdpau_upload_video_surface(struct mp_vdpau_ctx *ctx,
if (!hwmpi)
return NULL;
+ struct mp_image *src = mpi;
+ if (mpi->stride[0] < 0)
+ src = mp_image_new_copy(mpi); // unflips it when copying
+
if (hwmpi->imgfmt == IMGFMT_VDPAU) {
VdpVideoSurface surface = (intptr_t)hwmpi->planes[3];
- const void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
- if (mpi->imgfmt == IMGFMT_NV12)
+ const void *destdata[3] = {src->planes[0], src->planes[2], src->planes[1]};
+ if (src->imgfmt == IMGFMT_NV12)
destdata[1] = destdata[2];
vdp_st = vdp->video_surface_put_bits_y_cb_cr(surface,
- ycbcr, destdata, mpi->stride);
+ ycbcr, destdata, src->stride);
} else {
VdpOutputSurface rgb_surface = (intptr_t)hwmpi->planes[3];
vdp_st = vdp->output_surface_put_bits_native(rgb_surface,
- &(const void *){mpi->planes[0]},
- &(uint32_t){mpi->stride[0]},
+ &(const void *){src->planes[0]},
+ &(uint32_t){src->stride[0]},
NULL);
}
CHECK_VDP_WARNING(ctx, "Error when uploading surface");
+ if (src != mpi)
+ talloc_free(src);
+
mp_image_copy_attributes(hwmpi, mpi);
return hwmpi;
}