History

avutil/hwcontext_amf: add support for d3d12va initialisation

Dmitrii Ovchinnikov committed 1 year ago

Commit 39ab61b1 parent 64b79f91 file · +36 −0Browse files

Unified · Split

libavutil/hwcontext_amf.c+36−0
@@ -28,6 +28,9 @@ · 27 unmodified lines
2828 #if CONFIG_D3D11VA
2929 #include "libavutil/hwcontext_d3d11va.h"
3030 #endif
31+#if CONFIG_D3D12VA
32+#include "libavutil/hwcontext_d3d12va.h"
33+#endif
3134 #if CONFIG_DXVA2
3235 #define COBJMACROS
3336 #include "libavutil/hwcontext_dxva2.h"
@@ -146,6 +149,9 @@ static const enum AVPixelFormat supported_formats[] = { · 112 unmodified lines
146149 #if CONFIG_D3D11VA
147150 AV_PIX_FMT_D3D11,
148151 #endif
152+#if CONFIG_D3D12VA
153+ AV_PIX_FMT_D3D12,
154+#endif
149155 #if CONFIG_DXVA2
150156 AV_PIX_FMT_DXVA2_VLD,
151157 #endif
@@ -555,10 +561,33 @@ static int amf_init_from_d3d11_device(AVAMFDeviceContext* amf_ctx, AVD3D11VADevi · 403 unmodified lines
555561 av_log(hwctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D11 device: %d.\n", res);
556562 return AVERROR(ENODEV);
557563 }
564+ av_log(hwctx, AV_LOG_ERROR, "AMF via D3D11");
558565 return 0;
559566 }
560567 #endif
561568
569+#if CONFIG_D3D12VA
570+static int amf_init_from_d3d12_device(AVAMFDeviceContext* amf_ctx, AVD3D12VADeviceContext *hwctx)
571+{
572+ AMF_RESULT res;
573+ AMFContext2 *context2 = NULL;
574+ AMFGuid guid = IID_AMFContext2();
575+ res = amf_ctx->context->pVtbl->QueryInterface(amf_ctx->context, &guid, (void**)&context2);
576+ AMF_RETURN_IF_FALSE(hwctx, res == AMF_OK, AVERROR_UNKNOWN, "CreateContext2() failed with error %d\n", res);
577+ res = context2->pVtbl->InitDX12(context2, hwctx->device, AMF_DX12);
578+ context2->pVtbl->Release(context2);
579+ if (res != AMF_OK && res != AMF_ALREADY_INITIALIZED) {
580+ if (res == AMF_NOT_SUPPORTED)
581+ av_log(hwctx, AV_LOG_ERROR, "AMF via D3D12 is not supported on the given device.\n");
582+ else
583+ av_log(hwctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D12 device: %d.\n", res);
584+ return AVERROR(ENODEV);
585+ }
586+ return 0;
587+}
588+#endif
589+
590+
562591 static int amf_device_derive(AVHWDeviceContext *device_ctx,
563592 AVHWDeviceContext *child_device_ctx, AVDictionary *opts,
564593 int flags)
@@ -588,6 +617,13 @@ static int amf_device_derive(AVHWDeviceContext *device_ctx, · 23 unmodified lines
588617 return amf_init_from_d3d11_device(amf_ctx, child_device_hwctx);
589618 }
590619 break;
620+#endif
621+#if CONFIG_D3D12VA
622+ case AV_HWDEVICE_TYPE_D3D12VA: {
623+ AVD3D12VADeviceContext *child_device_hwctx = child_device_ctx->hwctx;
624+ return amf_init_from_d3d12_device(amf_ctx, child_device_hwctx);
625+ }
626+ break;
591627 #endif
592628 default: {
593629 av_log(child_device_ctx, AV_LOG_ERROR, "AMF initialisation from a %s device is not supported.\n",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t