Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin.conf: modernize internal profiles #12384

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions DOCS/interface-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ Interface changes
- remove `bcspline` filter (`bicubic` is now the same as `bcspline`)
- rename `--cache-dir` and `--cache-unlink-files` to `--demuxer-cache-dir` and
`--demuxer-cache-unlink-files`
- enable `--correct-downscaling`, `--linear-downscaling`, `--sigmoid-upscaling`
- `--cscale` defaults to `--scale` if not defined
kasper93 marked this conversation as resolved.
Show resolved Hide resolved
- change `--tscale` default to `oversample`
- change `--dither-depth` to `auto`
- deprecate `--profile=gpu-hq`, add `--profile=<fast|high-quality>`
--- mpv 0.36.0 ---
- add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used.
Expand Down
38 changes: 19 additions & 19 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5252,17 +5252,16 @@ them.
The filter function to use when upscaling video.

``bilinear``
Bilinear hardware texture filtering (fastest, very low quality). This
is the default for compatibility reasons.
Bilinear hardware texture filtering (fastest, very low quality). This is
the default when using the ``fast`` profile.

``spline36``
Mid quality and speed. This is the default when using ``gpu-hq``.
Mid quality and speed.

``lanczos``
Lanczos scaling. Provides mid quality and speed. Generally worse than
``spline36``, but it results in a slightly sharper image which is good
for some content types. The number of taps can be controlled with
``scale-radius``, but is best left unchanged.
Lanczos scaling. Provides good balance between quality and performance.
sfan5 marked this conversation as resolved.
Show resolved Hide resolved
This is the default for ``scale``. The number of taps can be controlled
with ``scale-radius``, but is best left unchanged.

(This filter is an alias for ``sinc``-windowed ``sinc``)

Expand All @@ -5275,8 +5274,8 @@ them.
(This filter is an alias for ``jinc``-windowed ``jinc``)

``ewa_lanczossharp``
A slightly sharpened version of ewa_lanczos. If your hardware can run
it, this is probably what you should use by default.
A slightly sharpened version of ewa_lanczos. This is the default when
using the ``high-quality`` profile.

``ewa_lanczos4sharpest``
Very sharp scaler, but also slightly slower than ``ewa_lanczossharp``.
Expand All @@ -5287,13 +5286,13 @@ them.
``mitchell``
Mitchell-Netravali. The ``B`` and ``C`` parameters can be set with
``--scale-param1`` and ``--scale-param2``. This filter is very good at
downscaling (see ``--dscale``).
downscaling. This is the default for ``--dscale``.

``catmull_rom``
Catmull-Rom. A Cubic filter in the same vein as ``mitchell``, where
the ``B`` and ``C`` parameters are ``0.0`` and ``0.5`` respectively.
This filter is sharper than ``mitchell``, but it results in mild
ringing. Like ``mitchell``, this filter is good at downscaling (see
ringing. Like ``mitchell``, this filter is good at downscaling (see
``--dscale``).

``oversample``
kasper93 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -5314,17 +5313,17 @@ them.

``--cscale=<filter>``
As ``--scale``, but for interpolating chroma information. If the image is
not subsampled, this option is ignored entirely.
not subsampled, this option is ignored entirely. If this option is unset,
the filter implied by ``--scale`` will be applied.

``--dscale=<filter>``
Like ``--scale``, but apply these filters on downscaling instead. If this
option is unset, the filter implied by ``--scale`` will be applied.
Like ``--scale``, but apply these filters on downscaling instead.
haasn marked this conversation as resolved.
Show resolved Hide resolved

``--tscale=<filter>``
The filter used for interpolating the temporal axis (frames). This is only
used if ``--interpolation`` is enabled. The only valid choices for
``--tscale`` are separable convolution filters (use ``--tscale=help`` to
get a list). The default is ``mitchell``.
get a list). The default is ``oversample``.

Common ``--tscale`` choices include ``oversample``, ``linear``,
``catmull_rom``, ``mitchell``, ``gaussian``, or ``bicubic``. These are
Expand Down Expand Up @@ -5438,17 +5437,18 @@ them.
``--correct-downscaling``
When using convolution based filters, extend the filter size when
downscaling. Increases quality, but reduces performance while downscaling.
Enabled by default.

This will perform slightly sub-optimally for anamorphic video (but still
better than without it) since it will extend the size to match only the
kasper93 marked this conversation as resolved.
Show resolved Hide resolved
milder of the scale factors between the axes.

Note: this option is ignored when using bilinear downscaling (the default).
Note: this option is ignored when using bilinear downscaling with ``--vo=gpu``.

``--linear-downscaling``
Scale in linear light when downscaling. It should only be used with a
``--fbo-format`` that has at least 16 bit precision. This option
has no effect on HDR content.
has no effect on HDR content. Enabled by default.

``--linear-upscaling``
Scale in linear light when upscaling. Like ``--linear-downscaling``, it
Expand All @@ -5459,7 +5459,7 @@ them.

``--sigmoid-upscaling``
When upscaling, use a sigmoidal color transform to avoid emphasizing
ringing artifacts. This is incompatible with and replaces
ringing artifacts. Enabled by default. This is incompatible with and replaces
``--linear-upscaling``. (Note that sigmoidization also requires
linearization, so the ``LINEAR`` rendering step fires in both cases)

