summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2012-06-28 11:54:24 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2012-06-28 12:04:48 +0800
commit8ecb68e5c4eb1c5b94eac47c0d92057b2ec27c03 (patch)
treeaf08dd524d92e2114fd5944e9530e2ec5954217f
parentae06e5a93186dc8707bcfcd16d6edc8c6e9d7219 (diff)
downloadvaapi-intel-driver-8ecb68e5c4eb1c5b94eac47c0d92057b2ec27c03.tar.gz
vaapi-intel-driver-8ecb68e5c4eb1c5b94eac47c0d92057b2ec27c03.tar.bz2
vaapi-intel-driver-8ecb68e5c4eb1c5b94eac47c0d92057b2ec27c03.zip
color conversion between planar and packed formats on IVB
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rwxr-xr-xsrc/i965_post_processing.c175
1 files changed, 111 insertions, 64 deletions
diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c
index d0868f0..499d786 100755
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -553,12 +553,16 @@ static const uint32_t pp_nv12_dndi_gen7[][4] = {
static const uint32_t pp_nv12_dn_gen7[][4] = {
};
static const uint32_t pp_nv12_load_save_pa_gen7[][4] = {
+#include "shaders/post_processing/gen7/pl2_to_pa.g7b"
};
static const uint32_t pp_pl3_load_save_pa_gen7[][4] = {
+#include "shaders/post_processing/gen7/pl3_to_pa.g7b"
};
static const uint32_t pp_pa_load_save_nv12_gen7[][4] = {
+#include "shaders/post_processing/gen7/pa_to_pl2.g7b"
};
static const uint32_t pp_pa_load_save_pl3_gen7[][4] = {
+#include "shaders/post_processing/gen7/pa_to_pl3.g7b"
};
static VAStatus gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
@@ -697,7 +701,7 @@ static struct pp_module pp_modules_gen7[] = {
NULL,
},
- pp_plx_load_save_plx_initialize,
+ gen7_pp_plx_avs_initialize,
},
{
@@ -709,7 +713,7 @@ static struct pp_module pp_modules_gen7[] = {
NULL,
},
- pp_plx_load_save_plx_initialize,
+ gen7_pp_plx_avs_initialize,
},
{
@@ -721,7 +725,7 @@ static struct pp_module pp_modules_gen7[] = {
NULL,
},
- pp_plx_load_save_plx_initialize,
+ gen7_pp_plx_avs_initialize,
},
{
@@ -733,7 +737,7 @@ static struct pp_module pp_modules_gen7[] = {
NULL,
},
- pp_plx_load_save_plx_initialize,
+ gen7_pp_plx_avs_initialize,
},
};
@@ -1361,6 +1365,7 @@ gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_proc
const int V = (fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
fourcc == VA_FOURCC('I', 'M', 'C', '1')) ? 1 : 2;
int interleaved_uv = fourcc == VA_FOURCC('N', 'V', '1', '2');
+ int packed_yuv = (fourcc == VA_FOURCC('Y', 'U', 'Y', '2'));
if (surface->type == I965_SURFACE_TYPE_SURFACE) {
obj_surface = SURFACE(surface->id);
@@ -1370,6 +1375,15 @@ gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_proc
pitch[0] = obj_surface->width;
offset[0] = 0;
+ if (packed_yuv) {
+ if (is_target)
+ width[0] = obj_surface->orig_width * 2; /* surface format is R8, so double the width */
+ else
+ width[0] = obj_surface->orig_width; /* surface foramt is YCBCR, width is specified in units of pixels */
+
+ pitch[0] = obj_surface->width * 2;
+ }
+
width[1] = obj_surface->cb_cr_width;
height[1] = obj_surface->cb_cr_height;
pitch[1] = obj_surface->cb_cr_pitch;
@@ -1387,7 +1401,12 @@ gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_proc
pitch[0] = obj_image->image.pitches[0];
offset[0] = obj_image->image.offsets[0];
- if (interleaved_uv) {
+ if (packed_yuv) {
+ if (is_target)
+ width[0] = obj_image->image.width * 2; /* surface format is R8, so double the width */
+ else
+ width[0] = obj_image->image.width; /* surface foramt is YCBCR, width is specified in units of pixels */
+ } else if (interleaved_uv) {
width[1] = obj_image->image.width / 2;
height[1] = obj_image->image.height / 2;
pitch[1] = obj_image->image.pitches[1];
@@ -1411,52 +1430,67 @@ gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_proc
I965_SURFACEFORMAT_R8_SINT,
base_index, 1);
- if (interleaved_uv) {
- gen7_pp_set_surface_state(ctx, pp_context,
- bo, offset[1],
- width[1] / 2, height[1], pitch[1],
- I965_SURFACEFORMAT_R8G8_SINT,
- base_index + 1, 1);
- } else {
- gen7_pp_set_surface_state(ctx, pp_context,
- bo, offset[1],
- width[1] / 4, height[1], pitch[1],
- I965_SURFACEFORMAT_R8_SINT,
- base_index + 1, 1);
- gen7_pp_set_surface_state(ctx, pp_context,
- bo, offset[2],
- width[2] / 4, height[2], pitch[2],
- I965_SURFACEFORMAT_R8_SINT,
- base_index + 2, 1);
+ if (!packed_yuv) {
+ if (interleaved_uv) {
+ gen7_pp_set_surface_state(ctx, pp_context,
+ bo, offset[1],
+ width[1] / 2, height[1], pitch[1],
+ I965_SURFACEFORMAT_R8G8_SINT,
+ base_index + 1, 1);
+ } else {
+ gen7_pp_set_surface_state(ctx, pp_context,
+ bo, offset[1],
+ width[1] / 4, height[1], pitch[1],
+ I965_SURFACEFORMAT_R8_SINT,
+ base_index + 1, 1);
+ gen7_pp_set_surface_state(ctx, pp_context,
+ bo, offset[2],
+ width[2] / 4, height[2], pitch[2],
+ I965_SURFACEFORMAT_R8_SINT,
+ base_index + 2, 1);
+ }
}
} else {
+ int format0 = SURFACE_FORMAT_Y8_UNORM;
+
+ switch (fourcc) {
+ case VA_FOURCC('Y', 'U', 'Y', '2'):
+ format0 = SURFACE_FORMAT_YCRCB_NORMAL;
+ break;
+
+ default:
+ break;
+ }
+
gen7_pp_set_surface2_state(ctx, pp_context,
bo, offset[0],
width[0], height[0], pitch[0],
0, 0,
- SURFACE_FORMAT_Y8_UNORM, 0,
+ format0, 0,
base_index);
- if (interleaved_uv) {
- gen7_pp_set_surface2_state(ctx, pp_context,
- bo, offset[1],
- width[1], height[1], pitch[1],
- 0, 0,
- SURFACE_FORMAT_R8B8_UNORM, 0,
- base_index + 1);
- } else {
- gen7_pp_set_surface2_state(ctx, pp_context,
- bo, offset[1],
- width[1], height[1], pitch[1],
- 0, 0,
- SURFACE_FORMAT_R8_UNORM, 0,
- base_index + 1);
- gen7_pp_set_surface2_state(ctx, pp_context,
- bo, offset[2],
- width[2], height[2], pitch[2],
- 0, 0,
- SURFACE_FORMAT_R8_UNORM, 0,
- base_index + 2);
+ if (!packed_yuv) {
+ if (interleaved_uv) {
+ gen7_pp_set_surface2_state(ctx, pp_context,
+ bo, offset[1],
+ width[1], height[1], pitch[1],
+ 0, 0,
+ SURFACE_FORMAT_R8B8_UNORM, 0,
+ base_index + 1);
+ } else {
+ gen7_pp_set_surface2_state(ctx, pp_context,
+ bo, offset[1],
+ width[1], height[1], pitch[1],
+ 0, 0,
+ SURFACE_FORMAT_R8_UNORM, 0,
+ base_index + 1);
+ gen7_pp_set_surface2_state(ctx, pp_context,
+ bo, offset[2],
+ width[2], height[2], pitch[2],
+ 0, 0,
+ SURFACE_FORMAT_R8_UNORM, 0,
+ base_index + 2);
+ }
}
}
}
@@ -2158,6 +2192,20 @@ gen7_pp_avs_set_block_parameter(struct i965_post_processing_context *pp_context,
return 0;
}
+static void gen7_update_src_surface_uv_offset(VADriverContextP ctx,
+ struct i965_post_processing_context *pp_context,
+ const struct i965_surface *surface)
+{
+ struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
+ int fourcc = pp_get_surface_fourcc(ctx, surface);
+
+ if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
+ pp_static_parameter->grf2.di_destination_packed_y_component_offset = 0;
+ pp_static_parameter->grf2.di_destination_packed_u_component_offset = 1;
+ pp_static_parameter->grf2.di_destination_packed_v_component_offset = 3;
+ }
+}
+
static VAStatus
gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
const struct i965_surface *src_surface,
@@ -2343,6 +2391,8 @@ gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con
pp_static_parameter->grf5.sampler_load_vertical_frame_origin = -(float)pp_avs_context->dest_y / pp_avs_context->dest_h;
pp_static_parameter->grf6.sampler_load_horizontal_frame_origin = -(float)pp_avs_context->dest_x / dw;
+ gen7_update_src_surface_uv_offset(ctx, pp_context, dst_surface);
+
dst_surface->flags = src_surface->flags;
return VA_STATUS_SUCCESS;
@@ -3972,14 +4022,13 @@ i965_image_pl3_processing(VADriverContextP ctx,
PP_PL3_LOAD_SAVE_PL3,
NULL);
} else if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
- if (IS_GEN6(i965->intel.device_id))
- vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
- src_surface,
- src_rect,
- dst_surface,
- dst_rect,
- PP_PL3_LOAD_SAVE_PA,
- NULL);
+ vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
+ src_surface,
+ src_rect,
+ dst_surface,
+ dst_rect,
+ PP_PL3_LOAD_SAVE_PA,
+ NULL);
}
else {
assert(0);
@@ -4022,13 +4071,12 @@ i965_image_pl2_processing(VADriverContextP ctx,
PP_NV12_LOAD_SAVE_PL3,
NULL);
} else if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
- if (IS_GEN6(i965->intel.device_id))
- vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
- src_surface,
- src_rect,
- dst_surface,
- dst_rect,
- PP_NV12_LOAD_SAVE_PA,
+ vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
+ src_surface,
+ src_rect,
+ dst_surface,
+ dst_rect,
+ PP_NV12_LOAD_SAVE_PA,
NULL);
}
@@ -4111,12 +4159,11 @@ i965_image_processing(VADriverContextP ctx,
dst_rect);
break;
case VA_FOURCC('Y', 'U', 'Y', '2'):
- if (IS_GEN6(i965->intel.device_id))
- status = i965_image_pl1_processing(ctx,
- src_surface,
- src_rect,
- dst_surface,
- dst_rect);
+ status = i965_image_pl1_processing(ctx,
+ src_surface,
+ src_rect,
+ dst_surface,
+ dst_rect);
break;
default: