summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2014-10-27 19:03:47 +1100
committerwm4 <wm4@nowhere>2014-10-27 10:56:00 +0100
commitac35e3b308a2469ef49b7094de8b571f054ac2f4 (patch)
treec19e413b61f1812f66d322b2399c4cc962914379 /video
parentf22acd94aff9c5e24ec87ce9a914cbdb14d5cb7e (diff)
downloadmpv-ac35e3b308a2469ef49b7094de8b571f054ac2f4.tar.bz2
mpv-ac35e3b308a2469ef49b7094de8b571f054ac2f4.tar.xz
dxva2: fix copying surfaces with different stride
Diffstat (limited to 'video')
-rw-r--r--video/decode/dxva2.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/video/decode/dxva2.c b/video/decode/dxva2.c
index f2a70f099d..00c33fd43d 100644
--- a/video/decode/dxva2.c
+++ b/video/decode/dxva2.c
@@ -250,21 +250,29 @@ static struct mp_image *dxva2_allocate_image(struct lavc_ctx *s, int fmt,
static void copy_nv12_fallback(struct mp_image *dest, uint8_t *src_bits,
unsigned src_pitch, unsigned surf_height)
{
- unsigned height = dest->h * src_pitch;
- memcpy(dest->planes[0], src_bits, height);
- dest->stride[0] = src_pitch;
- memcpy(dest->planes[1], src_bits + src_pitch * surf_height, height / 2);
- dest->stride[1] = src_pitch;
+ struct mp_image buf = {0};
+ mp_image_setfmt(&buf, IMGFMT_NV12);
+ mp_image_set_size(&buf, dest->w, dest->h);
+
+ buf.planes[0] = src_bits;
+ buf.stride[0] = src_pitch;
+ buf.planes[1] = src_bits + src_pitch * surf_height;
+ buf.stride[1] = src_pitch;
+ mp_image_copy(dest, &buf);
}
static void copy_nv12_gpu_sse4(struct mp_image *dest, uint8_t *src_bits,
unsigned src_pitch, unsigned surf_height)
{
- unsigned height = dest->h * src_pitch;
- gpu_memcpy(dest->planes[0], src_bits, height);
- dest->stride[0] = src_pitch;
- gpu_memcpy(dest->planes[1], src_bits + src_pitch * surf_height, height / 2);
- dest->stride[1] = src_pitch;
+ // Unfortunately the fallback must be used if the stride doesn't match
+ if (dest->stride[0] != src_pitch) {
+ copy_nv12_fallback(dest, src_bits, src_pitch, surf_height);
+ return;
+ }
+
+ unsigned size = dest->h * src_pitch;
+ gpu_memcpy(dest->planes[0], src_bits, size);
+ gpu_memcpy(dest->planes[1], src_bits + src_pitch * surf_height, size / 2);
}
static struct mp_image *dxva2_retrieve_image(struct lavc_ctx *s,