summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2013-03-08 14:57:08 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2013-03-15 15:45:28 +0800
commitb391d699b35e6f64f9a9bd82b02fdcf845a6adf3 (patch)
treed028d2c03d638b9ec980ace2e4938ea475dae5a0
parentbef3715ea52c696c39d6780f98343d81bf934104 (diff)
downloadlibva-intel-driver-b391d699b35e6f64f9a9bd82b02fdcf845a6adf3.tar.gz
libva-intel-driver-b391d699b35e6f64f9a9bd82b02fdcf845a6adf3.tar.bz2
libva-intel-driver-b391d699b35e6f64f9a9bd82b02fdcf845a6adf3.zip
Encoder: check whether the coded buffer and reconstructed surface are valid
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rw-r--r--src/i965_encoder.c97
1 files changed, 96 insertions, 1 deletions
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 8374548..0343b1a 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -134,6 +134,101 @@ intel_encoder_check_yuv_surface(VADriverContextP ctx,
}
static VAStatus
+intel_encoder_check_avc_parameter(VADriverContextP ctx,
+ struct encode_state *encode_state,
+ struct intel_encoder_context *encoder_context)
+{
+ struct i965_driver_data *i965 = i965_driver_data(ctx);
+ struct object_surface *obj_surface;
+ struct object_buffer *obj_buffer;
+ VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
+
+ assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
+
+ if (pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID)
+ goto error;
+
+ obj_surface = SURFACE(pic_param->CurrPic.picture_id);
+ assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
+
+ if (!obj_surface)
+ goto error;
+
+ obj_buffer = BUFFER(pic_param->coded_buf);
+ assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
+
+ if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
+ goto error;
+
+ return VA_STATUS_SUCCESS;
+
+error:
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+}
+
+static VAStatus
+intel_encoder_check_mpeg2_parameter(VADriverContextP ctx,
+ struct encode_state *encode_state,
+ struct intel_encoder_context *encoder_context)
+{
+ struct i965_driver_data *i965 = i965_driver_data(ctx);
+ VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
+ struct object_surface *obj_surface;
+ struct object_buffer *obj_buffer;
+
+ obj_surface = SURFACE(pic_param->reconstructed_picture);
+ assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
+
+ if (!obj_surface)
+ goto error;
+
+ obj_buffer = BUFFER(pic_param->coded_buf);
+ assert(obj_buffer && obj_buffer->buffer_store && obj_buffer->buffer_store->bo);
+
+ if (!obj_buffer || !obj_buffer->buffer_store || !obj_buffer->buffer_store->bo)
+ goto error;
+
+ return VA_STATUS_SUCCESS;
+
+error:
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+}
+
+static VAStatus
+intel_encoder_sanity_check_input(VADriverContextP ctx,
+ VAProfile profile,
+ struct encode_state *encode_state,
+ struct intel_encoder_context *encoder_context)
+{
+ VAStatus vaStatus;
+
+ switch (profile) {
+ case VAProfileH264Baseline:
+ case VAProfileH264Main:
+ case VAProfileH264High:
+ vaStatus = intel_encoder_check_avc_parameter(ctx, encode_state, encoder_context);
+ break;
+
+ case VAProfileMPEG2Simple:
+ case VAProfileMPEG2Main:
+ vaStatus = intel_encoder_check_mpeg2_parameter(ctx, encode_state, encoder_context);
+ break;
+
+ default:
+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ break;
+ }
+
+ if (vaStatus != VA_STATUS_SUCCESS)
+ goto out;
+
+ vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
+
+out:
+ return vaStatus;
+}
+
+static VAStatus
intel_encoder_end_picture(VADriverContextP ctx,
VAProfile profile,
union codec_state *codec_state,
@@ -143,7 +238,7 @@ intel_encoder_end_picture(VADriverContextP ctx,
struct encode_state *encode_state = &codec_state->encode;
VAStatus vaStatus;
- vaStatus = intel_encoder_check_yuv_surface(ctx, profile, encode_state, encoder_context);
+ vaStatus = intel_encoder_sanity_check_input(ctx, profile, encode_state, encoder_context);
if (vaStatus != VA_STATUS_SUCCESS)
return vaStatus;