From 3d4889e91e7ae519e7fc44911974a52d1770e249 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 17 Apr 2016 13:07:14 +0200 Subject: [PATCH] vo_opengl: minor change to scaler_resizes_only Instead of rounding down, we round to the nearest float. This reduces the maximum possible error introduced by this rounding operation. Also clarify the comment. --- video/out/opengl/video.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 30ac790fa9..ba48e2873b 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -1711,9 +1711,12 @@ static void pass_scale_main(struct gl_video *p) struct scaler_config scaler_conf = p->opts.scaler[SCALER_SCALE]; if (p->opts.scaler_resizes_only && !downscaling && !upscaling) { scaler_conf.kernel.name = "bilinear"; - // bilinear is going to be used, just remove all sub-pixel offsets. - p->texture_offset.t[0] = (int)p->texture_offset.t[0]; - p->texture_offset.t[1] = (int)p->texture_offset.t[1]; + // For scaler-resizes-only, we round the texture offset to + // the nearest round value in order to prevent ugly blurriness + // (in exchange for slightly shifting the image by up to half a + // subpixel) + p->texture_offset.t[0] = roundf(p->texture_offset.t[0]); + p->texture_offset.t[1] = roundf(p->texture_offset.t[1]); } if (downscaling && p->opts.scaler[SCALER_DSCALE].kernel.name) { scaler_conf = p->opts.scaler[SCALER_DSCALE];