* [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32.
@ 2023-04-12 12:27 Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 2/3] Update -device argument usage in VAAPI documentation to indicate now also DirectX Adapter indices are supported Sil Vilerino
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Sil Vilerino @ 2023-04-12 12:27 UTC (permalink / raw)
To: ffmpeg-devel
Libva 2.17+ adds a new libva-win32 node and Mesa 22.3 adds a VAAPI driver based on Direct3D 12 for Windows.
Both of them are available at: https://www.nuget.org/packages/Microsoft.Direct3D.VideoAccelerationCompatibilityPack
Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
---
Changelog | 1 +
configure | 27 ++++++++++++-
libavutil/hwcontext_vaapi.c | 76 ++++++++++++++++++++++++++++++++++++-
libavutil/tests/hwdevice.c | 2 +-
4 files changed, 102 insertions(+), 4 deletions(-)
diff --git a/Changelog b/Changelog
index a40f32c23f..4ae8a4fe20 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
version <next>:
- libaribcaption decoder
+- Extend VAAPI support for libva-win32 on Windows
version 6.0:
- Radiance HDR image support
diff --git a/configure b/configure
index 033db7442d..2a45b11aa4 100755
--- a/configure
+++ b/configure
@@ -2316,6 +2316,7 @@ SYSTEM_LIBRARIES="
bcrypt
vaapi_drm
vaapi_x11
+ vaapi_win32
vdpau_x11
"
@@ -3826,7 +3827,7 @@ swscale_suggest="libm stdatomic"
avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs lcms2_extralibs"
avfilter_extralibs="pthreads_extralibs"
-avutil_extralibs="d3d11va_extralibs mediacodec_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
+avutil_extralibs="d3d11va_extralibs mediacodec_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vaapi_win32_extralibs vdpau_x11_extralibs"
# programs
ffmpeg_deps="avcodec avfilter avformat threads"
@@ -6947,6 +6948,21 @@ test_cpp <<EOF && enable uwp && d3d11va_extralibs="-ldxgi -ld3d11"
#endif
EOF
+# vaapi_win32 requires linking directly to dxgi if not building for
+# the desktop api partition
+test_cpp <<EOF && enable uwp && vaapi_win32_extralibs="-ldxgi"
+#ifdef WINAPI_FAMILY
+#include <winapifamily.h>
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#error desktop, not uwp
+#else
+// WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP
+#endif
+#else
+#error no family set
+#endif
+EOF
+
# mediafoundation requires linking directly to mfplat if building for uwp target
enabled uwp && mediafoundation_extralibs="-lmfplat -lmfuuid -lole32 -lstrmiids" || mediafoundation_extralibs="-lmfuuid -lole32 -lstrmiids"
@@ -6957,7 +6973,14 @@ enabled vaapi &&
check_pkg_config vaapi "libva >= 0.35.0" "va/va.h" vaInitialize
if enabled vaapi; then
- check_pkg_config vaapi_drm "libva-drm" "va/va_drm.h" vaGetDisplayDRM
+ case $target_os in
+ mingw32*|mingw64*|win32|win64)
+ check_pkg_config vaapi_win32 "libva-win32" "va/va_win32.h" vaGetDisplayWin32
+ ;;
+ *)
+ check_pkg_config vaapi_drm "libva-drm" "va/va_drm.h" vaGetDisplayDRM
+ ;;
+ esac
if enabled xlib_x11; then
check_pkg_config vaapi_x11 "libva-x11" "va/va_x11.h" vaGetDisplay
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 90c2c191d9..13633bdff1 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -18,6 +18,15 @@
#include "config.h"
+#if HAVE_VAAPI_WIN32
+# include <windows.h>
+#define COBJMACROS
+# include <initguid.h>
+# include <dxgi1_2.h>
+# include "compat/w32dlfcn.h"
+# include <va/va_win32.h>
+typedef HRESULT (WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
+#endif
#if HAVE_VAAPI_X11
# include <va/va_x11.h>
#endif
@@ -1663,7 +1672,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
VAAPIDevicePriv *priv;
VADisplay display = NULL;
const AVDictionaryEntry *ent;
- int try_drm, try_x11, try_all;
+ int try_drm, try_x11, try_win32, try_all;
priv = av_mallocz(sizeof(*priv));
if (!priv)
@@ -1681,6 +1690,8 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
try_drm = 1;
} else if (!strcmp(ent->value, "x11")) {
try_x11 = 1;
+ } else if (!strcmp(ent->value, "win32")) {
+ try_win32 = 1;
} else {
av_log(ctx, AV_LOG_ERROR, "Invalid connection type %s.\n",
ent->value);
@@ -1690,6 +1701,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
try_all = 1;
try_drm = HAVE_VAAPI_DRM;
try_x11 = HAVE_VAAPI_X11;
+ try_win32 = HAVE_VAAPI_WIN32;
}
#if HAVE_VAAPI_DRM
@@ -1797,6 +1809,68 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
}
#endif
+#if HAVE_VAAPI_WIN32
+ if (!display && try_win32) {
+ // Try to create a display from the specified device, if any.
+ if (!device) {
+ display = vaGetDisplayWin32(NULL);
+ } else {
+ IDXGIFactory2 *pDXGIFactory = NULL;
+ IDXGIAdapter *pAdapter = NULL;
+#if !HAVE_UWP
+ HANDLE dxgi = dlopen("dxgi.dll", 0);
+ if (!dxgi) {
+ av_log(ctx, AV_LOG_ERROR, "Failed to load dxgi.dll\n");
+ return AVERROR_UNKNOWN;
+ }
+ PFN_CREATE_DXGI_FACTORY pfnCreateDXGIFactory =
+ (PFN_CREATE_DXGI_FACTORY)dlsym(dxgi, "CreateDXGIFactory");
+ if (!pfnCreateDXGIFactory) {
+ av_log(ctx, AV_LOG_ERROR, "CreateDXGIFactory load failed\n");
+ dlclose(dxgi);
+ return AVERROR_UNKNOWN;
+ }
+#else
+ // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't
+ // available, only CreateDXGIFactory1
+ PFN_CREATE_DXGI_FACTORY pfnCreateDXGIFactory =
+ (PFN_CREATE_DXGI_FACTORY)CreateDXGIFactory1;
+#endif
+ if (SUCCEEDED(pfnCreateDXGIFactory(&IID_IDXGIFactory2,
+ (void **)&pDXGIFactory))) {
+ int adapter = atoi(device);
+ if (SUCCEEDED(IDXGIFactory2_EnumAdapters(pDXGIFactory,
+ adapter,
+ &pAdapter))) {
+ DXGI_ADAPTER_DESC desc;
+ if (SUCCEEDED(IDXGIAdapter2_GetDesc(pAdapter, &desc))) {
+ av_log(ctx, AV_LOG_INFO,
+ "Using device %04x:%04x (%ls) - LUID %lu %ld.\n",
+ desc.VendorId, desc.DeviceId, desc.Description,
+ desc.AdapterLuid.LowPart,
+ desc.AdapterLuid.HighPart);
+ display = vaGetDisplayWin32(&desc.AdapterLuid);
+ }
+ IDXGIAdapter_Release(pAdapter);
+ }
+ IDXGIFactory2_Release(pDXGIFactory);
+ }
+#if !HAVE_UWP
+ dlclose(dxgi);
+#endif
+ }
+
+ if (!display) {
+ av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display "
+ "from Win32 display.\n");
+ return AVERROR_UNKNOWN;
+ }
+
+ av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via "
+ "Win32 display.\n");
+ }
+#endif
+
if (!display) {
if (device)
av_log(ctx, AV_LOG_ERROR, "No VA display found for "
diff --git a/libavutil/tests/hwdevice.c b/libavutil/tests/hwdevice.c
index 7eb355c988..c57586613a 100644
--- a/libavutil/tests/hwdevice.c
+++ b/libavutil/tests/hwdevice.c
@@ -140,7 +140,7 @@ static const struct {
{ AV_HWDEVICE_TYPE_OPENCL,
{ "0.0", "0.1", "1.0", "1.1" } },
{ AV_HWDEVICE_TYPE_VAAPI,
- { "/dev/dri/renderD128", "/dev/dri/renderD129", ":0" } },
+ { "/dev/dri/renderD128", "/dev/dri/renderD129", ":0", "0", "1" } },
};
static int test_device_type(enum AVHWDeviceType type)
--
2.39.2.vfs.0.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH v3 2/3] Update -device argument usage in VAAPI documentation to indicate now also DirectX Adapter indices are supported.
2023-04-12 12:27 [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Sil Vilerino
@ 2023-04-12 12:27 ` Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows: Sil Vilerino
2023-04-12 12:57 ` [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Fahad Mustafa
2 siblings, 0 replies; 8+ messages in thread
From: Sil Vilerino @ 2023-04-12 12:27 UTC (permalink / raw)
To: ffmpeg-devel
Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
---
doc/ffmpeg.texi | 5 +++--
fftools/ffmpeg_opt.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index d433d60ce9..a79a9a694d 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1171,9 +1171,10 @@ Choose the first device and use the primary device context.
@var{device} is the number of the Direct3D 11 display adapter.
@item vaapi
-@var{device} is either an X11 display name or a DRM render node.
+@var{device} is either an X11 display name, a DRM render node or a DirectX adapter index.
If not specified, it will attempt to open the default X11 display (@emph{$DISPLAY})
-and then the first DRM render node (@emph{/dev/dri/renderD128}).
+and then the first DRM render node (@emph{/dev/dri/renderD128}), or the default
+DirectX adapter on Windows.
@item vdpau
@var{device} is an X11 display name.
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 055275d813..043cf539a5 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1758,7 +1758,7 @@ const OptionDef options[] = {
#if CONFIG_VAAPI
{ "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device },
- "set VAAPI hardware device (DRM path or X11 display name)", "device" },
+ "set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
#endif
#if CONFIG_QSV
--
2.39.2.vfs.0.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows:
2023-04-12 12:27 [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 2/3] Update -device argument usage in VAAPI documentation to indicate now also DirectX Adapter indices are supported Sil Vilerino
@ 2023-04-12 12:27 ` Sil Vilerino
2023-04-12 16:18 ` Hendrik Leppkes
2023-04-12 22:37 ` Neal Gompa
2023-04-12 12:57 ` [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Fahad Mustafa
2 siblings, 2 replies; 8+ messages in thread
From: Sil Vilerino @ 2023-04-12 12:27 UTC (permalink / raw)
To: ffmpeg-devel
- qsv_internal.h: Remove unnecessary include va_drm.h
- qsv_internal.h: Enable AVCODEC_QSV_LINUX_SESSION_HANDLE on Linux/VA only
- hwcontext_qsv.c: Do not allow child_device_type VAAPI for Windows until support is added, keep D3D11/DXVA2 as more prioritary defaults.
Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
---
libavcodec/qsv_internal.h | 5 ++---
libavutil/hwcontext_qsv.c | 14 ++++++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 5119ef4dff..df5e1e05ca 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -23,9 +23,9 @@
#include "config.h"
-#if CONFIG_VAAPI
+#if CONFIG_VAAPI && !_WIN32 // Do not enable for libva-win32 on Windows
#define AVCODEC_QSV_LINUX_SESSION_HANDLE
-#endif //CONFIG_VAAPI
+#endif //CONFIG_VAAPI && !_WIN32
#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
#include <stdio.h>
@@ -35,7 +35,6 @@
#endif
#include <fcntl.h>
#include <va/va.h>
-#include <va/va_drm.h>
#include "libavutil/hwcontext_vaapi.h"
#endif
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 6780428875..71212b177a 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -2126,8 +2126,6 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
"\"%s\".\n", e->value);
return AVERROR(EINVAL);
}
- } else if (CONFIG_VAAPI) {
- child_device_type = AV_HWDEVICE_TYPE_VAAPI;
#if QSV_ONEVPL
} else if (CONFIG_D3D11VA) { // Use D3D11 by default if d3d11va is enabled
av_log(ctx, AV_LOG_VERBOSE,
@@ -2147,11 +2145,23 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
} else if (CONFIG_D3D11VA) {
child_device_type = AV_HWDEVICE_TYPE_D3D11VA;
#endif
+ } else if (CONFIG_VAAPI) {
+ child_device_type = AV_HWDEVICE_TYPE_VAAPI;
} else {
av_log(ctx, AV_LOG_ERROR, "No supported child device type is enabled\n");
return AVERROR(ENOSYS);
}
+#if CONFIG_VAAPI && _WIN32
+ /* AV_HWDEVICE_TYPE_VAAPI on Windows/Libva-win32 not supported */
+ /* Reject user specified child_device_type or CONFIG_VAAPI on Windows */
+ if (child_device_type == AV_HWDEVICE_TYPE_VAAPI) {
+ av_log(ctx, AV_LOG_ERROR, "VAAPI child device type not supported for oneVPL on Windows"
+ "\"%s\".\n", e->value);
+ return AVERROR(EINVAL);
+ }
+#endif
+
child_device_opts = NULL;
switch (child_device_type) {
#if CONFIG_VAAPI
--
2.39.2.vfs.0.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32.
2023-04-12 12:27 [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 2/3] Update -device argument usage in VAAPI documentation to indicate now also DirectX Adapter indices are supported Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows: Sil Vilerino
@ 2023-04-12 12:57 ` Fahad Mustafa
2 siblings, 0 replies; 8+ messages in thread
From: Fahad Mustafa @ 2023-04-12 12:57 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Please don't send emails again.
On Wed, Apr 12, 2023, 5:28 PM Sil Vilerino <
sivileri-at-microsoft.com@ffmpeg.org> wrote:
> Libva 2.17+ adds a new libva-win32 node and Mesa 22.3 adds a VAAPI driver
> based on Direct3D 12 for Windows.
> Both of them are available at:
> https://www.nuget.org/packages/Microsoft.Direct3D.VideoAccelerationCompatibilityPack
>
> Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/
> Reviewed-by
> <https://github.com/intel-media-ci/ffmpeg/pull/619/Reviewed-by>: Dmitry
> Rogozhkin <dmitry.v.rogozhkin@intel.com>
> Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
> ---
> Changelog | 1 +
> configure | 27 ++++++++++++-
> libavutil/hwcontext_vaapi.c | 76 ++++++++++++++++++++++++++++++++++++-
> libavutil/tests/hwdevice.c | 2 +-
> 4 files changed, 102 insertions(+), 4 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index a40f32c23f..4ae8a4fe20 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
>
> version <next>:
> - libaribcaption decoder
> +- Extend VAAPI support for libva-win32 on Windows
>
> version 6.0:
> - Radiance HDR image support
> diff --git a/configure b/configure
> index 033db7442d..2a45b11aa4 100755
> --- a/configure
> +++ b/configure
> @@ -2316,6 +2316,7 @@ SYSTEM_LIBRARIES="
> bcrypt
> vaapi_drm
> vaapi_x11
> + vaapi_win32
> vdpau_x11
> "
>
> @@ -3826,7 +3827,7 @@ swscale_suggest="libm stdatomic"
>
> avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs
> lcms2_extralibs"
> avfilter_extralibs="pthreads_extralibs"
> -avutil_extralibs="d3d11va_extralibs mediacodec_extralibs
> nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs
> vaapi_x11_extralibs vdpau_x11_extralibs"
> +avutil_extralibs="d3d11va_extralibs mediacodec_extralibs
> nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs
> vaapi_x11_extralibs vaapi_win32_extralibs vdpau_x11_extralibs"
>
> # programs
> ffmpeg_deps="avcodec avfilter avformat threads"
> @@ -6947,6 +6948,21 @@ test_cpp <<EOF && enable uwp &&
> d3d11va_extralibs="-ldxgi -ld3d11"
> #endif
> EOF
>
> +# vaapi_win32 requires linking directly to dxgi if not building for
> +# the desktop api partition
> +test_cpp <<EOF && enable uwp && vaapi_win32_extralibs="-ldxgi"
> +#ifdef WINAPI_FAMILY
> +#include <winapifamily.h>
> +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
> +#error desktop, not uwp
> +#else
> +// WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP
> +#endif
> +#else
> +#error no family set
> +#endif
> +EOF
> +
> # mediafoundation requires linking directly to mfplat if building for uwp
> target
> enabled uwp && mediafoundation_extralibs="-lmfplat -lmfuuid -lole32
> -lstrmiids" || mediafoundation_extralibs="-lmfuuid -lole32 -lstrmiids"
>
> @@ -6957,7 +6973,14 @@ enabled vaapi &&
> check_pkg_config vaapi "libva >= 0.35.0" "va/va.h" vaInitialize
>
> if enabled vaapi; then
> - check_pkg_config vaapi_drm "libva-drm" "va/va_drm.h" vaGetDisplayDRM
> + case $target_os in
> + mingw32*|mingw64*|win32|win64)
> + check_pkg_config vaapi_win32 "libva-win32" "va/va_win32.h"
> vaGetDisplayWin32
> + ;;
> + *)
> + check_pkg_config vaapi_drm "libva-drm" "va/va_drm.h"
> vaGetDisplayDRM
> + ;;
> + esac
>
> if enabled xlib_x11; then
> check_pkg_config vaapi_x11 "libva-x11" "va/va_x11.h" vaGetDisplay
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 90c2c191d9..13633bdff1 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -18,6 +18,15 @@
>
> #include "config.h"
>
> +#if HAVE_VAAPI_WIN32
> +# include <windows.h>
> +#define COBJMACROS
> +# include <initguid.h>
> +# include <dxgi1_2.h>
> +# include "compat/w32dlfcn.h"
> +# include <va/va_win32.h>
> +typedef HRESULT (WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void
> **ppFactory);
> +#endif
> #if HAVE_VAAPI_X11
> # include <va/va_x11.h>
> #endif
> @@ -1663,7 +1672,7 @@ static int vaapi_device_create(AVHWDeviceContext
> *ctx, const char *device,
> VAAPIDevicePriv *priv;
> VADisplay display = NULL;
> const AVDictionaryEntry *ent;
> - int try_drm, try_x11, try_all;
> + int try_drm, try_x11, try_win32, try_all;
>
> priv = av_mallocz(sizeof(*priv));
> if (!priv)
> @@ -1681,6 +1690,8 @@ static int vaapi_device_create(AVHWDeviceContext
> *ctx, const char *device,
> try_drm = 1;
> } else if (!strcmp(ent->value, "x11")) {
> try_x11 = 1;
> + } else if (!strcmp(ent->value, "win32")) {
> + try_win32 = 1;
> } else {
> av_log(ctx, AV_LOG_ERROR, "Invalid connection type %s.\n",
> ent->value);
> @@ -1690,6 +1701,7 @@ static int vaapi_device_create(AVHWDeviceContext
> *ctx, const char *device,
> try_all = 1;
> try_drm = HAVE_VAAPI_DRM;
> try_x11 = HAVE_VAAPI_X11;
> + try_win32 = HAVE_VAAPI_WIN32;
> }
>
> #if HAVE_VAAPI_DRM
> @@ -1797,6 +1809,68 @@ static int vaapi_device_create(AVHWDeviceContext
> *ctx, const char *device,
> }
> #endif
>
> +#if HAVE_VAAPI_WIN32
> + if (!display && try_win32) {
> + // Try to create a display from the specified device, if any.
> + if (!device) {
> + display = vaGetDisplayWin32(NULL);
> + } else {
> + IDXGIFactory2 *pDXGIFactory = NULL;
> + IDXGIAdapter *pAdapter = NULL;
> +#if !HAVE_UWP
> + HANDLE dxgi = dlopen("dxgi.dll", 0);
> + if (!dxgi) {
> + av_log(ctx, AV_LOG_ERROR, "Failed to load dxgi.dll\n");
> + return AVERROR_UNKNOWN;
> + }
> + PFN_CREATE_DXGI_FACTORY pfnCreateDXGIFactory =
> + (PFN_CREATE_DXGI_FACTORY)dlsym(dxgi, "CreateDXGIFactory");
> + if (!pfnCreateDXGIFactory) {
> + av_log(ctx, AV_LOG_ERROR, "CreateDXGIFactory load
> failed\n");
> + dlclose(dxgi);
> + return AVERROR_UNKNOWN;
> + }
> +#else
> + // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't
> + // available, only CreateDXGIFactory1
> + PFN_CREATE_DXGI_FACTORY pfnCreateDXGIFactory =
> + (PFN_CREATE_DXGI_FACTORY)CreateDXGIFactory1;
> +#endif
> + if (SUCCEEDED(pfnCreateDXGIFactory(&IID_IDXGIFactory2,
> + (void **)&pDXGIFactory))) {
> + int adapter = atoi(device);
> + if (SUCCEEDED(IDXGIFactory2_EnumAdapters(pDXGIFactory,
> + adapter,
> + &pAdapter))) {
> + DXGI_ADAPTER_DESC desc;
> + if (SUCCEEDED(IDXGIAdapter2_GetDesc(pAdapter,
> &desc))) {
> + av_log(ctx, AV_LOG_INFO,
> + "Using device %04x:%04x (%ls) - LUID %lu
> %ld.\n",
> + desc.VendorId, desc.DeviceId,
> desc.Description,
> + desc.AdapterLuid.LowPart,
> + desc.AdapterLuid.HighPart);
> + display = vaGetDisplayWin32(&desc.AdapterLuid);
> + }
> + IDXGIAdapter_Release(pAdapter);
> + }
> + IDXGIFactory2_Release(pDXGIFactory);
> + }
> +#if !HAVE_UWP
> + dlclose(dxgi);
> +#endif
> + }
> +
> + if (!display) {
> + av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display "
> + "from Win32 display.\n");
> + return AVERROR_UNKNOWN;
> + }
> +
> + av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via "
> + "Win32 display.\n");
> + }
> +#endif
> +
> if (!display) {
> if (device)
> av_log(ctx, AV_LOG_ERROR, "No VA display found for "
> diff --git a/libavutil/tests/hwdevice.c b/libavutil/tests/hwdevice.c
> index 7eb355c988..c57586613a 100644
> --- a/libavutil/tests/hwdevice.c
> +++ b/libavutil/tests/hwdevice.c
> @@ -140,7 +140,7 @@ static const struct {
> { AV_HWDEVICE_TYPE_OPENCL,
> { "0.0", "0.1", "1.0", "1.1" } },
> { AV_HWDEVICE_TYPE_VAAPI,
> - { "/dev/dri/renderD128", "/dev/dri/renderD129", ":0" } },
> + { "/dev/dri/renderD128", "/dev/dri/renderD129", ":0", "0", "1" } },
> };
>
> static int test_device_type(enum AVHWDeviceType type)
> --
> 2.39.2.vfs.0.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows:
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows: Sil Vilerino
@ 2023-04-12 16:18 ` Hendrik Leppkes
[not found] ` <BL1PR21MB3354B2FAD414E1222FC1AB7CE5989@BL1PR21MB3354.namprd21.prod.outlook.com>
2023-04-12 22:37 ` Neal Gompa
1 sibling, 1 reply; 8+ messages in thread
From: Hendrik Leppkes @ 2023-04-12 16:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, Apr 12, 2023 at 2:28 PM Sil Vilerino
<sivileri-at-microsoft.com@ffmpeg.org> wrote:
>
> - qsv_internal.h: Remove unnecessary include va_drm.h
> - qsv_internal.h: Enable AVCODEC_QSV_LINUX_SESSION_HANDLE on Linux/VA only
> - hwcontext_qsv.c: Do not allow child_device_type VAAPI for Windows until support is added, keep D3D11/DXVA2 as more prioritary defaults.
>
> Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/
> Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
> Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
> ---
> libavcodec/qsv_internal.h | 5 ++---
> libavutil/hwcontext_qsv.c | 14 ++++++++++++--
> 2 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> index 5119ef4dff..df5e1e05ca 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -23,9 +23,9 @@
>
> #include "config.h"
>
> -#if CONFIG_VAAPI
> +#if CONFIG_VAAPI && !_WIN32 // Do not enable for libva-win32 on Windows
Shouldn't this be defined(_WIN32), same below?
> #define AVCODEC_QSV_LINUX_SESSION_HANDLE
> -#endif //CONFIG_VAAPI
> +#endif //CONFIG_VAAPI && !_WIN32
>
> #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
> #include <stdio.h>
> @@ -35,7 +35,6 @@
> #endif
> #include <fcntl.h>
> #include <va/va.h>
> -#include <va/va_drm.h>
> #include "libavutil/hwcontext_vaapi.h"
> #endif
>
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index 6780428875..71212b177a 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -2126,8 +2126,6 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
> "\"%s\".\n", e->value);
> return AVERROR(EINVAL);
> }
> - } else if (CONFIG_VAAPI) {
> - child_device_type = AV_HWDEVICE_TYPE_VAAPI;
> #if QSV_ONEVPL
> } else if (CONFIG_D3D11VA) { // Use D3D11 by default if d3d11va is enabled
> av_log(ctx, AV_LOG_VERBOSE,
> @@ -2147,11 +2145,23 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
> } else if (CONFIG_D3D11VA) {
> child_device_type = AV_HWDEVICE_TYPE_D3D11VA;
> #endif
> + } else if (CONFIG_VAAPI) {
> + child_device_type = AV_HWDEVICE_TYPE_VAAPI;
> } else {
> av_log(ctx, AV_LOG_ERROR, "No supported child device type is enabled\n");
> return AVERROR(ENOSYS);
> }
>
> +#if CONFIG_VAAPI && _WIN32
> + /* AV_HWDEVICE_TYPE_VAAPI on Windows/Libva-win32 not supported */
> + /* Reject user specified child_device_type or CONFIG_VAAPI on Windows */
> + if (child_device_type == AV_HWDEVICE_TYPE_VAAPI) {
> + av_log(ctx, AV_LOG_ERROR, "VAAPI child device type not supported for oneVPL on Windows"
> + "\"%s\".\n", e->value);
> + return AVERROR(EINVAL);
> + }
> +#endif
> +
> child_device_opts = NULL;
> switch (child_device_type) {
> #if CONFIG_VAAPI
> --
> 2.39.2.vfs.0.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows:
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows: Sil Vilerino
2023-04-12 16:18 ` Hendrik Leppkes
@ 2023-04-12 22:37 ` Neal Gompa
[not found] ` <BL1PR21MB3354D2B6E5BD3B88AF554073E5989@BL1PR21MB3354.namprd21.prod.outlook.com>
1 sibling, 1 reply; 8+ messages in thread
From: Neal Gompa @ 2023-04-12 22:37 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, Apr 12, 2023 at 8:28 AM Sil Vilerino
<sivileri-at-microsoft.com@ffmpeg.org> wrote:
>
> - qsv_internal.h: Remove unnecessary include va_drm.h
> - qsv_internal.h: Enable AVCODEC_QSV_LINUX_SESSION_HANDLE on Linux/VA only
> - hwcontext_qsv.c: Do not allow child_device_type VAAPI for Windows until support is added, keep D3D11/DXVA2 as more prioritary defaults.
>
> Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/
> Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
> Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
This email address is... interesting.
Perhaps you might want to add a manual From: statement to ensure
correct attribution?
--
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows:
[not found] ` <BL1PR21MB3354D2B6E5BD3B88AF554073E5989@BL1PR21MB3354.namprd21.prod.outlook.com>
@ 2023-04-13 13:08 ` Sil Vilerino
0 siblings, 0 replies; 8+ messages in thread
From: Sil Vilerino @ 2023-04-13 13:08 UTC (permalink / raw)
To: ffmpeg-devel-bounces, ffmpeg-devel
On 4/12/2023 6:38 PM, Neal Gompa wrote:
>
> This email address is... interesting.
>
> Perhaps you might want to add a manual From: statement to ensure correct attribution?
Oh, I'm not sure why it's showing like this, thanks for pointing this
out. I checked git send-email with another destination address and seems
to be using the intended sender address sivileri@linux.microsoft.com
I'll make sure to add the Signed-Off-By tag and check the From:
statement in next versions of the patches to ensure correct attribution.
--
Sil Vilerino
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows:
[not found] ` <BL1PR21MB3354B2FAD414E1222FC1AB7CE5989@BL1PR21MB3354.namprd21.prod.outlook.com>
@ 2023-04-13 13:11 ` Sil Vilerino
0 siblings, 0 replies; 8+ messages in thread
From: Sil Vilerino @ 2023-04-13 13:11 UTC (permalink / raw)
To: ffmpeg-devel-bounces, ffmpeg-devel
On 4/12/2023 12:18 PM, Hendrik Leppkes wrote:
>> -#if CONFIG_VAAPI
>> +#if CONFIG_VAAPI && !_WIN32 // Do not enable for libva-win32 on
>> +Windows
>
> Shouldn't this be defined(_WIN32), same below?
>
Great catch, thanks for pointing this out. Will change to
defined(_WIN32) on both files qsv_internal.h and hwcontext_qsv.c, will
wait a couple more days for comments on V3 before sending V4 with those
changes.
--
Sil Vilerino
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-04-13 13:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 12:27 [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 2/3] Update -device argument usage in VAAPI documentation to indicate now also DirectX Adapter indices are supported Sil Vilerino
2023-04-12 12:27 ` [FFmpeg-devel] [PATCH v3 3/3] Update QSV after adding support for VAAPI on Windows: Sil Vilerino
2023-04-12 16:18 ` Hendrik Leppkes
[not found] ` <BL1PR21MB3354B2FAD414E1222FC1AB7CE5989@BL1PR21MB3354.namprd21.prod.outlook.com>
2023-04-13 13:11 ` Sil Vilerino
2023-04-12 22:37 ` Neal Gompa
[not found] ` <BL1PR21MB3354D2B6E5BD3B88AF554073E5989@BL1PR21MB3354.namprd21.prod.outlook.com>
2023-04-13 13:08 ` Sil Vilerino
2023-04-12 12:57 ` [FFmpeg-devel] [PATCH v3 1/3] Add support for VAAPI on Windows in hwcontext_vaapi using vaGetDisplayWin32 Fahad Mustafa
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git