Expand Down Expand Up @@ -5526,7 +5526,7 @@ them.
might be slower or cause latency issues.

``--dither-depth=<N|no|auto>``
Set dither target depth to N. Default: no.
Set dither target depth to N. Default: auto.

no
Disable any dithering done by mpv.
Expand Down
24 changes: 16 additions & 8 deletions etc/builtin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,26 @@ vlang=
alang=
slang=

[gpu-hq]
scale=spline36
cscale=spline36
dscale=mitchell
dither-depth=auto
[fast]
scale=bilinear
dscale=bilinear
dither=no
correct-downscaling=no
linear-downscaling=no
sigmoid-upscaling=no
hdr-compute-peak=no

[high-quality]
scale=ewa_lanczossharp
hdr-peak-percentile=99.995
hdr-contrast-recovery=0.30
allow-delayed-peak-detect=no
correct-downscaling=yes
linear-downscaling=yes
sigmoid-upscaling=yes
deband=yes
scaler-lut-size=8
haasn marked this conversation as resolved.
Show resolved Hide resolved

# Deprecated alias
[gpu-hq]
profile=high-quality
kasper93 marked this conversation as resolved.
Show resolved Hide resolved

[low-latency]
audio-buffer=0 # minimize extra audio buffer (can lead to dropouts)
Expand Down
28 changes: 22 additions & 6 deletions video/out/gpu/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,25 @@ struct gl_video {

static const struct gl_video_opts gl_video_opts_def = {
.dither_algo = DITHER_FRUIT,
.dither_depth = -1,
.dither_size = 6,
.temporal_dither_period = 1,
.error_diffusion = "sierra-lite",
.fbo_format = "auto",
.sigmoid_center = 0.75,
.sigmoid_slope = 6.5,
.scaler = {
{{"bilinear", .params={NAN, NAN}}, {.params = {NAN, NAN}},
{{"lanczos", .params={NAN, NAN}}, {.params = {NAN, NAN}},
.cutoff = 0.001}, // scale
{{NULL, .params={NAN, NAN}}, {.params = {NAN, NAN}},
{{"mitchell", .params={NAN, NAN}}, {.params = {NAN, NAN}},
.cutoff = 0.001}, // dscale
{{"bilinear", .params={NAN, NAN}}, {.params = {NAN, NAN}},
{{NULL, .params={NAN, NAN}}, {.params = {NAN, NAN}},
.cutoff = 0.001}, // cscale
{{"mitchell", .params={NAN, NAN}}, {.params = {NAN, NAN}},
.clamp = 1, }, // tscale
{{"oversample", .params={NAN, NAN}}, {.params = {NAN, NAN}}}, // tscale
},
.scaler_resizes_only = true,
.correct_downscaling = true,
.linear_downscaling = true,
.sigmoid_upscaling = true,
kasper93 marked this conversation as resolved.
Show resolved Hide resolved
.scaler_lut_size = 6,
.interpolation_threshold = 0.01,
.alpha_mode = ALPHA_BLEND_TILES,
Expand Down Expand Up @@ -1730,6 +1731,12 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
conf = &p->opts.scaler[SCALER_SCALE];
}

if (conf && scaler->index == SCALER_CSCALE && (!conf->kernel.name ||
!conf->kernel.name[0]))
{
conf = &p->opts.scaler[SCALER_SCALE];
}

struct filter_kernel bare_window;
const struct filter_kernel *t_kernel = mp_find_filter_kernel(conf->kernel.name);
const struct filter_window *t_window = mp_find_filter_window(conf->window.name);
Expand Down Expand Up @@ -2299,6 +2306,13 @@ static void pass_read_video(struct gl_video *p)
continue;

const struct scaler_config *conf = &p->opts.scaler[scaler_id];

if (scaler_id == SCALER_CSCALE && (!conf->kernel.name ||
!conf->kernel.name[0]))
{
conf = &p->opts.scaler[SCALER_SCALE];
}

struct scaler *scaler = &p->scaler[scaler_id];

// bilinear scaling is a free no-op thanks to GPU sampling
Expand Down Expand Up @@ -4177,6 +4191,8 @@ static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt,
r = M_OPT_EXIT;
} else if (bstr_equals0(name, "dscale") && !param.len) {
return r; // empty dscale means "use same as upscaler"
} else if (bstr_equals0(name, "cscale") && !param.len) {
return r; // empty cscale means "use same as upscaler"
} else {
snprintf(s, sizeof(s), "%.*s", BSTR_P(param));
if (!handle_scaler_opt(s, tscale))
Expand Down
4 changes: 3 additions & 1 deletion video/out/vo_gpu_next.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,9 @@ static const struct pl_filter_config *map_scaler(struct priv *p,

const struct gl_video_opts *opts = p->opts_cache->opts;
const struct scaler_config *cfg = &opts->scaler[unit];
if (unit == SCALER_DSCALE && (!cfg->kernel.name || !strcmp(cfg->kernel.name, "")))
if (unit == SCALER_DSCALE && (!cfg->kernel.name || !cfg->kernel.name[0]))
cfg = &opts->scaler[SCALER_SCALE];
if (unit == SCALER_CSCALE && (!cfg->kernel.name || !cfg->kernel.name[0]))
cfg = &opts->scaler[SCALER_SCALE];

for (int i = 0; fixed_presets[i].name; i++) {
Expand Down