};
static void
-gen6_mfd_avc_frame_store_index(VADriverContextP ctx,
- VAPictureParameterBufferH264 *pic_param,
- struct gen6_mfd_context *gen6_mfd_context)
-{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- int i, j;
-
- assert(ARRAY_ELEMS(gen6_mfd_context->reference_surface) == ARRAY_ELEMS(pic_param->ReferenceFrames));
-
- for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) {
- int found = 0;
-
- if (gen6_mfd_context->reference_surface[i].surface_id == VA_INVALID_ID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[j];
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- if (gen6_mfd_context->reference_surface[i].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- struct object_surface *obj_surface = SURFACE(gen6_mfd_context->reference_surface[i].surface_id);
- obj_surface->flags &= ~SURFACE_REFERENCED;
-
- if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
- dri_bo_unreference(obj_surface->bo);
- obj_surface->bo = NULL;
- obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
- }
-
- if (obj_surface->free_private_data)
- obj_surface->free_private_data(&obj_surface->private_data);
-
- gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
- gen6_mfd_context->reference_surface[i].frame_store_id = -1;
- }
- }
-
- for (i = 0; i < ARRAY_ELEMS(pic_param->ReferenceFrames); i++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[i];
- int found = 0;
-
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(gen6_mfd_context->reference_surface); j++) {
- if (gen6_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (gen6_mfd_context->reference_surface[j].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- int frame_idx;
- struct object_surface *obj_surface = SURFACE(ref_pic->picture_id);
-
- assert(obj_surface);
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
-
- for (frame_idx = 0; frame_idx < ARRAY_ELEMS(gen6_mfd_context->reference_surface); frame_idx++) {
- for (j = 0; j < ARRAY_ELEMS(gen6_mfd_context->reference_surface); j++) {
- if (gen6_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (gen6_mfd_context->reference_surface[j].frame_store_id == frame_idx)
- break;
- }
-
- if (j == ARRAY_ELEMS(gen6_mfd_context->reference_surface))
- break;
- }
-
- assert(frame_idx < ARRAY_ELEMS(gen6_mfd_context->reference_surface));
-
- for (j = 0; j < ARRAY_ELEMS(gen6_mfd_context->reference_surface); j++) {
- if (gen6_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID) {
- gen6_mfd_context->reference_surface[j].surface_id = ref_pic->picture_id;
- gen6_mfd_context->reference_surface[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
- }
-
- /* sort */
- for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface) - 1; i++) {
- if (gen6_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
- gen6_mfd_context->reference_surface[i].frame_store_id == i)
- continue;
-
- for (j = i + 1; j < ARRAY_ELEMS(gen6_mfd_context->reference_surface); j++) {
- if (gen6_mfd_context->reference_surface[j].surface_id != VA_INVALID_ID &&
- gen6_mfd_context->reference_surface[j].frame_store_id == i) {
- VASurfaceID id = gen6_mfd_context->reference_surface[i].surface_id;
- int frame_idx = gen6_mfd_context->reference_surface[i].frame_store_id;
-
- gen6_mfd_context->reference_surface[i].surface_id = gen6_mfd_context->reference_surface[j].surface_id;
- gen6_mfd_context->reference_surface[i].frame_store_id = gen6_mfd_context->reference_surface[j].frame_store_id;
- gen6_mfd_context->reference_surface[j].surface_id = id;
- gen6_mfd_context->reference_surface[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
-}
-
-static void
gen6_mfd_init_avc_surface(VADriverContextP ctx,
VAPictureParameterBufferH264 *pic_param,
struct object_surface *obj_surface)
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);
int i;
BEGIN_BCS_BATCH(batch, 24);
for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) {
struct object_surface *obj_surface;
- if (gen6_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen6_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface && obj_surface->bo);
+ if (gen6_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen6_mfd_context->reference_surface[i].obj_surface &&
+ gen6_mfd_context->reference_surface[i].obj_surface->bo) {
+ obj_surface = gen6_mfd_context->reference_surface[i].obj_surface;
OUT_BCS_RELOC(batch, obj_surface->bo,
I915_GEM_DOMAIN_INSTRUCTION, 0,
VASliceParameterBufferH264 *slice_param,
struct gen6_mfd_context *gen6_mfd_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = gen6_mfd_context->base.batch;
struct object_surface *obj_surface;
GenAvcSurface *gen6_avc_surface;
/* reference surfaces 0..15 */
for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) {
- if (gen6_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen6_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface);
+ if (gen6_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen6_mfd_context->reference_surface[i].obj_surface &&
+ gen6_mfd_context->reference_surface[i].obj_surface->private_data) {
+
+ obj_surface = gen6_mfd_context->reference_surface[i].obj_surface;
gen6_avc_surface = obj_surface->private_data;
+ OUT_BCS_RELOC(batch, gen6_avc_surface->dmv_top,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
- if (gen6_avc_surface == NULL) {
- OUT_BCS_BATCH(batch, 0);
- OUT_BCS_BATCH(batch, 0);
- } else {
+ if (gen6_avc_surface->dmv_bottom_flag == 1)
+ OUT_BCS_RELOC(batch, gen6_avc_surface->dmv_bottom,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+ else
OUT_BCS_RELOC(batch, gen6_avc_surface->dmv_top,
I915_GEM_DOMAIN_INSTRUCTION, 0,
0);
-
- if (gen6_avc_surface->dmv_bottom_flag == 1)
- OUT_BCS_RELOC(batch, gen6_avc_surface->dmv_bottom,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- else
- OUT_BCS_RELOC(batch, gen6_avc_surface->dmv_top,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- }
} else {
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, 0);
for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) {
if (gen6_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
int found = 0;
+
+ assert(gen6_mfd_context->reference_surface[i].obj_surface != NULL);
+
for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
va_pic = &pic_param->ReferenceFrames[j];
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- gen6_mfd_avc_frame_store_index(ctx, pic_param, gen6_mfd_context);
+ intel_update_avc_frame_store_index(ctx, decode_state, pic_param, gen6_mfd_context->reference_surface);
width_in_mbs = ((pic_param->picture_width_in_mbs_minus1 + 1) & 0xff);
/* Current decoded picture */
VAPictureParameterBufferVC1 *pic_param;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- int i;
dri_bo *bo;
int width_in_mbs;
int picture_type;
width_in_mbs = ALIGN(pic_param->coded_width, 16) / 16;
picture_type = pic_param->picture_fields.bits.picture_type;
- /* reference picture */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
-
- if (obj_surface && obj_surface->bo)
- gen6_mfd_context->reference_surface[0].surface_id = pic_param->forward_reference_picture;
- else
- gen6_mfd_context->reference_surface[0].surface_id = VA_INVALID_ID;
-
- obj_surface = SURFACE(pic_param->backward_reference_picture);
-
- if (obj_surface && obj_surface->bo)
- gen6_mfd_context->reference_surface[1].surface_id = pic_param->backward_reference_picture;
- else
- gen6_mfd_context->reference_surface[1].surface_id = pic_param->forward_reference_picture;
-
- /* must do so !!! */
- for (i = 2; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++)
- gen6_mfd_context->reference_surface[i].surface_id = gen6_mfd_context->reference_surface[i % 2].surface_id;
+ intel_update_vc1_frame_store_index(ctx,
+ decode_state,
+ pic_param,
+ gen6_mfd_context->reference_surface);
/* Current decoded picture */
obj_surface = decode_state->render_object;
{
struct intel_batchbuffer *batch = gen6_mfd_context->base.batch;
VAPictureParameterBufferVC1 *pic_param;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
int alt_pquant_config = 0, alt_pquant_edge_mask = 0, alt_pq;
int dquant, dquantfrm, dqprofile, dqdbedge, dqsbedge, dqbilevel;
if (picture_type == GEN6_VC1_B_PICTURE) {
struct gen6_vc1_surface *gen6_vc1_surface = NULL;
- obj_surface = SURFACE(pic_param->backward_reference_picture);
- assert(obj_surface);
- gen6_vc1_surface = obj_surface->private_data;
+ obj_surface = decode_state->reference_objects[1];
+
+ if (obj_surface)
+ gen6_vc1_surface = obj_surface->private_data;
if (!gen6_vc1_surface ||
(va_to_gen6_vc1_pic_type[gen6_vc1_surface->picture_type] == GEN6_VC1_I_PICTURE ||
struct gen6_mfd_context *gen6_mfd_context)
{
struct intel_batchbuffer *batch = gen6_mfd_context->base.batch;
- VAPictureParameterBufferVC1 *pic_param;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *dmv_read_buffer = NULL, *dmv_write_buffer = NULL;
- assert(decode_state->pic_param && decode_state->pic_param->buffer);
- pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
-
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;
}
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = decode_state->reference_objects[1];
if (obj_surface && obj_surface->private_data) {
dmv_read_buffer = ((struct gen6_vc1_surface *)(obj_surface->private_data))->dmv;
for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) {
gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
gen6_mfd_context->reference_surface[i].frame_store_id = -1;
+ gen6_mfd_context->reference_surface[i].obj_surface = NULL;
}
gen6_mfd_context->wa_mpeg2_slice_vertical_position = -1;
};
static void
-gen75_mfd_avc_frame_store_index(VADriverContextP ctx,
- VAPictureParameterBufferH264 *pic_param,
- struct gen7_mfd_context *gen7_mfd_context)
-{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- int i, j;
-
- assert(ARRAY_ELEMS(gen7_mfd_context->reference_surface) == ARRAY_ELEMS(pic_param->ReferenceFrames));
-
- for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
- int found = 0;
-
- if (gen7_mfd_context->reference_surface[i].surface_id == VA_INVALID_ID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[j];
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- if (gen7_mfd_context->reference_surface[i].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- struct object_surface *obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- obj_surface->flags &= ~SURFACE_REFERENCED;
-
- if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
- dri_bo_unreference(obj_surface->bo);
- obj_surface->bo = NULL;
- obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
- }
-
- if (obj_surface->free_private_data)
- obj_surface->free_private_data(&obj_surface->private_data);
-
- gen7_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
- gen7_mfd_context->reference_surface[i].frame_store_id = -1;
- }
- }
-
- for (i = 0; i < ARRAY_ELEMS(pic_param->ReferenceFrames); i++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[i];
- int found = 0;
-
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (gen7_mfd_context->reference_surface[j].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- int frame_idx;
- struct object_surface *obj_surface = SURFACE(ref_pic->picture_id);
-
- assert(obj_surface);
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
-
- for (frame_idx = 0; frame_idx < ARRAY_ELEMS(gen7_mfd_context->reference_surface); frame_idx++) {
- for (j = 0; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (gen7_mfd_context->reference_surface[j].frame_store_id == frame_idx)
- break;
- }
-
- if (j == ARRAY_ELEMS(gen7_mfd_context->reference_surface))
- break;
- }
-
- assert(frame_idx < ARRAY_ELEMS(gen7_mfd_context->reference_surface));
-
- for (j = 0; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID) {
- gen7_mfd_context->reference_surface[j].surface_id = ref_pic->picture_id;
- gen7_mfd_context->reference_surface[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
- }
-
- /* sort */
- for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface) - 1; i++) {
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
- gen7_mfd_context->reference_surface[i].frame_store_id == i)
- continue;
-
- for (j = i + 1; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id != VA_INVALID_ID &&
- gen7_mfd_context->reference_surface[j].frame_store_id == i) {
- VASurfaceID id = gen7_mfd_context->reference_surface[i].surface_id;
- int frame_idx = gen7_mfd_context->reference_surface[i].frame_store_id;
-
- gen7_mfd_context->reference_surface[i].surface_id = gen7_mfd_context->reference_surface[j].surface_id;
- gen7_mfd_context->reference_surface[i].frame_store_id = gen7_mfd_context->reference_surface[j].frame_store_id;
- gen7_mfd_context->reference_surface[j].surface_id = id;
- gen7_mfd_context->reference_surface[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
-}
-
-static void
gen75_mfd_init_avc_surface(VADriverContextP ctx,
VAPictureParameterBufferH264 *pic_param,
struct object_surface *obj_surface)
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);
int i;
BEGIN_BCS_BATCH(batch, 61);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
struct object_surface *obj_surface;
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface && obj_surface->bo);
+ if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen7_mfd_context->reference_surface[i].obj_surface &&
+ gen7_mfd_context->reference_surface[i].obj_surface->bo) {
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
OUT_BCS_RELOC(batch, obj_surface->bo,
I915_GEM_DOMAIN_INSTRUCTION, 0,
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
struct object_surface *obj_surface;
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface && obj_surface->bo);
+ if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen7_mfd_context->reference_surface[i].obj_surface &&
+ gen7_mfd_context->reference_surface[i].obj_surface->bo) {
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
OUT_BCS_RELOC(batch, obj_surface->bo,
I915_GEM_DOMAIN_INSTRUCTION, 0,
VASliceParameterBufferH264 *slice_param,
struct gen7_mfd_context *gen7_mfd_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
struct object_surface *obj_surface;
GenAvcSurface *gen7_avc_surface;
/* reference surfaces 0..15 */
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface);
- gen7_avc_surface = obj_surface->private_data;
+ if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen7_mfd_context->reference_surface[i].obj_surface &&
+ gen7_mfd_context->reference_surface[i].obj_surface->private_data) {
- if (gen7_avc_surface == NULL) {
- OUT_BCS_BATCH(batch, 0);
- OUT_BCS_BATCH(batch, 0);
- } else {
- OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- OUT_BCS_BATCH(batch, 0);
- }
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
+ gen7_avc_surface = obj_surface->private_data;
+ OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+ OUT_BCS_BATCH(batch, 0);
} else {
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, 0);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
int found = 0;
+
+ assert(gen7_mfd_context->reference_surface[i].obj_surface != NULL);
+
for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
va_pic = &pic_param->ReferenceFrames[j];
/* reference surfaces 0..15 */
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface);
+ if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen7_mfd_context->reference_surface[i].obj_surface &&
+ gen7_mfd_context->reference_surface[i].obj_surface->private_data) {
+
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
gen7_avc_surface = obj_surface->private_data;
- if (gen7_avc_surface == NULL) {
- OUT_BCS_BATCH(batch, 0);
- OUT_BCS_BATCH(batch, 0);
- } else {
+ OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+
+ if (gen7_avc_surface->dmv_bottom_flag == 1)
+ OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_bottom,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+ else
OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
I915_GEM_DOMAIN_INSTRUCTION, 0,
0);
-
- if (gen7_avc_surface->dmv_bottom_flag == 1)
- OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_bottom,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- else
- OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- }
} else {
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, 0);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
int found = 0;
+
+ assert(gen7_mfd_context->reference_surface[i].obj_surface != NULL);
+
for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
va_pic = &pic_param->ReferenceFrames[j];
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- gen75_mfd_avc_frame_store_index(ctx, pic_param, gen7_mfd_context);
+ intel_update_avc_frame_store_index(ctx, decode_state, pic_param, gen7_mfd_context->reference_surface);
width_in_mbs = pic_param->picture_width_in_mbs_minus1 + 1;
height_in_mbs = pic_param->picture_height_in_mbs_minus1 + 1;
assert(width_in_mbs > 0 && width_in_mbs <= 256); /* 4K */
VAPictureParameterBufferVC1 *pic_param;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- int i;
dri_bo *bo;
int width_in_mbs;
int picture_type;
width_in_mbs = ALIGN(pic_param->coded_width, 16) / 16;
picture_type = pic_param->picture_fields.bits.picture_type;
- /* reference picture */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
-
- if (obj_surface && obj_surface->bo)
- gen7_mfd_context->reference_surface[0].surface_id = pic_param->forward_reference_picture;
- else
- gen7_mfd_context->reference_surface[0].surface_id = VA_INVALID_ID;
-
- obj_surface = SURFACE(pic_param->backward_reference_picture);
-
- if (obj_surface && obj_surface->bo)
- gen7_mfd_context->reference_surface[1].surface_id = pic_param->backward_reference_picture;
- else
- gen7_mfd_context->reference_surface[1].surface_id = pic_param->forward_reference_picture;
-
- /* must do so !!! */
- for (i = 2; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++)
- gen7_mfd_context->reference_surface[i].surface_id = gen7_mfd_context->reference_surface[i % 2].surface_id;
+ intel_update_vc1_frame_store_index(ctx,
+ decode_state,
+ pic_param,
+ gen7_mfd_context->reference_surface);
/* Current decoded picture */
obj_surface = decode_state->render_object;
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
VAPictureParameterBufferVC1 *pic_param;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
int alt_pquant_config = 0, alt_pquant_edge_mask = 0, alt_pq;
int dquant, dquantfrm, dqprofile, dqdbedge, dqsbedge, dqbilevel;
if (picture_type == GEN7_VC1_B_PICTURE) {
struct gen7_vc1_surface *gen7_vc1_surface = NULL;
- obj_surface = SURFACE(pic_param->backward_reference_picture);
- assert(obj_surface);
- gen7_vc1_surface = obj_surface->private_data;
+ obj_surface = decode_state->reference_objects[1];
+
+ if (obj_surface)
+ gen7_vc1_surface = obj_surface->private_data;
if (!gen7_vc1_surface ||
(va_to_gen7_vc1_pic_type[gen7_vc1_surface->picture_type] == GEN7_VC1_I_PICTURE ||
struct gen7_mfd_context *gen7_mfd_context)
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
- VAPictureParameterBufferVC1 *pic_param;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *dmv_read_buffer = NULL, *dmv_write_buffer = NULL;
- assert(decode_state->pic_param && decode_state->pic_param->buffer);
- pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
-
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;
}
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = decode_state->reference_objects[1];
if (obj_surface && obj_surface->private_data) {
dmv_read_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
struct gen7_mfd_context *gen7_mfd_context)
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
- VAPictureParameterBufferVC1 *pic_param;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *dmv_read_buffer = NULL, *dmv_write_buffer = NULL;
gen75_mfd_vc1_directmode_state_bplus(ctx, decode_state, gen7_mfd_context);
return;
}
- assert(decode_state->pic_param && decode_state->pic_param->buffer);
- pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
obj_surface = decode_state->render_object;
dmv_write_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
}
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = decode_state->reference_objects[1];
if (obj_surface && obj_surface->private_data) {
dmv_read_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
gen7_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
gen7_mfd_context->reference_surface[i].frame_store_id = -1;
+ gen7_mfd_context->reference_surface[i].obj_surface = NULL;
}
gen7_mfd_context->jpeg_wa_surface_id = VA_INVALID_SURFACE;
};
static void
-gen7_mfd_avc_frame_store_index(VADriverContextP ctx,
- VAPictureParameterBufferH264 *pic_param,
- struct gen7_mfd_context *gen7_mfd_context)
-{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- int i, j;
-
- assert(ARRAY_ELEMS(gen7_mfd_context->reference_surface) == ARRAY_ELEMS(pic_param->ReferenceFrames));
-
- for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
- int found = 0;
-
- if (gen7_mfd_context->reference_surface[i].surface_id == VA_INVALID_ID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[j];
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- if (gen7_mfd_context->reference_surface[i].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- struct object_surface *obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- obj_surface->flags &= ~SURFACE_REFERENCED;
-
- if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
- dri_bo_unreference(obj_surface->bo);
- obj_surface->bo = NULL;
- obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
- }
-
- if (obj_surface->free_private_data)
- obj_surface->free_private_data(&obj_surface->private_data);
-
- gen7_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
- gen7_mfd_context->reference_surface[i].frame_store_id = -1;
- }
- }
-
- for (i = 0; i < ARRAY_ELEMS(pic_param->ReferenceFrames); i++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[i];
- int found = 0;
-
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (gen7_mfd_context->reference_surface[j].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- int frame_idx;
- struct object_surface *obj_surface = SURFACE(ref_pic->picture_id);
-
- assert(obj_surface);
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
-
- for (frame_idx = 0; frame_idx < ARRAY_ELEMS(gen7_mfd_context->reference_surface); frame_idx++) {
- for (j = 0; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (gen7_mfd_context->reference_surface[j].frame_store_id == frame_idx)
- break;
- }
-
- if (j == ARRAY_ELEMS(gen7_mfd_context->reference_surface))
- break;
- }
-
- assert(frame_idx < ARRAY_ELEMS(gen7_mfd_context->reference_surface));
-
- for (j = 0; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id == VA_INVALID_ID) {
- gen7_mfd_context->reference_surface[j].surface_id = ref_pic->picture_id;
- gen7_mfd_context->reference_surface[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
- }
-
- /* sort */
- for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface) - 1; i++) {
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
- gen7_mfd_context->reference_surface[i].frame_store_id == i)
- continue;
-
- for (j = i + 1; j < ARRAY_ELEMS(gen7_mfd_context->reference_surface); j++) {
- if (gen7_mfd_context->reference_surface[j].surface_id != VA_INVALID_ID &&
- gen7_mfd_context->reference_surface[j].frame_store_id == i) {
- VASurfaceID id = gen7_mfd_context->reference_surface[i].surface_id;
- int frame_idx = gen7_mfd_context->reference_surface[i].frame_store_id;
-
- gen7_mfd_context->reference_surface[i].surface_id = gen7_mfd_context->reference_surface[j].surface_id;
- gen7_mfd_context->reference_surface[i].frame_store_id = gen7_mfd_context->reference_surface[j].frame_store_id;
- gen7_mfd_context->reference_surface[j].surface_id = id;
- gen7_mfd_context->reference_surface[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
-}
-
-static void
gen7_mfd_init_avc_surface(VADriverContextP ctx,
VAPictureParameterBufferH264 *pic_param,
struct object_surface *obj_surface)
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);
int i;
BEGIN_BCS_BATCH(batch, 24);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
struct object_surface *obj_surface;
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface && obj_surface->bo);
+ if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen7_mfd_context->reference_surface[i].obj_surface &&
+ gen7_mfd_context->reference_surface[i].obj_surface->bo) {
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
OUT_BCS_RELOC(batch, obj_surface->bo,
I915_GEM_DOMAIN_INSTRUCTION, 0,
VASliceParameterBufferH264 *slice_param,
struct gen7_mfd_context *gen7_mfd_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
struct object_surface *obj_surface;
GenAvcSurface *gen7_avc_surface;
/* reference surfaces 0..15 */
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
- if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
- obj_surface = SURFACE(gen7_mfd_context->reference_surface[i].surface_id);
- assert(obj_surface);
+ if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID &&
+ gen7_mfd_context->reference_surface[i].obj_surface &&
+ gen7_mfd_context->reference_surface[i].obj_surface->private_data) {
+
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
gen7_avc_surface = obj_surface->private_data;
+ OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
- if (gen7_avc_surface == NULL) {
- OUT_BCS_BATCH(batch, 0);
- OUT_BCS_BATCH(batch, 0);
- } else {
+ if (gen7_avc_surface->dmv_bottom_flag == 1)
+ OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_bottom,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+ else
OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
I915_GEM_DOMAIN_INSTRUCTION, 0,
0);
-
- if (gen7_avc_surface->dmv_bottom_flag == 1)
- OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_bottom,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- else
- OUT_BCS_RELOC(batch, gen7_avc_surface->dmv_top,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- }
} else {
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, 0);
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
if (gen7_mfd_context->reference_surface[i].surface_id != VA_INVALID_ID) {
int found = 0;
+
+ assert(gen7_mfd_context->reference_surface[i].obj_surface != NULL);
+
for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
va_pic = &pic_param->ReferenceFrames[j];
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- gen7_mfd_avc_frame_store_index(ctx, pic_param, gen7_mfd_context);
+ intel_update_avc_frame_store_index(ctx, decode_state, pic_param, gen7_mfd_context->reference_surface);
width_in_mbs = pic_param->picture_width_in_mbs_minus1 + 1;
height_in_mbs = pic_param->picture_height_in_mbs_minus1 + 1;
assert(width_in_mbs > 0 && width_in_mbs <= 256); /* 4K */
VAPictureParameterBufferVC1 *pic_param;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
- int i;
dri_bo *bo;
int width_in_mbs;
int picture_type;
width_in_mbs = ALIGN(pic_param->coded_width, 16) / 16;
picture_type = pic_param->picture_fields.bits.picture_type;
- /* reference picture */
- obj_surface = SURFACE(pic_param->forward_reference_picture);
-
- if (obj_surface && obj_surface->bo)
- gen7_mfd_context->reference_surface[0].surface_id = pic_param->forward_reference_picture;
- else
- gen7_mfd_context->reference_surface[0].surface_id = VA_INVALID_ID;
-
- obj_surface = SURFACE(pic_param->backward_reference_picture);
-
- if (obj_surface && obj_surface->bo)
- gen7_mfd_context->reference_surface[1].surface_id = pic_param->backward_reference_picture;
- else
- gen7_mfd_context->reference_surface[1].surface_id = pic_param->forward_reference_picture;
-
- /* must do so !!! */
- for (i = 2; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++)
- gen7_mfd_context->reference_surface[i].surface_id = gen7_mfd_context->reference_surface[i % 2].surface_id;
+ intel_update_vc1_frame_store_index(ctx,
+ decode_state,
+ pic_param,
+ gen7_mfd_context->reference_surface);
/* Current decoded picture */
obj_surface = decode_state->render_object;
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
VAPictureParameterBufferVC1 *pic_param;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
int alt_pquant_config = 0, alt_pquant_edge_mask = 0, alt_pq;
int dquant, dquantfrm, dqprofile, dqdbedge, dqsbedge, dqbilevel;
if (picture_type == GEN7_VC1_B_PICTURE) {
struct gen7_vc1_surface *gen7_vc1_surface = NULL;
- obj_surface = SURFACE(pic_param->backward_reference_picture);
- assert(obj_surface);
- gen7_vc1_surface = obj_surface->private_data;
+ obj_surface = decode_state->reference_objects[1];
+
+ if (obj_surface)
+ gen7_vc1_surface = obj_surface->private_data;
if (!gen7_vc1_surface ||
(va_to_gen7_vc1_pic_type[gen7_vc1_surface->picture_type] == GEN7_VC1_I_PICTURE ||
struct gen7_mfd_context *gen7_mfd_context)
{
struct intel_batchbuffer *batch = gen7_mfd_context->base.batch;
- VAPictureParameterBufferVC1 *pic_param;
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
dri_bo *dmv_read_buffer = NULL, *dmv_write_buffer = NULL;
- assert(decode_state->pic_param && decode_state->pic_param->buffer);
- pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
-
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;
}
- obj_surface = SURFACE(pic_param->backward_reference_picture);
+ obj_surface = decode_state->reference_objects[1];
if (obj_surface && obj_surface->private_data) {
dmv_read_buffer = ((struct gen7_vc1_surface *)(obj_surface->private_data))->dmv;
for (i = 0; i < ARRAY_ELEMS(gen7_mfd_context->reference_surface); i++) {
gen7_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID;
gen7_mfd_context->reference_surface[i].frame_store_id = -1;
+ gen7_mfd_context->reference_surface[i].obj_surface = NULL;
}
gen7_mfd_context->jpeg_wa_surface_id = VA_INVALID_SURFACE;
VASliceParameterBufferH264 *slice_param,
struct i965_h264_context *i965_h264_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct intel_batchbuffer *batch = i965_h264_context->batch;
struct i965_avc_bsd_context *i965_avc_bsd_context;
int i, j;
OUT_BCS_BATCH(batch, 0);
for (i = 0; i < ARRAY_ELEMS(i965_h264_context->fsid_list); i++) {
- if (i965_h264_context->fsid_list[i].surface_id != VA_INVALID_ID) {
+ if (i965_h264_context->fsid_list[i].surface_id != VA_INVALID_ID &&
+ i965_h264_context->fsid_list[i].obj_surface &&
+ i965_h264_context->fsid_list[i].obj_surface->private_data) {
int found = 0;
for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
va_pic = &pic_param->ReferenceFrames[j];
}
assert(found == 1);
-
- if (!(va_pic->flags & VA_PICTURE_H264_INVALID)) {
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
- avc_bsd_surface = obj_surface->private_data;
+ obj_surface = i965_h264_context->fsid_list[i].obj_surface;
+ avc_bsd_surface = obj_surface->private_data;
- if (avc_bsd_surface == NULL) {
- OUT_BCS_BATCH(batch, 0);
- OUT_BCS_BATCH(batch, 0);
- } else {
- OUT_BCS_RELOC(batch, avc_bsd_surface->dmv_top,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
-
- if (avc_bsd_surface->dmv_bottom_flag == 1)
- OUT_BCS_RELOC(batch, avc_bsd_surface->dmv_bottom,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- else
- OUT_BCS_RELOC(batch, avc_bsd_surface->dmv_top,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0);
- }
- }
+ OUT_BCS_RELOC(batch, avc_bsd_surface->dmv_top,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+
+ if (avc_bsd_surface->dmv_bottom_flag == 1)
+ OUT_BCS_RELOC(batch, avc_bsd_surface->dmv_bottom,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
+ else
+ OUT_BCS_RELOC(batch, avc_bsd_surface->dmv_top,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0);
} else {
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, 0);
i965_avc_bsd_object(ctx, decode_state, pic_param, NULL, 0, i965_h264_context);
}
-static void
-i965_avc_bsd_frame_store_index(VADriverContextP ctx,
- VAPictureParameterBufferH264 *pic_param,
- struct i965_h264_context *i965_h264_context)
-{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
- int i, j;
-
- assert(ARRAY_ELEMS(i965_h264_context->fsid_list) == ARRAY_ELEMS(pic_param->ReferenceFrames));
-
- for (i = 0; i < ARRAY_ELEMS(i965_h264_context->fsid_list); i++) {
- int found = 0;
-
- if (i965_h264_context->fsid_list[i].surface_id == VA_INVALID_ID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[j];
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- if (i965_h264_context->fsid_list[i].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- struct object_surface *obj_surface = SURFACE(i965_h264_context->fsid_list[i].surface_id);
- obj_surface->flags &= ~SURFACE_REFERENCED;
-
- if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
- dri_bo_unreference(obj_surface->bo);
- obj_surface->bo = NULL;
- obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
- }
-
- if (obj_surface->free_private_data)
- obj_surface->free_private_data(&obj_surface->private_data);
-
- i965_h264_context->fsid_list[i].surface_id = VA_INVALID_ID;
- i965_h264_context->fsid_list[i].frame_store_id = -1;
- }
- }
-
- for (i = 0; i < ARRAY_ELEMS(pic_param->ReferenceFrames); i++) {
- VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[i];
- int found = 0;
-
- if (ref_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
-
- for (j = 0; j < ARRAY_ELEMS(i965_h264_context->fsid_list); j++) {
- if (i965_h264_context->fsid_list[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (i965_h264_context->fsid_list[j].surface_id == ref_pic->picture_id) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- int frame_idx;
- struct object_surface *obj_surface = SURFACE(ref_pic->picture_id);
- assert(obj_surface);
- i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
-
- for (frame_idx = 0; frame_idx < ARRAY_ELEMS(i965_h264_context->fsid_list); frame_idx++) {
- for (j = 0; j < ARRAY_ELEMS(i965_h264_context->fsid_list); j++) {
- if (i965_h264_context->fsid_list[j].surface_id == VA_INVALID_ID)
- continue;
-
- if (i965_h264_context->fsid_list[j].frame_store_id == frame_idx)
- break;
- }
-
- if (j == ARRAY_ELEMS(i965_h264_context->fsid_list))
- break;
- }
-
- assert(frame_idx < ARRAY_ELEMS(i965_h264_context->fsid_list));
-
- for (j = 0; j < ARRAY_ELEMS(i965_h264_context->fsid_list); j++) {
- if (i965_h264_context->fsid_list[j].surface_id == VA_INVALID_ID) {
- i965_h264_context->fsid_list[j].surface_id = ref_pic->picture_id;
- i965_h264_context->fsid_list[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
- }
-
- for (i = 0; i < ARRAY_ELEMS(i965_h264_context->fsid_list) - 1; i++) {
- if (i965_h264_context->fsid_list[i].surface_id != VA_INVALID_ID &&
- i965_h264_context->fsid_list[i].frame_store_id == i)
- continue;
-
- for (j = i + 1; j < ARRAY_ELEMS(i965_h264_context->fsid_list); j++) {
- if (i965_h264_context->fsid_list[j].surface_id != VA_INVALID_ID &&
- i965_h264_context->fsid_list[j].frame_store_id == i) {
- VASurfaceID id = i965_h264_context->fsid_list[i].surface_id;
- int frame_idx = i965_h264_context->fsid_list[i].frame_store_id;
-
- i965_h264_context->fsid_list[i].surface_id = i965_h264_context->fsid_list[j].surface_id;
- i965_h264_context->fsid_list[i].frame_store_id = i965_h264_context->fsid_list[j].frame_store_id;
- i965_h264_context->fsid_list[j].surface_id = id;
- i965_h264_context->fsid_list[j].frame_store_id = frame_idx;
- break;
- }
- }
- }
-}
-
void
i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, void *h264_context)
{
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
- i965_avc_bsd_frame_store_index(ctx, pic_param, i965_h264_context);
+ intel_update_avc_frame_store_index(ctx, decode_state, pic_param, i965_h264_context->fsid_list);
i965_h264_context->enable_avc_ildb = 0;
i965_h264_context->picture.i_flag = 1;
struct gen_frame_store {
VASurfaceID surface_id;
int frame_store_id;
+ struct object_surface *obj_surface;
};
typedef struct gen_buffer GenBuffer;
set_ref_frame(
struct i965_driver_data *i965,
GenFrameStore *ref_frame,
- VASurfaceID va_surface
+ VASurfaceID va_surface,
+ struct object_surface *obj_surface
)
{
- struct object_surface *obj_surface;
-
if (va_surface == VA_INVALID_ID)
return 0;
- obj_surface = SURFACE(va_surface);
if (!obj_surface || !obj_surface->bo)
return 0;
ref_frame->surface_id = va_surface;
+ ref_frame->obj_surface = obj_surface;
return 1;
}
struct i965_driver_data * const i965 = i965_driver_data(ctx);
VASurfaceID va_surface;
unsigned pic_structure, is_second_field, n = 0;
+ struct object_surface *obj_surface;
pic_structure = pic_param->picture_coding_extension.bits.picture_structure;
is_second_field = pic_structure != MPEG_FRAME &&
!pic_param->picture_coding_extension.bits.is_first_field;
ref_frames[0].surface_id = VA_INVALID_ID;
+ ref_frames[0].obj_surface = NULL;
/* Reference frames are indexed by frame store ID (0:top, 1:bottom) */
switch (pic_param->picture_coding_type) {
case MPEG_P_PICTURE:
if (is_second_field && pic_structure == MPEG_BOTTOM_FIELD) {
va_surface = decode_state->current_render_target;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->render_object;
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
}
va_surface = pic_param->forward_reference_picture;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->reference_objects[0];
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
break;
case MPEG_B_PICTURE:
va_surface = pic_param->forward_reference_picture;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->reference_objects[0];
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
va_surface = pic_param->backward_reference_picture;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->reference_objects[1];
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
break;
}
- while (n != 2)
+ while (n != 2) {
+ ref_frames[n].obj_surface = ref_frames[0].obj_surface;
ref_frames[n++].surface_id = ref_frames[0].surface_id;
+ }
if (pic_param->picture_coding_extension.bits.progressive_frame)
return;
ref_frames[2].surface_id = VA_INVALID_ID;
+ ref_frames[2].obj_surface = NULL;
/* Bottom field pictures used as reference */
switch (pic_param->picture_coding_type) {
case MPEG_P_PICTURE:
if (is_second_field && pic_structure == MPEG_TOP_FIELD) {
va_surface = decode_state->current_render_target;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->render_object;
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
}
va_surface = pic_param->forward_reference_picture;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->reference_objects[0];
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
break;
case MPEG_B_PICTURE:
va_surface = pic_param->forward_reference_picture;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->reference_objects[0];
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
va_surface = pic_param->backward_reference_picture;
- n += set_ref_frame(i965, &ref_frames[n], va_surface);
+ obj_surface = decode_state->reference_objects[1];
+ n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
break;
}
- while (n != 4)
+ while (n != 4) {
+ ref_frames[n].obj_surface = ref_frames[2].obj_surface;
ref_frames[n++].surface_id = ref_frames[2].surface_id;
+ }
}
/* Generate flat scaling matrices for H.264 decoding */
);
}
+void
+intel_update_avc_frame_store_index(VADriverContextP ctx,
+ struct decode_state *decode_state,
+ VAPictureParameterBufferH264 *pic_param,
+ GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES])
+{
+ int i, j;
+
+ assert(MAX_GEN_REFERENCE_FRAMES == ARRAY_ELEMS(pic_param->ReferenceFrames));
+
+ for (i = 0; i < MAX_GEN_REFERENCE_FRAMES; i++) {
+ int found = 0;
+
+ if (frame_store[i].surface_id == VA_INVALID_ID ||
+ frame_store[i].obj_surface == NULL)
+ continue;
+
+ assert(frame_store[i].frame_store_id != -1);
+
+ for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
+ VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[j];
+ if (ref_pic->flags & VA_PICTURE_H264_INVALID)
+ continue;
+
+ if (frame_store[i].surface_id == ref_pic->picture_id) {
+ found = 1;
+ break;
+ }
+ }
+
+ /* remove it from the internal DPB */
+ if (!found) {
+ struct object_surface *obj_surface = frame_store[i].obj_surface;
+
+ obj_surface->flags &= ~SURFACE_REFERENCED;
+
+ if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
+ dri_bo_unreference(obj_surface->bo);
+ obj_surface->bo = NULL;
+ obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
+ }
+
+ if (obj_surface->free_private_data)
+ obj_surface->free_private_data(&obj_surface->private_data);
+
+ frame_store[i].surface_id = VA_INVALID_ID;
+ frame_store[i].frame_store_id = -1;
+ frame_store[i].obj_surface = NULL;
+ }
+ }
+
+ for (i = 0; i < MAX_GEN_REFERENCE_FRAMES; i++) {
+ VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[i];
+ int found = 0;
+
+ if (ref_pic->flags & VA_PICTURE_H264_INVALID ||
+ ref_pic->picture_id == VA_INVALID_SURFACE ||
+ decode_state->reference_objects[i] == NULL)
+ continue;
+
+ for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
+ if (frame_store[j].surface_id == ref_pic->picture_id) {
+ found = 1;
+ break;
+ }
+ }
+
+ /* add the new reference frame into the internal DPB */
+ if (!found) {
+ int frame_idx;
+ struct object_surface *obj_surface = decode_state->reference_objects[i];
+
+ /*
+ * Sometimes a dummy frame comes from the upper layer library, call i965_check_alloc_surface_bo()
+ * to ake sure the store buffer is allocated for this reference frame
+ */
+ i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
+
+ /* Find a free frame store index */
+ for (frame_idx = 0; frame_idx < MAX_GEN_REFERENCE_FRAMES; frame_idx++) {
+ for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
+ if (frame_store[j].surface_id == VA_INVALID_ID ||
+ frame_store[j].obj_surface == NULL)
+ continue;
+
+ if (frame_store[j].frame_store_id == frame_idx) /* the store index is in use */
+ break;
+ }
+
+ if (j == MAX_GEN_REFERENCE_FRAMES)
+ break;
+ }
+
+ assert(frame_idx < MAX_GEN_REFERENCE_FRAMES);
+
+ for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
+ if (frame_store[j].surface_id == VA_INVALID_ID ||
+ frame_store[j].obj_surface == NULL) {
+ frame_store[j].surface_id = ref_pic->picture_id;
+ frame_store[j].frame_store_id = frame_idx;
+ frame_store[j].obj_surface = obj_surface;
+ break;
+ }
+ }
+ }
+ }
+
+ /* sort */
+ for (i = 0; i < MAX_GEN_REFERENCE_FRAMES - 1; i++) {
+ if (frame_store[i].surface_id != VA_INVALID_ID &&
+ frame_store[i].obj_surface != NULL &&
+ frame_store[i].frame_store_id == i)
+ continue;
+
+ for (j = i + 1; j < MAX_GEN_REFERENCE_FRAMES; j++) {
+ if (frame_store[j].surface_id != VA_INVALID_ID &&
+ frame_store[j].obj_surface != NULL &&
+ frame_store[j].frame_store_id == i) {
+ VASurfaceID id = frame_store[i].surface_id;
+ int frame_idx = frame_store[i].frame_store_id;
+ struct object_surface *obj_surface = frame_store[i].obj_surface;
+
+ frame_store[i].surface_id = frame_store[j].surface_id;
+ frame_store[i].frame_store_id = frame_store[j].frame_store_id;
+ frame_store[i].obj_surface = frame_store[j].obj_surface;
+ frame_store[j].surface_id = id;
+ frame_store[j].frame_store_id = frame_idx;
+ frame_store[j].obj_surface = obj_surface;
+ break;
+ }
+ }
+ }
+}
+
+void
+intel_update_vc1_frame_store_index(VADriverContextP ctx,
+ struct decode_state *decode_state,
+ VAPictureParameterBufferVC1 *pic_param,
+ GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES])
+{
+ struct object_surface *obj_surface;
+ int i;
+
+ obj_surface = decode_state->reference_objects[0];
+
+ if (pic_param->forward_reference_picture == VA_INVALID_ID ||
+ !obj_surface ||
+ !obj_surface->bo) {
+ frame_store[0].surface_id = VA_INVALID_ID;
+ frame_store[0].obj_surface = NULL;
+ } else {
+ frame_store[0].surface_id = pic_param->forward_reference_picture;
+ frame_store[0].obj_surface = obj_surface;
+ }
+
+ obj_surface = decode_state->reference_objects[1];
+
+ if (pic_param->backward_reference_picture == VA_INVALID_ID ||
+ !obj_surface ||
+ !obj_surface->bo) {
+ frame_store[1].surface_id = frame_store[0].surface_id;
+ frame_store[1].obj_surface = frame_store[0].obj_surface;
+ } else {
+ frame_store[1].surface_id = pic_param->backward_reference_picture;
+ frame_store[1].obj_surface = obj_surface;
+ }
+ for (i = 2; i < MAX_GEN_REFERENCE_FRAMES; i++) {
+ frame_store[i].surface_id = frame_store[i % 2].surface_id;
+ frame_store[i].obj_surface = frame_store[i % 2].obj_surface;
+ }
+
+}
+
static VAStatus
intel_decoder_check_avc_parameter(VADriverContextP ctx,
struct decode_state *decode_state)
struct object_surface *obj_surface;
int i = 0;
- if (pic_param->picture_coding_type == 1) {
- } else if (pic_param->picture_coding_type == 2) {
- assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
+ if (pic_param->picture_coding_type == MPEG_I_PICTURE) {
+ } else if (pic_param->picture_coding_type == MPEG_P_PICTURE) {
obj_surface = SURFACE(pic_param->forward_reference_picture);
- if (!obj_surface)
- goto error;
-
- if (!obj_surface->bo)
+ if (!obj_surface || !obj_surface->bo)
decode_state->reference_objects[i++] = NULL;
else
decode_state->reference_objects[i++] = obj_surface;
- } else if (pic_param->picture_coding_type == 3) {
- assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
+ } else if (pic_param->picture_coding_type == MPEG_B_PICTURE) {
obj_surface = SURFACE(pic_param->forward_reference_picture);
- if (!obj_surface)
- goto error;
-
- if (!obj_surface->bo)
+ if (!obj_surface || !obj_surface->bo)
decode_state->reference_objects[i++] = NULL;
else
decode_state->reference_objects[i++] = obj_surface;
- assert(pic_param->backward_reference_picture != VA_INVALID_SURFACE);
obj_surface = SURFACE(pic_param->backward_reference_picture);
- if (!obj_surface)
- goto error;
-
- if (!obj_surface->bo)
+ if (!obj_surface || !obj_surface->bo)
decode_state->reference_objects[i++] = NULL;
else
decode_state->reference_objects[i++] = obj_surface;
- } else
+ } else
goto error;
for ( ; i < 16; i++)
pic_param->picture_fields.bits.picture_type == 3) {
} else if (pic_param->picture_fields.bits.picture_type == 1 ||
pic_param->picture_fields.bits.picture_type == 4) {
- assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
obj_surface = SURFACE(pic_param->forward_reference_picture);
- if (!obj_surface)
- goto error;
-
- if (!obj_surface->bo)
+ if (!obj_surface || !obj_surface->bo)
decode_state->reference_objects[i++] = NULL;
else
decode_state->reference_objects[i++] = obj_surface;
} else if (pic_param->picture_fields.bits.picture_type == 2) {
- assert(pic_param->forward_reference_picture != VA_INVALID_SURFACE);
obj_surface = SURFACE(pic_param->forward_reference_picture);
- if (!obj_surface)
- goto error;
-
- if (!obj_surface->bo)
+ if (!obj_surface || !obj_surface->bo)
decode_state->reference_objects[i++] = NULL;
else
decode_state->reference_objects[i++] = obj_surface;
- assert(pic_param->backward_reference_picture != VA_INVALID_SURFACE);
obj_surface = SURFACE(pic_param->backward_reference_picture);
- if (!obj_surface)
- goto error;
-
- if (!obj_surface->bo)
+ if (!obj_surface || !obj_surface->bo)
decode_state->reference_objects[i++] = NULL;
else
decode_state->reference_objects[i++] = obj_surface;
VAProfile profile,
struct decode_state *decode_state);
+void
+intel_update_avc_frame_store_index(VADriverContextP ctx,
+ struct decode_state *decode_state,
+ VAPictureParameterBufferH264 *pic_param,
+ GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES]);
+
+void
+intel_update_vc1_frame_store_index(VADriverContextP ctx,
+ struct decode_state *decode_state,
+ VAPictureParameterBufferVC1 *pic_param,
+ GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES]);
#endif /* I965_DECODER_UTILS_H */
struct decode_state *decode_state,
struct i965_media_context *media_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_h264_context *i965_h264_context;
struct object_surface *obj_surface;
VAPictureParameterBufferH264 *pic_param;
/* Reference Pictures */
for (i = 0; i < ARRAY_ELEMS(i965_h264_context->fsid_list); i++) {
- if (i965_h264_context->fsid_list[i].surface_id != VA_INVALID_ID) {
+ if (i965_h264_context->fsid_list[i].surface_id != VA_INVALID_ID &&
+ i965_h264_context->fsid_list[i].obj_surface != NULL) {
int found = 0;
for (j = 0; j < ARRAY_ELEMS(pic_param->ReferenceFrames); j++) {
va_pic = &pic_param->ReferenceFrames[j];
assert(found == 1);
- obj_surface = SURFACE(va_pic->picture_id);
- assert(obj_surface);
+ obj_surface = i965_h264_context->fsid_list[i].obj_surface;
w = obj_surface->width;
h = obj_surface->height;
field_picture = !!(va_pic->flags & (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD));
struct decode_state *decode_state,
struct i965_media_context *media_context)
{
- struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_surface *obj_surface;
VAPictureParameterBufferMPEG2 *param;
SURFACE_TARGET,
media_context);
- obj_surface = SURFACE(param->forward_reference_picture);
+ obj_surface = decode_state->reference_objects[0];
+
if (!obj_surface) {
// assert(param->picture_coding_type == 1); /* I-picture */
} else {
param->picture_coding_extension.bits.picture_structure,
SURFACE_FORWARD,
media_context);
- obj_surface = SURFACE(param->backward_reference_picture);
+
+ obj_surface = decode_state->reference_objects[1];
+
if (!obj_surface) {
assert(param->picture_coding_type == 2); /* P-picture */
- obj_surface = SURFACE(param->forward_reference_picture);
+ obj_surface = decode_state->reference_objects[0];
i965_media_mpeg2_surface_setup(ctx, 7, obj_surface, False,
param->picture_coding_extension.bits.picture_structure,
SURFACE_BACKWARD,