mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 01:47:38 +00:00
vo_gpu_next: add new libplacebo-based renderer
As discussed in #8799, this will eventually replace vo_gpu. However, it is not yet complete. Currently missing: - OpenGL contexts - hardware decoding - blend-subtitles=video - VOCTRL_SCREENSHOT However, it's usable enough to cover most use cases, and as such is enough to start getting in some crucial testing.
This commit is contained in:
parent
872015813c
commit
9d5d9b2424
@ -26,6 +26,11 @@ Interface changes
|
||||
|
||||
::
|
||||
|
||||
--- mpv 0.35.0 ---
|
||||
- add the `--vo=gpu-next` video output driver, as well as the options
|
||||
`--allow-delayed-peak-detect`, `--builtin-scalers`,
|
||||
`--interpolation-preserve` `--lut`, `--lut-type`, `--image-lut`,
|
||||
`--image-lut-type` and `--target-lut` along with it.
|
||||
--- mpv 0.34.0 ---
|
||||
- deprecate selecting by card number with `--drm-connector`, add
|
||||
`--drm-device` which can be used instead
|
||||
|
@ -5013,8 +5013,9 @@ ALSA audio output options
|
||||
GPU renderer options
|
||||
-----------------------
|
||||
|
||||
The following video options are currently all specific to ``--vo=gpu`` and
|
||||
``--vo=libmpv`` only, which are the only VOs that implement them.
|
||||
The following video options are currently all specific to ``--vo=gpu``,
|
||||
``--vo=libmpv`` and ``--vo=gpu-next``, which are the only VOs that implement
|
||||
them.
|
||||
|
||||
``--scale=<filter>``
|
||||
The filter function to use when upscaling video.
|
||||
@ -5191,6 +5192,12 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
will reproduce the source image perfectly if no scaling is performed.
|
||||
Enabled by default. Note that this option never affects ``--cscale``.
|
||||
|
||||
``--builtin-scalers``
|
||||
Allow using faster built-in replacements for common scalers such as
|
||||
``nearest``, ``bilinear`` or ``bicubic``. These have the disadvantage of
|
||||
not being configurable, unlike normal scaler kernels. Defaults to
|
||||
enabled. (This option only affects ``--vo=gpu-next``)
|
||||
|
||||
``--correct-downscaling``
|
||||
When using convolution based filters, extend the filter size when
|
||||
downscaling. Increases quality, but reduces performance while downscaling.
|
||||
@ -5267,6 +5274,15 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
|
||||
Set this to ``-1`` to disable this logic.
|
||||
|
||||
``--interpolation-preserve``
|
||||
Preserve the previous frames' interpolated results even when renderer
|
||||
parameters are changed - with the exception of options related to
|
||||
cropping and video placement, which always invalidate the cache. Enabling
|
||||
this option makes dynamic updates of renderer settings slightly smoother at
|
||||
the cost of slightly higher latency in response to such changes. Defaults
|
||||
to on. (Only affects ``--vo=gpu-next``, note that ``-vo=gpu`` always
|
||||
invalidates interpolated frames)
|
||||
|
||||
``--opengl-pbo``
|
||||
Enable use of PBOs. On some drivers this can be faster, especially if the
|
||||
source video size is huge (e.g. so called "4K" video). On other drivers it
|
||||
@ -6139,6 +6155,29 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
|
||||
NOTE: Only implemented on macOS.
|
||||
|
||||
``--image-lut=<file>``
|
||||
Specifies a custom LUT file (in Adobe .cube format) to apply to the colors
|
||||
during image decoding. The exact interpretation of the LUT depends on
|
||||
the value of ``--image-lut-type``. (Only for ``--vo=gpu-next``)
|
||||
|
||||
``--image-lut-type=<value>``
|
||||
Controls the interpretation of color values fed to and from the LUT
|
||||
specified as ``--image-lut``. Valid values are:
|
||||
|
||||
auto
|
||||
Chooses the interpretation of the LUT automatically from tagged
|
||||
metadata, and otherwise falls back to ``native``. (Default)
|
||||
native
|
||||
Applied to the raw image contents in its native colorspace, before
|
||||
decoding to RGB. For example, for a HDR10 image, this would be fed
|
||||
PQ-encoded YCbCr values in the range 0.0 - 1.0.
|
||||
normalized
|
||||
Applied to the normalized RGB image contents, after decoding from
|
||||
its native color encoding, but before linearization.
|
||||
conversion
|
||||
Fully replaces the color decoding. A LUT of this type should ingest the
|
||||
image's native colorspace and output normalized non-linear RGB.
|
||||
|
||||
``--target-prim=<value>``
|
||||
Specifies the primaries of the display. Video colors will be adapted to
|
||||
this colorspace when ICC color management is not being used. Valid values
|
||||
@ -6254,6 +6293,12 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
In such a configuration, we highly recommend setting ``--tone-mapping``
|
||||
to ``mobius`` or even ``clip``.
|
||||
|
||||
``--target-lut=<file>``
|
||||
Specifies a custom LUT file (in Adobe .cube format) to apply to the colors
|
||||
before display on-screen. This LUT is fed values in normalized RGB, after
|
||||
encoding into the target colorspace, so after the application of
|
||||
``--target-trc``. (Only for ``--vo=gpu-next``)
|
||||
|
||||
``--tone-mapping=<value>``
|
||||
Specifies the algorithm used for tone-mapping images onto the target
|
||||
display. This is relevant for both HDR->SDR conversion as well as gamut
|
||||
@ -6335,6 +6380,14 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
The special value ``auto`` (default) will enable HDR peak computation
|
||||
automatically if compute shaders and SSBOs are supported.
|
||||
|
||||
``--allow-delayed-peak-detect``
|
||||
When using ``--hdr-compute-peak``, allow delaying the detected peak by a
|
||||
frame when beneficial for performance. In particular, this is required to
|
||||
avoid an unnecessary FBO indirection when no advanced rendering is required
|
||||
otherwise. Has no effect if there already is an indirect pass, such as when
|
||||
advanced scaling is enabled. Defaults to on. (Only affects
|
||||
``--vo=gpu-next``, note that ``--vo=gpu`` always delays the peak.)
|
||||
|
||||
``--hdr-peak-decay-rate=<1.0..1000.0>``
|
||||
The decay rate used for the HDR peak detection algorithm (default: 100.0).
|
||||
This is only relevant when ``--hdr-compute-peak`` is enabled. Higher values
|
||||
@ -6456,6 +6509,30 @@ The following video options are currently all specific to ``--vo=gpu`` and
|
||||
value ``inf`` causes the BT.1886 curve to be treated as a pure power gamma
|
||||
2.4 function.
|
||||
|
||||
``--lut=<file>``
|
||||
Specifies a custom LUT (in Adobe .cube format) to apply to the colors
|
||||
as part of color conversion. The exact interpretation depends on the value
|
||||
of ``--lut-type``. (Only for ``--vo=gpu-next``)
|
||||
|
||||
``--lut-type=<value>``
|
||||
Controls the interpretation of color values fed to and from the LUT
|
||||
specified as ``--lut``. Valid values are:
|
||||
|
||||
auto
|
||||
Chooses the interpretation of the LUT automatically from tagged
|
||||
metadata, and otherwise falls back to ``native``. (Default)
|
||||
native
|
||||
Applied to raw image contents in its native RGB colorspace (non-linear
|
||||
light), before conversion to the output color space.
|
||||
normalized
|
||||
Applied to the normalized RGB image contents, in linear light, before
|
||||
conversion to the output color space.
|
||||
conversion
|
||||
Fully replaces the conversion from the image color space to the output
|
||||
color space. If such a LUT is present, it has the highest priority, and
|
||||
overrides any ICC profiles, as well as options related to tone mapping
|
||||
and output colorimetry (``--target-prim``, ``--target-trc`` etc.).
|
||||
|
||||
``--blend-subtitles=<yes|video|no>``
|
||||
Blend subtitles directly onto upscaled video frames, before interpolation
|
||||
and/or color management (default: no). Enabling this causes subtitles to be
|
||||
|
@ -257,6 +257,18 @@ Available video output drivers are:
|
||||
with ``rgb32f``. If you have problems, you can also try enabling the
|
||||
``--gpu-dumb-mode=yes`` option.
|
||||
|
||||
``gpu-next``
|
||||
Experimental video renderer based on ``libplacebo``. This supports almost
|
||||
the same set of features as ``--vo=gpu``. See `GPU renderer options`_ for a
|
||||
list.
|
||||
|
||||
Currently, this only supports ``--gpu-api=vulkan``, and no hardware
|
||||
decoding. Unlike ``--vo=gpu``, the FBO formats are not tunable, but you can
|
||||
still set ``--gpu-dumb-mode=yes`` to forcibly disable their use.
|
||||
|
||||
Should generally be faster and higher quality, but some features may still
|
||||
be missing or misbehave. Expect (and report!) bugs.
|
||||
|
||||
``sdl``
|
||||
SDL 2.0+ Render video output driver, depending on system with or without
|
||||
hardware acceleration. Should work on all platforms supported by SDL 2.0.
|
||||
|
@ -58,3 +58,121 @@ void mppl_ctx_set_log(struct pl_context *ctx, struct mp_log *log, bool probing)
|
||||
.log_priv = log,
|
||||
});
|
||||
}
|
||||
|
||||
enum pl_color_primaries mp_prim_to_pl(enum mp_csp_prim prim)
|
||||
{
|
||||
switch (prim) {
|
||||
case MP_CSP_PRIM_AUTO: return PL_COLOR_PRIM_UNKNOWN;
|
||||
case MP_CSP_PRIM_BT_601_525: return PL_COLOR_PRIM_BT_601_525;
|
||||
case MP_CSP_PRIM_BT_601_625: return PL_COLOR_PRIM_BT_601_625;
|
||||
case MP_CSP_PRIM_BT_709: return PL_COLOR_PRIM_BT_709;
|
||||
case MP_CSP_PRIM_BT_2020: return PL_COLOR_PRIM_BT_2020;
|
||||
case MP_CSP_PRIM_BT_470M: return PL_COLOR_PRIM_BT_470M;
|
||||
case MP_CSP_PRIM_APPLE: return PL_COLOR_PRIM_APPLE;
|
||||
case MP_CSP_PRIM_ADOBE: return PL_COLOR_PRIM_ADOBE;
|
||||
case MP_CSP_PRIM_PRO_PHOTO: return PL_COLOR_PRIM_PRO_PHOTO;
|
||||
case MP_CSP_PRIM_CIE_1931: return PL_COLOR_PRIM_CIE_1931;
|
||||
case MP_CSP_PRIM_DCI_P3: return PL_COLOR_PRIM_DCI_P3;
|
||||
case MP_CSP_PRIM_DISPLAY_P3: return PL_COLOR_PRIM_DISPLAY_P3;
|
||||
case MP_CSP_PRIM_V_GAMUT: return PL_COLOR_PRIM_V_GAMUT;
|
||||
case MP_CSP_PRIM_S_GAMUT: return PL_COLOR_PRIM_S_GAMUT;
|
||||
case MP_CSP_PRIM_COUNT: return PL_COLOR_PRIM_COUNT;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
||||
enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc)
|
||||
{
|
||||
switch (trc) {
|
||||
case MP_CSP_TRC_AUTO: return PL_COLOR_TRC_UNKNOWN;
|
||||
case MP_CSP_TRC_BT_1886: return PL_COLOR_TRC_BT_1886;
|
||||
case MP_CSP_TRC_SRGB: return PL_COLOR_TRC_SRGB;
|
||||
case MP_CSP_TRC_LINEAR: return PL_COLOR_TRC_LINEAR;
|
||||
case MP_CSP_TRC_GAMMA18: return PL_COLOR_TRC_GAMMA18;
|
||||
case MP_CSP_TRC_GAMMA20: return PL_COLOR_TRC_UNKNOWN; // missing
|
||||
case MP_CSP_TRC_GAMMA22: return PL_COLOR_TRC_GAMMA22;
|
||||
case MP_CSP_TRC_GAMMA24: return PL_COLOR_TRC_UNKNOWN; // missing
|
||||
case MP_CSP_TRC_GAMMA26: return PL_COLOR_TRC_UNKNOWN; // missing
|
||||
case MP_CSP_TRC_GAMMA28: return PL_COLOR_TRC_GAMMA28;
|
||||
case MP_CSP_TRC_PRO_PHOTO: return PL_COLOR_TRC_PRO_PHOTO;
|
||||
case MP_CSP_TRC_PQ: return PL_COLOR_TRC_PQ;
|
||||
case MP_CSP_TRC_HLG: return PL_COLOR_TRC_HLG;
|
||||
case MP_CSP_TRC_V_LOG: return PL_COLOR_TRC_V_LOG;
|
||||
case MP_CSP_TRC_S_LOG1: return PL_COLOR_TRC_S_LOG1;
|
||||
case MP_CSP_TRC_S_LOG2: return PL_COLOR_TRC_S_LOG2;
|
||||
case MP_CSP_TRC_COUNT: return PL_COLOR_TRC_COUNT;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
||||
enum pl_color_light mp_light_to_pl(enum mp_csp_light light)
|
||||
{
|
||||
switch (light) {
|
||||
case MP_CSP_LIGHT_AUTO: return PL_COLOR_LIGHT_UNKNOWN;
|
||||
case MP_CSP_LIGHT_DISPLAY: return PL_COLOR_LIGHT_DISPLAY;
|
||||
case MP_CSP_LIGHT_SCENE_HLG: return PL_COLOR_LIGHT_SCENE_HLG;
|
||||
case MP_CSP_LIGHT_SCENE_709_1886: return PL_COLOR_LIGHT_SCENE_709_1886;
|
||||
case MP_CSP_LIGHT_SCENE_1_2: return PL_COLOR_LIGHT_SCENE_1_2;
|
||||
case MP_CSP_LIGHT_COUNT: return PL_COLOR_LIGHT_COUNT;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
||||
enum pl_color_system mp_csp_to_pl(enum mp_csp csp)
|
||||
{
|
||||
switch (csp) {
|
||||
case MP_CSP_AUTO: return PL_COLOR_SYSTEM_UNKNOWN;
|
||||
case MP_CSP_BT_601: return PL_COLOR_SYSTEM_BT_601;
|
||||
case MP_CSP_BT_709: return PL_COLOR_SYSTEM_BT_709;
|
||||
case MP_CSP_SMPTE_240M: return PL_COLOR_SYSTEM_SMPTE_240M;
|
||||
case MP_CSP_BT_2020_NC: return PL_COLOR_SYSTEM_BT_2020_NC;
|
||||
case MP_CSP_BT_2020_C: return PL_COLOR_SYSTEM_BT_2020_C;
|
||||
case MP_CSP_RGB: return PL_COLOR_SYSTEM_RGB;
|
||||
case MP_CSP_XYZ: return PL_COLOR_SYSTEM_XYZ;
|
||||
case MP_CSP_YCGCO: return PL_COLOR_SYSTEM_YCGCO;
|
||||
case MP_CSP_COUNT: return PL_COLOR_SYSTEM_COUNT;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
||||
enum pl_color_levels mp_levels_to_pl(enum mp_csp_levels levels)
|
||||
{
|
||||
switch (levels) {
|
||||
case MP_CSP_LEVELS_AUTO: return PL_COLOR_LEVELS_UNKNOWN;
|
||||
case MP_CSP_LEVELS_TV: return PL_COLOR_LEVELS_TV;
|
||||
case MP_CSP_LEVELS_PC: return PL_COLOR_LEVELS_PC;
|
||||
case MP_CSP_LEVELS_COUNT: return PL_COLOR_LEVELS_COUNT;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
||||
enum pl_alpha_mode mp_alpha_to_pl(enum mp_alpha_type alpha)
|
||||
{
|
||||
switch (alpha) {
|
||||
// Note: Older versions of libplacebo incorreclty handled PL_ALPHA_UNKNOWN
|
||||
// as premultiplied, so explicitly default this to independent instead.
|
||||
case MP_ALPHA_AUTO: return PL_ALPHA_INDEPENDENT;
|
||||
case MP_ALPHA_STRAIGHT: return PL_ALPHA_INDEPENDENT;
|
||||
case MP_ALPHA_PREMUL: return PL_ALPHA_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
||||
enum pl_chroma_location mp_chroma_to_pl(enum mp_chroma_location chroma)
|
||||
{
|
||||
switch (chroma) {
|
||||
case MP_CHROMA_AUTO: return PL_CHROMA_UNKNOWN;
|
||||
case MP_CHROMA_TOPLEFT: return PL_CHROMA_TOP_LEFT;
|
||||
case MP_CHROMA_LEFT: return PL_CHROMA_LEFT;
|
||||
case MP_CHROMA_CENTER: return PL_CHROMA_CENTER;
|
||||
case MP_CHROMA_COUNT: return PL_CHROMA_COUNT;
|
||||
}
|
||||
|
||||
MP_UNREACHABLE();
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/msg.h"
|
||||
#include "video/csputils.h"
|
||||
|
||||
#include <libplacebo/common.h>
|
||||
#include <libplacebo/context.h>
|
||||
#include <libplacebo/colorspace.h>
|
||||
|
||||
void mppl_ctx_set_log(struct pl_context *ctx, struct mp_log *log, bool probing);
|
||||
|
||||
@ -17,3 +19,11 @@ static inline struct pl_rect2d mp_rect2d_to_pl(struct mp_rect rc)
|
||||
.y1 = rc.y1,
|
||||
};
|
||||
}
|
||||
|
||||
enum pl_color_primaries mp_prim_to_pl(enum mp_csp_prim prim);
|
||||
enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc);
|
||||
enum pl_color_light mp_light_to_pl(enum mp_csp_light light);
|
||||
enum pl_color_system mp_csp_to_pl(enum mp_csp csp);
|
||||
enum pl_color_levels mp_levels_to_pl(enum mp_csp_levels levels);
|
||||
enum pl_alpha_mode mp_alpha_to_pl(enum mp_alpha_type alpha);
|
||||
enum pl_chroma_location mp_chroma_to_pl(enum mp_chroma_location chroma);
|
||||
|
@ -52,6 +52,7 @@ extern const struct vo_driver video_out_x11;
|
||||
extern const struct vo_driver video_out_vdpau;
|
||||
extern const struct vo_driver video_out_xv;
|
||||
extern const struct vo_driver video_out_gpu;
|
||||
extern const struct vo_driver video_out_gpu_next;
|
||||
extern const struct vo_driver video_out_libmpv;
|
||||
extern const struct vo_driver video_out_null;
|
||||
extern const struct vo_driver video_out_image;
|
||||
@ -73,6 +74,9 @@ const struct vo_driver *const video_out_drivers[] =
|
||||
&video_out_mediacodec_embed,
|
||||
#endif
|
||||
&video_out_gpu,
|
||||
#if HAVE_LIBPLACEBO_V4
|
||||
&video_out_gpu_next,
|
||||
#endif
|
||||
#if HAVE_VDPAU
|
||||
&video_out_vdpau,
|
||||
#endif
|
||||
|
1264
video/out/vo_gpu_next.c
Normal file
1264
video/out/vo_gpu_next.c
Normal file
File diff suppressed because it is too large
Load Diff
6
wscript
6
wscript
@ -739,6 +739,12 @@ video_output_features = [
|
||||
'name': '--libplacebo',
|
||||
'desc': 'libplacebo support',
|
||||
'func': check_pkg_config('libplacebo >= 3.104.0'),
|
||||
}, {
|
||||
'name': 'libplacebo-v4',
|
||||
'desc': 'libplacebo v4.157+, needed for vo_gpu_next',
|
||||
'deps': 'libplacebo',
|
||||
'func': check_preprocessor('libplacebo/config.h', 'PL_API_VER >= 157',
|
||||
use='libplacebo'),
|
||||
}, {
|
||||
'name': '--vulkan',
|
||||
'desc': 'Vulkan context support',
|
||||
|
@ -492,6 +492,7 @@ def build(ctx):
|
||||
( "video/out/vo_direct3d.c", "direct3d" ),
|
||||
( "video/out/vo_drm.c", "drm" ),
|
||||
( "video/out/vo_gpu.c" ),
|
||||
( "video/out/vo_gpu_next.c", "libplacebo-v4" ),
|
||||
( "video/out/vo_image.c" ),
|
||||
( "video/out/vo_lavc.c" ),
|
||||
( "video/out/vo_libmpv.c" ),
|
||||
|
Loading…
Reference in New Issue
Block a user