From 9f688ec61a8f0a0140bbb3c57aaebb408f7b277c Mon Sep 17 00:00:00 2001 From: neonloop Date: Fri, 15 Dec 2023 18:48:43 +0000 Subject: Fixes smooth shader on FunKey S Musl or ffast-math caused round to round incorrectly. 0.6 rounded to 0, not 1. Avoid by using integer math instead. --- scale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scale.c b/scale.c index c220aac..682b6c1 100644 --- a/scale.c +++ b/scale.c @@ -528,7 +528,7 @@ static void scale_select_scaler(unsigned w, unsigned h, size_t pitch) { blend_args.w_ratio_in = w / gcd_w; blend_args.w_ratio_out = dst_w / gcd_w; - div_w = round(blend_args.w_ratio_out / 5.0); + div_w = (blend_args.w_ratio_out + 2) / 5; /* rounded integer divide by 5 */ blend_args.w_bp[0] = div_w; blend_args.w_bp[1] = blend_args.w_ratio_out >> 1; @@ -536,7 +536,7 @@ static void scale_select_scaler(unsigned w, unsigned h, size_t pitch) { blend_args.h_ratio_in = h / gcd_h; blend_args.h_ratio_out = dst_h / gcd_h; - div_h = round(blend_args.h_ratio_out / 5.0); + div_h = (blend_args.w_ratio_out + 2) / 5; /* rounded integer divide by 5 */ blend_args.h_bp[0] = div_h; blend_args.h_bp[1] = blend_args.h_ratio_out >> 1; -- cgit v1.2.3