Re: [FFmpeg-devel] [PATCH v7 3/8] libavutil/hwcontext_qsv: enabling d3d11va usage by default, add usage child_device_type argument

2021-03-10 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Soft Works
> Sent: Thursday, February 25, 2021 8:50 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Artem Galin 
> Subject: Re: [FFmpeg-devel] [PATCH v7 3/8] libavutil/hwcontext_qsv:
> enabling d3d11va usage by default, add usage child_device_type argument
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Artem Galin
> > Sent: Tuesday, November 3, 2020 7:46 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Artem Galin 
> > Subject: [FFmpeg-devel] [PATCH v7 3/8] libavutil/hwcontext_qsv:
> > enabling d3d11va usage by default, add usage child_device_type
> > argument
> >
> > Makes selection of d3d11va device type by default and over DirectX 9,
> > which might break users with older drivers/systems.
> > DCH driver with Gen6th support should be still fine.
> >
> > Decode, encode, transcode have been validated.
> >
> > child_device_type option is responsible for d3d11va/dxva2 device
> > selection
> >
> > Usage examples:
> >
> > DirectX 11
> > -init_hw_device qsv:hw,child_device_type=d3d11va
> >
> > DirectX 9 is still supported but requires explicit selection
> > -init_hw_device
> > qsv:hw,child_device_type=dxva2
> >
> 
> Hi Artem,
> 
> Could you please show a complete command line, demonstrating how to use
> a D3D9/DXVA2 hardware context with your patch?
> 
> Something like qsv decoder, scale_qsv and qsv encoder...
> 
> Thanks,
> Softworkz

Hello Artem,

I don't know whether you read my message above, but in case you did, I suppose 
that you have realized that this would be no longer possible with your patch.
The QSV decoders do not allow setting a hardware device, and that means that 
the command snippet in your commit message (-init_hw_device 
qsv:hw,child_device_type=dxva2) doesn't affect decoders, but only filters and 
encoders at best.

That's why I had that global parameter (qsv_use_dx11) in my original patch 
(that follows the existing implementation of the qsc_device parameter, which is 
global as well).

As long as the patch breaks usage of D3D9 (for QSV decoding), I don't think it 
will ever get merged.
(not insisting to change the default to DX11 might help as well)

Kind regards,
Softworkz




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v7 3/8] libavutil/hwcontext_qsv: enabling d3d11va usage by default, add usage child_device_type argument

2021-02-25 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Artem Galin
> Sent: Tuesday, November 3, 2020 7:46 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Artem Galin 
> Subject: [FFmpeg-devel] [PATCH v7 3/8] libavutil/hwcontext_qsv: enabling
> d3d11va usage by default, add usage child_device_type argument
> 
> Makes selection of d3d11va device type by default and over DirectX 9, which
> might break users with older drivers/systems.
> DCH driver with Gen6th support should be still fine.
> 
> Decode, encode, transcode have been validated.
> 
> child_device_type option is responsible for d3d11va/dxva2 device selection
> 
> Usage examples:
> 
> DirectX 11
> -init_hw_device qsv:hw,child_device_type=d3d11va
> 
> DirectX 9 is still supported but requires explicit selection -init_hw_device
> qsv:hw,child_device_type=dxva2
> 

Hi Artem,

Could you please show a complete command line, demonstrating how to
use a D3D9/DXVA2 hardware context with your patch?

Something like qsv decoder, scale_qsv and qsv encoder...

Thanks,
softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v7 3/8] libavutil/hwcontext_qsv: enabling d3d11va usage by default, add usage child_device_type argument

2020-11-03 Thread Artem Galin
Makes selection of d3d11va device type by default and over DirectX 9,
which might break users with older drivers/systems.
DCH driver with Gen6th support should be still fine.

Decode, encode, transcode have been validated.

child_device_type option is responsible for d3d11va/dxva2 device selection

Usage examples:

DirectX 11
-init_hw_device qsv:hw,child_device_type=d3d11va

DirectX 9 is still supported but requires explicit selection
-init_hw_device qsv:hw,child_device_type=dxva2

Signed-off-by: Artem Galin 
---
 doc/ffmpeg.texi   | 20 -
 libavutil/hwcontext_qsv.c | 59 +--
 2 files changed, 64 insertions(+), 15 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 95d6463685..2fa99813c6 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -974,6 +974,9 @@ device type:
 @item dxva2
 @var{device} is the number of the Direct3D 9 display adapter.
 
