diff options
author | wm4 <wm4@nowhere> | 2013-05-25 23:47:55 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-05-26 16:44:20 +0200 |
commit | 39225ed19676aa054aa36eb1e09b72ec712ae368 (patch) | |
tree | b9c30c3fd281b26985a70e515443ccf8ea6b081c /video/out | |
parent | f44a242258c282eb1407899a64571c39d010285b (diff) | |
download | mpv-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')
-rw-r--r-- | video/out/gl_video.c | 24 | ||||
-rw-r--r-- | video/out/gl_video.h | 1 |
2 files changed, 25 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) { 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; |