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
28#if CONFIG_D3D11VA28#if CONFIG_D3D11VA
29#include "libavutil/hwcontext_d3d11va.h"29#include "libavutil/hwcontext_d3d11va.h"
30#endif30#endif
31#if CONFIG_D3D12VA
32#include "libavutil/hwcontext_d3d12va.h"
33#endif
31#if CONFIG_DXVA234#if CONFIG_DXVA2
32#define COBJMACROS35#define COBJMACROS
33#include "libavutil/hwcontext_dxva2.h"36#include "libavutil/hwcontext_dxva2.h"
@@ -146,6 +149,9 @@ static const enum AVPixelFormat supported_formats[] = { · 112 unmodified lines
146#if CONFIG_D3D11VA149#if CONFIG_D3D11VA
147 AV_PIX_FMT_D3D11,150 AV_PIX_FMT_D3D11,
148#endif151#endif
152#if CONFIG_D3D12VA
153 AV_PIX_FMT_D3D12,
154#endif
149#if CONFIG_DXVA2155#if CONFIG_DXVA2
150 AV_PIX_FMT_DXVA2_VLD,156 AV_PIX_FMT_DXVA2_VLD,
151#endif157#endif
@@ -555,10 +561,33 @@ static int amf_init_from_d3d11_device(AVAMFDeviceContext* amf_ctx, AVD3D11VADevi · 403 unmodified lines
555 av_log(hwctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D11 device: %d.\n", res);561 av_log(hwctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D11 device: %d.\n", res);
556 return AVERROR(ENODEV);562 return AVERROR(ENODEV);
557 }563 }
564 av_log(hwctx, AV_LOG_ERROR, "AMF via D3D11");
558 return 0;565 return 0;
559}566}
560#endif567#endif
561 568
569#if CONFIG_D3D12VA
570static 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
562static int amf_device_derive(AVHWDeviceContext *device_ctx,591static int amf_device_derive(AVHWDeviceContext *device_ctx,
563 AVHWDeviceContext *child_device_ctx, AVDictionary *opts,592 AVHWDeviceContext *child_device_ctx, AVDictionary *opts,
564 int flags)593 int flags)
@@ -588,6 +617,13 @@ static int amf_device_derive(AVHWDeviceContext *device_ctx, · 23 unmodified lines
588 return amf_init_from_d3d11_device(amf_ctx, child_device_hwctx);617 return amf_init_from_d3d11_device(amf_ctx, child_device_hwctx);
589 }618 }
590 break;619 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;
591#endif627#endif
592 default: {628 default: {
593 av_log(child_device_ctx, AV_LOG_ERROR, "AMF initialisation from a %s device is not supported.\n",629 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