+@item d3d11va
+@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.
 If not specified, it will attempt to open the default X11 display 
(@emph{$DISPLAY})
@@ -997,9 +1000,21 @@ If not specified, it will attempt to open the default X11 
display (@emph{$DISPLA
 @end table
 If not specified, @samp{auto_any} is used.
 (Note that it may be easier to achieve the desired result for QSV by creating 
the
-platform-appropriate subdevice (@samp{dxva2} or @samp{vaapi}) and then 
deriving a
+platform-appropriate subdevice (@samp{dxva2} or @samp{d3d11va} or 
@samp{vaapi}) and then deriving a
 QSV device from that.)
 
+Alternatively, @samp{child_device_type} helps to choose platform-appropriate 
subdevice type.
+On Windows @samp{d3d11va} is used as default subdevice type.
+
+Examples:
+@table @emph
+@item -init_hw_device qsv:hw,child_device_type=d3d11va
+Choose the GPU subdevice with type @samp{d3d11va} and create QSV device with 
@samp{MFX_IMPL_HARDWARE}.
+
+@item -init_hw_device qsv:hw,child_device_type=dxva2
+Choose the GPU subdevice with type @samp{dxva2} and create QSV device with 
@samp{MFX_IMPL_HARDWARE}.
+@end table
+
 @item opencl
 @var{device} selects the platform and device as 
@emph{platform_index.device_index}.
 
@@ -1102,6 +1117,9 @@ Use VDPAU (Video Decode and Presentation API for Unix) 
hardware acceleration.
 @item dxva2
 Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
 
+@item d3d11va
+Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
+
 @item vaapi
 Use VAAPI (Video Acceleration API) hardware acceleration.
 
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 1f5a3d1c57..c0a71c9822 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1440,28 +1440,59 @@ static int qsv_device_create(AVHWDeviceContext *ctx, 
const char *device,
 ctx->user_opaque = priv;
 ctx->free= qsv_device_free;
 
-e = av_dict_get(opts, "child_device", NULL, 0);
-
-child_device_opts = NULL;
-if (CONFIG_VAAPI) {
+e = av_dict_get(opts, "child_device_type", NULL, 0);
+if (e) {
+child_device_type = av_hwdevice_find_type_by_name(e ? e->value : NULL);
+if (child_device_type == AV_HWDEVICE_TYPE_NONE) {
+av_log(ctx, AV_LOG_ERROR, "Unknown child device type "
+   "\"%s\".\n", e ? e->value : NULL);
+return AVERROR(EINVAL);
+}
+} else if (CONFIG_VAAPI) {
 child_device_type = AV_HWDEVICE_TYPE_VAAPI;
-// libmfx does not actually implement VAAPI properly, rather it
-// depends on the specific behaviour of a matching iHD driver when
-// used on recent Intel hardware.  Set options to the VAAPI device
-// creation so that we should pick a usable setup by default if
-// possible, even when multiple devices and drivers are available.
-av_dict_set(_device_opts, "kernel_driver", "i915", 0);
-av_dict_set(_device_opts, "driver","iHD",  0);
-} else if (CONFIG_DXVA2)
+} else if (CONFIG_D3D11VA) {
+child_device_type = AV_HWDEVICE_TYPE_D3D11VA;
+} else if (CONFIG_DXVA2) {
 child_device_type = AV_HWDEVICE_TYPE_DXVA2;
-else {
+} else {
 av_log(ctx, AV_LOG_ERROR, "No supported child device type is 
enabled\n");
 return AVERROR(ENOSYS);
 }
 
+child_device_opts = NULL;
+switch (child_device_type) {
+#if CONFIG_VAAPI
+case AV_HWDEVICE_TYPE_VAAPI:
+{
+// libmfx does not actually implement VAAPI properly, rather it
+// depends on the specific behaviour of a matching iHD driver when
+// used on recent Intel hardware.  Set options to the VAAPI device
+// creation so that we should pick a usable setup by default if
+// possible, even when multiple devices and drivers are available.
+av_dict_set(_device_opts, "kernel_driver", "i915", 0);
+av_dict_set(_device_opts, "driver",