/* 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
);
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;
#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;
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 */
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <math.h>
#include <va/va_drmcommon.h>
#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"
};
#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"
};
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"
};
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"
};
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"
};
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)
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);
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);
}
INTEL_G4I = \
exa_wm.g4i \
- exa_wm_affine.g4i
+ exa_wm_affine.g4i \
+ exa_wm_yuv_color_balance.gxa
INTEL_G4A = \
exa_sf.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
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
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)
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)
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 =
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)
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')
--- /dev/null
+/*
+ * 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')
--- /dev/null
+ { 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 },
--- /dev/null
+ { 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 },
--- /dev/null
+/*
+ * 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')
--- /dev/null
+ { 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 },
--- /dev/null
+/*
+ * 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')
--- /dev/null
+ { 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 },
--- /dev/null
+ { 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 },
--- /dev/null
+/*
+ * 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: