Skip to contentSkip to conversation

sna/video: XV_COLORSPACE/BT.709 textured Xv support

PATCH In review Ville Syrjala 2 participants 5 messages Feb 19, 2018

lore
Share & tools
lore
#0 lore raw

cover sna/video: XV_COLORSPACE/BT.709 textured Xv support

From: Ville Syrjälä <[email protected]>

I figured I should expose XV_COLORSPACE/BT.709 on the textured Xv adator as well. So here it is. This depends on the earlier sprite Xv XV_COLORSPACE patch I posted earlier.

Ville Syrjälä (3):
Remove duplicate exa_wm_yuv_rgb.g5a shader source Rename current yuv->rgb shader sources to exa_wm_yuv_rgb_bt601 sna/video: Add XV_COLORSPACE attribute for the textured Xv adaptor

 src/render_program/Makefile.am                     |  33 ++++--
 src/render_program/exa_wm_yuv_rgb.g6a              |   1 -
 src/render_program/exa_wm_yuv_rgb.g7a              |   1 -
 ...exa_wm_yuv_rgb.g4a => exa_wm_yuv_rgb_bt601.g4a} |  32 ++++--
 ...exa_wm_yuv_rgb.g4b => exa_wm_yuv_rgb_bt601.g4b} |   0
 ..._rgb.g4b.gen5 => exa_wm_yuv_rgb_bt601.g4b.gen5} |   0
 src/render_program/exa_wm_yuv_rgb_bt601.g5a        |   1 +
 ...exa_wm_yuv_rgb.g5b => exa_wm_yuv_rgb_bt601.g5b} |   0
 src/render_program/exa_wm_yuv_rgb_bt601.g6a        |   1 +
 ...exa_wm_yuv_rgb.g6b => exa_wm_yuv_rgb_bt601.g6b} |   0
 src/render_program/exa_wm_yuv_rgb_bt601.g7a        |   1 +
 ...exa_wm_yuv_rgb.g7b => exa_wm_yuv_rgb_bt601.g7b} |   0
 ...exa_wm_yuv_rgb.g8a => exa_wm_yuv_rgb_bt601.g8a} |  31 ++++--
 ...exa_wm_yuv_rgb.g8b => exa_wm_yuv_rgb_bt601.g8b} |   0
 ...exa_wm_yuv_rgb.g5a => exa_wm_yuv_rgb_bt709.g4a} |  39 ++++---
 src/render_program/exa_wm_yuv_rgb_bt709.g4b        |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5   |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g5a        |   1 +
 src/render_program/exa_wm_yuv_rgb_bt709.g5b        |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g6a        |   1 +
 src/render_program/exa_wm_yuv_rgb_bt709.g6b        |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g7a        |   1 +
 src/render_program/exa_wm_yuv_rgb_bt709.g7b        |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g8a        | 118 +++++++++++++++++++++
 src/render_program/exa_wm_yuv_rgb_bt709.g8b        |  19 ++++
 src/sna/brw/brw_test_gen4.c                        |   4 +-
 src/sna/brw/brw_test_gen5.c                        |   4 +-
 src/sna/brw/brw_test_gen6.c                        |   4 +-
 src/sna/brw/brw_test_gen7.c                        |   4 +-
 src/sna/gen4_render.c                              |  73 ++++++++++---
 src/sna/gen4_render.h                              |  11 +-
 src/sna/gen5_render.c                              |  73 ++++++++++---
 src/sna/gen5_render.h                              |  11 +-
 src/sna/gen6_render.c                              |  73 ++++++++++---
 src/sna/gen7_render.c                              |  59 ++++++++---
 src/sna/gen8_render.c                              |  59 ++++++++---
 src/sna/gen9_render.c                              |  59 ++++++++---
 src/sna/sna_render.h                               |  44 +++++---
 src/sna/sna_video_textured.c                       |  12 ++-
 src/uxa/i965_video.c                               |  16 +--
 40 files changed, 687 insertions(+), 159 deletions(-)
 delete mode 120000 src/render_program/exa_wm_yuv_rgb.g6a
 delete mode 120000 src/render_program/exa_wm_yuv_rgb.g7a
 rename src/render_program/{exa_wm_yuv_rgb.g4a => exa_wm_yuv_rgb_bt601.g4a} (79%)
 rename src/render_program/{exa_wm_yuv_rgb.g4b => exa_wm_yuv_rgb_bt601.g4b} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g4b.gen5 => exa_wm_yuv_rgb_bt601.g4b.gen5} (100%)
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt601.g5a
 rename src/render_program/{exa_wm_yuv_rgb.g5b => exa_wm_yuv_rgb_bt601.g5b} (100%)
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt601.g6a
 rename src/render_program/{exa_wm_yuv_rgb.g6b => exa_wm_yuv_rgb_bt601.g6b} (100%)
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt601.g7a
 rename src/render_program/{exa_wm_yuv_rgb.g7b => exa_wm_yuv_rgb_bt601.g7b} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g8a => exa_wm_yuv_rgb_bt601.g8a} (82%)
 rename src/render_program/{exa_wm_yuv_rgb.g8b => exa_wm_yuv_rgb_bt601.g8b} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g5a => exa_wm_yuv_rgb_bt709.g4a} (73%)
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g4b
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt709.g5a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g5b
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt709.g6a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g6b
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt709.g7a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g7b
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g8a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g8b
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/3 Remove duplicate exa_wm_yuv_rgb.g5a shader source

From: Ville Syrjälä <[email protected]>

exa_wm_yuv_rgb.g5a is identical to exa_wm_yuv_rgb.g4a. Just use a symlink intead of duplicating the whole file.

---
 src/render_program/exa_wm_yuv_rgb.g5a | 99 +----------------------------------
 1 file changed, 1 insertion(+), 98 deletions(-)
 mode change 100644 => 120000 src/render_program/exa_wm_yuv_rgb.g5a
