summaryrefslogtreecommitdiffstats
path: root/video/decode/hw_d3d11va.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_d3d11va.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_d3d11va.c')
-rw-r--r--video/decode/hw_d3d11va.c47
1 files changed, 2 insertions, 45 deletions
diff --git a/video/decode/hw_d3d11va.c b/video/decode/hw_d3d11va.c
index cc1d122f59..76af9a52a9 100644
--- a/video/decode/hw_d3d11va.c
+++ b/video/decode/hw_d3d11va.c
@@ -33,50 +33,6 @@
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_d3d11va.h>
-static void d3d11_destroy_dev(struct mp_hwdec_ctx *ctx)
-{
- av_buffer_unref(&ctx->av_device_ref);
- ID3D11Device_Release((ID3D11Device *)ctx->ctx);
- talloc_free(ctx);
-}
-
-static struct mp_hwdec_ctx *d3d11_create_dev(struct mpv_global *global,
- struct mp_log *plog, bool probing)
-{
- ID3D11Device *device = NULL;
- HRESULT hr;
-
- d3d_load_dlls();
- if (!d3d11_D3D11CreateDevice) {
- mp_err(plog, "Failed to load D3D11 library\n");
- return NULL;
- }
-
- hr = d3d11_D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL,
- D3D11_CREATE_DEVICE_VIDEO_SUPPORT, NULL, 0,
- D3D11_SDK_VERSION, &device, NULL, NULL);
- if (FAILED(hr)) {
- mp_err(plog, "Failed to create D3D11 Device: %s\n",
- mp_HRESULT_to_str(hr));
- return NULL;
- }
-
- struct mp_hwdec_ctx *ctx = talloc_ptrtype(NULL, ctx);
- *ctx = (struct mp_hwdec_ctx) {
- .type = HWDEC_D3D11VA_COPY,
- .ctx = device,
- .destroy = d3d11_destroy_dev,
- .av_device_ref = d3d11_wrap_device_ref(device),
- };
-
- if (!ctx->av_device_ref) {
- mp_err(plog, "Failed to allocate AVHWDeviceContext.\n");
- d3d11_destroy_dev(ctx);
- return NULL;
- }
-
- return ctx;
-}
const struct vd_lavc_hwdec mp_vd_lavc_d3d11va = {
.type = HWDEC_D3D11VA,
@@ -90,7 +46,8 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = {
.copying = true,
.image_format = IMGFMT_D3D11VA,
.generic_hwaccel = true,
- .create_dev = d3d11_create_dev,
+ .create_standalone_dev = true,
+ .create_standalone_dev_type = AV_HWDEVICE_TYPE_D3D11VA,
.set_hwframes = true,
.delay_queue = HWDEC_DELAY_QUEUE_COUNT,
};