diff options
author | Bin Jin <bjin@ctrl-d.org> | 2019-06-06 12:40:05 +0000 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-06-06 20:01:56 +0200 |
commit | fbe267150d9b6a2486a73c13d58b2b24d69b50ad (patch) | |
tree | c32646c1b20cd06912f6a02a2b63a2193627ac8a /video/out/gpu | |
parent | f2119d9d889913ab07dabc797d0288ca996d47d8 (diff) | |
download | mpv-fbe267150d9b6a2486a73c13d58b2b24d69b50ad.tar.bz2 mpv-fbe267150d9b6a2486a73c13d58b2b24d69b50ad.tar.xz |
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.
Diffstat (limited to 'video/out/gpu')
-rw-r--r-- | video/out/gpu/video.c | 9 |
1 files 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 <assert.h> +#include <float.h> #include <math.h> #include <stdarg.h> #include <stdbool.h> #include <string.h> -#include <assert.h> #include <libavutil/common.h> #include <libavutil/lfg.h> @@ -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]; |