Add the support of brightness/contrast/hue/saturation for BDW rendering
authorZhao Yakui <yakui.zhao@intel.com>
Thu, 19 Dec 2013 09:03:31 +0000 (17:03 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 27 Feb 2014 02:26:25 +0000 (10:26 +0800)
This is picked up from the commit 04ecb6e79f4382d96eb5d4b51733049d420f592a

Signed-off-by: Xiang Haihao <haihao.xiang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
src/i965_render.c
src/shaders/render/Makefile.am
src/shaders/render/exa_wm_yuv_color_balance.g8a [new file with mode: 0644]
src/shaders/render/exa_wm_yuv_color_balance.g8b [new file with mode: 0644]

index d79f6b1..3c99614 100644 (file)
@@ -157,6 +157,7 @@ static const uint32_t sf_kernel_static_gen8[][4] =
 static const uint32_t ps_kernel_static_gen8[][4] = {
 #include "shaders/render/exa_wm_src_affine.g8b"
 #include "shaders/render/exa_wm_src_sample_planar.g8b"
+#include "shaders/render/exa_wm_yuv_color_balance.g8b"
 #include "shaders/render/exa_wm_yuv_rgb.g8b"
 #include "shaders/render/exa_wm_write.g8b"
 };
@@ -2867,6 +2868,11 @@ gen8_render_upload_constants(VADriverContextP ctx,
     struct i965_render_state *render_state = &i965->render_state;
     unsigned short *constant_buffer;
     unsigned char *cc_ptr;
+    float *color_balance_base;
+    float contrast = (float)i965->contrast_attrib->value / DEFAULT_CONTRAST;
+    float brightness = (float)i965->brightness_attrib->value / 255; /* YUV is float in the shader */
+    float hue = (float)i965->hue_attrib->value / 180 * PI;
+    float saturation = (float)i965->saturation_attrib->value / DEFAULT_SATURATION;
 
     dri_bo_map(render_state->dynamic_state.bo, 1);
     assert(render_state->dynamic_state.bo->virtual);
@@ -2887,6 +2893,20 @@ gen8_render_upload_constants(VADriverContextP ctx,
             *constant_buffer = 0;
     }
 
+    if (i965->contrast_attrib->value == DEFAULT_CONTRAST &&
+        i965->brightness_attrib->value == DEFAULT_BRIGHTNESS &&
+        i965->hue_attrib->value == DEFAULT_HUE &&
+        i965->saturation_attrib->value == DEFAULT_SATURATION)
+        constant_buffer[1] = 1; /* skip color balance transformation */
+    else
+        constant_buffer[1] = 0;
+
+    color_balance_base = (float *)constant_buffer + 4;
+    *color_balance_base++ = contrast;
+    *color_balance_base++ = brightness;
+    *color_balance_base++ = cos(hue) * contrast * saturation;
+    *color_balance_base++ = sin(hue) * contrast * saturation;
+
     dri_bo_unmap(render_state->dynamic_state.bo);
 }
 
index 33aa367..e59869c 100644 (file)
@@ -89,6 +89,7 @@ INTEL_G8A =                           \
        exa_wm_src_affine.g8a           \
        exa_wm_src_sample_planar.g8a    \
        exa_wm_src_sample_argb.g8a      \
+       exa_wm_yuv_color_balance.g8a    \
        exa_wm_write.g8a                \
        exa_wm_yuv_rgb.g8a
 
@@ -98,6 +99,7 @@ INTEL_G8B =                           \
        exa_wm_src_affine.g8b           \
        exa_wm_src_sample_planar.g8b    \
        exa_wm_src_sample_argb.g8b      \
+       exa_wm_yuv_color_balance.g8b    \
        exa_wm_yuv_rgb.g8b              \
        exa_wm_write.g8b 
 
diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g8a b/src/shaders/render/exa_wm_yuv_color_balance.g8a
new file mode 100644 (file)
index 0000000..f3cc28f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2013 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:
+ *    Haihao Xiang <haihao.xiang@intel.com>
+ *    Zhao Yakui  <yakui.zhao@intel.com>
+ *
+ */
+
+include(`exa_wm.g4i')
+
+/* Color Balance parameters */
+define(`skip_color_balance',    `g6.2<0,1,0>uw')
+define(`contrast',              `g6.16<0,1,0>f')
+define(`brightness',            `g6.20<0,1,0>f')
+define(`cos_c_s',               `g6.24<0,1,0>f')
+define(`sin_c_s',               `g6.28<0,1,0>f')
+define(`sin_c_s_t',             `g6.28')
+
+include(`exa_wm_yuv_color_balance.gxa')
diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g8b b/src/shaders/render/exa_wm_yuv_color_balance.g8b
new file mode 100644 (file)
index 0000000..5dc2c8b
--- /dev/null
@@ -0,0 +1,15 @@
+   { 0x01000010, 0x200012e0, 0x160000c2, 0x00010001 },
+   { 0x00010020, 0x34000000, 0x0e001400, 0x000000d0 },
+   { 0x00800040, 0x24003ae8, 0x3e8d01c0, 0xbd808081 },
+   { 0x00800041, 0x24003ae8, 0x3a8d0400, 0x000000d0 },
+   { 0x00800040, 0x24003ae8, 0x3a8d0400, 0x000000d4 },
+   { 0x00800040, 0x21c03ae8, 0x3e8d0400, 0x3d808081 },
+   { 0x00800040, 0x24803ae8, 0x3e8d0200, 0xbf008084 },
+   { 0x00800040, 0x24403ae8, 0x3e8d0240, 0xbf008084 },
+   { 0x00800001, 0x24003ee0, 0x38000000, 0x3f008084 },
+   { 0x00800048, 0x24003ae0, 0x3a8d0440, 0x000000dc },
+   { 0x00800048, 0x22003ae8, 0x3a8d0480, 0x000000d8 },
+   { 0x00000041, 0x20dc3ae8, 0x3e0000dc, 0xbf800000 },
+   { 0x00800001, 0x24003ee0, 0x38000000, 0x3f008084 },
+   { 0x00800048, 0x24003ae0, 0x3a8d0480, 0x000000dc },
+   { 0x00800048, 0x22403ae8, 0x3a8d0440, 0x000000d8 },