From dcd167ca37fcb14719f97ca637ec5f3efc3952d8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 6 Jul 2015 21:25:07 +0200 Subject: dxva2: fix handling of cropped video Basically, we need to make sure to allocate enough data for the pretty dumb copy_nv12 function. (It could be avoided by making the function less dumb, but this fix is simpler.) --- video/decode/dxva2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/video/decode/dxva2.c b/video/decode/dxva2.c index 0e99d550ba..c87093812c 100644 --- a/video/decode/dxva2.c +++ b/video/decode/dxva2.c @@ -311,8 +311,11 @@ static struct mp_image *dxva2_retrieve_image(struct lavc_ctx *s, IDirect3DSurface9_GetDesc(surface, &surfaceDesc); + if (surfaceDesc.Width < img->w || surfaceDesc.Height < img->h) + return img; + struct mp_image *sw_img = - mp_image_pool_get(ctx->sw_pool, IMGFMT_NV12, img->w, img->h); + mp_image_pool_get(ctx->sw_pool, IMGFMT_NV12, surfaceDesc.Width, surfaceDesc.Height); if (!sw_img) return img; @@ -325,6 +328,7 @@ static struct mp_image *dxva2_retrieve_image(struct lavc_ctx *s, } ctx->copy_nv12(sw_img, LockedRect.pBits, LockedRect.Pitch, surfaceDesc.Height); + mp_image_set_size(sw_img, img->w, img->h); mp_image_copy_attributes(sw_img, img); IDirect3DSurface9_UnlockRect(surface); -- cgit v1.2.3