Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/3] lib/igt_fb: round rgb->yuv conversion results
@ 2023-05-15 12:03 Swati Sharma
  2023-05-15 12:03 ` [igt-dev] [PATCH i-g-t 2/3] tests/kms_pipe_crc_basic: Add NV12 CRC sanitycheck tests Swati Sharma
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Swati Sharma @ 2023-05-15 12:03 UTC (permalink / raw)
  To: igt-dev

Round rgb->yuv conversion results.

Signed-off-by: Ville Syrjala <ville.syrjala@linux.intel.com>
Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 lib/igt_fb.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 0fe5b6ad..2fa84288 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -3047,11 +3047,16 @@ static void igt_fb_destroy_cairo_shadow_buffer(struct igt_fb *shadow,
 	munmap(ptr, shadow->size);
 }
 
-static uint8_t clamprgb(float val)
+static uint8_t clamp8(float val)
 {
 	return clamp((int)(val + 0.5f), 0, 255);
 }
 
+static uint8_t clamp16(float val)
+{
+	return clamp((int)(val + 0.5f), 0, 65535);
+}
+
 static void read_rgb(struct igt_vec4 *rgb, const uint8_t *rgb24)
 {
 	rgb->d[0] = rgb24[2];
@@ -3062,9 +3067,9 @@ static void read_rgb(struct igt_vec4 *rgb, const uint8_t *rgb24)
 
 static void write_rgb(uint8_t *rgb24, const struct igt_vec4 *rgb)
 {
-	rgb24[2] = clamprgb(rgb->d[0]);
-	rgb24[1] = clamprgb(rgb->d[1]);
-	rgb24[0] = clamprgb(rgb->d[2]);
+	rgb24[2] = clamp8(rgb->d[0]);
+	rgb24[1] = clamp8(rgb->d[1]);
+	rgb24[0] = clamp8(rgb->d[2]);
 }
 
 struct fb_convert_buf {
@@ -3384,7 +3389,7 @@ static void convert_rgb24_to_yuv(struct fb_convert *cvt)
 
 			rgb_tmp += bpp;
 
-			*y_tmp = yuv.d[0];
+			*y_tmp = clamp8(yuv.d[0]);
 			y_tmp += params.ay_inc;
 
 			if ((i % dst_fmt->vsub) || (j % dst_fmt->hsub))
@@ -3414,8 +3419,8 @@ static void convert_rgb24_to_yuv(struct fb_convert *cvt)
 			read_rgb(&pair_rgb, pair_rgb24);
 			pair_yuv = igt_matrix_transform(&m, &pair_rgb);
 
-			*u_tmp = (yuv.d[1] + pair_yuv.d[1]) / 2.0f;
-			*v_tmp = (yuv.d[2] + pair_yuv.d[2]) / 2.0f;
+			*u_tmp = clamp8((yuv.d[1] + pair_yuv.d[1]) / 2.0f);
+			*v_tmp = clamp8((yuv.d[2] + pair_yuv.d[2]) / 2.0f);
 
 			u_tmp += params.uv_inc;
 			v_tmp += params.uv_inc;
@@ -3573,7 +3578,7 @@ static void convert_float_to_yuv16(struct fb_convert *cvt, bool alpha)
 
 			rgb_tmp += fpp;
 
-			*y_tmp = yuv.d[0];
+			*y_tmp = clamp16(yuv.d[0]);
 			y_tmp += params.ay_inc;
 
 			if ((i % dst_fmt->vsub) || (j % dst_fmt->hsub))
@@ -3603,8 +3608,8 @@ static void convert_float_to_yuv16(struct fb_convert *cvt, bool alpha)
 			read_rgbf(&pair_rgb, pair_float);
 			pair_yuv = igt_matrix_transform(&m, &pair_rgb);
 
-			*u_tmp = (yuv.d[1] + pair_yuv.d[1]) / 2.0f;
-			*v_tmp = (yuv.d[2] + pair_yuv.d[2]) / 2.0f;
+			*u_tmp = clamp16((yuv.d[1] + pair_yuv.d[1]) / 2.0f);
+			*v_tmp = clamp16((yuv.d[2] + pair_yuv.d[2]) / 2.0f);
 
 			u_tmp += params.uv_inc;
 			v_tmp += params.uv_inc;
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [igt-dev] [PATCH i-g-t 1/3] lib/igt_fb: round rgb->yuv conversion results
@ 2023-05-26 17:43 Swati Sharma
  2023-05-26 17:43 ` [igt-dev] [PATCH i-g-t 3/3] intel-ci: update fastfeedback testlist Swati Sharma
  0 siblings, 1 reply; 12+ messages in thread
From: Swati Sharma @ 2023-05-26 17:43 UTC (permalink / raw)
  To: igt-dev

Round rgb->yuv conversion results.

Signed-off-by: Ville Syrjala <ville.syrjala@linux.intel.com>
Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 lib/igt_fb.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 71a199d4..11a5d6c0 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -3064,11 +3064,16 @@ static void igt_fb_destroy_cairo_shadow_buffer(struct igt_fb *shadow,
 	munmap(ptr, shadow->size);
 }
 