src/render_program/exa_wm_yuv_rgb.g5a deleted +0 -98
deleted file mode 100644
index 4fb2576ab5f9..000000000000
@@ -1,98 +0,0 @@
-/*
- * Copyright © 2006 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- *    Keith Packard <[email protected]>
- *    Eric Anholt <[email protected]>
- *
- */
-
-include(`exa_wm.g4i')
-
-define(`YCbCr_base',	`src_sample_base')
-
-define(`Cr',		`src_sample_r')
-define(`Cr_01',		`src_sample_r_01')
-define(`Cr_23',		`src_sample_r_23')
-
-define(`Y',		`src_sample_g')
-define(`Y_01',		`src_sample_g_01')
-define(`Y_23',		`src_sample_g_23')
-
-define(`Cb',		`src_sample_b')
-define(`Cb_01',		`src_sample_b_01')
-define(`Cb_23',		`src_sample_b_23')
-
-define(`Crn',		`mask_sample_r')
-define(`Crn_01',	`mask_sample_r_01')
-define(`Crn_23',	`mask_sample_r_23')
-
-define(`Yn',		`mask_sample_g')
-define(`Yn_01',		`mask_sample_g_01')
-define(`Yn_23',		`mask_sample_g_23')
-
-define(`Cbn',		`mask_sample_b')
-define(`Cbn_01',	`mask_sample_b_01')
-define(`Cbn_23',	`mask_sample_b_23')
-
-    /* color space conversion function:
-     * R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1)
-     * G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1)
-     * B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1)
-     */
-
-    /* Normalize Y, Cb and Cr:
-     *
-     * Yn = (Y - 16/255) * 1.164
-     * Crn = Cr - 128 / 255
-     * Cbn = Cb - 128 / 255
-     */
-add (16)    Yn<1>F		Y<8,8,1>F	-0.0627451F { compr align1 };
-mul (16)    Yn<1>F		Yn<8,8,1>F	1.164F	    { compr align1 };
-
-add (16)    Crn<1>F		Cr<8,8,1>F	-0.501961F  { compr align1 };
-
-add (16)    Cbn<1>F		Cb<8,8,1>F	-0.501961F  { compr align1 };
-
-    /* 
-     * R = Y + Cr * 1.596
-     */
-mov (16)    acc0<1>F		Yn<8,8,1>F		    { compr align1 };
-mac.sat(16) src_sample_r<1>F	Crn<8,8,1>F	1.596F	    { compr align1 };
-     
-    /*
-     * G = Crn * -0.813 + Cbn * -0.392 + Y
-     */
-mov (16)    acc0<1>F		Yn<8,8,1>F		    { compr align1 };
-mac (16)    acc0<1>F		Crn<8,8,1>F    	-0.813F	    { compr align1 };
-mac.sat(16) src_sample_g<1>F	Cbn<8,8,1>F    	-0.392F	    { compr align1 };
-
-    /*
-     * B = Cbn * 2.017 + Y
-     */
-mov (16)    acc0<1>F	        Yn<8,8,1>F		    { compr align1 };
-mac.sat(16) src_sample_b<1>F	Cbn<8,8,1>F     2.017F	    { compr align1 };
-
-    /*
-     * A = 1.0
-     */
-mov (16)    src_sample_a<1>F	1.0F			    { compr align1 };
src/render_program/exa_wm_yuv_rgb.g5a new file +1 -0
new file mode 120000
index 000000000000..d34d246d5a9b
@@ -0,0 +1 @@
+exa_wm_yuv_rgb.g4a
\ No newline at end of file
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/3 Rename current yuv->rgb shader sources to exa_wm_yuv_rgb_bt601

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Our current yuv->rgb shaders follow the BT.601 conversion formula. Rename the shader sources to indicate that fact.

---
 src/render_program/Makefile.am                     | 22 +++++++++++-----------
 src/render_program/exa_wm_yuv_rgb.g5a              |  1 -
 src/render_program/exa_wm_yuv_rgb.g6a              |  1 -
 src/render_program/exa_wm_yuv_rgb.g7a              |  1 -
 ...exa_wm_yuv_rgb.g4a => exa_wm_yuv_rgb_bt601.g4a} |  0
 ...exa_wm_yuv_rgb.g4b => exa_wm_yuv_rgb_bt601.g4b} |  0
 ..._rgb.g4b.gen5 => exa_wm_yuv_rgb_bt601.g4b.gen5} |  0
 src/render_program/exa_wm_yuv_rgb_bt601.g5a        |  1 +
 ...exa_wm_yuv_rgb.g5b => exa_wm_yuv_rgb_bt601.g5b} |  0
 src/render_program/exa_wm_yuv_rgb_bt601.g6a        |  1 +
 ...exa_wm_yuv_rgb.g6b => exa_wm_yuv_rgb_bt601.g6b} |  0
 src/render_program/exa_wm_yuv_rgb_bt601.g7a        |  1 +
 ...exa_wm_yuv_rgb.g7b => exa_wm_yuv_rgb_bt601.g7b} |  0
 ...exa_wm_yuv_rgb.g8a => exa_wm_yuv_rgb_bt601.g8a} |  0
 ...exa_wm_yuv_rgb.g8b => exa_wm_yuv_rgb_bt601.g8b} |  0
 src/sna/brw/brw_test_gen4.c                        |  4 ++--
 src/sna/brw/brw_test_gen5.c                        |  4 ++--
 src/sna/brw/brw_test_gen6.c                        |  4 ++--
 src/sna/brw/brw_test_gen7.c                        |  4 ++--
 src/sna/gen4_render.c                              |  6 +++---
 src/sna/gen5_render.c                              |  6 +++---
 src/sna/gen6_render.c                              |  6 +++---
 src/sna/gen7_render.c                              |  6 +++---
 src/sna/gen8_render.c                              |  6 +++---
 src/sna/gen9_render.c                              |  6 +++---
 src/uxa/i965_video.c                               | 16 ++++++++--------
 26 files changed, 48 insertions(+), 48 deletions(-)
 delete mode 120000 src/render_program/exa_wm_yuv_rgb.g5a
 delete mode 120000 src/render_program/exa_wm_yuv_rgb.g6a
 delete mode 120000 src/render_program/exa_wm_yuv_rgb.g7a
 rename src/render_program/{exa_wm_yuv_rgb.g4a => exa_wm_yuv_rgb_bt601.g4a} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g4b => exa_wm_yuv_rgb_bt601.g4b} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g4b.gen5 => exa_wm_yuv_rgb_bt601.g4b.gen5} (100%)
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt601.g5a
 rename src/render_program/{exa_wm_yuv_rgb.g5b => exa_wm_yuv_rgb_bt601.g5b} (100%)
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt601.g6a
 rename src/render_program/{exa_wm_yuv_rgb.g6b => exa_wm_yuv_rgb_bt601.g6b} (100%)
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt601.g7a
 rename src/render_program/{exa_wm_yuv_rgb.g7b => exa_wm_yuv_rgb_bt601.g7b} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g8a => exa_wm_yuv_rgb_bt601.g8a} (100%)
 rename src/render_program/{exa_wm_yuv_rgb.g8b => exa_wm_yuv_rgb_bt601.g8b} (100%)
src/render_program/Makefile.am +11 -11
index 7b835e1a3fde..4493673435b6 100644
@@ -15,7 +15,7 @@ INTEL_G4A =				\
 	exa_wm_ca.g4a			\
 	exa_wm_ca_srcalpha.g4a		\
 	exa_wm_write.g4a 		\
-	exa_wm_yuv_rgb.g4a		\
+	exa_wm_yuv_rgb_bt601.g4a	\
 	exa_wm_xy.g4a			\
 	$(NULL)
 
@@ -45,7 +45,7 @@ INTEL_G4B = 				\
 	exa_wm_ca.g4b			\
 	exa_wm_ca_srcalpha.g4b		\
 	exa_wm_write.g4b 		\
-	exa_wm_yuv_rgb.g4b		\
+	exa_wm_yuv_rgb_bt601.g4b	\
 	exa_wm_xy.g4b			\
 	$(NULL)
 
@@ -67,7 +67,7 @@ INTEL_G4B_GEN5 = 				\
 	exa_wm_ca.g4b.gen5			\
 	exa_wm_ca_srcalpha.g4b.gen5		\
 	exa_wm_write.g4b.gen5 			\
-	exa_wm_yuv_rgb.g4b.gen5			\
+	exa_wm_yuv_rgb_bt601.g4b.gen5		\
 	exa_wm_xy.g4b.gen5			\
 	$(NULL)
 
@@ -88,7 +88,7 @@ INTEL_G5A =				\
 	exa_wm_ca.g5a			\
 	exa_wm_ca_srcalpha.g5a		\
 	exa_wm_write.g5a 		\
-	exa_wm_yuv_rgb.g5a		\
+	exa_wm_yuv_rgb_bt601.g5a	\
 	exa_wm_xy.g5a			\
 	$(NULL)
 
@@ -109,7 +109,7 @@ INTEL_G5B = 				\
 	exa_wm_ca.g5b			\
 	exa_wm_ca_srcalpha.g5b		\
 	exa_wm_write.g5b 		\
-	exa_wm_yuv_rgb.g5b		\
+	exa_wm_yuv_rgb_bt601.g5b	\
 	exa_wm_xy.g5b			\
 	$(NULL)
 
@@ -133,7 +133,7 @@ INTEL_G6A =				\
 	exa_wm_ca_srcalpha.g6a		\
 	exa_wm_noca.g6a			\
 	exa_wm_write.g6a 		\
-	exa_wm_yuv_rgb.g6a		\
+	exa_wm_yuv_rgb_bt601.g6a	\
 	$(NULL)
 
 INTEL_G6B =				\
@@ -151,7 +151,7 @@ INTEL_G6B =				\
 	exa_wm_ca_srcalpha.g6b		\
 	exa_wm_noca.g6b			\
 	exa_wm_write.g6b 		\
-	exa_wm_yuv_rgb.g6b		\
+	exa_wm_yuv_rgb_bt601.g6b	\
 	$(NULL)
 
 INTEL_G7A =				\
@@ -166,7 +166,7 @@ INTEL_G7A =				\
 	exa_wm_src_sample_nv12.g7a 	\
 	exa_wm_src_sample_planar.g7a 	\
 	exa_wm_write.g7a 		\
-	exa_wm_yuv_rgb.g7a		\
+	exa_wm_yuv_rgb_bt601.g7a	\
 	$(NULL)
 
 INTEL_G7B =				\
@@ -181,7 +181,7 @@ INTEL_G7B =				\
 	exa_wm_src_sample_nv12.g7b 	\
 	exa_wm_src_sample_planar.g7b 	\
 	exa_wm_write.g7b 		\
-	exa_wm_yuv_rgb.g7b		\
+	exa_wm_yuv_rgb_bt601.g7b	\
 	$(NULL)
 
 INTEL_G8A =				\
@@ -190,7 +190,7 @@ INTEL_G8A =				\
 	exa_wm_src_sample_nv12.g8a 	\
 	exa_wm_src_sample_planar.g8a 	\
 	exa_wm_write.g8a 		\
-	exa_wm_yuv_rgb.g8a		\
+	exa_wm_yuv_rgb_bt601.g8a	\
 	$(NULL)
 
 INTEL_G8B =				\
@@ -199,7 +199,7 @@ INTEL_G8B =				\
 	exa_wm_src_sample_nv12.g8b 	\
 	exa_wm_src_sample_planar.g8b 	\
 	exa_wm_write.g8b 		\
-	exa_wm_yuv_rgb.g8b		\
+	exa_wm_yuv_rgb_bt601.g8b	\
 	$(NULL)
 
 EXTRA_DIST = 		\
src/render_program/exa_wm_yuv_rgb.g5a deleted +0 -1
deleted file mode 120000
index d34d246d5a9b..000000000000
@@ -1 +0,0 @@
-exa_wm_yuv_rgb.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb.g6a deleted +0 -1
deleted file mode 120000
index d34d246d5a9b..000000000000
@@ -1 +0,0 @@
-exa_wm_yuv_rgb.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb.g7a deleted +0 -1
deleted file mode 120000
index d34d246d5a9b..000000000000
@@ -1 +0,0 @@
-exa_wm_yuv_rgb.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt601.g4a renamed from src/render_program/exa_wm_yuv_rgb.g4a +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g4a
rename to src/render_program/exa_wm_yuv_rgb_bt601.g4a
src/render_program/exa_wm_yuv_rgb_bt601.g4b renamed from src/render_program/exa_wm_yuv_rgb.g4b +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g4b
rename to src/render_program/exa_wm_yuv_rgb_bt601.g4b
src/render_program/exa_wm_yuv_rgb_bt601.g4b.gen5 renamed from src/render_program/exa_wm_yuv_rgb.g4b.gen5 +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g4b.gen5
rename to src/render_program/exa_wm_yuv_rgb_bt601.g4b.gen5
src/render_program/exa_wm_yuv_rgb_bt601.g5a new file +1 -0
new file mode 120000
index 000000000000..8c98e82d0f02
@@ -0,0 +1 @@
+exa_wm_yuv_rgb_bt601.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt601.g5b renamed from src/render_program/exa_wm_yuv_rgb.g5b +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g5b
rename to src/render_program/exa_wm_yuv_rgb_bt601.g5b
src/render_program/exa_wm_yuv_rgb_bt601.g6a new file +1 -0
new file mode 120000
index 000000000000..8c98e82d0f02
@@ -0,0 +1 @@
+exa_wm_yuv_rgb_bt601.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt601.g6b renamed from src/render_program/exa_wm_yuv_rgb.g6b +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g6b
rename to src/render_program/exa_wm_yuv_rgb_bt601.g6b
src/render_program/exa_wm_yuv_rgb_bt601.g7a new file +1 -0
new file mode 120000
index 000000000000..8c98e82d0f02
@@ -0,0 +1 @@
+exa_wm_yuv_rgb_bt601.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt601.g7b renamed from src/render_program/exa_wm_yuv_rgb.g7b +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g7b
rename to src/render_program/exa_wm_yuv_rgb_bt601.g7b
src/render_program/exa_wm_yuv_rgb_bt601.g8a renamed from src/render_program/exa_wm_yuv_rgb.g8a +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g8a
rename to src/render_program/exa_wm_yuv_rgb_bt601.g8a
src/render_program/exa_wm_yuv_rgb_bt601.g8b renamed from src/render_program/exa_wm_yuv_rgb.g8b +0 -0
similarity index 100%
rename from src/render_program/exa_wm_yuv_rgb.g8b
rename to src/render_program/exa_wm_yuv_rgb_bt601.g8b
src/sna/brw/brw_test_gen4.c +2 -2
index c0a185f3ce7f..78ff74653b63 100644
@@ -115,7 +115,7 @@ static const uint32_t ps_kernel_packed_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_argb.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
@@ -123,7 +123,7 @@ static const uint32_t ps_kernel_planar_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_planar.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
src/sna/brw/brw_test_gen5.c +2 -2
index 5f909fe55a2a..e821ce8bb814 100644
@@ -115,7 +115,7 @@ static const uint32_t ps_kernel_packed_static[][4] = {
 #include "exa_wm_xy.g5b"
 #include "exa_wm_src_affine.g5b"
 #include "exa_wm_src_sample_argb.g5b"
-#include "exa_wm_yuv_rgb.g5b"
+#include "exa_wm_yuv_rgb_bt601.g5b"
 #include "exa_wm_write.g5b"
 };
 
@@ -123,7 +123,7 @@ static const uint32_t ps_kernel_planar_static[][4] = {
 #include "exa_wm_xy.g5b"
 #include "exa_wm_src_affine.g5b"
 #include "exa_wm_src_sample_planar.g5b"
-#include "exa_wm_yuv_rgb.g5b"
+#include "exa_wm_yuv_rgb_bt601.g5b"
 #include "exa_wm_write.g5b"
 };
 
src/sna/brw/brw_test_gen6.c +2 -2
index 813ea8ac07fd..9603b9d99ceb 100644
@@ -98,14 +98,14 @@ static const uint32_t ps_kernel_masknoca_projective[][4] = {
 static const uint32_t ps_kernel_packed[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_argb.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
 static const uint32_t ps_kernel_planar[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_planar.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
src/sna/brw/brw_test_gen7.c +2 -2
index 297ae470cb1b..658b6699594a 100644
@@ -98,14 +98,14 @@ static const uint32_t ps_kernel_masknoca_projective[][4] = {
 static const uint32_t ps_kernel_packed[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_argb.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
 static const uint32_t ps_kernel_planar[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_planar.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
src/sna/gen4_render.c +3 -3
index f74b76f092e2..01f8040f79fe 100644
@@ -103,7 +103,7 @@ static const uint32_t ps_kernel_packed_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_argb.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
@@ -111,7 +111,7 @@ static const uint32_t ps_kernel_planar_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_planar.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
@@ -119,7 +119,7 @@ static const uint32_t ps_kernel_nv12_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_nv12.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
src/sna/gen5_render.c +3 -3
index 46535f7ba085..bed4a3edd7ab 100644
@@ -93,7 +93,7 @@ static const uint32_t ps_kernel_packed_static[][4] = {
 #include "exa_wm_xy.g5b"
 #include "exa_wm_src_affine.g5b"
 #include "exa_wm_src_sample_argb.g5b"
-#include "exa_wm_yuv_rgb.g5b"
+#include "exa_wm_yuv_rgb_bt601.g5b"
 #include "exa_wm_write.g5b"
 };
 
@@ -101,7 +101,7 @@ static const uint32_t ps_kernel_planar_static[][4] = {
 #include "exa_wm_xy.g5b"
 #include "exa_wm_src_affine.g5b"
 #include "exa_wm_src_sample_planar.g5b"
-#include "exa_wm_yuv_rgb.g5b"
+#include "exa_wm_yuv_rgb_bt601.g5b"
 #include "exa_wm_write.g5b"
 };
 
@@ -109,7 +109,7 @@ static const uint32_t ps_kernel_nv12_static[][4] = {
 #include "exa_wm_xy.g5b"
 #include "exa_wm_src_affine.g5b"
 #include "exa_wm_src_sample_nv12.g5b"
-#include "exa_wm_yuv_rgb.g5b"
+#include "exa_wm_yuv_rgb_bt601.g5b"
 #include "exa_wm_write.g5b"
 };
 
src/sna/gen6_render.c +3 -3
index e847062f7a79..39ea5b6ff558 100644
@@ -104,21 +104,21 @@ static const struct gt_info gt2_info = {
 static const uint32_t ps_kernel_packed[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_argb.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
 static const uint32_t ps_kernel_planar[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_planar.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
 static const uint32_t ps_kernel_nv12[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_nv12.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
src/sna/gen7_render.c +3 -3
index c3f81c52a9c1..b1fdfb5199c5 100644
@@ -196,21 +196,21 @@ inline static bool is_hsw(struct sna *sna)
 static const uint32_t ps_kernel_packed[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_argb.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
 static const uint32_t ps_kernel_planar[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_planar.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
 static const uint32_t ps_kernel_nv12[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_nv12.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
src/sna/gen8_render.c +3 -3
index 46369d6b1193..eadb09ebf1f3 100644
@@ -96,21 +96,21 @@
 static const uint32_t ps_kernel_packed[][4] = {
 #include "exa_wm_src_affine.g8b"
 #include "exa_wm_src_sample_argb.g8b"
-#include "exa_wm_yuv_rgb.g8b"
+#include "exa_wm_yuv_rgb_bt601.g8b"
 #include "exa_wm_write.g8b"
 };
 
 static const uint32_t ps_kernel_planar[][4] = {
 #include "exa_wm_src_affine.g8b"
 #include "exa_wm_src_sample_planar.g8b"
-#include "exa_wm_yuv_rgb.g8b"
+#include "exa_wm_yuv_rgb_bt601.g8b"
 #include "exa_wm_write.g8b"
 };
 
 static const uint32_t ps_kernel_nv12[][4] = {
 #include "exa_wm_src_affine.g8b"
 #include "exa_wm_src_sample_nv12.g8b"
-#include "exa_wm_yuv_rgb.g8b"
+#include "exa_wm_yuv_rgb_bt601.g8b"
 #include "exa_wm_write.g8b"
 };
 
src/sna/gen9_render.c +3 -3
index dd25b7b1da3e..721a186a0ce9 100644
@@ -97,21 +97,21 @@
 static const uint32_t ps_kernel_packed[][4] = {
 #include "exa_wm_src_affine.g8b"
 #include "exa_wm_src_sample_argb.g8b"
-#include "exa_wm_yuv_rgb.g8b"
+#include "exa_wm_yuv_rgb_bt601.g8b"
 #include "exa_wm_write.g8b"
 };
 
 static const uint32_t ps_kernel_planar[][4] = {
 #include "exa_wm_src_affine.g8b"
 #include "exa_wm_src_sample_planar.g8b"
-#include "exa_wm_yuv_rgb.g8b"
+#include "exa_wm_yuv_rgb_bt601.g8b"
 #include "exa_wm_write.g8b"
 };
 
 static const uint32_t ps_kernel_nv12[][4] = {
 #include "exa_wm_src_affine.g8b"
 #include "exa_wm_src_sample_nv12.g8b"
-#include "exa_wm_yuv_rgb.g8b"
+#include "exa_wm_yuv_rgb_bt601.g8b"
 #include "exa_wm_write.g8b"
 };
 
src/uxa/i965_video.c +8 -8
index 438ab909ca62..9b9203b66f25 100644
@@ -101,7 +101,7 @@ static const uint32_t ps_kernel_packed_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_argb.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
@@ -109,7 +109,7 @@ static const uint32_t ps_kernel_planar_static[][4] = {
 #include "exa_wm_xy.g4b"
 #include "exa_wm_src_affine.g4b"
 #include "exa_wm_src_sample_planar.g4b"
-#include "exa_wm_yuv_rgb.g4b"
+#include "exa_wm_yuv_rgb_bt601.g4b"
 #include "exa_wm_write.g4b"
 };
 
@@ -122,7 +122,7 @@ static const uint32_t ps_kernel_packed_static_gen5[][4] = {
 #include "exa_wm_xy.g4b.gen5"
 #include "exa_wm_src_affine.g4b.gen5"
 #include "exa_wm_src_sample_argb.g4b.gen5"
-#include "exa_wm_yuv_rgb.g4b.gen5"
+#include "exa_wm_yuv_rgb_bt601.g4b.gen5"
 #include "exa_wm_write.g4b.gen5"
 };
 
@@ -130,7 +130,7 @@ static const uint32_t ps_kernel_planar_static_gen5[][4] = {
 #include "exa_wm_xy.g4b.gen5"
 #include "exa_wm_src_affine.g4b.gen5"
 #include "exa_wm_src_sample_planar.g4b.gen5"
-#include "exa_wm_yuv_rgb.g4b.gen5"
+#include "exa_wm_yuv_rgb_bt601.g4b.gen5"
 #include "exa_wm_write.g4b.gen5"
 };
 
@@ -138,14 +138,14 @@ static const uint32_t ps_kernel_planar_static_gen5[][4] = {
 static const uint32_t ps_kernel_packed_static_gen6[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_argb.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
 static const uint32_t ps_kernel_planar_static_gen6[][4] = {
 #include "exa_wm_src_affine.g6b"
 #include "exa_wm_src_sample_planar.g6b"
-#include "exa_wm_yuv_rgb.g6b"
+#include "exa_wm_yuv_rgb_bt601.g6b"
 #include "exa_wm_write.g6b"
 };
 
@@ -153,14 +153,14 @@ static const uint32_t ps_kernel_planar_static_gen6[][4] = {
 static const uint32_t ps_kernel_packed_static_gen7[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_argb.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
 static const uint32_t ps_kernel_planar_static_gen7[][4] = {
 #include "exa_wm_src_affine.g7b"
 #include "exa_wm_src_sample_planar.g7b"
-#include "exa_wm_yuv_rgb.g7b"
+#include "exa_wm_yuv_rgb_bt601.g7b"
 #include "exa_wm_write.g7b"
 };
 
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/3 sna/video: Add XV_COLORSPACE attribute for the textured Xv adaptor

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

Allow the client to select between BT.601 and BT.709 via the XV_COLORSPACE port attribute with the textured Xv adaptor as well.

Since the BT.601 coefficients are currently hardcoded in the yuv->rgb shader, let's just add a mostly duplicated shader with hardcoded BT.709 coefficients instead. Not the most elegant solution but avoids having to touch any state setup etc.

---
 src/render_program/Makefile.am                   |  11 +++
 src/render_program/exa_wm_yuv_rgb_bt601.g4a      |  32 ++++--
 src/render_program/exa_wm_yuv_rgb_bt601.g8a      |  31 ++++--
 src/render_program/exa_wm_yuv_rgb_bt709.g4a      | 111 +++++++++++++++++++++
 src/render_program/exa_wm_yuv_rgb_bt709.g4b      |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5 |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g5a      |   1 +
 src/render_program/exa_wm_yuv_rgb_bt709.g5b      |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g6a      |   1 +
 src/render_program/exa_wm_yuv_rgb_bt709.g6b      |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g7a      |   1 +
 src/render_program/exa_wm_yuv_rgb_bt709.g7b      |  12 +++
 src/render_program/exa_wm_yuv_rgb_bt709.g8a      | 118 +++++++++++++++++++++++
 src/render_program/exa_wm_yuv_rgb_bt709.g8b      |  19 ++++
 src/sna/gen4_render.c                            |  67 +++++++++++--
 src/sna/gen4_render.h                            |  11 ++-
 src/sna/gen5_render.c                            |  67 +++++++++++--
 src/sna/gen5_render.h                            |  11 ++-
 src/sna/gen6_render.c                            |  67 ++++++++++---
 src/sna/gen7_render.c                            |  53 +++++++---
 src/sna/gen8_render.c                            |  53 +++++++---
 src/sna/gen9_render.c                            |  53 +++++++---
 src/sna/sna_render.h                             |  44 ++++++---
 src/sna/sna_video_textured.c                     |  12 ++-
 24 files changed, 724 insertions(+), 99 deletions(-)
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g4a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g4b
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt709.g5a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g5b
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt709.g6a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g6b
 create mode 120000 src/render_program/exa_wm_yuv_rgb_bt709.g7a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g7b
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g8a
 create mode 100644 src/render_program/exa_wm_yuv_rgb_bt709.g8b
src/render_program/Makefile.am +11 -0
index 4493673435b6..dc58138f356e 100644
@@ -16,6 +16,7 @@ INTEL_G4A =				\
 	exa_wm_ca_srcalpha.g4a		\
 	exa_wm_write.g4a 		\
 	exa_wm_yuv_rgb_bt601.g4a	\
+	exa_wm_yuv_rgb_bt709.g4a	\
 	exa_wm_xy.g4a			\
 	$(NULL)
 
@@ -46,6 +47,7 @@ INTEL_G4B = 				\
 	exa_wm_ca_srcalpha.g4b		\
 	exa_wm_write.g4b 		\
 	exa_wm_yuv_rgb_bt601.g4b	\
+	exa_wm_yuv_rgb_bt709.g4b	\
 	exa_wm_xy.g4b			\
 	$(NULL)
 
@@ -68,6 +70,7 @@ INTEL_G4B_GEN5 = 				\
 	exa_wm_ca_srcalpha.g4b.gen5		\
 	exa_wm_write.g4b.gen5 			\
 	exa_wm_yuv_rgb_bt601.g4b.gen5		\
+	exa_wm_yuv_rgb_bt709.g4b.gen5		\
 	exa_wm_xy.g4b.gen5			\
 	$(NULL)
 
@@ -89,6 +92,7 @@ INTEL_G5A =				\
 	exa_wm_ca_srcalpha.g5a		\
 	exa_wm_write.g5a 		\
 	exa_wm_yuv_rgb_bt601.g5a	\
+	exa_wm_yuv_rgb_bt709.g5a	\
 	exa_wm_xy.g5a			\
 	$(NULL)
 
@@ -110,6 +114,7 @@ INTEL_G5B = 				\
 	exa_wm_ca_srcalpha.g5b		\
 	exa_wm_write.g5b 		\
 	exa_wm_yuv_rgb_bt601.g5b	\
+	exa_wm_yuv_rgb_bt709.g5b	\
 	exa_wm_xy.g5b			\
 	$(NULL)
 
@@ -134,6 +139,7 @@ INTEL_G6A =				\
 	exa_wm_noca.g6a			\
 	exa_wm_write.g6a 		\
 	exa_wm_yuv_rgb_bt601.g6a	\
+	exa_wm_yuv_rgb_bt709.g6a	\
 	$(NULL)
 
 INTEL_G6B =				\
@@ -152,6 +158,7 @@ INTEL_G6B =				\
 	exa_wm_noca.g6b			\
 	exa_wm_write.g6b 		\
 	exa_wm_yuv_rgb_bt601.g6b	\
+	exa_wm_yuv_rgb_bt709.g6b	\
 	$(NULL)
 
 INTEL_G7A =				\
@@ -167,6 +174,7 @@ INTEL_G7A =				\
 	exa_wm_src_sample_planar.g7a 	\
 	exa_wm_write.g7a 		\
 	exa_wm_yuv_rgb_bt601.g7a	\
+	exa_wm_yuv_rgb_bt709.g7a	\
 	$(NULL)
 
 INTEL_G7B =				\
@@ -182,6 +190,7 @@ INTEL_G7B =				\
 	exa_wm_src_sample_planar.g7b 	\
 	exa_wm_write.g7b 		\
 	exa_wm_yuv_rgb_bt601.g7b	\
+	exa_wm_yuv_rgb_bt709.g7b	\
 	$(NULL)
 
 INTEL_G8A =				\
@@ -191,6 +200,7 @@ INTEL_G8A =				\
 	exa_wm_src_sample_planar.g8a 	\
 	exa_wm_write.g8a 		\
 	exa_wm_yuv_rgb_bt601.g8a	\
+	exa_wm_yuv_rgb_bt709.g8a	\
 	$(NULL)
 
 INTEL_G8B =				\
@@ -200,6 +210,7 @@ INTEL_G8B =				\
 	exa_wm_src_sample_planar.g8b 	\
 	exa_wm_write.g8b 		\
 	exa_wm_yuv_rgb_bt601.g8b	\
+	exa_wm_yuv_rgb_bt709.g8b	\
 	$(NULL)
 
 EXTRA_DIST = 		\
src/render_program/exa_wm_yuv_rgb_bt601.g4a +23 -9
index 4fb2576ab5f9..7bc8dd14d9c4 100644
@@ -55,14 +55,24 @@ define(`Cbn_01',	`mask_sample_b_01')
 define(`Cbn_23',	`mask_sample_b_23')
 
     /* color space conversion function:
-     * R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1)
-     * G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1)
-     * B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1)
+     * Cy = 255/(235-16)
+     * R = Clamp ( 255/(235-16)(Y-16/255) +
+     *             255/112(1.0-Kr)(Cr-128/255), 0, 1)
+     * G = Clamp ( 255/(235-16)(Y-16/255) -
+     *             255/112(1.0-Kr)Kr/Kg(Cr-128/255) -
+     *             255/112(1.0-Kb)Kb/Kg(Cb-128/255), 0, 1)
+     * B = Clamp ( 255/(235-16)(Y-16/255) +
+     *             255/112(1.0-Kb)(Cb-128/255), 0, 1)
+     *
+     * BT.601:
+     * Kr = 0.299
+     * Kb = 0.114
+     * Kg = (1.0 - Kr - Kb) = 0.587
      */
 
     /* Normalize Y, Cb and Cr:
      *
-     * Yn = (Y - 16/255) * 1.164
+     * Yn = (Y - 16/255) * 255/(235-16)
      * Crn = Cr - 128 / 255
      * Cbn = Cb - 128 / 255
      */
@@ -73,21 +83,25 @@ add (16)    Crn<1>F		Cr<8,8,1>F	-0.501961F  { compr align1 };
 
 add (16)    Cbn<1>F		Cb<8,8,1>F	-0.501961F  { compr align1 };
 
-    /* 
-     * R = Y + Cr * 1.596
+    /*
+     * R = Yn +
+     *     Crn * 255/112 * (1.0 - Kr)
      */
 mov (16)    acc0<1>F		Yn<8,8,1>F		    { compr align1 };
 mac.sat(16) src_sample_r<1>F	Crn<8,8,1>F	1.596F	    { compr align1 };
-     
+
     /*
-     * G = Crn * -0.813 + Cbn * -0.392 + Y
+     * G = Yn -
+     *     Crn * 255/112 * (1.0 - Kr) * Kr / Kg -
+     *     Cbn * 255/112 * (1.0 - Kb) * Kb / Kg
      */
 mov (16)    acc0<1>F		Yn<8,8,1>F		    { compr align1 };
 mac (16)    acc0<1>F		Crn<8,8,1>F    	-0.813F	    { compr align1 };
 mac.sat(16) src_sample_g<1>F	Cbn<8,8,1>F    	-0.392F	    { compr align1 };
 
     /*
-     * B = Cbn * 2.017 + Y
+     * B = Yn +
+     *     Cbn * 255/112 * (1.0 - Kb)
      */
 mov (16)    acc0<1>F	        Yn<8,8,1>F		    { compr align1 };
 mac.sat(16) src_sample_b<1>F	Cbn<8,8,1>F     2.017F	    { compr align1 };
src/render_program/exa_wm_yuv_rgb_bt601.g8a +22 -9
index 34973ba88592..360501dc9653 100644
@@ -55,14 +55,23 @@ define(`Cbn_01',	`mask_sample_b_01')
 define(`Cbn_23',	`mask_sample_b_23')
 
     /* color space conversion function:
-     * R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1)
-     * G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1)
-     * B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1)
+     * R = Clamp ( 255/(235-16)(Y-16/255) +
+     *             255/112(1.0-Kr)(Cr-128/255), 0, 1)
+     * G = Clamp ( 255/(235-16)(Y-16/255) -
+     *             255/112(1.0-Kr)Kr/Kg(Cr-128/255) -
+     *             255/112(1.0-Kb)Kb/Kg(Cb-128/255), 0, 1)
+     * B = Clamp ( 255/(235-16)(Y-16/255) +
+     *             255/112(1.0-Kb)(Cb-128/255), 0, 1)
+     *
+     * BT.601:
+     * Kr = 0.299
+     * Kb = 0.114
+     * Kg = (1.0 - Kr - Kb) = 0.587
      */
 
     /* Normalize Y, Cb and Cr:
      *
-     * Yn = (Y - 16/255) * 1.164
+     * Yn = (Y - 16/255) * 255/(235-16)
      * Crn = Cr - 128 / 255
      * Cbn = Cb - 128 / 255
      */
@@ -73,16 +82,19 @@ add (16)    Crn<1>F		Cr<8,8,1>F	-0.501961F  { compr align1 };
 
 add (16)    Cbn<1>F		Cb<8,8,1>F	-0.501961F  { compr align1 };
 
-    /* 
-     * R = Y + Cr * 1.596
+    /*
+     * R = Yn +
+     *     Crn * 255/112 * (1.0 - Kr)
      */
 mov (8)    acc0<1>F		Yn_01<8,8,1>F		    { compr align1 };
 mac.sat(8) src_sample_r_01<1>F	Crn_01<8,8,1>F	1.596F	    { compr align1 };
-     
+
 mov (8)    acc0<1>F		Yn_23<8,8,1>F		    { compr align1 };
 mac.sat(8) src_sample_r_23<1>F	Crn_23<8,8,1>F	1.596F	    { compr align1 };
     /*
-     * G = Crn * -0.813 + Cbn * -0.392 + Y
+     * G = Yn -
+     *     Crn * 255/112 * (1.0 - Kr) * Kr / Kg -
+     *     Cbn * 255/112 * (1.0 - Kb) * Kb / Kg
      */
 mov (8)    acc0<1>F		Yn_01<8,8,1>F		    { compr align1 };
 mac (8)    acc0<1>F		Crn_01<8,8,1>F    	-0.813F	    { compr align1 };
@@ -92,7 +104,8 @@ mov (8)    acc0<1>F		Yn_23<8,8,1>F	    { compr align1 };
 mac (8)    acc0<1>F		Crn_23<8,8,1>F    	-0.813F	    { compr align1 };
 mac.sat(16) src_sample_g_23<1>F	Cbn_23<8,8,1>F    	-0.392F	    { compr align1 };
     /*
-     * B = Cbn * 2.017 + Y
+     * B = Yn +
+     *     Cbn * 255/112 * (1.0 - Kb)
      */
 mov (8)    acc0<1>F	        Yn_01<8,8,1>F		    { compr align1 };
 mac.sat(8) src_sample_b_01<1>F	Cbn_01<8,8,1>F     2.017F	    { compr align1 };
src/render_program/exa_wm_yuv_rgb_bt709.g4a new file +111 -0

111 lines not on this page · raw message

src/render_program/exa_wm_yuv_rgb_bt709.g4b new file +12 -0
new file mode 100644
index 000000000000..5b7621b54b43
@@ -0,0 +1,12 @@
+   { 0x00802040, 0x23007fbd, 0x008d0200, 0xbd808081 },
+   { 0x00802041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
+   { 0x00802040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
+   { 0x00802040, 0x23407fbd, 0x008d0240, 0xbf008084 },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80802048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x00802048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
+   { 0x80802048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80802048, 0x22407fbd, 0x008d0340, 0x40072b02 },
+   { 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5 new file +12 -0
new file mode 100644
index 000000000000..5b7621b54b43
@@ -0,0 +1,12 @@
+   { 0x00802040, 0x23007fbd, 0x008d0200, 0xbd808081 },
+   { 0x00802041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
+   { 0x00802040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
+   { 0x00802040, 0x23407fbd, 0x008d0240, 0xbf008084 },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80802048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x00802048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
+   { 0x80802048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80802048, 0x22407fbd, 0x008d0340, 0x40072b02 },
+   { 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
src/render_program/exa_wm_yuv_rgb_bt709.g5a new file +1 -0
new file mode 120000
index 000000000000..9b4ca31203c3
@@ -0,0 +1 @@
+exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt709.g5b new file +12 -0
new file mode 100644
index 000000000000..5b7621b54b43
@@ -0,0 +1,12 @@
+   { 0x00802040, 0x23007fbd, 0x008d0200, 0xbd808081 },
+   { 0x00802041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
+   { 0x00802040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
+   { 0x00802040, 0x23407fbd, 0x008d0240, 0xbf008084 },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80802048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x00802048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
+   { 0x80802048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
+   { 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80802048, 0x22407fbd, 0x008d0340, 0x40072b02 },
+   { 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
src/render_program/exa_wm_yuv_rgb_bt709.g6a new file +1 -0
new file mode 120000
index 000000000000..9b4ca31203c3
@@ -0,0 +1 @@
+exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt709.g6b new file +12 -0
new file mode 100644
index 000000000000..392957e70c38
@@ -0,0 +1,12 @@
+   { 0x00800040, 0x23007fbd, 0x008d0200, 0xbd808081 },
+   { 0x00800041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
+   { 0x00800040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
+   { 0x00800040, 0x23407fbd, 0x008d0240, 0xbf008084 },
+   { 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80800048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
+   { 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x00800048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
+   { 0x80800048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
+   { 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80800048, 0x22407fbd, 0x008d0340, 0x40072b02 },
+   { 0x00800001, 0x228003fd, 0x00000000, 0x3f800000 },
src/render_program/exa_wm_yuv_rgb_bt709.g7a new file +1 -0
new file mode 120000
index 000000000000..9b4ca31203c3
@@ -0,0 +1 @@
+exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file
src/render_program/exa_wm_yuv_rgb_bt709.g7b new file +12 -0
new file mode 100644
index 000000000000..392957e70c38
@@ -0,0 +1,12 @@
+   { 0x00800040, 0x23007fbd, 0x008d0200, 0xbd808081 },
+   { 0x00800041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
+   { 0x00800040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
+   { 0x00800040, 0x23407fbd, 0x008d0240, 0xbf008084 },
+   { 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80800048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
+   { 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x00800048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
+   { 0x80800048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
+   { 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
+   { 0x80800048, 0x22407fbd, 0x008d0340, 0x40072b02 },
+   { 0x00800001, 0x228003fd, 0x00000000, 0x3f800000 },
src/render_program/exa_wm_yuv_rgb_bt709.g8a new file +118 -0

118 lines not on this page · raw message

src/render_program/exa_wm_yuv_rgb_bt709.g8b new file +19 -0
new file mode 100644
index 000000000000..9bfe1ca4b919
@@ -0,0 +1,19 @@
+   { 0x00800040, 0x23003ae8, 0x3e8d0200, 0xbd808081 },
+   { 0x00800041, 0x23003ae8, 0x3e8d0300, 0x3f94fdf4 },
+   { 0x00800040, 0x22c03ae8, 0x3e8d01c0, 0xbf008084 },
+   { 0x00800040, 0x23403ae8, 0x3e8d0240, 0xbf008084 },
+   { 0x00600001, 0x24003ae0, 0x008d0300, 0x00000000 },
+   { 0x80600048, 0x21c03ae8, 0x3e8d02c0, 0x3fe58106 },
+   { 0x00600001, 0x24003ae0, 0x008d0320, 0x00000000 },
+   { 0x80600048, 0x21e03ae8, 0x3e8d02e0, 0x3fe58106 },
+   { 0x00600001, 0x24003ae0, 0x008d0300, 0x00000000 },
+   { 0x00600048, 0x24003ae0, 0x3e8d02c0, 0xbf0872b0 },
+   { 0x80600048, 0x22003ae8, 0x3e8d0340, 0xbe5a1cac },
+   { 0x00600001, 0x24003ae0, 0x008d0320, 0x00000000 },
+   { 0x00600048, 0x24003ae0, 0x3e8d02e0, 0xbf0872b0 },
+   { 0x80800048, 0x22203ae8, 0x3e8d0360, 0xbe5a1cac },
+   { 0x00600001, 0x24003ae0, 0x008d0300, 0x00000000 },
+   { 0x80600048, 0x22403ae8, 0x3e8d0340, 0x40072b02 },
+   { 0x00600001, 0x24003ae0, 0x008d0320, 0x00000000 },
+   { 0x80600048, 0x22603ae8, 0x3e8d0360, 0x40072b02 },
+   { 0x00800001, 0x22803ee8, 0x38000000, 0x3f800000 },
src/sna/gen4_render.c +58 -9

109 lines not on this page · raw message

src/sna/gen4_render.h +8 -3
index 3b37f96adc74..f516c316c096 100644
@@ -2685,9 +2685,14 @@ typedef enum {
 	WM_KERNEL_OPACITY,
 	WM_KERNEL_OPACITY_P,
 
-	WM_KERNEL_VIDEO_PLANAR,
-	WM_KERNEL_VIDEO_NV12,
-	WM_KERNEL_VIDEO_PACKED,
+	WM_KERNEL_VIDEO_PLANAR_BT601,
+	WM_KERNEL_VIDEO_NV12_BT601,
+	WM_KERNEL_VIDEO_PACKED_BT601,
+
+	WM_KERNEL_VIDEO_PLANAR_BT709,
+	WM_KERNEL_VIDEO_NV12_BT709,
+	WM_KERNEL_VIDEO_PACKED_BT709,
+
 	KERNEL_COUNT
 } wm_kernel_t;
 
src/sna/gen5_render.c +58 -9

109 lines not on this page · raw message

src/sna/gen5_render.h +8 -3
index f1a9a68c2e71..8901480a6d0f 100644
@@ -2765,9 +2765,14 @@ typedef enum {
 	WM_KERNEL_OPACITY,
 	WM_KERNEL_OPACITY_P,
 
-	WM_KERNEL_VIDEO_PLANAR,
-	WM_KERNEL_VIDEO_NV12,
-	WM_KERNEL_VIDEO_PACKED,
+	WM_KERNEL_VIDEO_PLANAR_BT601,
+	WM_KERNEL_VIDEO_NV12_BT601,
+	WM_KERNEL_VIDEO_PACKED_BT601,
+
+	WM_KERNEL_VIDEO_PLANAR_BT709,
+	WM_KERNEL_VIDEO_NV12_BT709,
+	WM_KERNEL_VIDEO_PACKED_BT709,
+
 	KERNEL_COUNT
 } wm_kernel_t;
 #endif
src/sna/gen6_render.c +56 -11

109 lines not on this page · raw message

src/sna/gen7_render.c +42 -11

108 lines not on this page · raw message

src/sna/gen8_render.c +42 -11

108 lines not on this page · raw message

src/sna/gen9_render.c +42 -11

108 lines not on this page · raw message

src/sna/sna_render.h +32 -12

68 lines not on this page · raw message

src/sna/sna_video_textured.c +11 -1
index bcd4232024e0..a784fe2ec0f4 100644
@@ -36,7 +36,7 @@
 
 #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, true)
 
-static Atom xvBrightness, xvContrast, xvSyncToVblank;
+static Atom xvBrightness, xvContrast, xvSyncToVblank, xvColorspace;
 
 static XvFormatRec Formats[] = {
 	{15}, {16}, {24}
@@ -44,6 +44,7 @@ static XvFormatRec Formats[] = {
 
 static const XvAttributeRec Attributes[] = {
 	{XvSettable | XvGettable, -1, 1, (char *)"XV_SYNC_TO_VBLANK"},
+	{XvSettable | XvGettable, 0, 1, (char *)"XV_COLORSPACE"}, /* BT.601, BT.709 */
 	//{XvSettable | XvGettable, -128, 127, (char *)"XV_BRIGHTNESS"},
 	//{XvSettable | XvGettable, 0, 255, (char *)"XV_CONTRAST"},
 };
@@ -102,6 +103,11 @@ sna_video_textured_set_attribute(ddSetPortAttribute_ARGS)
 			return BadValue;
 
 		video->SyncToVblank = value;
+	} else if (attribute == xvColorspace) {
+		if (value < 0 || value > 1)
+			return BadValue;
+
+		video->colorspace = value;
 	} else
 		return BadMatch;
 
@@ -119,6 +125,8 @@ sna_video_textured_get_attribute(ddGetPortAttribute_ARGS)
 		*value = video->contrast;
 	else if (attribute == xvSyncToVblank)
 		*value = video->SyncToVblank;
+	else if (attribute == xvColorspace)
+		*value = video->colorspace;
 	else
 		return BadMatch;
 
@@ -426,6 +434,7 @@ void sna_video_textured_setup(struct sna *sna, ScreenPtr screen)
 		v->sna = sna;
 		v->textured = true;
 		v->alignment = 4;
+		v->colorspace = 1; /* BT.709 */
 		v->SyncToVblank = (sna->flags & SNA_NO_WAIT) == 0;
 
 		RegionNull(&v->clip);
@@ -446,6 +455,7 @@ void sna_video_textured_setup(struct sna *sna, ScreenPtr screen)
 
 	xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
 	xvContrast = MAKE_ATOM("XV_CONTRAST");
+	xvColorspace = MAKE_ATOM("XV_COLORSPACE");
 	xvSyncToVblank = MAKE_ATOM("XV_SYNC_TO_VBLANK");
 
 	DBG(("%s: '%s' initialized %d ports\n", __FUNCTION__, adaptor->name, adaptor->nPorts));
Signature · 6 lines
2.13.6

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
In reply to Ville Syrjala

Quoting Ville Syrjala (2018-02-19 18:03:33)

Quoted 5 lines

From: Ville Syrjälä <[email protected]>

I figured I should expose XV_COLORSPACE/BT.709 on the textured Xv adator as well. So here it is. This depends on the earlier sprite Xv XV_COLORSPACE patch I posted earlier.

Looked believable. :)
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx