summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2013-03-13 14:11:05 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2013-03-15 15:45:28 +0800
commit9fbbc9b03a52c45571d0407b889461619a8dce52 (patch)
treeab076cc9263c9ce8a7cb5a57a98af4936af23039 /src
parent5fd469eb5b0e991cddbdd3038b5d224faed5db35 (diff)
downloadvaapi-intel-driver-9fbbc9b03a52c45571d0407b889461619a8dce52.tar.gz
vaapi-intel-driver-9fbbc9b03a52c45571d0407b889461619a8dce52.tar.bz2
vaapi-intel-driver-9fbbc9b03a52c45571d0407b889461619a8dce52.zip
Decoder: directly use surface object for decoding
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/gen6_mfd.c199
-rw-r--r--src/gen75_mfd.c237
-rwxr-xr-xsrc/gen7_mfd.c199
-rw-r--r--src/i965_avc_bsd.c158
-rw-r--r--src/i965_decoder.h1
-rw-r--r--src/i965_decoder_utils.c259
-rw-r--r--src/i965_decoder_utils.h11
-rw-r--r--src/i965_media_h264.c7
-rw-r--r--src/i965_media_mpeg2.c10
9 files changed, 361 insertions, 720 deletions
diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c
index 76a44f5..4246709 100755
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -53,122 +53,6 @@ static const uint32_t zigzag_direct[64] = {
};
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)
@@ -280,7 +164,6 @@ gen6_mfd_pipe_buf_addr_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);
int i;
BEGIN_BCS_BATCH(batch, 24);
@@ -320,9 +203,10 @@ gen6_mfd_pipe_buf_addr_state(VADriverContextP ctx,
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,
@@ -556,7 +440,6 @@ gen6_mfd_avc_directmode_state(VADriverContextP ctx,
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;
@@ -568,28 +451,24 @@ gen6_mfd_avc_directmode_state(VADriverContextP ctx,
/* 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);
@@ -619,6 +498,9 @@ gen6_mfd_avc_directmode_state(VADriverContextP ctx,
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];
@@ -927,7 +809,7 @@ gen6_mfd_avc_decode_init(VADriverContextP ctx,
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 */
@@ -1390,7 +1272,6 @@ gen6_mfd_vc1_decode_init(VADriverContextP ctx,
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;
@@ -1400,24 +1281,10 @@ gen6_mfd_vc1_decode_init(VADriverContextP ctx,
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;
@@ -1523,7 +1390,6 @@ gen6_mfd_vc1_pic_state(VADriverContextP ctx,
{
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;
@@ -1643,9 +1509,10 @@ gen6_mfd_vc1_pic_state(VADriverContextP ctx,
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 ||
@@ -1816,21 +1683,16 @@ gen6_mfd_vc1_directmode_state(VADriverContextP ctx,
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;
@@ -2060,6 +1922,7 @@ gen6_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
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;
diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c
index e1f2c80..c01796c 100644
--- a/src/gen75_mfd.c
+++ b/src/gen75_mfd.c
@@ -58,122 +58,6 @@ static const uint32_t zigzag_direct[64] = {
};
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)
@@ -294,7 +178,6 @@ gen75_mfd_pipe_buf_addr_state_bplus(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);
int i;
BEGIN_BCS_BATCH(batch, 61);
@@ -352,9 +235,10 @@ gen75_mfd_pipe_buf_addr_state_bplus(VADriverContextP ctx,
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,
@@ -434,9 +318,10 @@ gen75_mfd_pipe_buf_addr_state(VADriverContextP ctx,
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,
@@ -797,7 +682,6 @@ gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx,
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;
@@ -809,20 +693,16 @@ gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx,
/* 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);
@@ -847,6 +727,9 @@ gen75_mfd_avc_directmode_state_bplus(VADriverContextP ctx,
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];
@@ -903,28 +786,25 @@ gen75_mfd_avc_directmode_state(VADriverContextP ctx,
/* 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);
@@ -954,6 +834,9 @@ gen75_mfd_avc_directmode_state(VADriverContextP ctx,
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];
@@ -1216,7 +1099,7 @@ gen75_mfd_avc_decode_init(VADriverContextP ctx,
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 */
@@ -1695,7 +1578,6 @@ gen75_mfd_vc1_decode_init(VADriverContextP ctx,
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;
@@ -1705,24 +1587,10 @@ gen75_mfd_vc1_decode_init(VADriverContextP ctx,
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;
@@ -1828,7 +1696,6 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
{
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;
@@ -1950,9 +1817,10 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
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 ||
@@ -2119,21 +1987,16 @@ gen75_mfd_vc1_directmode_state_bplus(VADriverContextP ctx,
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;
@@ -2170,7 +2033,6 @@ gen75_mfd_vc1_directmode_state(VADriverContextP ctx,
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;
@@ -2179,8 +2041,6 @@ gen75_mfd_vc1_directmode_state(VADriverContextP ctx,
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;
@@ -2188,7 +2048,7 @@ gen75_mfd_vc1_directmode_state(VADriverContextP ctx,
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;
@@ -3419,6 +3279,7 @@ gen75_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config
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;
diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c
index 84f917f..3421c07 100755
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -54,122 +54,6 @@ static const uint32_t zigzag_direct[64] = {
};
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)
@@ -290,7 +174,6 @@ gen7_mfd_pipe_buf_addr_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);
int i;
BEGIN_BCS_BATCH(batch, 24);
@@ -330,9 +213,10 @@ gen7_mfd_pipe_buf_addr_state(VADriverContextP ctx,
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,
@@ -565,7 +449,6 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
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;
@@ -577,28 +460,24 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
/* 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);
@@ -628,6 +507,9 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
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];
@@ -894,7 +776,7 @@ gen7_mfd_avc_decode_init(VADriverContextP ctx,
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 */
@@ -1377,7 +1259,6 @@ gen7_mfd_vc1_decode_init(VADriverContextP ctx,
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;
@@ -1387,24 +1268,10 @@ gen7_mfd_vc1_decode_init(VADriverContextP ctx,
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;
@@ -1510,7 +1377,6 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
{
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;
@@ -1632,9 +1498,10 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
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 ||
@@ -1802,21 +1669,16 @@ gen7_mfd_vc1_directmode_state(VADriverContextP ctx,
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;
@@ -2847,6 +2709,7 @@ gen7_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
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;
diff --git a/src/i965_avc_bsd.c b/src/i965_avc_bsd.c
index 363160a..68c6b12 100644
--- a/src/i965_avc_bsd.c
+++ b/src/i965_avc_bsd.c
@@ -379,7 +379,6 @@ i965_avc_bsd_buf_base_state(VADriverContextP ctx,
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;
@@ -412,7 +411,9 @@ i965_avc_bsd_buf_base_state(VADriverContextP ctx,
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];
@@ -427,30 +428,21 @@ i965_avc_bsd_buf_base_state(VADriverContextP ctx,
}
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);
@@ -819,120 +811,6 @@ i965_avc_bsd_phantom_slice(VADriverContextP ctx,
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)
{
@@ -944,7 +822,7 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, v
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;
diff --git a/src/i965_decoder.h b/src/i965_decoder.h
index f36df44..cec601d 100644
--- a/src/i965_decoder.h
+++ b/src/i965_decoder.h
@@ -37,6 +37,7 @@ typedef struct gen_frame_store GenFrameStore;
struct gen_frame_store {
VASurfaceID surface_id;
int frame_store_id;
+ struct object_surface *obj_surface;
};
typedef struct gen_buffer GenBuffer;
diff --git a/src/i965_decoder_utils.c b/src/i965_decoder_utils.c
index 4ba5151..a45f725 100644
--- a/src/i965_decoder_utils.c
+++ b/src/i965_decoder_utils.c
@@ -35,19 +35,18 @@ static inline int
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;
}
@@ -103,61 +102,76 @@ mpeg2_set_reference_surfaces(
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 */
@@ -327,6 +341,179 @@ gen6_send_avc_ref_idx_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])
+{
+ 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)
@@ -385,41 +572,29 @@ intel_decoder_check_mpeg2_parameter(VADriverContextP ctx,
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++)
@@ -444,35 +619,23 @@ intel_decoder_check_vc1_parameter(VADriverContextP ctx,
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;
diff --git a/src/i965_decoder_utils.h b/src/i965_decoder_utils.h
index b5025eb..2a71f3e 100644
--- a/src/i965_decoder_utils.h
+++ b/src/i965_decoder_utils.h
@@ -80,4 +80,15 @@ intel_decoder_sanity_check_input(VADriverContextP ctx,
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 */
diff --git a/src/i965_media_h264.c b/src/i965_media_h264.c
index 7e3b128..f6c8c11 100644
--- a/src/i965_media_h264.c
+++ b/src/i965_media_h264.c
@@ -339,7 +339,6 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx,
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;
@@ -376,7 +375,8 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx,
/* 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];
@@ -392,8 +392,7 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx,
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));
diff --git a/src/i965_media_mpeg2.c b/src/i965_media_mpeg2.c
index e83b79f..1c105b3 100644
--- a/src/i965_media_mpeg2.c
+++ b/src/i965_media_mpeg2.c
@@ -594,7 +594,6 @@ i965_media_mpeg2_surfaces_setup(VADriverContextP ctx,
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;
@@ -608,7 +607,8 @@ i965_media_mpeg2_surfaces_setup(VADriverContextP ctx,
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 {
@@ -616,11 +616,13 @@ i965_media_mpeg2_surfaces_setup(VADriverContextP ctx,
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,