diff options
author | James Ross-Gowan <rossymiles@gmail.com> | 2014-10-27 19:03:47 +1100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-10-27 10:56:00 +0100 |
commit | ac35e3b308a2469ef49b7094de8b571f054ac2f4 (patch) | |
tree | c19e413b61f1812f66d322b2399c4cc962914379 | |
parent | f22acd94aff9c5e24ec87ce9a914cbdb14d5cb7e (diff) | |
download | mpv-ac35e3b308a2469ef49b7094de8b571f054ac2f4.tar.bz2 mpv-ac35e3b308a2469ef49b7094de8b571f054ac2f4.tar.xz |
dxva2: fix copying surfaces with different stride
-rw-r--r-- | video/decode/dxva2.c | 28 |
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, |