From ee26fef07ec4a74c3bf06f6480f34bb23c453624 Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Tue, 27 Feb 2018 22:38:05 +0200 Subject: lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ville Syrjälä Reviewed-by: Chris Wilson --- lib/igt_aux.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/igt_aux.h') diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 9bb03b77..0eb96e44 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); \ -- cgit v1.2.3