From 39225ed19676aa054aa36eb1e09b72ec712ae368 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 25 May 2013 23:47:55 +0200 Subject: gl_video: add scaler-resizes-only sub-option This option disables the scaler set with lscale if the video image is not resized. --- DOCS/man/en/vo.rst | 8 ++++++++ video/out/gl_video.c | 24 ++++++++++++++++++++++++ video/out/gl_video.h | 1 + 3 files changed, 33 insertions(+) diff --git a/DOCS/man/en/vo.rst b/DOCS/man/en/vo.rst index 6e39e57793..3204169a47 100644 --- a/DOCS/man/en/vo.rst +++ b/DOCS/man/en/vo.rst @@ -291,6 +291,14 @@ opengl lparam2= 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= 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. 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) { diff --git a/video/out/gl_video.h b/video/out/gl_video.h index 8418df1bc1..72cfcf51a9 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -35,6 +35,7 @@ struct gl_video_opts { int srgb; int scale_sep; int fancy_downscaling; + int scaler_resizes_only; int npot; int pbo; int dither_depth; -- cgit v1.2.3