diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2018-05-29 21:33:10 +0300 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-05-31 20:35:32 +0100 |
commit | e4f2b5d5af9548f950b20b4699a2f751ca2146dc (patch) | |
tree | f454246ebb95c956383920d372c91ad5bb8b3904 /src/render_program | |
parent | 35a9e96992a9298577d81e6b98c1329475282db1 (diff) |
sna/video: Add XV_COLORSPACE attribute for the textured Xv adaptor
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.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/render_program')
-rw-r--r-- | src/render_program/Makefile.am | 11 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt601.g4a | 32 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt601.g8a | 31 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g4a | 111 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g4b | 12 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5 | 12 | ||||
l--------- | src/render_program/exa_wm_yuv_rgb_bt709.g5a | 1 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g5b | 12 | ||||
l--------- | src/render_program/exa_wm_yuv_rgb_bt709.g6a | 1 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g6b | 12 | ||||
l--------- | src/render_program/exa_wm_yuv_rgb_bt709.g7a | 1 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g7b | 12 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g8a | 118 | ||||
-rw-r--r-- | src/render_program/exa_wm_yuv_rgb_bt709.g8b | 19 |
14 files changed, 367 insertions, 18 deletions
diff --git a/src/render_program/Makefile.am b/src/render_program/Makefile.am index 44936734..dc58138f 100644 --- a/src/render_program/Makefile.am +++ b/src/render_program/Makefile.am @@ -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 = \ diff --git a/src/render_program/exa_wm_yuv_rgb_bt601.g4a b/src/render_program/exa_wm_yuv_rgb_bt601.g4a index 4fb2576a..7bc8dd14 100644 --- a/src/render_program/exa_wm_yuv_rgb_bt601.g4a +++ b/src/render_program/exa_wm_yuv_rgb_bt601.g4a @@ -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 }; diff --git a/src/render_program/exa_wm_yuv_rgb_bt601.g8a b/src/render_program/exa_wm_yuv_rgb_bt601.g8a index 34973ba8..360501dc 100644 --- a/src/render_program/exa_wm_yuv_rgb_bt601.g8a +++ b/src/render_program/exa_wm_yuv_rgb_bt601.g8a @@ -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 }; diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g4a b/src/render_program/exa_wm_yuv_rgb_bt709.g4a new file mode 100644 index 00000000..e498f18f --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g4a @@ -0,0 +1,111 @@ +/* + * 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 <keithp@keithp.com> + * Eric Anholt <eric@anholt.net> + * + */ + +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 ( 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.709: + * Kr = .2126 + * Kb = .0722 + * Kg = (1.0 - Kr - Kb) = 0.7152 + */ + + /* Normalize Y, Cb and Cr: + * + * Yn = (Y - 16/255) * 255/(235-16) + * 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 = 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.793F { compr align1 }; + + /* + * 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.533F { compr align1 }; +mac.sat(16) src_sample_g<1>F Cbn<8,8,1>F -0.213F { compr align1 }; + + /* + * 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.112F { compr align1 }; + + /* + * A = 1.0 + */ +mov (16) src_sample_a<1>F 1.0F { compr align1 }; diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g4b b/src/render_program/exa_wm_yuv_rgb_bt709.g4b new file mode 100644 index 00000000..5b7621b5 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g4b @@ -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 }, diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5 b/src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5 new file mode 100644 index 00000000..5b7621b5 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g4b.gen5 @@ -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 }, diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g5a b/src/render_program/exa_wm_yuv_rgb_bt709.g5a new file mode 120000 index 00000000..9b4ca312 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g5a @@ -0,0 +1 @@ +exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g5b b/src/render_program/exa_wm_yuv_rgb_bt709.g5b new file mode 100644 index 00000000..5b7621b5 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g5b @@ -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 }, diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g6a b/src/render_program/exa_wm_yuv_rgb_bt709.g6a new file mode 120000 index 00000000..9b4ca312 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g6a @@ -0,0 +1 @@ +exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g6b b/src/render_program/exa_wm_yuv_rgb_bt709.g6b new file mode 100644 index 00000000..392957e7 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g6b @@ -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 }, diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g7a b/src/render_program/exa_wm_yuv_rgb_bt709.g7a new file mode 120000 index 00000000..9b4ca312 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g7a @@ -0,0 +1 @@ +exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g7b b/src/render_program/exa_wm_yuv_rgb_bt709.g7b new file mode 100644 index 00000000..392957e7 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g7b @@ -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 }, diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g8a b/src/render_program/exa_wm_yuv_rgb_bt709.g8a new file mode 100644 index 00000000..9ab2ca0d --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g8a @@ -0,0 +1,118 @@ +/* + * 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 <keithp@keithp.com> + * Eric Anholt <eric@anholt.net> + * + */ + +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 ( 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.709: + * Kr = .2126 + * Kb = .0722 + * Kg = (1.0 - Kr - Kb) = 0.7152 + */ + + /* Normalize Y, Cb and Cr: + * + * Yn = (Y - 16/255) * 255/(235-16) + * 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 = 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.793F { 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.793F { compr align1 }; + /* + * 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.533F { compr align1 }; +mac.sat(8) src_sample_g_01<1>F Cbn_01<8,8,1>F -0.213F { compr align1 }; + +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.533F { compr align1 }; +mac.sat(16) src_sample_g_23<1>F Cbn_23<8,8,1>F -0.213F { compr align1 }; + /* + * 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.112F { compr align1 }; + +mov (8) acc0<1>F Yn_23<8,8,1>F { compr align1 }; +mac.sat(8) src_sample_b_23<1>F Cbn_23<8,8,1>F 2.112F { compr align1 }; + /* + * A = 1.0 + */ +mov (16) src_sample_a<1>F 1.0F { compr align1 }; diff --git a/src/render_program/exa_wm_yuv_rgb_bt709.g8b b/src/render_program/exa_wm_yuv_rgb_bt709.g8b new file mode 100644 index 00000000..9bfe1ca4 --- /dev/null +++ b/src/render_program/exa_wm_yuv_rgb_bt709.g8b @@ -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 }, |