From d1a93aa7e1507de76c6c71be15931cc4b90111bb Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Wed, 6 Jun 2018 20:36:44 +0300 Subject: lib/igt_fb: Round to nearest when clamping rgb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I think round to nearest is maybe more correct here. Also do the clamp with integers as it actually makes the resulting code measurably faster. Cc: Maarten Lankhorst Signed-off-by: Ville Syrjälä Reviewed-by: Maarten Lankhorst --- lib/igt_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index a926a08d..6ff90d53 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1323,7 +1323,7 @@ struct fb_convert_blit_upload { static uint8_t clamprgb(float val) { - return clamp(val, 0.0f, 255.0f); + return clamp((int)(val + 0.5f), 0, 255); } static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_upload *blit) -- cgit v1.2.3