[igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Round to nearest when clamping rgb

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Thu Jun 7 08:20:07 UTC 2018


Op 06-06-18 om 22:16 schreef Ville Syrjala:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> 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 <maarten.lankhorst at linux.intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  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 a926a08d44e1..6ff90d53f433 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)

No algorithm:
real    0m22,052s

Original algorithm:
real    0m26,091s

New algorithm:
real    0m29,342s

Amount of conversions that are 2560x1440: 18. Some smaller 64x64 and 128x128 are done too but not where most time will be spent..

Each conversion (back and forth) approximately takes .405s, which would interpolate to 0.911s for a 4K fb. Just about doable without further optimizations.

Reviewed-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>



More information about the igt-dev mailing list