mirror of https://github.com/mpv-player/mpv
gl_video: add scaler-resizes-only sub-option
This option disables the scaler set with lscale if the video image is not resized.
This commit is contained in:
parent
f44a242258
commit
39225ed196
|
@ -291,6 +291,14 @@ opengl
|
||||||
lparam2=<value>
|
lparam2=<value>
|
||||||
See ``lparam1``.
|
See ``lparam1``.
|
||||||
|
|
||||||
|
scaler-resizes-only
|
||||||
|
Disable the scaler if the video image is not resized. In that case,
|
||||||
|
``bilinear`` is used instead whatever is set with ``lscale``. Bilinear
|
||||||
|
will reproduce the source image perfectly if no scaling is performed.
|
||||||
|
Note that this option never affects ``cscale``, although the different
|
||||||
|
processing chain might do chroma scaling differently if ``lscale`` is
|
||||||
|
disabled.
|
||||||
|
|
||||||
stereo=<value>
|
stereo=<value>
|
||||||
Select a method for stereo display. You may have to use ``--aspect`` to
|
Select a method for stereo display. You may have to use ``--aspect`` to
|
||||||
fix the aspect value. Experimental, do not expect too much from it.
|
fix the aspect value. Experimental, do not expect too much from it.
|
||||||
|
|
|
@ -251,6 +251,7 @@ const struct m_sub_options gl_video_conf = {
|
||||||
OPT_STRING_VALIDATE("cscale", scalers[1], 0, validate_scaler_opt),
|
OPT_STRING_VALIDATE("cscale", scalers[1], 0, validate_scaler_opt),
|
||||||
OPT_FLOAT("lparam1", scaler_params[0], 0),
|
OPT_FLOAT("lparam1", scaler_params[0], 0),
|
||||||
OPT_FLOAT("lparam2", scaler_params[1], 0),
|
OPT_FLOAT("lparam2", scaler_params[1], 0),
|
||||||
|
OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0),
|
||||||
OPT_FLAG("fancy-downscaling", fancy_downscaling, 0),
|
OPT_FLAG("fancy-downscaling", fancy_downscaling, 0),
|
||||||
OPT_FLAG("indirect", indirect, 0),
|
OPT_FLAG("indirect", indirect, 0),
|
||||||
OPT_FLAG("scale-sep", scale_sep, 0),
|
OPT_FLAG("scale-sep", scale_sep, 0),
|
||||||
|
@ -985,6 +986,22 @@ static void recreate_osd(struct gl_video *p)
|
||||||
p->osd->use_pbo = p->opts.pbo;
|
p->osd->use_pbo = p->opts.pbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool does_resize(struct mp_rect src, struct mp_rect dst)
|
||||||
|
{
|
||||||
|
return src.x1 - src.x0 != dst.x1 - dst.x0 ||
|
||||||
|
src.y1 - src.y0 != dst.y1 - dst.y0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *expected_scaler(struct gl_video *p, int unit)
|
||||||
|
{
|
||||||
|
if (p->opts.scaler_resizes_only && unit == 0 &&
|
||||||
|
!does_resize(p->src_rect, p->dst_rect))
|
||||||
|
{
|
||||||
|
return "bilinear";
|
||||||
|
}
|
||||||
|
return p->opts.scalers[unit];
|
||||||
|
}
|
||||||
|
|
||||||
static void reinit_rendering(struct gl_video *p)
|
static void reinit_rendering(struct gl_video *p)
|
||||||
{
|
{
|
||||||
mp_msg(MSGT_VO, MSGL_V, "[gl] Reinit rendering.\n");
|
mp_msg(MSGT_VO, MSGL_V, "[gl] Reinit rendering.\n");
|
||||||
|
@ -996,6 +1013,9 @@ static void reinit_rendering(struct gl_video *p)
|
||||||
if (!p->image.planes[0].gl_texture)
|
if (!p->image.planes[0].gl_texture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (int n = 0; n < 2; n++)
|
||||||
|
p->scalers[n].name = expected_scaler(p, n);
|
||||||
|
|
||||||
init_dither(p);
|
init_dither(p);
|
||||||
|
|
||||||
init_scaler(p, &p->scalers[0]);
|
init_scaler(p, &p->scalers[0]);
|
||||||
|
@ -1288,6 +1308,10 @@ static void check_resize(struct gl_video *p)
|
||||||
need_scaler_update |= (tkernel.inv_scale != old.inv_scale);
|
need_scaler_update |= (tkernel.inv_scale != old.inv_scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int n = 0; n < 2; n++) {
|
||||||
|
if (strcmp(p->scalers[n].name, expected_scaler(p, n)) != 0)
|
||||||
|
need_scaler_reinit = true;
|
||||||
|
}
|
||||||
if (need_scaler_reinit) {
|
if (need_scaler_reinit) {
|
||||||
reinit_rendering(p);
|
reinit_rendering(p);
|
||||||
} else if (need_scaler_update) {
|
} else if (need_scaler_update) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ struct gl_video_opts {
|
||||||
int srgb;
|
int srgb;
|
||||||
int scale_sep;
|
int scale_sep;
|
||||||
int fancy_downscaling;
|
int fancy_downscaling;
|
||||||
|
int scaler_resizes_only;
|
||||||
int npot;
|
int npot;
|
||||||
int pbo;
|
int pbo;
|
||||||
int dither_depth;
|
int dither_depth;
|
||||||
|
|
Loading…
Reference in New Issue