diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2013-09-26 11:02:09 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2013-11-13 15:34:42 +0800 |
commit | 04ed735e9056aa1ee74ffdc9a545619cb1eba28c (patch) | |
tree | 36fd013f636de824111e03c0c5b0012d9bab9604 | |
parent | 500d8d174b25f7ea91f134166e5968beb43f3957 (diff) | |
download | libva-intel-driver-04ed735e9056aa1ee74ffdc9a545619cb1eba28c.tar.gz libva-intel-driver-04ed735e9056aa1ee74ffdc9a545619cb1eba28c.tar.bz2 libva-intel-driver-04ed735e9056aa1ee74ffdc9a545619cb1eba28c.zip |
render: add support for brightness/contrast/hue/saturation
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
(cherry picked from commit 04ecb6e79f4382d96eb5d4b51733049d420f592a)
-rwxr-xr-x | src/i965_drv_video.c | 35 | ||||
-rw-r--r-- | src/i965_drv_video.h | 9 | ||||
-rw-r--r-- | src/i965_render.c | 33 | ||||
-rw-r--r-- | src/shaders/render/Makefile.am | 17 | ||||
-rw-r--r-- | src/shaders/render/exa_wm.g4i | 19 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g4a | 38 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g4b | 15 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g4b.gen5 | 15 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g6a | 38 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g6b | 15 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g7a | 38 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g7b | 15 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.g7b.haswell | 15 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_color_balance.gxa | 75 |
14 files changed, 371 insertions, 6 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index b1dac63..eec7762 100755 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -97,6 +97,30 @@ enum { /* List of supported display attributes */ static const VADisplayAttribute i965_display_attributes[] = { { + VADisplayAttribBrightness, + -100, 100, DEFAULT_BRIGHTNESS, + VA_DISPLAY_ATTRIB_GETTABLE | VA_DISPLAY_ATTRIB_SETTABLE + }, + + { + VADisplayAttribContrast, + 0, 100, DEFAULT_CONTRAST, + VA_DISPLAY_ATTRIB_GETTABLE | VA_DISPLAY_ATTRIB_SETTABLE + }, + + { + VADisplayAttribHue, + -180, 180, DEFAULT_HUE, + VA_DISPLAY_ATTRIB_GETTABLE | VA_DISPLAY_ATTRIB_SETTABLE + }, + + { + VADisplayAttribSaturation, + 0, 100, DEFAULT_SATURATION, + VA_DISPLAY_ATTRIB_GETTABLE | VA_DISPLAY_ATTRIB_SETTABLE + }, + + { VADisplayAttribRotation, 0, 3, VA_ROTATION_NONE, VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE @@ -2431,7 +2455,16 @@ i965_display_attributes_init(VADriverContextP ctx) ); i965->rotation_attrib = get_display_attribute(ctx, VADisplayAttribRotation); - if (!i965->rotation_attrib) { + i965->brightness_attrib = get_display_attribute(ctx, VADisplayAttribBrightness); + i965->contrast_attrib = get_display_attribute(ctx, VADisplayAttribContrast); + i965->hue_attrib = get_display_attribute(ctx, VADisplayAttribHue); + i965->saturation_attrib = get_display_attribute(ctx, VADisplayAttribSaturation); + + if (!i965->rotation_attrib || + !i965->brightness_attrib || + !i965->contrast_attrib || + !i965->hue_attrib || + !i965->saturation_attrib) { goto error; } return true; diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h index a0e7790..3b06ac0 100644 --- a/src/i965_drv_video.h +++ b/src/i965_drv_video.h @@ -59,6 +59,11 @@ #define I965_SURFACE_FLAG_TOP_FIELD_FIRST 0x00000001 #define I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST 0x00000002 +#define DEFAULT_BRIGHTNESS 0 +#define DEFAULT_CONTRAST 10 +#define DEFAULT_HUE 0 +#define DEFAULT_SATURATION 10 + struct i965_surface { struct object_base *base; @@ -321,6 +326,10 @@ struct i965_driver_data VADisplayAttribute *display_attributes; unsigned int num_display_attributes; VADisplayAttribute *rotation_attrib; + VADisplayAttribute *brightness_attrib; + VADisplayAttribute *contrast_attrib; + VADisplayAttribute *hue_attrib; + VADisplayAttribute *saturation_attrib; VAContextID current_context_id; /* VA/DRI (X11) specific data */ diff --git a/src/i965_render.c b/src/i965_render.c index 26a7baf..b4fd29b 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -35,6 +35,7 @@ #include <stdlib.h> #include <string.h> #include <assert.h> +#include <math.h> #include <va/va_drmcommon.h> @@ -64,6 +65,7 @@ static const uint32_t ps_kernel_static[][4] = #include "shaders/render/exa_wm_xy.g4b" #include "shaders/render/exa_wm_src_affine.g4b" #include "shaders/render/exa_wm_src_sample_planar.g4b" +#include "shaders/render/exa_wm_yuv_color_balance.g4b" #include "shaders/render/exa_wm_yuv_rgb.g4b" #include "shaders/render/exa_wm_write.g4b" }; @@ -86,6 +88,7 @@ static const uint32_t ps_kernel_static_gen5[][4] = #include "shaders/render/exa_wm_xy.g4b.gen5" #include "shaders/render/exa_wm_src_affine.g4b.gen5" #include "shaders/render/exa_wm_src_sample_planar.g4b.gen5" +#include "shaders/render/exa_wm_yuv_color_balance.g4b.gen5" #include "shaders/render/exa_wm_yuv_rgb.g4b.gen5" #include "shaders/render/exa_wm_write.g4b.gen5" }; @@ -105,6 +108,7 @@ static const uint32_t sf_kernel_static_gen6[][4] = static const uint32_t ps_kernel_static_gen6[][4] = { #include "shaders/render/exa_wm_src_affine.g6b" #include "shaders/render/exa_wm_src_sample_planar.g6b" +#include "shaders/render/exa_wm_yuv_color_balance.g6b" #include "shaders/render/exa_wm_yuv_rgb.g6b" #include "shaders/render/exa_wm_write.g6b" }; @@ -123,6 +127,7 @@ static const uint32_t sf_kernel_static_gen7[][4] = static const uint32_t ps_kernel_static_gen7[][4] = { #include "shaders/render/exa_wm_src_affine.g7b" #include "shaders/render/exa_wm_src_sample_planar.g7b" +#include "shaders/render/exa_wm_yuv_color_balance.g7b" #include "shaders/render/exa_wm_yuv_rgb.g7b" #include "shaders/render/exa_wm_write.g7b" }; @@ -137,6 +142,7 @@ static const uint32_t ps_subpic_kernel_static_gen7[][4] = { static const uint32_t ps_kernel_static_gen7_haswell[][4] = { #include "shaders/render/exa_wm_src_affine.g7b" #include "shaders/render/exa_wm_src_sample_planar.g7b.haswell" +#include "shaders/render/exa_wm_yuv_color_balance.g7b.haswell" #include "shaders/render/exa_wm_yuv_rgb.g7b" #include "shaders/render/exa_wm_write.g7b" }; @@ -1050,6 +1056,8 @@ i965_render_upload_vertex( i965_fill_vertex_buffer(ctx, tex_coords, vid_coords); } +#define PI 3.1415926 + static void i965_render_upload_constants(VADriverContextP ctx, struct object_surface *obj_surface) @@ -1057,6 +1065,11 @@ i965_render_upload_constants(VADriverContextP ctx, struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; unsigned short *constant_buffer; + 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->curbe.bo, 1); assert(render_state->curbe.bo->virtual); @@ -1065,14 +1078,28 @@ i965_render_upload_constants(VADriverContextP ctx, if (obj_surface->subsampling == SUBSAMPLE_YUV400) { assert(obj_surface->fourcc == VA_FOURCC('Y', '8', '0', '0')); - *constant_buffer = 2; + constant_buffer[0] = 2; } else { if (obj_surface->fourcc == VA_FOURCC('N', 'V', '1', '2')) - *constant_buffer = 1; + constant_buffer[0] = 1; else - *constant_buffer = 0; + constant_buffer[0] = 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->curbe.bo); } diff --git a/src/shaders/render/Makefile.am b/src/shaders/render/Makefile.am index dac58c7..1653b4a 100644 --- a/src/shaders/render/Makefile.am +++ b/src/shaders/render/Makefile.am @@ -1,7 +1,8 @@ INTEL_G4I = \ exa_wm.g4i \ - exa_wm_affine.g4i + exa_wm_affine.g4i \ + exa_wm_yuv_color_balance.gxa INTEL_G4A = \ exa_sf.g4a \ @@ -9,6 +10,7 @@ INTEL_G4A = \ exa_wm_src_affine.g4a \ exa_wm_src_sample_argb.g4a \ exa_wm_src_sample_planar.g4a \ + exa_wm_yuv_color_balance.g4a \ exa_wm_yuv_rgb.g4a \ exa_wm_write.g4a @@ -20,6 +22,7 @@ INTEL_G4B = \ exa_wm_src_affine.g4b \ exa_wm_src_sample_argb.g4b \ exa_wm_src_sample_planar.g4b \ + exa_wm_yuv_color_balance.g4b \ exa_wm_yuv_rgb.g4b \ exa_wm_write.g4b @@ -29,14 +32,18 @@ INTEL_G4B_GEN5 = \ exa_wm_src_affine.g4b.gen5 \ exa_wm_src_sample_argb.g4b.gen5 \ exa_wm_src_sample_planar.g4b.gen5 \ + exa_wm_yuv_color_balance.g4b.gen5 \ exa_wm_yuv_rgb.g4b.gen5 \ exa_wm_write.g4b.gen5 +INTEL_G6I = $(INTEL_G4I) + INTEL_G6A = \ exa_wm_src_affine.g6a \ exa_wm_src_sample_argb.g6a \ exa_wm_src_sample_planar.g6a \ exa_wm_write.g6a \ + exa_wm_yuv_color_balance.g6a \ exa_wm_yuv_rgb.g6a INTEL_G6S = $(INTEL_G6A:%.g6a=%.g6s) @@ -46,13 +53,17 @@ INTEL_G6B = \ exa_wm_src_sample_argb.g6b \ exa_wm_src_sample_planar.g6b \ exa_wm_write.g6b \ + exa_wm_yuv_color_balance.g6b \ exa_wm_yuv_rgb.g6b +INTEL_G7I = $(INTEL_G4I) + INTEL_G7A = \ exa_wm_src_affine.g7a \ exa_wm_src_sample_argb.g7a \ exa_wm_src_sample_planar.g7a \ exa_wm_write.g7a \ + exa_wm_yuv_color_balance.g7a \ exa_wm_yuv_rgb.g7a INTEL_G7S = $(INTEL_G7A:%.g7a=%.g7s) @@ -62,11 +73,13 @@ INTEL_G7B = \ exa_wm_src_sample_argb.g7b \ exa_wm_src_sample_planar.g7b \ exa_wm_write.g7b \ + exa_wm_yuv_color_balance.g7b \ exa_wm_yuv_rgb.g7b # XXX: only regenerate binary for EU code containing JMPI instructions INTEL_G7B_HASWELL = \ exa_wm_src_sample_planar.g7b.haswell \ + exa_wm_yuv_color_balance.g7b.haswell \ $(NULL) TARGETS = @@ -80,7 +93,7 @@ endif all-local: $(TARGETS) -SUFFIXES = .g4a .g4s .g4b .g6a .g6s .g6b .g7a .g7s .g7b .g7b.haswell +SUFFIXES = .g4a .g4s .g4b .g4b.gen5 .g6a .g6s .g6b .g7a .g7s .g7b .g7b.haswell if HAVE_GEN4ASM $(INTEL_G4S): $(INTEL_G4A) $(INTEL_G4I) diff --git a/src/shaders/render/exa_wm.g4i b/src/shaders/render/exa_wm.g4i index 8163de5..dd47d51 100644 --- a/src/shaders/render/exa_wm.g4i +++ b/src/shaders/render/exa_wm.g4i @@ -142,6 +142,25 @@ define(`mask_sample_a', `g28') define(`mask_sample_a_01', `g28') define(`mask_sample_a_23', `g29') +/* Color Balance to these registers */ +define(`color_balance_base', `g32') + +define(`color_balance_r', `g32') +define(`color_balance_r_01', `g32') +define(`color_balance_r_23', `g33') + +define(`color_balance_g', `g34') +define(`color_balance_g_01', `g34') +define(`color_balance_g_23', `g35') + +define(`color_balance_b', `g36') +define(`color_balance_b_01', `g37') +define(`color_balance_b_23', `g37') + +define(`color_balance_a', `g38') +define(`color_balance_a_01', `g39') +define(`color_balance_a_23', `g39') + /* data port SIMD16 send registers */ define(`data_port_msg_0', `m0') diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g4a b/src/shaders/render/exa_wm_yuv_color_balance.g4a new file mode 100644 index 0000000..33ba67a --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g4a @@ -0,0 +1,38 @@ +/* + * 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> + * + */ + +include(`exa_wm.g4i') + +/* Color Balance parameters */ +define(`skip_color_balance', `g2.2<0,1,0>uw') +define(`contrast', `g2.16<0,1,0>f') +define(`brightness', `g2.20<0,1,0>f') +define(`cos_c_s', `g2.24<0,1,0>f') +define(`sin_c_s', `g2.28<0,1,0>f') +define(`sin_c_s_t', `g2.28') + +include(`exa_wm_yuv_color_balance.gxa') diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g4b b/src/shaders/render/exa_wm_yuv_color_balance.g4b new file mode 100644 index 0000000..cba9aca --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g4b @@ -0,0 +1,15 @@ + { 0x01000010, 0x20002d3c, 0x00000042, 0x00010001 }, + { 0x00010020, 0x34001c00, 0x00001400, 0x0000000d }, + { 0x00802040, 0x24007fbd, 0x008d01c0, 0xbd808081 }, + { 0x00802041, 0x240077bd, 0x008d0400, 0x00000050 }, + { 0x00802040, 0x240077bd, 0x008d0400, 0x00000054 }, + { 0x00802040, 0x21c07fbd, 0x008d0400, 0x3d808081 }, + { 0x00802040, 0x24807fbd, 0x008d0200, 0xbf008084 }, + { 0x00802040, 0x24407fbd, 0x008d0240, 0xbf008084 }, + { 0x00802001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00802048, 0x240077bc, 0x008d0440, 0x0000005c }, + { 0x00802048, 0x220077bd, 0x008d0480, 0x00000058 }, + { 0x00000041, 0x205c7fbd, 0x0000005c, 0xbf800000 }, + { 0x00802001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00802048, 0x240077bc, 0x008d0480, 0x0000005c }, + { 0x00802048, 0x224077bd, 0x008d0440, 0x00000058 }, diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g4b.gen5 b/src/shaders/render/exa_wm_yuv_color_balance.g4b.gen5 new file mode 100644 index 0000000..5a24a0e --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g4b.gen5 @@ -0,0 +1,15 @@ + { 0x01000010, 0x20002d3c, 0x00000042, 0x00010001 }, + { 0x00010020, 0x34001c00, 0x00001400, 0x0000001a }, + { 0x00802040, 0x24007fbd, 0x008d01c0, 0xbd808081 }, + { 0x00802041, 0x240077bd, 0x008d0400, 0x00000050 }, + { 0x00802040, 0x240077bd, 0x008d0400, 0x00000054 }, + { 0x00802040, 0x21c07fbd, 0x008d0400, 0x3d808081 }, + { 0x00802040, 0x24807fbd, 0x008d0200, 0xbf008084 }, + { 0x00802040, 0x24407fbd, 0x008d0240, 0xbf008084 }, + { 0x00802001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00802048, 0x240077bc, 0x008d0440, 0x0000005c }, + { 0x00802048, 0x220077bd, 0x008d0480, 0x00000058 }, + { 0x00000041, 0x205c7fbd, 0x0000005c, 0xbf800000 }, + { 0x00802001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00802048, 0x240077bc, 0x008d0480, 0x0000005c }, + { 0x00802048, 0x224077bd, 0x008d0440, 0x00000058 }, diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g6a b/src/shaders/render/exa_wm_yuv_color_balance.g6a new file mode 100644 index 0000000..6906357 --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g6a @@ -0,0 +1,38 @@ +/* + * 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> + * + */ + +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.g6b b/src/shaders/render/exa_wm_yuv_color_balance.g6b new file mode 100644 index 0000000..0a9e6b9 --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g6b @@ -0,0 +1,15 @@ + { 0x01000010, 0x20002d3c, 0x000000c2, 0x00010001 }, + { 0x00010020, 0x34001c00, 0x00001400, 0x0000001a }, + { 0x00800040, 0x24007fbd, 0x008d01c0, 0xbd808081 }, + { 0x00800041, 0x240077bd, 0x008d0400, 0x000000d0 }, + { 0x00800040, 0x240077bd, 0x008d0400, 0x000000d4 }, + { 0x00800040, 0x21c07fbd, 0x008d0400, 0x3d808081 }, + { 0x00800040, 0x24807fbd, 0x008d0200, 0xbf008084 }, + { 0x00800040, 0x24407fbd, 0x008d0240, 0xbf008084 }, + { 0x00800001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00800048, 0x240077bc, 0x008d0440, 0x000000dc }, + { 0x00800048, 0x220077bd, 0x008d0480, 0x000000d8 }, + { 0x00000041, 0x20dc7fbd, 0x000000dc, 0xbf800000 }, + { 0x00800001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00800048, 0x240077bc, 0x008d0480, 0x000000dc }, + { 0x00800048, 0x224077bd, 0x008d0440, 0x000000d8 }, diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g7a b/src/shaders/render/exa_wm_yuv_color_balance.g7a new file mode 100644 index 0000000..6906357 --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g7a @@ -0,0 +1,38 @@ +/* + * 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> + * + */ + +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.g7b b/src/shaders/render/exa_wm_yuv_color_balance.g7b new file mode 100644 index 0000000..0a9e6b9 --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g7b @@ -0,0 +1,15 @@ + { 0x01000010, 0x20002d3c, 0x000000c2, 0x00010001 }, + { 0x00010020, 0x34001c00, 0x00001400, 0x0000001a }, + { 0x00800040, 0x24007fbd, 0x008d01c0, 0xbd808081 }, + { 0x00800041, 0x240077bd, 0x008d0400, 0x000000d0 }, + { 0x00800040, 0x240077bd, 0x008d0400, 0x000000d4 }, + { 0x00800040, 0x21c07fbd, 0x008d0400, 0x3d808081 }, + { 0x00800040, 0x24807fbd, 0x008d0200, 0xbf008084 }, + { 0x00800040, 0x24407fbd, 0x008d0240, 0xbf008084 }, + { 0x00800001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00800048, 0x240077bc, 0x008d0440, 0x000000dc }, + { 0x00800048, 0x220077bd, 0x008d0480, 0x000000d8 }, + { 0x00000041, 0x20dc7fbd, 0x000000dc, 0xbf800000 }, + { 0x00800001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00800048, 0x240077bc, 0x008d0480, 0x000000dc }, + { 0x00800048, 0x224077bd, 0x008d0440, 0x000000d8 }, diff --git a/src/shaders/render/exa_wm_yuv_color_balance.g7b.haswell b/src/shaders/render/exa_wm_yuv_color_balance.g7b.haswell new file mode 100644 index 0000000..2780c08 --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.g7b.haswell @@ -0,0 +1,15 @@ + { 0x01000010, 0x20002d3c, 0x000000c2, 0x00010001 }, + { 0x00010020, 0x34001c00, 0x00001400, 0x000000d0 }, + { 0x00800040, 0x24007fbd, 0x008d01c0, 0xbd808081 }, + { 0x00800041, 0x240077bd, 0x008d0400, 0x000000d0 }, + { 0x00800040, 0x240077bd, 0x008d0400, 0x000000d4 }, + { 0x00800040, 0x21c07fbd, 0x008d0400, 0x3d808081 }, + { 0x00800040, 0x24807fbd, 0x008d0200, 0xbf008084 }, + { 0x00800040, 0x24407fbd, 0x008d0240, 0xbf008084 }, + { 0x00800001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00800048, 0x240077bc, 0x008d0440, 0x000000dc }, + { 0x00800048, 0x220077bd, 0x008d0480, 0x000000d8 }, + { 0x00000041, 0x20dc7fbd, 0x000000dc, 0xbf800000 }, + { 0x00800001, 0x240003fc, 0x00000000, 0x3f008084 }, + { 0x00800048, 0x240077bc, 0x008d0480, 0x000000dc }, + { 0x00800048, 0x224077bd, 0x008d0440, 0x000000d8 }, diff --git a/src/shaders/render/exa_wm_yuv_color_balance.gxa b/src/shaders/render/exa_wm_yuv_color_balance.gxa new file mode 100644 index 0000000..948067c --- /dev/null +++ b/src/shaders/render/exa_wm_yuv_color_balance.gxa @@ -0,0 +1,75 @@ +/* + * 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> + * + */ + +define(`Cr', `src_sample_b') +define(`Cr_01', `src_sample_b_01') +define(`Cr_23', `src_sample_b_23') + +define(`Y', `src_sample_r') +define(`Y_01', `src_sample_r_01') +define(`Y_23', `src_sample_r_23') + +define(`Cb', `src_sample_g') +define(`Cb_01', `src_sample_g_01') +define(`Cb_23', `src_sample_g_23') + +define(`Crn', `color_balance_g') +define(`Crn_01', `color_balance_g_01') +define(`Crn_23', `color_balance_g_23') + +define(`Yn', `color_balance_r') +define(`Yn_01', `color_balance_r_01') +define(`Yn_23', `color_balance_r_23') + +define(`Cbn', `color_balance_b') +define(`Cbn_01', `color_balance_b_01') +define(`Cbn_23', `color_balance_b_23') + +cmp.e.f0.0 (1) null skip_color_balance 0x1uw {align1}; +(f0.0) jmpi _DONE_COLOR_BALANCE; + +/* Yout = (Yin - 16 / 255) * contrast + brightness + 16 / 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 contrast { compr align1 }; +add (16) Yn<1>F Yn<8,8,1>F brightness { compr align1 }; +add (16) Y<1>F Yn<8,8,1>F 0.0627451F { compr align1 }; + +/* Uout = (Uin - 128 / 255) * cos_c_s + (Vin - 128 / 255) * sin_c_s + 128 / 255 */ +/* Vout = (Vin - 128 / 255) * cos_c_s - (Uin - 128 / 255) * sin_c_s + 128 / 255 */ +add (16) Cbn<1>F Cb<8,8,1>F -0.501961F { compr align1 }; +add (16) Crn<1>F Cr<8,8,1>F -0.501961F { compr align1 }; + +mov (16) acc0<1>F 0.501961F { compr align1 }; +mac (16) acc0<1>F Crn<8,8,1>F sin_c_s { compr align1 }; +mac (16) Cb<1>F Cbn<8,8,1>F cos_c_s { compr align1 }; + +mul (1) sin_c_s_t<1>F sin_c_s -1.0F { align1}; +mov (16) acc0<1>F 0.501961F { compr align1 }; +mac (16) acc0<1>F Cbn<8,8,1>F sin_c_s { compr align1 }; +mac (16) Cr<1>F Crn<8,8,1>F cos_c_s { compr align1 }; + +_DONE_COLOR_BALANCE: |