From fbe267150d9b6a2486a73c13d58b2b24d69b50ad Mon Sep 17 00:00:00 2001 From: Bin Jin Date: Thu, 6 Jun 2019 12:40:05 +0000 Subject: vo_gpu: fix --scaler-resizes-only for fractional ratio scaling The calculation of scale factor involves 32-bit float, and a strict equality test will effectively ignore `--scaler-resizes-only` option for some non-integer scale factor. Fix this by using non-strict equality check. --- video/out/gpu/video.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index bc6c6f2cd5..b3e9c0ee1c 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -16,11 +16,11 @@ */ #include +#include #include #include #include #include -#include #include #include @@ -2358,8 +2358,11 @@ static void pass_scale_main(struct gl_video *p) xy[0] /= p->texture_offset.m[0][0]; xy[1] /= p->texture_offset.m[1][1]; - bool downscaling = xy[0] < 1.0 || xy[1] < 1.0; - bool upscaling = !downscaling && (xy[0] > 1.0 || xy[1] > 1.0); + // The calculation of scale factor involves 32-bit float(from gl_transform), + // use non-strict equality test to tolerate precision loss. + bool downscaling = xy[0] < 1.0 - FLT_EPSILON || xy[1] < 1.0 - FLT_EPSILON; + bool upscaling = !downscaling && (xy[0] > 1.0 + FLT_EPSILON || + xy[1] > 1.0 + FLT_EPSILON); double scale_factor = 1.0; struct scaler *scaler = &p->scaler[SCALER_SCALE]; -- cgit v1.2.3