All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion
@ 2018-02-27 21:21 Ville Syrjala
  2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 2/8] lib: Clear packed YUV formats to black Ville Syrjala
                   ` (14 more replies)
  0 siblings, 15 replies; 26+ messages in thread
From: Ville Syrjala @ 2018-02-27 21:21 UTC (permalink / raw)
  To: igt-dev

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_aux.h |  7 +++++++
 lib/igt_fb.c  | 11 ++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 43dd15fe3b32..7f61fc5a458b 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -228,6 +228,13 @@ void intel_require_files(uint64_t count);
 	_a > _b ? _a : _b;		\
 })
 
+#define clamp(x, min, max) ({		\
+	typeof(min) _min = (min);	\
+	typeof(max) _max = (max);	\
+	typeof(x) _x = (x);		\
+	_x < _min ? _min : _x > _max ? _max : _x;	\
+})
+
 #define igt_swap(a, b) do {	\
 	typeof(a) _tmp = (a);	\
 	(a) = (b);		\
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ecd73053f16f..9af600896e50 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -30,6 +30,7 @@
 #include <inttypes.h>
 
 #include "drmtest.h"
+#include "igt_aux.h"
 #include "igt_fb.h"
 #include "igt_kms.h"
 #include "ioctl_wrappers.h"
@@ -1318,13 +1319,9 @@ struct fb_convert_blit_upload {
 	struct fb_blit_linear linear;
 };
 
-static uint8_t clamprgb(float val) {
-	if (val < 0)
-		return 0;
-	if (val > 255)
-		return 255;
-
-	return (uint8_t)val;
+static uint8_t clamprgb(float val)
+{
+	return clamp(val, 0.0f, 255.0f);
 }
 
 static void convert_nv12_to_rgb24(struct igt_fb *fb, struct fb_convert_blit_upload *blit)
-- 
2.13.6

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2018-03-02 21:09 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 21:21 [igt-dev] [PATCH i-g-t 1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 2/8] lib: Clear packed YUV formats to black Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 3/8] lib: Don't use dumb buffers for YCbCr Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 4/8] lib: Clean up format_desc Ville Syrjala
2018-02-28 18:44   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 5/8] lib: Add igt_matrix Ville Syrjala
2018-02-27 21:33   ` Chris Wilson
2018-02-28 14:57     ` Ville Syrjälä
2018-02-28 15:01       ` Ville Syrjälä
2018-02-28 17:36   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 6/8] lib: Add igt_color_encoding Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 7/8] lib: Use igt_matrix for ycbcr<->rgb conversion Ville Syrjala
2018-03-02  8:35   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2018-02-27 21:21 ` [igt-dev] [PATCH i-g-t 8/8] lib: Add support for rendering into packed YCbCr framebuffers Ville Syrjala
2018-02-27 21:36   ` Chris Wilson
2018-02-28 14:59     ` Ville Syrjälä
2018-03-01 11:00   ` [igt-dev] [PATCH i-g-t v2 " Ville Syrjala
2018-03-02  8:35   ` [igt-dev] [PATCH i-g-t v3 " Ville Syrjala
2018-02-27 23:27 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion Patchwork
2018-02-28 18:28 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev2) Patchwork
2018-02-28 19:34 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev3) Patchwork
2018-02-28 23:20 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev2) Patchwork
2018-03-01  0:33 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev3) Patchwork
2018-03-01 16:33 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev4) Patchwork
2018-03-02 17:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/8] lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion (rev6) Patchwork
2018-03-02 21:09 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.