summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2013-03-12 15:12:07 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2013-03-15 15:45:28 +0800
commit4f21aad1165f3d0a2e5978e0524db735d19944b3 (patch)
tree11dd569ec215db14ead396c4b551ba0d507e178f /src
parent54384c9585394db538b73eaf4227a59c7a452157 (diff)
downloadvaapi-intel-driver-4f21aad1165f3d0a2e5978e0524db735d19944b3.tar.gz
vaapi-intel-driver-4f21aad1165f3d0a2e5978e0524db735d19944b3.tar.bz2
vaapi-intel-driver-4f21aad1165f3d0a2e5978e0524db735d19944b3.zip
Decoder: check whether the surface for decoding output is valid
In addition, uses the corresponding surface object directly. Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/gen6_mfd.c38
-rw-r--r--src/gen75_mfd.c52
-rwxr-xr-xsrc/gen7_mfd.c41
-rw-r--r--src/i965_avc_bsd.c9
-rw-r--r--src/i965_avc_ildb.c5
-rw-r--r--src/i965_decoder_utils.c74
-rw-r--r--src/i965_decoder_utils.h5
-rw-r--r--src/i965_drv_video.h2
-rw-r--r--src/i965_media.c12
-rw-r--r--src/i965_media_h264.c4
-rw-r--r--src/i965_media_mpeg2.c4
11 files changed, 164 insertions, 82 deletions
diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c
index 7513dda..76a44f5 100755
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -250,9 +250,7 @@ gen6_mfd_surface_state(VADriverContextP ctx,
struct gen6_mfd_context *gen6_mfd_context)
{
struct intel_batchbuffer *batch = gen6_mfd_context->base.batch;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- struct object_surface *obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ struct object_surface *obj_surface = decode_state->render_object;
BEGIN_BCS_BATCH(batch, 6);
OUT_BCS_BATCH(batch, MFX_SURFACE_STATE | (6 - 2));
@@ -433,7 +431,6 @@ gen6_mfd_avc_img_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
if (decode_state->iq_matrix && decode_state->iq_matrix->buffer)
qm_present_flag = 1;
@@ -554,6 +551,7 @@ gen6_mfd_avc_qm_state(VADriverContextP ctx,
static void
gen6_mfd_avc_directmode_state(VADriverContextP ctx,
+ struct decode_state *decode_state,
VAPictureParameterBufferH264 *pic_param,
VASliceParameterBufferH264 *slice_param,
struct gen6_mfd_context *gen6_mfd_context)
@@ -600,9 +598,8 @@ gen6_mfd_avc_directmode_state(VADriverContextP ctx,
/* the current decoding frame/field */
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface && obj_surface->bo && obj_surface->private_data);
+ obj_surface = decode_state->render_object;
+ assert(obj_surface->bo && obj_surface->private_data);
gen6_avc_surface = obj_surface->private_data;
OUT_BCS_RELOC(batch, gen6_avc_surface->dmv_top,
@@ -901,7 +898,6 @@ gen6_mfd_avc_decode_init(VADriverContextP ctx,
{
VAPictureParameterBufferH264 *pic_param;
VASliceParameterBufferH264 *slice_param;
- VAPictureH264 *va_pic;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *bo;
@@ -935,10 +931,7 @@ gen6_mfd_avc_decode_init(VADriverContextP ctx,
width_in_mbs = ((pic_param->picture_width_in_mbs_minus1 + 1) & 0xff);
/* Current decoded picture */
- va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
obj_surface->flags |= (pic_param->pic_fields.bits.reference_pic_flag ? SURFACE_REFERENCED : 0);
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
@@ -1052,7 +1045,7 @@ gen6_mfd_avc_decode_picture(VADriverContextP ctx,
else
next_slice_param = next_slice_group_param;
- gen6_mfd_avc_directmode_state(ctx, pic_param, slice_param, gen6_mfd_context);
+ gen6_mfd_avc_directmode_state(ctx, decode_state, pic_param, slice_param, gen6_mfd_context);
gen6_mfd_avc_slice_state(ctx, pic_param, slice_param, next_slice_param, gen6_mfd_context);
gen6_mfd_avc_ref_idx_state(ctx, pic_param, slice_param, gen6_mfd_context);
gen6_mfd_avc_weightoffset_state(ctx, pic_param, slice_param, gen6_mfd_context);
@@ -1089,8 +1082,7 @@ gen6_mfd_mpeg2_decode_init(VADriverContextP ctx,
);
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
dri_bo_unreference(gen6_mfd_context->pre_deblocking_output.bo);
@@ -1428,8 +1420,7 @@ gen6_mfd_vc1_decode_init(VADriverContextP ctx,
gen6_mfd_context->reference_surface[i].surface_id = gen6_mfd_context->reference_surface[i % 2].surface_id;
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
gen6_mfd_init_vc1_surface(ctx, pic_param, obj_surface);
@@ -1833,7 +1824,7 @@ gen6_mfd_vc1_directmode_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
- obj_surface = SURFACE(decode_state->current_render_target);
+ obj_surface = decode_state->render_object;
if (obj_surface && obj_surface->private_data) {
dmv_write_buffer = ((struct gen6_vc1_surface *)(obj_surface->private_data))->dmv;
@@ -1987,9 +1978,15 @@ gen6_mfd_decode_picture(VADriverContextP ctx,
{
struct gen6_mfd_context *gen6_mfd_context = (struct gen6_mfd_context *)hw_context;
struct decode_state *decode_state = &codec_state->decode;
+ VAStatus vaStatus;
assert(gen6_mfd_context);
+ vaStatus = intel_decoder_sanity_check_input(ctx, profile, decode_state);
+
+ if (vaStatus != VA_STATUS_SUCCESS)
+ goto out;
+
switch (profile) {
case VAProfileMPEG2Simple:
case VAProfileMPEG2Main:
@@ -2013,7 +2010,10 @@ gen6_mfd_decode_picture(VADriverContextP ctx,
break;
}
- return VA_STATUS_SUCCESS;
+ vaStatus = VA_STATUS_SUCCESS;
+
+out:
+ return vaStatus;
}
static void
diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c
index 37ca17f..e1f2c80 100644
--- a/src/gen75_mfd.c
+++ b/src/gen75_mfd.c
@@ -255,8 +255,7 @@ gen75_mfd_surface_state(VADriverContextP ctx,
struct gen7_mfd_context *gen7_mfd_context)
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- struct object_surface *obj_surface = SURFACE(decode_state->current_render_target);
+ struct object_surface *obj_surface = decode_state->render_object;
unsigned int y_cb_offset;
unsigned int y_cr_offset;
@@ -673,7 +672,6 @@ gen75_mfd_avc_img_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
if (pic_param->CurrPic.flags & VA_PICTURE_H264_TOP_FIELD)
img_struct = 1;
@@ -794,6 +792,7 @@ gen75_mfd_avc_picid_state(VADriverContextP ctx,
static void
gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx,
+ struct decode_state *decode_state,
VAPictureParameterBufferH264 *pic_param,
VASliceParameterBufferH264 *slice_param,
struct gen7_mfd_context *gen7_mfd_context)
@@ -833,9 +832,8 @@ gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx,
/* the current decoding frame/field */
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface && obj_surface->bo && obj_surface->private_data);
+ obj_surface = decode_state->render_object;
+ assert(obj_surface->bo && obj_surface->private_data);
gen7_avc_surface = obj_surface->private_data;
OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
@@ -881,6 +879,7 @@ gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx,
static void
gen75_mfd_avc_directmode_state(VADriverContextP ctx,
+ struct decode_state *decode_state,
VAPictureParameterBufferH264 *pic_param,
VASliceParameterBufferH264 *slice_param,
struct gen7_mfd_context *gen7_mfd_context)
@@ -893,7 +892,7 @@ gen75_mfd_avc_directmode_state(VADriverContextP ctx,
int i, j;
if (IS_STEPPING_BPLUS(i965)) {
- gen75_mfd_avc_directmode_state_bplus(ctx, pic_param, slice_param,
+ gen75_mfd_avc_directmode_state_bplus(ctx, decode_state, pic_param, slice_param,
gen7_mfd_context);
return;
@@ -934,9 +933,8 @@ gen75_mfd_avc_directmode_state(VADriverContextP ctx,
/* the current decoding frame/field */
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface && obj_surface->bo && obj_surface->private_data);
+ obj_surface = decode_state->render_object;
+ assert(obj_surface->bo && obj_surface->private_data);
gen7_avc_surface = obj_surface->private_data;
OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
@@ -1189,7 +1187,6 @@ gen75_mfd_avc_decode_init(VADriverContextP ctx,
{
VAPictureParameterBufferH264 *pic_param;
VASliceParameterBufferH264 *slice_param;
- VAPictureH264 *va_pic;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *bo;
@@ -1226,10 +1223,7 @@ gen75_mfd_avc_decode_init(VADriverContextP ctx,
assert(height_in_mbs > 0 && height_in_mbs <= 256);
/* Current decoded picture */
- va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
obj_surface->flags |= (pic_param->pic_fields.bits.reference_pic_flag ? SURFACE_REFERENCED : 0);
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
@@ -1344,7 +1338,7 @@ gen75_mfd_avc_decode_picture(VADriverContextP ctx,
else
next_slice_param = next_slice_group_param;
- gen75_mfd_avc_directmode_state(ctx, pic_param, slice_param, gen7_mfd_context);
+ gen75_mfd_avc_directmode_state(ctx, decode_state, pic_param, slice_param, gen7_mfd_context);
gen75_mfd_avc_ref_idx_state(ctx, pic_param, slice_param, gen7_mfd_context);
gen75_mfd_avc_weightoffset_state(ctx, pic_param, slice_param, gen7_mfd_context);
gen75_mfd_avc_slice_state(ctx, pic_param, slice_param, next_slice_param, gen7_mfd_context);
@@ -1380,8 +1374,7 @@ gen75_mfd_mpeg2_decode_init(VADriverContextP ctx,
);
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
dri_bo_unreference(gen7_mfd_context->pre_deblocking_output.bo);
@@ -1732,8 +1725,7 @@ gen75_mfd_vc1_decode_init(VADriverContextP ctx,
gen7_mfd_context->reference_surface[i].surface_id = gen7_mfd_context->reference_surface[i % 2].surface_id;
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
gen75_mfd_init_vc1_surface(ctx, pic_param, obj_surface);
@@ -2135,7 +2127,7 @@ gen75_mfd_vc1_directmode_state_bplus(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
- obj_surface = SURFACE(decode_state->current_render_target);
+ obj_surface = decode_state->render_object;
if (obj_surface && obj_surface->private_data) {
dmv_write_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
@@ -2190,7 +2182,7 @@ gen75_mfd_vc1_directmode_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
- obj_surface = SURFACE(decode_state->current_render_target);
+ obj_surface = decode_state->render_object;
if (obj_surface && obj_surface->private_data) {
dmv_write_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
@@ -2341,7 +2333,6 @@ gen75_mfd_jpeg_decode_init(VADriverContextP ctx,
struct decode_state *decode_state,
struct gen7_mfd_context *gen7_mfd_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
VAPictureParameterBufferJPEGBaseline *pic_param;
int subsampling = SUBSAMPLE_YUV420;
@@ -2386,8 +2377,8 @@ gen75_mfd_jpeg_decode_init(VADriverContextP ctx,
}
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
+
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('I','M','C','1'), subsampling);
dri_bo_unreference(gen7_mfd_context->pre_deblocking_output.bo);
@@ -3329,9 +3320,15 @@ gen75_mfd_decode_picture(VADriverContextP ctx,
{
struct gen7_mfd_context *gen7_mfd_context = (struct gen7_mfd_context *)hw_context;
struct decode_state *decode_state = &codec_state->decode;
+ VAStatus vaStatus;
assert(gen7_mfd_context);
+ vaStatus = intel_decoder_sanity_check_input(ctx, profile, decode_state);
+
+ if (vaStatus != VA_STATUS_SUCCESS)
+ goto out;
+
gen7_mfd_context->wa_mpeg2_slice_vertical_position = -1;
switch (profile) {
@@ -3361,7 +3358,10 @@ gen75_mfd_decode_picture(VADriverContextP ctx,
break;
}
- return VA_STATUS_SUCCESS;
+ vaStatus = VA_STATUS_SUCCESS;
+
+out:
+ return vaStatus;
}
static void
diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c
index 477ca32..84f917f 100755
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -251,8 +251,7 @@ gen7_mfd_surface_state(VADriverContextP ctx,
struct gen7_mfd_context *gen7_mfd_context)
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- struct object_surface *obj_surface = SURFACE(decode_state->current_render_target);
+ struct object_surface *obj_surface = decode_state->render_object;
unsigned int y_cb_offset;
unsigned int y_cr_offset;
@@ -463,7 +462,6 @@ gen7_mfd_avc_img_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
if (pic_param->CurrPic.flags & VA_PICTURE_H264_TOP_FIELD)
img_struct = 1;
@@ -562,6 +560,7 @@ gen7_mfd_avc_qm_state(VADriverContextP ctx,
static void
gen7_mfd_avc_directmode_state(VADriverContextP ctx,
+ struct decode_state *decode_state,
VAPictureParameterBufferH264 *pic_param,
VASliceParameterBufferH264 *slice_param,
struct gen7_mfd_context *gen7_mfd_context)
@@ -608,9 +607,8 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
/* the current decoding frame/field */
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface && obj_surface->bo && obj_surface->private_data);
+ obj_surface = decode_state->render_object;
+ assert(obj_surface->bo && obj_surface->private_data);
gen7_avc_surface = obj_surface->private_data;
OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
@@ -867,7 +865,6 @@ gen7_mfd_avc_decode_init(VADriverContextP ctx,
{
VAPictureParameterBufferH264 *pic_param;
VASliceParameterBufferH264 *slice_param;
- VAPictureH264 *va_pic;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *bo;
@@ -904,10 +901,7 @@ gen7_mfd_avc_decode_init(VADriverContextP ctx,
assert(height_in_mbs > 0 && height_in_mbs <= 256);
/* Current decoded picture */
- va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
obj_surface->flags |= (pic_param->pic_fields.bits.reference_pic_flag ? SURFACE_REFERENCED : 0);
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
@@ -1021,7 +1015,7 @@ gen7_mfd_avc_decode_picture(VADriverContextP ctx,
else
next_slice_param = next_slice_group_param;
- gen7_mfd_avc_directmode_state(ctx, pic_param, slice_param, gen7_mfd_context);
+ gen7_mfd_avc_directmode_state(ctx, decode_state, pic_param, slice_param, gen7_mfd_context);
gen7_mfd_avc_ref_idx_state(ctx, pic_param, slice_param, gen7_mfd_context);
gen7_mfd_avc_weightoffset_state(ctx, pic_param, slice_param, gen7_mfd_context);
gen7_mfd_avc_slice_state(ctx, pic_param, slice_param, next_slice_param, gen7_mfd_context);
@@ -1057,8 +1051,7 @@ gen7_mfd_mpeg2_decode_init(VADriverContextP ctx,
);
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
dri_bo_unreference(gen7_mfd_context->pre_deblocking_output.bo);
@@ -1414,8 +1407,7 @@ gen7_mfd_vc1_decode_init(VADriverContextP ctx,
gen7_mfd_context->reference_surface[i].surface_id = gen7_mfd_context->reference_surface[i % 2].surface_id;
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
gen7_mfd_init_vc1_surface(ctx, pic_param, obj_surface);
@@ -1818,7 +1810,7 @@ gen7_mfd_vc1_directmode_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
- obj_surface = SURFACE(decode_state->current_render_target);
+ obj_surface = decode_state->render_object;
if (obj_surface && obj_surface->private_data) {
dmv_write_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
@@ -1969,7 +1961,6 @@ gen7_mfd_jpeg_decode_init(VADriverContextP ctx,
struct decode_state *decode_state,
struct gen7_mfd_context *gen7_mfd_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
VAPictureParameterBufferJPEGBaseline *pic_param;
int subsampling = SUBSAMPLE_YUV420;
@@ -2014,8 +2005,7 @@ gen7_mfd_jpeg_decode_init(VADriverContextP ctx,
}
/* Current decoded picture */
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('I','M','C','1'), subsampling);
dri_bo_unreference(gen7_mfd_context->pre_deblocking_output.bo);
@@ -2758,9 +2748,15 @@ gen7_mfd_decode_picture(VADriverContextP ctx,
{
struct gen7_mfd_context *gen7_mfd_context = (struct gen7_mfd_context *)hw_context;
struct decode_state *decode_state = &codec_state->decode;
+ VAStatus vaStatus;
assert(gen7_mfd_context);
+ vaStatus = intel_decoder_sanity_check_input(ctx, profile, decode_state);
+
+ if (vaStatus != VA_STATUS_SUCCESS)
+ goto out;
+
gen7_mfd_context->wa_mpeg2_slice_vertical_position = -1;
switch (profile) {
@@ -2790,7 +2786,10 @@ gen7_mfd_decode_picture(VADriverContextP ctx,
break;
}
- return VA_STATUS_SUCCESS;
+ vaStatus = VA_STATUS_SUCCESS;
+
+out:
+ return vaStatus;
}
static void
diff --git a/src/i965_avc_bsd.c b/src/i965_avc_bsd.c
index 9990318..363160a 100644
--- a/src/i965_avc_bsd.c
+++ b/src/i965_avc_bsd.c
@@ -118,8 +118,6 @@ i965_avc_bsd_img_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
-
if (pic_param->CurrPic.flags & VA_PICTURE_H264_TOP_FIELD)
img_struct = 1;
else if (pic_param->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD)
@@ -376,6 +374,7 @@ i965_avc_bsd_slice_state(VADriverContextP ctx,
static void
i965_avc_bsd_buf_base_state(VADriverContextP ctx,
+ struct decode_state *decode_state,
VAPictureParameterBufferH264 *pic_param,
VASliceParameterBufferH264 *slice_param,
struct i965_h264_context *i965_h264_context)
@@ -459,9 +458,7 @@ i965_avc_bsd_buf_base_state(VADriverContextP ctx,
}
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
obj_surface->flags |= (pic_param->pic_fields.bits.reference_pic_flag ? SURFACE_REFERENCED : 0);
i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
@@ -998,7 +995,7 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, v
i965_h264_context->picture.i_flag = 0;
i965_avc_bsd_slice_state(ctx, pic_param, slice_param, i965_h264_context);
- i965_avc_bsd_buf_base_state(ctx, pic_param, slice_param, i965_h264_context);
+ i965_avc_bsd_buf_base_state(ctx, decode_state, pic_param, slice_param, i965_h264_context);
i965_avc_bsd_object(ctx, decode_state, pic_param, slice_param, j, i965_h264_context);
slice_param++;
}
diff --git a/src/i965_avc_ildb.c b/src/i965_avc_ildb.c
index a4277d7..8b93c51 100644
--- a/src/i965_avc_ildb.c
+++ b/src/i965_avc_ildb.c
@@ -130,7 +130,6 @@ i965_avc_ildb_surface_state(VADriverContextP ctx,
struct decode_state *decode_state,
struct i965_h264_context *i965_h264_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context;
struct i965_surface_state *ss;
struct object_surface *obj_surface;
@@ -142,9 +141,7 @@ i965_avc_ildb_surface_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
avc_ildb_context->surface[SURFACE_EDGE_CONTROL_DATA].s_bo = i965_h264_context->avc_ildb_data.bo;
dri_bo_reference(avc_ildb_context->surface[SURFACE_EDGE_CONTROL_DATA].s_bo);
diff --git a/src/i965_decoder_utils.c b/src/i965_decoder_utils.c
index ca0df3e..e253763 100644
--- a/src/i965_decoder_utils.c
+++ b/src/i965_decoder_utils.c
@@ -326,3 +326,77 @@ gen6_send_avc_ref_idx_state(
frame_store
);
}
+
+static VAStatus
+intel_decoder_check_avc_parameter(VADriverContextP ctx,
+ struct decode_state *decode_state)
+{
+ VAPictureParameterBufferH264 *pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
+
+ assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
+ assert(pic_param->CurrPic.picture_id != VA_INVALID_SURFACE);
+
+ if (pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID ||
+ pic_param->CurrPic.picture_id == VA_INVALID_SURFACE)
+ goto error;
+
+ assert(pic_param->CurrPic.picture_id == decode_state->current_render_target);
+
+ if (pic_param->CurrPic.picture_id != decode_state->current_render_target)
+ goto error;
+
+ return VA_STATUS_SUCCESS;
+
+error:
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+}
+
+VAStatus
+intel_decoder_sanity_check_input(VADriverContextP ctx,
+ VAProfile profile,
+ struct decode_state *decode_state)
+{
+ struct i965_driver_data *i965 = i965_driver_data(ctx);
+ struct object_surface *obj_surface;
+ VAStatus vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
+
+ if (decode_state->current_render_target == VA_INVALID_SURFACE)
+ goto out;
+
+ obj_surface = SURFACE(decode_state->current_render_target);
+
+ if (!obj_surface)
+ goto out;
+
+ decode_state->render_object = obj_surface;
+
+ switch (profile) {
+ case VAProfileMPEG2Simple:
+ case VAProfileMPEG2Main:
+ vaStatus = VA_STATUS_SUCCESS;
+ break;
+
+ case VAProfileH264Baseline:
+ case VAProfileH264Main:
+ case VAProfileH264High:
+ vaStatus = intel_decoder_check_avc_parameter(ctx, decode_state);
+ break;
+
+ case VAProfileVC1Simple:
+ case VAProfileVC1Main:
+ case VAProfileVC1Advanced:
+ vaStatus = VA_STATUS_SUCCESS;
+ break;
+
+ case VAProfileJPEGBaseline:
+ vaStatus = VA_STATUS_SUCCESS;
+ break;
+
+ default:
+ vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+out:
+ return vaStatus;
+}
diff --git a/src/i965_decoder_utils.h b/src/i965_decoder_utils.h
index 0d86523..b5025eb 100644
--- a/src/i965_decoder_utils.h
+++ b/src/i965_decoder_utils.h
@@ -75,4 +75,9 @@ gen6_send_avc_ref_idx_state(
const GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES]
);
+VAStatus
+intel_decoder_sanity_check_input(VADriverContextP ctx,
+ VAProfile profile,
+ struct decode_state *decode_state);
+
#endif /* I965_DECODER_UTILS_H */
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 29ecade..0b8ff0e 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -106,6 +106,8 @@ struct decode_state
int max_slice_datas;
int num_slice_params;
int num_slice_datas;
+
+ struct object_surface *render_object;
};
struct encode_state
diff --git a/src/i965_media.c b/src/i965_media.c
index d0d0a24..32cdf56 100644
--- a/src/i965_media.c
+++ b/src/i965_media.c
@@ -40,6 +40,7 @@
#include "i965_media.h"
#include "i965_media_mpeg2.h"
#include "i965_media_h264.h"
+#include "i965_decoder_utils.h"
static void
i965_media_pipeline_select(VADriverContextP ctx, struct i965_media_context *media_context)
@@ -276,6 +277,12 @@ i965_media_decode_picture(VADriverContextP ctx,
{
struct i965_media_context *media_context = (struct i965_media_context *)hw_context;
struct decode_state *decode_state = &codec_state->decode;
+ VAStatus vaStatus;
+
+ vaStatus = intel_decoder_sanity_check_input(ctx, profile, decode_state);
+
+ if (vaStatus != VA_STATUS_SUCCESS)
+ goto out;
i965_media_decode_init(ctx, profile, decode_state, media_context);
assert(media_context->media_states_setup);
@@ -283,7 +290,10 @@ i965_media_decode_picture(VADriverContextP ctx,
i965_media_pipeline_setup(ctx, decode_state, media_context);
intel_batchbuffer_flush(hw_context->batch);
- return VA_STATUS_SUCCESS;
+ vaStatus = VA_STATUS_SUCCESS;
+
+out:
+ return vaStatus;
}
static void
diff --git a/src/i965_media_h264.c b/src/i965_media_h264.c
index b31ef0b..7e3b128 100644
--- a/src/i965_media_h264.c
+++ b/src/i965_media_h264.c
@@ -355,9 +355,7 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx,
/* Target Picture */
va_pic = &pic_param->CurrPic;
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
w = obj_surface->width;
h = obj_surface->height;
field_picture = !!(va_pic->flags & (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD));
diff --git a/src/i965_media_mpeg2.c b/src/i965_media_mpeg2.c
index 55e2109..e83b79f 100644
--- a/src/i965_media_mpeg2.c
+++ b/src/i965_media_mpeg2.c
@@ -601,8 +601,8 @@ i965_media_mpeg2_surfaces_setup(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer;
- obj_surface = SURFACE(decode_state->current_render_target);
- assert(obj_surface);
+ obj_surface = decode_state->render_object;
+
i965_media_mpeg2_surface_setup(ctx, 0, obj_surface, True,
param->picture_coding_extension.bits.picture_structure,
SURFACE_TARGET,