hardware/intel/intel-driver
Revision | 2110b3a0bca6cecb42defd0b01d32530f5807b04 (tree) |
---|---|
Zeit | 2016-01-15 09:23:27 |
Autor | peng.chen <peng.c.chen@inte...> |
Commiter | Xiang, Haihao |
P010(10bits) enabling in vaCreateImage(), vaGetImage(), vaPutImage()
1, don't support the conversion from NV12 or other 8bits formats to P010
2, don't support scaling for P010->P010
v2:
add GEN arch limitation for vebox_processing_simple()
v1:
initial
Signed-off-by: peng.chen <peng.c.chen@intel.com>
@@ -42,6 +42,8 @@ | ||
42 | 42 | #include "i965_yuv_coefs.h" |
43 | 43 | #include "intel_media.h" |
44 | 44 | |
45 | +#include "gen75_picture_process.h" | |
46 | + | |
45 | 47 | #define SURFACE_STATE_PADDED_SIZE SURFACE_STATE_PADDED_SIZE_GEN8 |
46 | 48 | |
47 | 49 | #define SURFACE_STATE_OFFSET(index) (SURFACE_STATE_PADDED_SIZE * index) |
@@ -1460,6 +1462,11 @@ static void | ||
1460 | 1462 | gen8_post_processing_context_finalize(VADriverContextP ctx, |
1461 | 1463 | struct i965_post_processing_context *pp_context) |
1462 | 1464 | { |
1465 | + if(pp_context->vebox_proc_ctx){ | |
1466 | + gen75_vebox_context_destroy(ctx,pp_context->vebox_proc_ctx); | |
1467 | + pp_context->vebox_proc_ctx = NULL; | |
1468 | + } | |
1469 | + | |
1463 | 1470 | dri_bo_unreference(pp_context->surface_state_binding_table.bo); |
1464 | 1471 | pp_context->surface_state_binding_table.bo = NULL; |
1465 | 1472 |
@@ -319,6 +319,8 @@ i965_image_formats_map[I965_MAX_IMAGE_FORMATS + 1] = { | ||
319 | 319 | { VA_FOURCC_RGBX, VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000 } }, |
320 | 320 | { I965_SURFACETYPE_RGBA, |
321 | 321 | { VA_FOURCC_BGRX, VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff } }, |
322 | + { I965_SURFACETYPE_YUV, | |
323 | + { VA_FOURCC_P010, VA_LSB_FIRST, 24, } }, | |
322 | 324 | }; |
323 | 325 | |
324 | 326 | /* List of supported subpicture formats */ |
@@ -3768,6 +3770,14 @@ i965_CreateImage(VADriverContextP ctx, | ||
3768 | 3770 | image->offsets[0] = 0; |
3769 | 3771 | image->data_size = size * 2; |
3770 | 3772 | break; |
3773 | + case VA_FOURCC_P010: | |
3774 | + image->num_planes = 2; | |
3775 | + image->pitches[0] = awidth * 2; | |
3776 | + image->offsets[0] = 0; | |
3777 | + image->pitches[1] = awidth * 2; | |
3778 | + image->offsets[1] = size * 2; | |
3779 | + image->data_size = size * 2 + 2 * size2 * 2; | |
3780 | + break; | |
3771 | 3781 | default: |
3772 | 3782 | goto error; |
3773 | 3783 | } |
@@ -41,6 +41,8 @@ | ||
41 | 41 | #include "i965_yuv_coefs.h" |
42 | 42 | #include "intel_media.h" |
43 | 43 | |
44 | +#include "gen75_picture_process.h" | |
45 | + | |
44 | 46 | extern VAStatus |
45 | 47 | vpp_surface_convert(VADriverContextP ctx, |
46 | 48 | struct object_surface *src_obj_surf, |
@@ -5296,6 +5298,183 @@ i965_image_pl1_processing(VADriverContextP ctx, | ||
5296 | 5298 | return vaStatus; |
5297 | 5299 | } |
5298 | 5300 | |
5301 | +// it only support NV12 and P010 for vebox proc ctx | |
5302 | +static struct object_surface *derive_surface(VADriverContextP ctx, | |
5303 | + struct object_image *obj_image, | |
5304 | + struct object_surface *obj_surface) | |
5305 | +{ | |
5306 | + VAImage * const image = &obj_image->image; | |
5307 | + | |
5308 | + memset((void *)obj_surface, 0, sizeof(*obj_surface)); | |
5309 | + obj_surface->fourcc = image->format.fourcc; | |
5310 | + obj_surface->orig_width = image->width; | |
5311 | + obj_surface->orig_height = image->height; | |
5312 | + obj_surface->width = image->pitches[0]; | |
5313 | + obj_surface->height = image->height; | |
5314 | + obj_surface->y_cb_offset = image->offsets[1] / obj_surface->width; | |
5315 | + obj_surface->y_cr_offset = obj_surface->y_cb_offset; | |
5316 | + obj_surface->bo = obj_image->bo; | |
5317 | + obj_surface->subsampling = SUBSAMPLE_YUV420; | |
5318 | + | |
5319 | + return obj_surface; | |
5320 | +} | |
5321 | + | |
5322 | +static VAStatus | |
5323 | +vebox_processing_simple(VADriverContextP ctx, | |
5324 | + struct i965_post_processing_context *pp_context, | |
5325 | + struct object_surface *src_obj_surface, | |
5326 | + struct object_surface *dst_obj_surface, | |
5327 | + const VARectangle *rect) | |
5328 | +{ | |
5329 | + struct i965_driver_data *i965 = i965_driver_data(ctx); | |
5330 | + VAProcPipelineParameterBuffer pipeline_param; | |
5331 | + VAStatus status = VA_STATUS_ERROR_UNIMPLEMENTED; | |
5332 | + | |
5333 | + if(pp_context->vebox_proc_ctx == NULL) { | |
5334 | + pp_context->vebox_proc_ctx = gen75_vebox_context_init(ctx); | |
5335 | + } | |
5336 | + | |
5337 | + memset((void *)&pipeline_param, 0, sizeof(pipeline_param)); | |
5338 | + pipeline_param.surface_region = rect; | |
5339 | + pipeline_param.output_region = rect; | |
5340 | + pipeline_param.filter_flags = 0; | |
5341 | + pipeline_param.num_filters = 0; | |
5342 | + | |
5343 | + pp_context->vebox_proc_ctx->pipeline_param = &pipeline_param; | |
5344 | + pp_context->vebox_proc_ctx->surface_input_object = src_obj_surface; | |
5345 | + pp_context->vebox_proc_ctx->surface_output_object = dst_obj_surface; | |
5346 | + | |
5347 | + if (IS_GEN9(i965->intel.device_info)) | |
5348 | + status = gen9_vebox_process_picture(ctx, pp_context->vebox_proc_ctx); | |
5349 | + | |
5350 | + return status; | |
5351 | +} | |
5352 | + | |
5353 | +static VAStatus | |
5354 | +i965_image_p010_processing(VADriverContextP ctx, | |
5355 | + const struct i965_surface *src_surface, | |
5356 | + const VARectangle *src_rect, | |
5357 | + struct i965_surface *dst_surface, | |
5358 | + const VARectangle *dst_rect) | |
5359 | +{ | |
5360 | +#define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \ | |
5361 | + (ctx)->intel.has_bsd) | |
5362 | + | |
5363 | + struct i965_driver_data *i965 = i965_driver_data(ctx); | |
5364 | + struct i965_post_processing_context *pp_context = i965->pp_context; | |
5365 | + struct object_surface *src_obj_surface = NULL, *dst_obj_surface = NULL; | |
5366 | + struct object_surface tmp_src_obj_surface, tmp_dst_obj_surface; | |
5367 | + struct object_surface *tmp_surface = NULL; | |
5368 | + VASurfaceID tmp_surface_id[3], out_surface_id = VA_INVALID_ID; | |
5369 | + int num_tmp_surfaces = 0; | |
5370 | + int fourcc = pp_get_surface_fourcc(ctx, dst_surface); | |
5371 | + VAStatus vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED; | |
5372 | + int vpp_post = 0; | |
5373 | + | |
5374 | + if(HAS_VPP_P010(i965)) { | |
5375 | + vpp_post = 0; | |
5376 | + switch(fourcc) { | |
5377 | + case VA_FOURCC_NV12: | |
5378 | + if(src_rect->x != dst_rect->x || | |
5379 | + src_rect->y != dst_rect->y || | |
5380 | + src_rect->width != dst_rect->width || | |
5381 | + src_rect->height != dst_rect->height) { | |
5382 | + vpp_post = 1; | |
5383 | + } | |
5384 | + break; | |
5385 | + case VA_FOURCC_P010: | |
5386 | + // don't support scaling while the fourcc of dst_surface is P010 | |
5387 | + if(src_rect->x != dst_rect->x || | |
5388 | + src_rect->y != dst_rect->y || | |
5389 | + src_rect->width != dst_rect->width || | |
5390 | + src_rect->height != dst_rect->height) { | |
5391 | + vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED; | |
5392 | + goto EXIT; | |
5393 | + } | |
5394 | + break; | |
5395 | + default: | |
5396 | + vpp_post = 1; | |
5397 | + break; | |
5398 | + } | |
5399 | + | |
5400 | + if(src_surface->type == I965_SURFACE_TYPE_IMAGE) { | |
5401 | + src_obj_surface = derive_surface(ctx, (struct object_image *)src_surface->base, | |
5402 | + &tmp_src_obj_surface); | |
5403 | + } | |
5404 | + else | |
5405 | + src_obj_surface = (struct object_surface *)src_surface->base; | |
5406 | + | |
5407 | + if(src_obj_surface == NULL) { | |
5408 | + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
5409 | + goto EXIT; | |
5410 | + } | |
5411 | + | |
5412 | + if(vpp_post == 1) { | |
5413 | + vaStatus = i965_CreateSurfaces(ctx, | |
5414 | + src_obj_surface->orig_width, | |
5415 | + src_obj_surface->orig_height, | |
5416 | + VA_RT_FORMAT_YUV420, | |
5417 | + 1, | |
5418 | + &out_surface_id); | |
5419 | + assert(vaStatus == VA_STATUS_SUCCESS); | |
5420 | + tmp_surface_id[num_tmp_surfaces++] = out_surface_id; | |
5421 | + tmp_surface = SURFACE(out_surface_id); | |
5422 | + assert(tmp_surface); | |
5423 | + i965_check_alloc_surface_bo(ctx, tmp_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420); | |
5424 | + } | |
5425 | + | |
5426 | + if(tmp_surface != NULL) | |
5427 | + dst_obj_surface = tmp_surface; | |
5428 | + else { | |
5429 | + if(dst_surface->type == I965_SURFACE_TYPE_IMAGE) { | |
5430 | + dst_obj_surface = derive_surface(ctx, (struct object_image *)dst_surface->base, | |
5431 | + &tmp_dst_obj_surface); | |
5432 | + } | |
5433 | + else | |
5434 | + dst_obj_surface = (struct object_surface *)dst_surface->base; | |
5435 | + } | |
5436 | + | |
5437 | + if(dst_obj_surface == NULL) { | |
5438 | + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; | |
5439 | + goto EXIT; | |
5440 | + } | |
5441 | + | |
5442 | + vaStatus = vebox_processing_simple(ctx, | |
5443 | + pp_context, | |
5444 | + src_obj_surface, | |
5445 | + dst_obj_surface, | |
5446 | + src_rect); | |
5447 | + if(vaStatus != VA_STATUS_SUCCESS) | |
5448 | + goto EXIT; | |
5449 | + | |
5450 | + if(vpp_post == 1) { | |
5451 | + struct i965_surface src_surface_new; | |
5452 | + | |
5453 | + if(tmp_surface != NULL){ | |
5454 | + src_surface_new.base = (struct object_base *)tmp_surface; | |
5455 | + src_surface_new.type = I965_SURFACE_TYPE_SURFACE; | |
5456 | + src_surface_new.flags = I965_SURFACE_FLAG_FRAME; | |
5457 | + } | |
5458 | + else | |
5459 | + memcpy((void *)&src_surface_new, (void *)src_surface, sizeof(src_surface_new)); | |
5460 | + | |
5461 | + vaStatus = i965_image_pl2_processing(ctx, | |
5462 | + &src_surface_new, | |
5463 | + src_rect, | |
5464 | + dst_surface, | |
5465 | + dst_rect); | |
5466 | + } | |
5467 | + } | |
5468 | + | |
5469 | +EXIT: | |
5470 | + if(num_tmp_surfaces) | |
5471 | + i965_DestroySurfaces(ctx, | |
5472 | + tmp_surface_id, | |
5473 | + num_tmp_surfaces); | |
5474 | + | |
5475 | + return vaStatus; | |
5476 | +} | |
5477 | + | |
5299 | 5478 | VAStatus |
5300 | 5479 | i965_image_processing(VADriverContextP ctx, |
5301 | 5480 | const struct i965_surface *src_surface, |
@@ -5353,6 +5532,13 @@ i965_image_processing(VADriverContextP ctx, | ||
5353 | 5532 | dst_surface, |
5354 | 5533 | dst_rect); |
5355 | 5534 | break; |
5535 | + case VA_FOURCC_P010: | |
5536 | + status = i965_image_p010_processing(ctx, | |
5537 | + src_surface, | |
5538 | + src_rect, | |
5539 | + dst_surface, | |
5540 | + dst_rect); | |
5541 | + break; | |
5356 | 5542 | default: |
5357 | 5543 | status = VA_STATUS_ERROR_UNIMPLEMENTED; |
5358 | 5544 | break; |
@@ -528,6 +528,8 @@ struct i965_post_processing_context | ||
528 | 528 | unsigned int curbe_allocation_size : 16; |
529 | 529 | } vfe_gpu_state; |
530 | 530 | |
531 | + struct intel_vebox_context *vebox_proc_ctx; | |
532 | + | |
531 | 533 | struct pp_load_save_context pp_load_save_context; |
532 | 534 | struct pp_scaling_context pp_scaling_context; |
533 | 535 | struct pp_avs_context pp_avs_context; |