diff options
author | Zhao Yakui <yakui.zhao@intel.com> | 2013-11-22 13:39:34 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2013-12-03 12:09:38 +0800 |
commit | ef157465d77b8cb56fb8b1388e7bcf065b05b2ae (patch) | |
tree | 6f48b38be76662b4cf7b1b96e9791aa6bee48fc0 | |
parent | b4c9ca6eb7f2858cf8bd0d4799c2eb164f434781 (diff) | |
download | libva-intel-driver-ef157465d77b8cb56fb8b1388e7bcf065b05b2ae.tar.gz libva-intel-driver-ef157465d77b8cb56fb8b1388e7bcf065b05b2ae.tar.bz2 libva-intel-driver-ef157465d77b8cb56fb8b1388e7bcf065b05b2ae.zip |
Support the BT709 color standard for conversion from YUV to RGB
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 4c43ff9234a0a6f18744078d2e743cfa0cf8f34c)
-rw-r--r-- | src/i965_output_dri.c | 7 | ||||
-rw-r--r-- | src/i965_render.c | 22 | ||||
-rw-r--r-- | src/i965_render.h | 2 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/i965_output_dri.c b/src/i965_output_dri.c index de7be92..1467367 100644 --- a/src/i965_output_dri.c +++ b/src/i965_output_dri.c @@ -127,6 +127,7 @@ i965_put_surface_dri( bool new_region = false; uint32_t name; int i, ret; + unsigned int color_flag = 0; /* Currently don't support DRI1 */ if (!VA_CHECK_DRM_AUTH_TYPE(ctx, VA_DRM_AUTH_DRI2)) @@ -179,6 +180,12 @@ i965_put_surface_dri( assert(ret == 0); } + color_flag = flags & VA_SRC_COLOR_MASK; + if (color_flag == 0) + color_flag = VA_SRC_BT601; + + pp_flag = color_flag; + if ((flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC) pp_flag |= I965_PP_FLAG_AVS; diff --git a/src/i965_render.c b/src/i965_render.c index 5b1a1a5..5be8a96 100644 --- a/src/i965_render.c +++ b/src/i965_render.c @@ -317,6 +317,12 @@ static float yuv_to_rgb_bt601[3][4] = { {1.164, 2.017, 0, -0.50196,}, }; +static float yuv_to_rgb_bt709[3][4] = { +{1.164, 0, 1.793, -0.06275,}, +{1.164, -0.213, -0.533, -0.50196,}, +{1.164, 2.112, 0, -0.50196,}, +}; + static void i965_render_vs_unit(VADriverContextP ctx) { @@ -1066,7 +1072,8 @@ i965_render_upload_vertex( static void i965_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; @@ -1077,6 +1084,7 @@ i965_render_upload_constants(VADriverContextP ctx, 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->curbe.bo, 1); assert(render_state->curbe.bo->virtual); @@ -1107,8 +1115,12 @@ i965_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; - memcpy(yuv_to_rgb, yuv_to_rgb_bt601, sizeof(yuv_to_rgb_bt601)); + if (color_flag == VA_SRC_BT709) + memcpy(yuv_to_rgb, yuv_to_rgb_bt709, sizeof(yuv_to_rgb_bt709)); + else + memcpy(yuv_to_rgb, yuv_to_rgb_bt601, sizeof(yuv_to_rgb_bt601)); dri_bo_unmap(render_state->curbe.bo); } @@ -1155,7 +1167,7 @@ i965_surface_render_state_setup( i965_render_cc_viewport(ctx); i965_render_cc_unit(ctx); i965_render_upload_vertex(ctx, obj_surface, src_rect, dst_rect); - i965_render_upload_constants(ctx, obj_surface); + i965_render_upload_constants(ctx, obj_surface, flags); } static void @@ -1842,7 +1854,7 @@ gen6_render_setup_states( gen6_render_color_calc_state(ctx); gen6_render_blend_state(ctx); gen6_render_depth_stencil_state(ctx); - i965_render_upload_constants(ctx, obj_surface); + i965_render_upload_constants(ctx, obj_surface, flags); i965_render_upload_vertex(ctx, obj_surface, src_rect, dst_rect); } @@ -2436,7 +2448,7 @@ gen7_render_setup_states( gen7_render_color_calc_state(ctx); gen7_render_blend_state(ctx); gen7_render_depth_stencil_state(ctx); - i965_render_upload_constants(ctx, obj_surface); + i965_render_upload_constants(ctx, obj_surface, flags); i965_render_upload_vertex(ctx, obj_surface, src_rect, dst_rect); } diff --git a/src/i965_render.h b/src/i965_render.h index f09b535..1960ace 100644 --- a/src/i965_render.h +++ b/src/i965_render.h @@ -33,6 +33,8 @@ #define NUM_RENDER_KERNEL 3 +#define VA_SRC_COLOR_MASK 0x000000f0 + #include "i965_post_processing.h" struct i965_kernel; |