diff options
author | Zhao Yakui <yakui.zhao@intel.com> | 2013-12-19 17:03:31 +0800 |
---|---|---|
committer | Yakui Zhao <yakui.zhao@intel.com> | 2013-12-19 17:03:31 +0800 |
commit | 765269e2bf89ab83495aa4a482494c910e9154e5 (patch) | |
tree | 99287ce1182b2905b7e22117290da17d44619049 | |
parent | 92509398f8e8d3bc6f4ab0f6d54cf6fec5b24377 (diff) | |
download | libva-intel-driver-765269e2bf89ab83495aa4a482494c910e9154e5.tar.gz libva-intel-driver-765269e2bf89ab83495aa4a482494c910e9154e5.tar.bz2 libva-intel-driver-765269e2bf89ab83495aa4a482494c910e9154e5.zip |
Add the support of color BT709/SMPTE240M for color-space conversion on BDW
This is picked up from that on Haswell/Ivybridge.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
-rw-r--r-- | src/i965_render.c | 18 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_src_affine.g8a | 2 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_src_affine.g8b | 8 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_rgb.g8a | 78 | ||||
-rw-r--r-- | src/shaders/render/exa_wm_yuv_rgb.g8b | 30 |
5 files changed, 33 insertions, 103 deletions
diff --git a/src/i965_render.c b/src/i965_render.c index 3c99614..8e14d87 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -2862,7 +2862,8 @@ gen8_render_color_calc_state(VADriverContextP ctx) static void gen8_render_upload_constants(VADriverContextP ctx, - struct object_surface *obj_surface) + struct object_surface *obj_surface, + unsigned int flags) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; @@ -2873,6 +2874,8 @@ gen8_render_upload_constants(VADriverContextP ctx, 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; + float *yuv_to_rgb; + unsigned int color_flag; dri_bo_map(render_state->dynamic_state.bo, 1); assert(render_state->dynamic_state.bo->virtual); @@ -2907,6 +2910,15 @@ gen8_render_upload_constants(VADriverContextP ctx, *color_balance_base++ = cos(hue) * contrast * saturation; *color_balance_base++ = sin(hue) * contrast * saturation; + color_flag = flags & VA_SRC_COLOR_MASK; + yuv_to_rgb = (float *)constant_buffer + 8; + if (color_flag == VA_SRC_BT709) + memcpy(yuv_to_rgb, yuv_to_rgb_bt709, sizeof(yuv_to_rgb_bt709)); + else if (color_flag == VA_SRC_SMPTE_240) + memcpy(yuv_to_rgb, yuv_to_rgb_smpte_240, sizeof(yuv_to_rgb_smpte_240)); + else + memcpy(yuv_to_rgb, yuv_to_rgb_bt601, sizeof(yuv_to_rgb_bt601)); + dri_bo_unmap(render_state->dynamic_state.bo); } @@ -2925,7 +2937,7 @@ gen8_render_setup_states( gen8_render_cc_viewport(ctx); gen8_render_color_calc_state(ctx); gen8_render_blend_state(ctx); - gen8_render_upload_constants(ctx, obj_surface); + gen8_render_upload_constants(ctx, obj_surface, flags); i965_render_upload_vertex(ctx, obj_surface, src_rect, dst_rect); } @@ -4024,7 +4036,7 @@ gen8_emit_wm_state(VADriverContextP ctx, int kernel) BEGIN_BATCH(batch, 11); OUT_BATCH(batch, GEN6_3DSTATE_CONSTANT_PS | (11 - 2)); - OUT_BATCH(batch, 1); + OUT_BATCH(batch, URB_CS_ENTRY_SIZE); OUT_BATCH(batch, 0); /*DW3-4. Constant buffer 0 */ OUT_BATCH(batch, render_state->curbe_offset); diff --git a/src/shaders/render/exa_wm_src_affine.g8a b/src/shaders/render/exa_wm_src_affine.g8a index 1d4efcc..7927c3b 100644 --- a/src/shaders/render/exa_wm_src_affine.g8a +++ b/src/shaders/render/exa_wm_src_affine.g8a @@ -35,8 +35,6 @@ define(`vh', `g69') define(`bl', `g2.0<8,8,1>F') define(`bh', `g4.0<8,8,1>F') -define(`a0_a_x',`g7.0<0,1,0>F') -define(`a0_a_y',`g7.16<0,1,0>F') /* U */ pln (8) ul<1>F a0_a_x bl { align1 }; /* pixel 0-7 */ diff --git a/src/shaders/render/exa_wm_src_affine.g8b b/src/shaders/render/exa_wm_src_affine.g8b index 0273257..f5f9eca 100644 --- a/src/shaders/render/exa_wm_src_affine.g8b +++ b/src/shaders/render/exa_wm_src_affine.g8b @@ -1,4 +1,4 @@ - { 0x0060005a, 0x28403ae8, 0x3a0000e0, 0x008d0040 }, - { 0x0060005a, 0x28603ae8, 0x3a0000e0, 0x008d0080 }, - { 0x0060005a, 0x28803ae8, 0x3a0000f0, 0x008d0040 }, - { 0x0060005a, 0x28a03ae8, 0x3a0000f0, 0x008d0080 }, + { 0x0060005a, 0x28403ae8, 0x3a000140, 0x008d0040 }, + { 0x0060005a, 0x28603ae8, 0x3a000140, 0x008d0080 }, + { 0x0060005a, 0x28803ae8, 0x3a000150, 0x008d0040 }, + { 0x0060005a, 0x28a03ae8, 0x3a000150, 0x008d0080 }, diff --git a/src/shaders/render/exa_wm_yuv_rgb.g8a b/src/shaders/render/exa_wm_yuv_rgb.g8a index 62669c8..9da53c8 100644 --- a/src/shaders/render/exa_wm_yuv_rgb.g8a +++ b/src/shaders/render/exa_wm_yuv_rgb.g8a @@ -28,79 +28,5 @@ */ include(`exa_wm.g4i') - -define(`YCbCr_base', `src_sample_base') - -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', `mask_sample_g') -define(`Crn_01', `mask_sample_g_01') -define(`Crn_23', `mask_sample_g_23') - -define(`Yn', `mask_sample_r') -define(`Yn_01', `mask_sample_r_01') -define(`Yn_23', `mask_sample_r_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 (8) acc0<1>F Yn_01.0<8;8,1>F { align1 }; -mac.sat(8) src_sample_r_01<1>F Crn_01<8;8,1>F 1.596F { align1 }; -mov (8) acc0<1>F Yn_23.0<8;8,1>F { align1 }; -mac.sat(8) src_sample_r_23<1>F Crn_23<8;8,1>F 1.596F { align1 }; - - /* - * G = Crn * -0.813 + Cbn * -0.392 + Y - */ -mov (8) acc0<1>F Yn_01.0<8;8,1>F { align1 }; -mac (8) acc0<1>F Crn_01.0<8;8,1>F -0.813F { align1 }; -mac.sat(8) src_sample_g_01<1>F Cbn_01.0<8;8,1>F -0.392F { align1 }; -mov (8) acc0<1>F Yn_23.0<8;8,1>F { align1 }; -mac (8) acc0<1>F Crn_23.0<8;8,1>F -0.813F { align1 }; -mac.sat(8) src_sample_g_23<1>F Cbn_23.0<8;8,1>F -0.392F { align1 }; - - /* - * B = Cbn * 2.017 + Y - */ -mov (8) acc0<1>F Yn_01.0<8;8,1>F { align1 }; -mac.sat(8) src_sample_b_01<1>F Cbn_01.0<8;8,1>F 2.017F { align1 }; - -mov (8) acc0<1>F Yn_23.0<8;8,1>F { align1 }; -mac.sat(8) src_sample_b_23<1>F Cbn_23.0<8;8,1>F 2.017F { align1 }; - /* - * A = 1.0 - */ -mov (16) src_sample_a<1>F 1.0F { compr align1 }; +include(`exa_yuv_gen6.g4i') +include(`exa_yuv_rgb.gxa') diff --git a/src/shaders/render/exa_wm_yuv_rgb.g8b b/src/shaders/render/exa_wm_yuv_rgb.g8b index 8898a39..6b6b4d1 100644 --- a/src/shaders/render/exa_wm_yuv_rgb.g8b +++ b/src/shaders/render/exa_wm_yuv_rgb.g8b @@ -1,19 +1,13 @@ - { 0x00800040, 0x22c03ae8, 0x3e8d01c0, 0xbd808081 }, - { 0x00800041, 0x22c03ae8, 0x3e8d02c0, 0x3f94fdf4 }, - { 0x00800040, 0x23003ae8, 0x3e8d0240, 0xbf008084 }, - { 0x00800040, 0x23403ae8, 0x3e8d0200, 0xbf008084 }, - { 0x00600001, 0x24003ae0, 0x008d02c0, 0x00000000 }, - { 0x80600048, 0x21c03ae8, 0x3e8d0300, 0x3fcc49ba }, - { 0x00600001, 0x24003ae0, 0x008d02e0, 0x00000000 }, - { 0x80600048, 0x21e03ae8, 0x3e8d0320, 0x3fcc49ba }, - { 0x00600001, 0x24003ae0, 0x008d02c0, 0x00000000 }, - { 0x00600048, 0x24003ae0, 0x3e8d0300, 0xbf5020c5 }, - { 0x80600048, 0x22003ae8, 0x3e8d0340, 0xbec8b439 }, - { 0x00600001, 0x24003ae0, 0x008d02e0, 0x00000000 }, - { 0x00600048, 0x24003ae0, 0x3e8d0320, 0xbf5020c5 }, - { 0x80600048, 0x22203ae8, 0x3e8d0360, 0xbec8b439 }, - { 0x00600001, 0x24003ae0, 0x008d02c0, 0x00000000 }, - { 0x80600048, 0x22403ae8, 0x3e8d0340, 0x40011687 }, - { 0x00600001, 0x24003ae0, 0x008d02e0, 0x00000000 }, - { 0x80600048, 0x22603ae8, 0x3e8d0360, 0x40011687 }, + { 0x00800040, 0x22c03ae8, 0x3a8d01c0, 0x000000ec }, + { 0x00800040, 0x23003ae8, 0x3a8d0200, 0x000000fc }, + { 0x00800040, 0x23403ae8, 0x3a8d0240, 0x0000010c }, + { 0x00800041, 0x24003ae0, 0x3a8d02c0, 0x000000e0 }, + { 0x00800048, 0x24003ae0, 0x3a8d0300, 0x000000e4 }, + { 0x80800048, 0x21c03ae8, 0x3a8d0340, 0x000000e8 }, + { 0x00800041, 0x24003ae0, 0x3a8d02c0, 0x000000f0 }, + { 0x00800048, 0x24003ae0, 0x3a8d0300, 0x000000f4 }, + { 0x80800048, 0x22003ae8, 0x3a8d0340, 0x000000f8 }, + { 0x00800041, 0x24003ae0, 0x3a8d02c0, 0x00000100 }, + { 0x00800048, 0x24003ae0, 0x3a8d0300, 0x00000104 }, + { 0x80800048, 0x22403ae8, 0x3a8d0340, 0x00000108 }, { 0x00800001, 0x22803ee8, 0x38000000, 0x3f800000 }, |