mirror of
https://github.com/jellyfin/jellyfin-ffmpeg.git
synced 2026-09-02 21:03:08 +03:00
107 lines
4.0 KiB
Diff
107 lines
4.0 KiB
Diff
Index: FFmpeg/libavcodec/dxva2.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavcodec/dxva2.c
|
|
+++ FFmpeg/libavcodec/dxva2.c
|
|
@@ -616,6 +616,18 @@ int ff_dxva2_common_frame_params(AVCodec
|
|
else
|
|
surface_alignment = 16;
|
|
|
|
+#if CONFIG_D3D11VA
|
|
+ /* align surfaces to 32 on Intel to keep in line with the MSDK impl,
|
|
+ which avoids the unnecessary resizing when mapping to QSV */
|
|
+ if (device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
|
|
+ AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx;
|
|
+ if (device_hwctx->device_desc.VendorId == 0x8086) {
|
|
+ av_log(avctx, AV_LOG_DEBUG, "Intel DX11 device found, alignment changed!\n");
|
|
+ surface_alignment = 32;
|
|
+ }
|
|
+ }
|
|
+#endif
|
|
+
|
|
/* 1 base work surface */
|
|
num_surfaces = 1;
|
|
|
|
@@ -623,9 +635,9 @@ int ff_dxva2_common_frame_params(AVCodec
|
|
if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC)
|
|
num_surfaces += 16;
|
|
else if (avctx->codec_id == AV_CODEC_ID_VP9 || avctx->codec_id == AV_CODEC_ID_AV1)
|
|
- num_surfaces += 8;
|
|
+ num_surfaces += 8 + 4; /* 4 base work surface in vpp async */
|
|
else
|
|
- num_surfaces += 2;
|
|
+ num_surfaces += 2 + 4; /* 4 base work surface in vpp async */
|
|
|
|
frames_ctx->sw_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
|
|
AV_PIX_FMT_P010 : AV_PIX_FMT_NV12;
|
|
Index: FFmpeg/libavutil/hwcontext_d3d11va.c
|
|
===================================================================
|
|
--- FFmpeg.orig/libavutil/hwcontext_d3d11va.c
|
|
+++ FFmpeg/libavutil/hwcontext_d3d11va.c
|
|
@@ -622,6 +622,35 @@ static int d3d11va_device_find_adapter_b
|
|
return -1;
|
|
}
|
|
|
|
+static int d3d11va_check_uma_support(AVHWDeviceContext *ctx)
|
|
+{
|
|
+ AVD3D11VADeviceContext *device_hwctx = ctx->hwctx;
|
|
+ D3D11_FEATURE_DATA_D3D11_OPTIONS2 data = {};
|
|
+ HRESULT hr = ID3D11Device_CheckFeatureSupport(device_hwctx->device,
|
|
+ D3D11_FEATURE_D3D11_OPTIONS2,
|
|
+ &data, sizeof(data));
|
|
+ return SUCCEEDED(hr) && data.UnifiedMemoryArchitecture;
|
|
+}
|
|
+
|
|
+static void d3d11va_query_device_desc(AVHWDeviceContext *ctx,
|
|
+ DXGI_ADAPTER_DESC *desc)
|
|
+{
|
|
+ AVD3D11VADeviceContext *device_hwctx = ctx->hwctx;
|
|
+ IDXGIDevice *pDXGIDevice = NULL;
|
|
+ IDXGIAdapter *pDXGIAdapter = NULL;
|
|
+ HRESULT hr = ID3D11Device_QueryInterface(device_hwctx->device, &IID_IDXGIDevice,
|
|
+ (void **)&pDXGIDevice);
|
|
+ if (SUCCEEDED(hr) && pDXGIDevice) {
|
|
+ hr = IDXGIDevice_GetParent(pDXGIDevice, &IID_IDXGIAdapter,
|
|
+ (void **)&pDXGIAdapter);
|
|
+ if (SUCCEEDED(hr) && pDXGIAdapter) {
|
|
+ IDXGIAdapter_GetDesc(pDXGIAdapter, desc);
|
|
+ IDXGIAdapter_Release(pDXGIAdapter);
|
|
+ }
|
|
+ IDXGIDevice_Release(pDXGIDevice);
|
|
+ }
|
|
+}
|
|
+
|
|
static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
|
|
AVDictionary *opts, int flags)
|
|
{
|
|
@@ -699,6 +728,9 @@ static int d3d11va_device_create(AVHWDev
|
|
ID3D10Multithread_Release(pMultithread);
|
|
}
|
|
|
|
+ device_hwctx->is_uma = d3d11va_check_uma_support(ctx);
|
|
+ d3d11va_query_device_desc(ctx, &device_hwctx->device_desc);
|
|
+
|
|
#if !HAVE_UWP && HAVE_DXGIDEBUG_H
|
|
if (is_debug) {
|
|
HANDLE dxgidebug_dll = LoadLibrary("dxgidebug.dll");
|
|
Index: FFmpeg/libavutil/hwcontext_d3d11va.h
|
|
===================================================================
|
|
--- FFmpeg.orig/libavutil/hwcontext_d3d11va.h
|
|
+++ FFmpeg/libavutil/hwcontext_d3d11va.h
|
|
@@ -108,6 +108,16 @@ typedef struct AVD3D11VADeviceContext {
|
|
* It applies globally to all AVD3D11VAFramesContext allocated from this device context.
|
|
*/
|
|
UINT MiscFlags;
|
|
+
|
|
+ /**
|
|
+ * DXGI adapter description of the device.
|
|
+ */
|
|
+ DXGI_ADAPTER_DESC device_desc;
|
|
+
|
|
+ /**
|
|
+ * Whether the device is an UMA device.
|
|
+ */
|
|
+ int is_uma;
|
|
} AVD3D11VADeviceContext;
|
|
|
|
/**
|