summaryrefslogtreecommitdiffstats
path: root/video/decode/hw_dxva2.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-12-01 08:01:08 +0100
committerwm4 <wm4@nowhere>2017-12-01 08:05:16 +0100
commita0d9e15342ad48f51841d4fbfe3ae47e10e45592 (patch)
treee08465a5e54136e55ab2a35b2382fb9d8d06d634 /video/decode/hw_dxva2.c
parentafd5f3227ec38fea70bf7abfcd107a9493aa21fc (diff)
downloadmpv-a0d9e15342ad48f51841d4fbfe3ae47e10e45592.tar.bz2
mpv-a0d9e15342ad48f51841d4fbfe3ae47e10e45592.tar.xz
video: refactor hw device creation for hwdec copy modes
Lots of shit code for nothing. We probably could just use libavutil's code for all of this. But for now go with this, since it tends to prevent stupid terminal messages during probing (libavutil has no mechanism to selectively suppress errors specifically during probing). Ignores the "emulated" API flag (for avoiding vaapi/vdpau wrappers), but it doesn't matter that much for -copy anyway.
Diffstat (limited to 'video/decode/hw_dxva2.c')
-rw-r--r--video/decode/hw_dxva2.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/video/decode/hw_dxva2.c b/video/decode/hw_dxva2.c
index 37b2b78003..ede494ff4f 100644
--- a/video/decode/hw_dxva2.c
+++ b/video/decode/hw_dxva2.c
@@ -88,15 +88,8 @@ fail:
return NULL;
}
-static void d3d9_destroy_dev(struct mp_hwdec_ctx *ctx)
-{
- av_buffer_unref(&ctx->av_device_ref);
- IDirect3DDevice9_Release((IDirect3DDevice9 *)ctx->ctx);
- talloc_free(ctx);
-}
-
-static struct mp_hwdec_ctx *d3d9_create_dev(struct mpv_global *global,
- struct mp_log *plog, bool probing)
+static struct AVBufferRef *d3d9_create_standalone(struct mpv_global *global,
+ struct mp_log *plog, struct hwcontext_create_dev_params *params)
{
d3d_load_dlls();
if (!d3d9_dll || !dxva2_dll) {
@@ -149,23 +142,19 @@ static struct mp_hwdec_ctx *d3d9_create_dev(struct mpv_global *global,
return NULL;
}
- struct mp_hwdec_ctx *ctx = talloc_ptrtype(NULL, ctx);
- *ctx = (struct mp_hwdec_ctx) {
- .type = HWDEC_D3D11VA_COPY,
- .ctx = exdev,
- .destroy = d3d9_destroy_dev,
- .av_device_ref = d3d9_wrap_device_ref((IDirect3DDevice9 *)exdev),
- };
-
- if (!ctx->av_device_ref) {
+ AVBufferRef *avref = d3d9_wrap_device_ref((IDirect3DDevice9 *)exdev);
+ IDirect3DDevice9Ex_Release(exdev);
+ if (!avref)
mp_err(plog, "Failed to allocate AVHWDeviceContext.\n");
- d3d9_destroy_dev(ctx);
- return NULL;
- }
- return ctx;
+ return avref;
}
+const struct hwcontext_fns hwcontext_fns_dxva2 = {
+ .av_hwdevice_type = AV_HWDEVICE_TYPE_DXVA2,
+ .create_dev = d3d9_create_standalone,
+};
+
const struct vd_lavc_hwdec mp_vd_lavc_dxva2 = {
.type = HWDEC_DXVA2,
.image_format = IMGFMT_DXVA2,
@@ -178,7 +167,8 @@ const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy = {
.copying = true,
.image_format = IMGFMT_DXVA2,
.generic_hwaccel = true,
- .create_dev = d3d9_create_dev,
+ .create_standalone_dev = true,
+ .create_standalone_dev_type = AV_HWDEVICE_TYPE_DXVA2,
.set_hwframes = true,
.delay_queue = HWDEC_DELAY_QUEUE_COUNT,
};