summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2013-11-13 14:18:20 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2013-11-13 15:36:39 +0800
commitb45f566afed8470fc505132494b4c9985cf755a9 (patch)
treea01a10ce154171bce0c446ecd2cc4f7b65375f1b
parentfdde376c8c59a076f09e08cf5dbc62fd5f031f6d (diff)
downloadlibva-intel-driver-b45f566afed8470fc505132494b4c9985cf755a9.tar.gz
libva-intel-driver-b45f566afed8470fc505132494b4c9985cf755a9.tar.bz2
libva-intel-driver-b45f566afed8470fc505132494b4c9985cf755a9.zip
VPP: remove some assert()
Instead check the input parameters and return corresponding error status if failed Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com> (cherry picked from commit 40fa7d9ede00e804f15df4b7b805c7345a925e17)
-rw-r--r--src/gen75_picture_process.c43
-rwxr-xr-xsrc/i965_post_processing.c37
2 files changed, 56 insertions, 24 deletions
diff --git a/src/gen75_picture_process.c b/src/gen75_picture_process.c
index e2344aa..fee378f 100644
--- a/src/gen75_picture_process.c
+++ b/src/gen75_picture_process.c
@@ -123,25 +123,39 @@ gen75_proc_picture(VADriverContextP ctx,
(VAProcPipelineParameterBuffer *)proc_st->pipeline_param->buffer;
struct object_surface *obj_dst_surf = NULL;
struct object_surface *obj_src_surf = NULL;
+ VAStatus status;
+
proc_ctx->pipeline_param = pipeline_param;
- assert(proc_st->current_render_target != VA_INVALID_SURFACE);
if (proc_st->current_render_target == VA_INVALID_SURFACE ||
- pipeline_param->surface == VA_INVALID_SURFACE)
+ pipeline_param->surface == VA_INVALID_SURFACE) {
+ status = VA_STATUS_ERROR_INVALID_SURFACE;
goto error;
+ }
obj_dst_surf = SURFACE(proc_st->current_render_target);
- if (!obj_dst_surf)
+ if (!obj_dst_surf) {
+ status = VA_STATUS_ERROR_INVALID_SURFACE;
goto error;
+ }
obj_src_surf = SURFACE(proc_ctx->pipeline_param->surface);
- if (!obj_src_surf)
+ if (!obj_src_surf) {
+ status = VA_STATUS_ERROR_INVALID_SURFACE;
goto error;
+ }
- if (pipeline_param->num_filters && !pipeline_param->filters)
+ if (!obj_src_surf->bo) {
+ status = VA_STATUS_ERROR_INVALID_VALUE; /* The input surface is created without valid content */
goto error;
+ }
+
+ if (pipeline_param->num_filters && !pipeline_param->filters) {
+ status = VA_STATUS_ERROR_INVALID_PARAMETER;
+ goto error;
+ }
if (!obj_dst_surf->bo) {
unsigned int is_tiled = 0;
@@ -166,8 +180,10 @@ gen75_proc_picture(VADriverContextP ctx,
if (!obj_buf ||
!obj_buf->buffer_store ||
- !obj_buf->buffer_store->buffer)
+ !obj_buf->buffer_store->buffer) {
+ status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN;
goto error;
+ }
VAProcFilterParameterBuffer* filter =
(VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer;
@@ -177,12 +193,11 @@ gen75_proc_picture(VADriverContextP ctx,
filter->type == VAProcFilterColorBalance){
gen75_vpp_vebox(ctx, proc_ctx);
}else if(filter->type == VAProcFilterSharpening){
- assert(obj_src_surf->fourcc == VA_FOURCC('N','V','1','2') &&
- obj_dst_surf->fourcc == VA_FOURCC('N','V','1','2'));
-
if (obj_src_surf->fourcc != VA_FOURCC('N', 'V', '1', '2') ||
- obj_dst_surf->fourcc != VA_FOURCC('N', 'V', '1', '2'))
+ obj_dst_surf->fourcc != VA_FOURCC('N', 'V', '1', '2')) {
+ status = VA_STATUS_ERROR_UNIMPLEMENTED;
goto error;
+ }
gen75_vpp_gpe(ctx, proc_ctx);
}
@@ -191,12 +206,12 @@ gen75_proc_picture(VADriverContextP ctx,
for (i = 0; i < pipeline_param->num_filters; i++){
struct object_buffer * obj_buf = BUFFER(pipeline_param->filters[i]);
- assert(obj_buf && obj_buf->buffer_store && obj_buf->buffer_store->buffer);
-
if (!obj_buf ||
!obj_buf->buffer_store ||
- !obj_buf->buffer_store->buffer)
+ !obj_buf->buffer_store->buffer) {
+ status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN;
goto error;
+ }
VAProcFilterParameterBuffer* filter =
(VAProcFilterParameterBuffer*)obj_buf-> buffer_store->buffer;
@@ -214,7 +229,7 @@ gen75_proc_picture(VADriverContextP ctx,
return VA_STATUS_SUCCESS;
error:
- return VA_STATUS_ERROR_INVALID_PARAMETER;
+ return status;
}
static void
diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c
index eeff289..9ab6fde 100755
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -5483,14 +5483,28 @@ i965_proc_picture(VADriverContextP ctx,
unsigned int tiling = 0, swizzle = 0;
int in_width, in_height;
- assert(pipeline_param->surface != VA_INVALID_ID);
- assert(proc_state->current_render_target != VA_INVALID_ID);
+ if (pipeline_param->surface == VA_INVALID_ID ||
+ proc_state->current_render_target == VA_INVALID_ID) {
+ status = VA_STATUS_ERROR_INVALID_SURFACE;
+ goto error;
+ }
obj_surface = SURFACE(pipeline_param->surface);
- assert(obj_surface && obj_surface->bo);
- if (!obj_surface || !obj_surface->bo)
+ if (!obj_surface) {
+ status = VA_STATUS_ERROR_INVALID_SURFACE;
+ goto error;
+ }
+
+ if (!obj_surface->bo) {
+ status = VA_STATUS_ERROR_INVALID_VALUE; /* The input surface is created without valid content */
+ goto error;
+ }
+
+ if (pipeline_param->num_filters && !pipeline_param->filters) {
+ status = VA_STATUS_ERROR_INVALID_PARAMETER;
goto error;
+ }
in_width = obj_surface->orig_width;
in_height = obj_surface->orig_height;
@@ -5574,10 +5588,12 @@ i965_proc_picture(VADriverContextP ctx,
VAProcFilterType filter_type;
int kernel_index;
- assert(obj_buffer && obj_buffer->buffer_store);
-
- if (!obj_buffer || !obj_buffer->buffer_store)
+ if (!obj_buffer ||
+ !obj_buffer->buffer_store ||
+ !obj_buffer->buffer_store->buffer) {
+ status = VA_STATUS_ERROR_INVALID_FILTER_CHAIN;
goto error;
+ }
out_surface_id = VA_INVALID_ID;
filter_param = (VAProcFilterParameterBufferBase *)obj_buffer->buffer_store->buffer;
@@ -5617,10 +5633,11 @@ i965_proc_picture(VADriverContextP ctx,
proc_context->pp_context.pipeline_param = NULL;
obj_surface = SURFACE(proc_state->current_render_target);
- assert(obj_surface);
- if (!obj_surface)
+ if (!obj_surface) {
+ status = VA_STATUS_ERROR_INVALID_SURFACE;
goto error;
+ }
int csc_needed = 0;
if (obj_surface->fourcc && obj_surface->fourcc != VA_FOURCC('N','V','1','2')){
@@ -5694,7 +5711,7 @@ error:
tmp_surfaces,
num_tmp_surfaces);
- return VA_STATUS_ERROR_INVALID_PARAMETER;
+ return status;
}
static void