-static uint8_t clamprgb(float val)
+static uint8_t clamp8(float val)
 {
 	return clamp((int)(val + 0.5f), 0, 255);
 }
 
+static uint8_t clamp16(float val)
+{
+	return clamp((int)(val + 0.5f), 0, 65535);
+}
+
 static void read_rgb(struct igt_vec4 *rgb, const uint8_t *rgb24)
 {
 	rgb->d[0] = rgb24[2];
@@ -3079,9 +3084,9 @@ static void read_rgb(struct igt_vec4 *rgb, const uint8_t *rgb24)
 
 static void write_rgb(uint8_t *rgb24, const struct igt_vec4 *rgb)
 {
-	rgb24[2] = clamprgb(rgb->d[0]);
-	rgb24[1] = clamprgb(rgb->d[1]);
-	rgb24[0] = clamprgb(rgb->d[2]);
+	rgb24[2] = clamp8(rgb->d[0]);
+	rgb24[1] = clamp8(rgb->d[1]);
+	rgb24[0] = clamp8(rgb->d[2]);
 }
 
 struct fb_convert_buf {
@@ -3401,7 +3406,7 @@ static void convert_rgb24_to_yuv(struct fb_convert *cvt)
 
 			rgb_tmp += bpp;
 
-			*y_tmp = yuv.d[0];
+			*y_tmp = clamp8(yuv.d[0]);
 			y_tmp += params.ay_inc;
 
 			if ((i % dst_fmt->vsub) || (j % dst_fmt->hsub))
@@ -3431,8 +3436,8 @@ static void convert_rgb24_to_yuv(struct fb_convert *cvt)
 			read_rgb(&pair_rgb, pair_rgb24);
 			pair_yuv = igt_matrix_transform(&m, &pair_rgb);
 
-			*u_tmp = (yuv.d[1] + pair_yuv.d[1]) / 2.0f;
-			*v_tmp = (yuv.d[2] + pair_yuv.d[2]) / 2.0f;
+			*u_tmp = clamp8((yuv.d[1] + pair_yuv.d[1]) / 2.0f);
+			*v_tmp = clamp8((yuv.d[2] + pair_yuv.d[2]) / 2.0f);
 
 			u_tmp += params.uv_inc;
 			v_tmp += params.uv_inc;
@@ -3590,7 +3595,7 @@ static void convert_float_to_yuv16(struct fb_convert *cvt, bool alpha)
 
 			rgb_tmp += fpp;
 
-			*y_tmp = yuv.d[0];
+			*y_tmp = clamp16(yuv.d[0]);
 			y_tmp += params.ay_inc;
 
 			if ((i % dst_fmt->vsub) || (j % dst_fmt->hsub))
@@ -3620,8 +3625,8 @@ static void convert_float_to_yuv16(struct fb_convert *cvt, bool alpha)
 			read_rgbf(&pair_rgb, pair_float);
 			pair_yuv = igt_matrix_transform(&m, &pair_rgb);
 
-			*u_tmp = (yuv.d[1] + pair_yuv.d[1]) / 2.0f;
-			*v_tmp = (yuv.d[2] + pair_yuv.d[2]) / 2.0f;
+			*u_tmp = clamp16((yuv.d[1] + pair_yuv.d[1]) / 2.0f);
+			*v_tmp = clamp16((yuv.d[2] + pair_yuv.d[2]) / 2.0f);
 
 			u_tmp += params.uv_inc;
 			v_tmp += params.uv_inc;
-- 
2.25.1

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

end of thread, other threads:[~2023-05-29  5:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 12:03 [igt-dev] [PATCH i-g-t 1/3] lib/igt_fb: round rgb->yuv conversion results Swati Sharma
2023-05-15 12:03 ` [igt-dev] [PATCH i-g-t 2/3] tests/kms_pipe_crc_basic: Add NV12 CRC sanitycheck tests Swati Sharma
2023-05-15 12:45   ` Ville Syrjälä
2023-05-16 12:00     ` Sharma, Swati2
2023-05-15 12:03 ` [igt-dev] [PATCH i-g-t 3/3] intel-ci: Update fastfeedback testlist Swati Sharma
2023-05-15 14:02 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,1/3] lib/igt_fb: round rgb->yuv conversion results Patchwork
2023-05-15 14:25 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-05-15 19:33 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/igt_fb: round rgb->yuv conversion results (rev2) Patchwork
2023-05-15 20:37 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/3] lib/igt_fb: round rgb->yuv conversion results Patchwork
2023-05-16  2:24 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/3] lib/igt_fb: round rgb->yuv conversion results (rev2) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-05-26 17:43 [igt-dev] [PATCH i-g-t 1/3] lib/igt_fb: round rgb->yuv conversion results Swati Sharma
2023-05-26 17:43 ` [igt-dev] [PATCH i-g-t 3/3] intel-ci: update fastfeedback testlist Swati Sharma
2023-05-29  5:55   ` Modem, Bhanuprakash

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox