0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
mpv/video
Philip Langdale 59478b0059 hwtransfer: implement support for hw->hw format conversion
Historically, we have not attempted to support hw->hw format conversion
in the autoconvert logic. If a user needed to do these kinds of
conversions, they needed to manually insert the hw format's conversion
filter manually (eg: scale_vaapi).

This was usually fine because the general rule is that any format
supported by the hardware can be used as well as any other. ie: You
would only need to do conversion if you have a specific goal in mind.

However, we now have two situations where we can find ourselves with a
hardware format being produced by a decoder that cannot be accepted by
a VO via hwdec-interop:
 * dmabuf-wayland can only accept formats that the Wayland compositor
   accepts. In the case of GNOME, it can only accept a handful of RGB
   formats.
 * When decoding via VAAPI on Intel hardware, some of the more unusual
   video encodings (4:2:2, 10bit 4:4:4) lead to packed frame formats
   which gpu-next cannot handle, causing rendering to fail.

In both these cases (at least when using VAAPI with dmabuf-wayland), if
we could detect the failure case and insert a `scale_vaapi` filter, we
could get successful output automatically. For `hwdec=drm`, there is
currently no conversion filter, so dmabuf-wayland is still out of luck
there.

The basic approach to implementing this is to detect the case where we
are evaluating a hardware format where the VO can accept the hardware
format itself, but may not accept the underlying sw format. In the
current code, we bypass autoconvert as soon as we see the hardware
format is compatible.

My first observation was that we actually have logic in autoconvert to
detect when the input sw format is not in the list of allowed sw
formats passed into the autoconverter. Unfortunately, we never populate
this list, and the way you would expect to do that is vo-query-format
returning sw format information, which it does not. We could define an
extended vo-query-format-2, but we'd still need to implement the
probing logic to fill it in.

On the other hand, we already have the probing logic in the hwupload
filter - and most recently I used that logic to implement conversion
on upload. So if we could leverage that, we could both detect when
hw->hw conversion is required, and pick the best target format.

This exercise is then primarily one of detecting when we are in this
case and letting that code run in a useful way. The hwupload filter is
a bit awkward to work with today, and so I refactored a bunch of the
set up code to actually make it more encapsulated. Now, instead of the
caller instantiating it and then triggering the probe, we probe on
creation and instantiate the correct underlying filter (hwupload vs
conversion) automatically.
2023-08-26 10:07:55 -07:00
..
decode vd_lavc: repeatedly attempt to fallback if hwdec fails in reinit 2023-08-06 04:42:13 -07:00
filter vf_vapoursynth: save display resolution as a variable 2023-08-13 19:58:20 +00:00
out hwtransfer: implement support for hw->hw format conversion 2023-08-26 10:07:55 -07:00
csputils.c video: add missing libplacebo colorspace enums 2023-03-05 22:37:05 -05:00
csputils.h video: add missing libplacebo colorspace enums 2023-03-05 22:37:05 -05:00
cuda.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
d3d.c video: remove mp_image_params.hw_flags field 2019-10-17 22:43:14 +02:00
d3d.h video: move d3d.c out of decode sub directory 2017-12-01 17:58:56 +01:00
drmprime.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
fmt-conversion.c hwdec_vulkan: add Vulkan HW Interop 2023-05-28 15:46:05 -07:00
fmt-conversion.h video/fmt-conversion, img_format: change license to LGPL 2017-06-18 15:15:07 +02:00
hwdec.c filters: support loading new hwdec_interops from filters 2022-09-21 09:39:34 -07:00
hwdec.h hwtransfer: implement support for hw->hw format conversion 2023-08-26 10:07:55 -07:00
image_loader.c screenshot, vo_image: use global swscale/zimg parameters 2019-10-31 15:44:09 +01:00
image_loader.h x11: load icon differently 2017-07-01 15:56:12 +02:00
image_writer.c video_writer: fix gamma for YUV screenshots 2023-07-26 11:26:36 +02:00
image_writer.h video/image_writer: add avif screenshot support 2023-07-01 02:05:23 +00:00
img_format.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
img_format.h hwdec_vulkan: add Vulkan HW Interop 2023-05-28 15:46:05 -07:00
mp_image_pool.c f_hwtransfer: disable vulkan multiplane images when uploading from cuda 2023-05-28 15:46:05 -07:00
mp_image_pool.h f_hwtransfer: disable vulkan multiplane images when uploading from cuda 2023-05-28 15:46:05 -07:00
mp_image.c mp_image: properly infer color levels for some pixfmts 2023-08-07 18:22:41 +02:00
mp_image.h mp_image: forward AV_FRAME_DATA_DOVI_RPU_BUFFER side data 2023-02-19 20:50:37 +01:00
repack.c repack: add repacker for ccc16x16 formats 2022-09-10 12:31:44 -07:00
repack.h repack: add support for converting from/to float formats 2020-05-09 18:02:57 +02:00
sws_utils.c test: integrate unittests with meson 2023-03-02 15:45:27 +00:00
sws_utils.h sws_utils: work around libswscale corrupting memory yet again 2020-09-17 15:24:27 +02:00
vaapi.c vaapi: correct broken NULL check 2020-06-03 15:12:08 +02:00
vaapi.h vo_gpu: hwdec_vaapi: Suppress format errors when probing 2019-07-08 01:57:02 +02:00
vdpau_functions.inc vo_vdpau: directly get surface size from surface for screenshots 2015-06-05 22:34:16 +02:00
vdpau_mixer.c video: redo video equalizer option handling 2017-08-22 17:01:35 +02:00
vdpau_mixer.h options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
vdpau.c video: remove RGB32/BGR32 aliases 2020-05-11 19:57:34 +02:00
vdpau.h vd_lavc, vdpau, vaapi: restore emulated API avoidance 2017-12-02 04:53:51 +01:00
zimg.c zimg: fix abort on subsampled input with odd heights 2023-07-26 11:26:36 +02:00
zimg.h options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00