summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-25 23:47:55 +0200
committerwm4 <wm4@nowhere>2013-05-26 16:44:20 +0200
commit39225ed19676aa054aa36eb1e09b72ec712ae368 (patch)
treeb9c30c3fd281b26985a70e515443ccf8ea6b081c /video/out/gl_video.c
parentf44a242258c282eb1407899a64571c39d010285b (diff)
downloadmpv-39225ed19676aa054aa36eb1e09b72ec712ae368.tar.bz2
mpv-39225ed19676aa054aa36eb1e09b72ec712ae368.tar.xz
gl_video: add scaler-resizes-only sub-option
This option disables the scaler set with lscale if the video image is not resized.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r--video/out/gl_video.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index f0a6f60d84..791f302941 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -251,6 +251,7 @@ const struct m_sub_options gl_video_conf = {
OPT_STRING_VALIDATE("cscale", scalers[1], 0, validate_scaler_opt),
OPT_FLOAT("lparam1", scaler_params[0], 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("indirect", indirect, 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;
}
+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)
{
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)
return;
+ for (int n = 0; n < 2; n++)
+ p->scalers[n].name = expected_scaler(p, n);
+
init_dither(p);
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);
}
}
+ 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) {
reinit_rendering(p);
} else if (need_scaler_update) {