struct object_buffer *obj_buffer;
GenAvcSurface *gen6_avc_surface;
dri_bo *bo;
- VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
VAStatus vaStatus = VA_STATUS_SUCCESS;
int i, j, enable_avc_ildb = 0;
VAEncSliceParameterBufferH264 *slice_param;
/* Setup reference frames and direct mv buffers*/
for(i = 0; i < MAX_MFC_REFERENCE_SURFACES; i++) {
- if ( pPicParameter->ReferenceFrames[i].picture_id != VA_INVALID_ID ) {
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[i].picture_id);
- assert(obj_surface);
- if (obj_surface->bo != NULL) {
- mfc_context->reference_surfaces[i].bo = obj_surface->bo;
- dri_bo_reference(obj_surface->bo);
- }
+ obj_surface = encode_state->reference_objects[i];
+
+ if (obj_surface && obj_surface->bo) {
+ mfc_context->reference_surfaces[i].bo = obj_surface->bo;
+ dri_bo_reference(obj_surface->bo);
+
/* Check DMV buffer */
if ( obj_surface->private_data == NULL) {
int is_intra,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
/*Setup surfaces state*/
/* current picture for encoding */
if (!is_intra) {
/* reference 0 */
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[0].picture_id);
- assert(obj_surface);
- if ( obj_surface->bo != NULL)
+ obj_surface = encode_state->reference_objects[0];
+
+ if (obj_surface && obj_surface->bo)
gen6_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
/* reference 1 */
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[1].picture_id);
- assert(obj_surface);
- if ( obj_surface->bo != NULL )
+ obj_surface = encode_state->reference_objects[1];
+
+ if (obj_surface && obj_surface->bo)
gen6_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
}
int is_intra,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
/*Setup surfaces state*/
/* current picture for encoding */
if (!is_intra) {
/* reference 0 */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
- assert(obj_surface);
- if ( obj_surface->bo != NULL)
+ obj_surface = encode_state->reference_objects[0];
+ if (obj_surface->bo != NULL)
gen6_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
/* reference 1 */
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = encode_state->reference_objects[1];
if (obj_surface && obj_surface->bo != NULL)
gen6_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
}
struct encode_state *encode_state,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
struct object_surface *obj_surface;
struct object_buffer *obj_buffer;
- VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
struct i965_coded_buffer_segment *coded_buffer_segment;
VAStatus vaStatus = VA_STATUS_SUCCESS;
dri_bo *bo;
mfc_context->surface_state.h_pitch = obj_surface->height;
/* forward reference */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
+ obj_surface = encode_state->reference_objects[0];
if (obj_surface && obj_surface->bo) {
mfc_context->reference_surfaces[0].bo = obj_surface->bo;
mfc_context->reference_surfaces[0].bo = NULL;
/* backward reference */
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = encode_state->reference_objects[1];
if (obj_surface && obj_surface->bo) {
mfc_context->reference_surfaces[1].bo = obj_surface->bo;
int is_intra,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
/*Setup surfaces state*/
/* current picture for encoding */
if (!is_intra) {
/* reference 0 */
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[0].picture_id);
- assert(obj_surface);
- if ( obj_surface->bo != NULL)
+ obj_surface = encode_state->reference_objects[0];
+
+ if (obj_surface && obj_surface->bo)
gen75_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
/* reference 1 */
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[1].picture_id);
- assert(obj_surface);
- if ( obj_surface->bo != NULL )
+ obj_surface = encode_state->reference_objects[1];
+
+ if (obj_surface && obj_surface->bo)
gen75_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
}
int is_intra,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
/*Setup surfaces state*/
/* current picture for encoding */
if (!is_intra) {
/* reference 0 */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
- assert(obj_surface);
- if ( obj_surface->bo != NULL)
+ obj_surface = encode_state->reference_objects[0];
+ if (obj_surface->bo != NULL)
gen75_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
/* reference 1 */
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = encode_state->reference_objects[1];
if (obj_surface && obj_surface->bo != NULL)
gen75_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
}
struct encode_state *encode_state,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
struct object_surface *obj_surface;
struct object_buffer *obj_buffer;
- VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
struct i965_coded_buffer_segment *coded_buffer_segment;
VAStatus vaStatus = VA_STATUS_SUCCESS;
dri_bo *bo;
mfc_context->surface_state.h_pitch = obj_surface->height;
/* forward reference */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
+ obj_surface = encode_state->reference_objects[0];
if (obj_surface && obj_surface->bo) {
mfc_context->reference_surfaces[0].bo = obj_surface->bo;
mfc_context->reference_surfaces[0].bo = NULL;
/* backward reference */
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = encode_state->reference_objects[1];
if (obj_surface && obj_surface->bo) {
mfc_context->reference_surfaces[1].bo = obj_surface->bo;
int is_intra,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
/*Setup surfaces state*/
/* current picture for encoding */
if (!is_intra) {
/* reference 0 */
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[0].picture_id);
- assert(obj_surface);
- if ( obj_surface->bo != NULL)
+ obj_surface = encode_state->reference_objects[0];
+
+ if (obj_surface && obj_surface->bo)
gen7_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
/* reference 1 */
- obj_surface = SURFACE(pPicParameter->ReferenceFrames[1].picture_id);
- assert(obj_surface);
- if ( obj_surface->bo != NULL )
+ obj_surface = encode_state->reference_objects[1];
+
+ if (obj_surface && obj_surface->bo)
gen7_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
}
int is_intra,
struct intel_encoder_context *encoder_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
/*Setup surfaces state*/
/* current picture for encoding */
if (!is_intra) {
/* reference 0 */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
- assert(obj_surface);
- if ( obj_surface->bo != NULL)
+ obj_surface = encode_state->reference_objects[0];
+ if (obj_surface->bo != NULL)
gen7_vme_source_surface_state(ctx, 1, obj_surface, encoder_context);
/* reference 1 */
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = encode_state->reference_objects[1];
if (obj_surface && obj_surface->bo != NULL)
gen7_vme_source_surface_state(ctx, 2, obj_surface, encoder_context);
}
struct object_surface *input_yuv_object;
struct object_surface *reconstructed_object;
struct object_buffer *coded_buf_object;
+ struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/
};
struct proc_state
struct object_surface *obj_surface;
struct object_buffer *obj_buffer;
VAEncPictureParameterBufferH264 *pic_param = (VAEncPictureParameterBufferH264 *)encode_state->pic_param_ext->buffer;
+ int i;
assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
goto error;
encode_state->coded_buf_object = obj_buffer;
+
+ for (i = 0; i < 16; i++) {
+ if (pic_param->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID ||
+ pic_param->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE)
+ break;
+ else {
+ obj_surface = SURFACE(pic_param->ReferenceFrames[i].picture_id);
+ assert(obj_surface);
+
+ if (!obj_surface)
+ goto error;
+
+ if (obj_surface->bo)
+ encode_state->reference_objects[i] = obj_surface;
+ else
+ encode_state->reference_objects[i] = NULL; /* FIXME: Warning or Error ??? */
+ }
+ }
+
+ for ( ; i < 16; i++)
+ encode_state->reference_objects[i] = NULL;
return VA_STATUS_SUCCESS;
VAEncPictureParameterBufferMPEG2 *pic_param = (VAEncPictureParameterBufferMPEG2 *)encode_state->pic_param_ext->buffer;
struct object_surface *obj_surface;
struct object_buffer *obj_buffer;
-
+ int i = 0;
+
obj_surface = SURFACE(pic_param->reconstructed_picture);
assert(obj_surface); /* It is possible the store buffer isn't allocated yet */
encode_state->coded_buf_object = obj_buffer;
+ if (pic_param->picture_type == VAEncPictureTypeIntra) {
+ } else if (pic_param->picture_type == VAEncPictureTypePredictive) {
+ assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
+ obj_surface = SURFACE(pic_param->forward_reference_picture);
+ assert(obj_surface && obj_surface->bo);
+
+ if (!obj_surface || !obj_surface->bo)
+ goto error;
+
+ encode_state->reference_objects[i++] = obj_surface;
+ } else if (pic_param->picture_type == VAEncPictureTypeBidirectional) {
+ assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
+ obj_surface = SURFACE(pic_param->forward_reference_picture);
+ assert(obj_surface && obj_surface->bo);
+
+ if (!obj_surface || !obj_surface->bo)
+ goto error;
+
+ encode_state->reference_objects[i++] = obj_surface;
+
+ assert(pic_param->backward_reference_picture != VA_INVALID_SURFACE);
+ obj_surface = SURFACE(pic_param->backward_reference_picture);
+ assert(obj_surface && obj_surface->bo);
+
+ if (!obj_surface || !obj_surface->bo)
+ goto error;
+
+ encode_state->reference_objects[i++] = obj_surface;
+ } else
+ goto error;
+
+ for ( ; i < 16; i++)
+ encode_state->reference_objects[i] = NULL;
+
return VA_STATUS_SUCCESS;
error: