summaryrefslogtreecommitdiff
path: root/src/gen7_mfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gen7_mfd.c')
-rwxr-xr-xsrc/gen7_mfd.c145
1 files changed, 79 insertions, 66 deletions
diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c
index 8e0d503b..bfb95bf6 100755
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -65,6 +65,7 @@ gen7_mfd_init_avc_surface(VADriverContextP ctx,
if (!gen7_avc_surface) {
gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1);
+ gen7_avc_surface->frame_store_id = -1;
assert((obj_surface->size & 0x3f) == 0);
obj_surface->private_data = gen7_avc_surface;
}
@@ -135,12 +136,16 @@ gen7_mfd_surface_state(VADriverContextP ctx,
struct object_surface *obj_surface = decode_state->render_object;
unsigned int y_cb_offset;
unsigned int y_cr_offset;
+ unsigned int surface_format;
assert(obj_surface);
y_cb_offset = obj_surface->y_cb_offset;
y_cr_offset = obj_surface->y_cr_offset;
+ surface_format = obj_surface->fourcc == VA_FOURCC_Y800 ?
+ MFX_SURFACE_MONOCHROME : MFX_SURFACE_PLANAR_420_8;
+
BEGIN_BCS_BATCH(batch, 6);
OUT_BCS_BATCH(batch, MFX_SURFACE_STATE | (6 - 2));
OUT_BCS_BATCH(batch, 0);
@@ -148,7 +153,7 @@ gen7_mfd_surface_state(VADriverContextP ctx,
((obj_surface->orig_height - 1) << 18) |
((obj_surface->orig_width - 1) << 4));
OUT_BCS_BATCH(batch,
- (MFX_SURFACE_PLANAR_420_8 << 28) | /* 420 planar YUV surface */
+ (surface_format << 28) | /* 420 planar YUV surface */
((standard_select != MFX_FORMAT_JPEG) << 27) | /* interleave chroma, set to 0 for JPEG */
(0 << 22) | /* surface object control state, ignored */
((obj_surface->width - 1) << 3) | /* pitch */
@@ -353,7 +358,7 @@ gen7_mfd_avc_img_state(VADriverContextP ctx,
BEGIN_BCS_BATCH(batch, 16);
OUT_BCS_BATCH(batch, MFX_AVC_IMG_STATE | (16 - 2));
OUT_BCS_BATCH(batch,
- width_in_mbs * height_in_mbs);
+ (width_in_mbs * height_in_mbs - 1));
OUT_BCS_BATCH(batch,
((height_in_mbs - 1) << 16) |
((width_in_mbs - 1) << 0));
@@ -425,7 +430,7 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
struct object_surface *obj_surface;
GenAvcSurface *gen7_avc_surface;
VAPictureH264 *va_pic;
- int i, j;
+ int i;
BEGIN_BCS_BATCH(batch, 69);
OUT_BCS_BATCH(batch, MFX_AVC_DIRECTMODE_STATE | (69 - 2));
@@ -477,26 +482,14 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
/* POC List */
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];
-
- if (va_pic->flags & VA_PICTURE_H264_INVALID)
- continue;
+ obj_surface = gen7_mfd_context->reference_surface[i].obj_surface;
- if (va_pic->picture_id == gen7_mfd_context->reference_surface[i].surface_id) {
- found = 1;
- break;
- }
- }
+ if (obj_surface) {
+ const VAPictureH264 * const va_pic = avc_find_picture(
+ obj_surface->base.id, pic_param->ReferenceFrames,
+ ARRAY_ELEMS(pic_param->ReferenceFrames));
- assert(found == 1);
- assert(!(va_pic->flags & VA_PICTURE_H264_INVALID));
-
+ assert(va_pic != NULL);
OUT_BCS_BATCH(batch, va_pic->TopFieldOrderCnt);
OUT_BCS_BATCH(batch, va_pic->BottomFieldOrderCnt);
} else {
@@ -513,6 +506,15 @@ gen7_mfd_avc_directmode_state(VADriverContextP ctx,
}
static void
+gen7_mfd_avc_phantom_slice_first(VADriverContextP ctx,
+ VAPictureParameterBufferH264 *pic_param,
+ VASliceParameterBufferH264 *next_slice_param,
+ struct gen7_mfd_context *gen7_mfd_context)
+{
+ gen6_mfd_avc_phantom_slice(ctx, pic_param, next_slice_param, gen7_mfd_context->base.batch);
+}
+
+static void
gen7_mfd_avc_slice_state(VADriverContextP ctx,
VAPictureParameterBufferH264 *pic_param,
VASliceParameterBufferH264 *slice_param,
@@ -748,7 +750,8 @@ 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;
- intel_update_avc_frame_store_index(ctx, decode_state, pic_param, gen7_mfd_context->reference_surface);
+ intel_update_avc_frame_store_index(ctx, decode_state, pic_param,
+ gen7_mfd_context->reference_surface, &gen7_mfd_context->fs_ctx);
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 */
@@ -756,20 +759,12 @@ gen7_mfd_avc_decode_init(VADriverContextP ctx,
/* Current decoded picture */
obj_surface = decode_state->render_object;
- obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
- obj_surface->flags |= (pic_param->pic_fields.bits.reference_pic_flag ? SURFACE_REFERENCED : 0);
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
-
- /* initial uv component for YUV400 case */
- if (pic_param->seq_fields.bits.chroma_format_idc == 0) {
- unsigned int uv_offset = obj_surface->width * obj_surface->height;
- unsigned int uv_size = obj_surface->width * obj_surface->height / 2;
-
- drm_intel_gem_bo_map_gtt(obj_surface->bo);
- memset(obj_surface->bo->virtual + uv_offset, 0x80, uv_size);
- drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
- }
+ if (pic_param->pic_fields.bits.reference_pic_flag)
+ obj_surface->flags |= SURFACE_REFERENCED;
+ else
+ obj_surface->flags &= ~SURFACE_REFERENCED;
+ avc_ensure_surface_bo(ctx, decode_state, obj_surface, pic_param);
gen7_mfd_init_avc_surface(ctx, pic_param, obj_surface);
dri_bo_unreference(gen7_mfd_context->post_deblocking_output.bo);
@@ -856,6 +851,9 @@ gen7_mfd_avc_decode_picture(VADriverContextP ctx,
else
next_slice_group_param = (VASliceParameterBufferH264 *)decode_state->slice_params[j + 1]->buffer;
+ if (j == 0 && slice_param->first_mb_in_slice)
+ gen7_mfd_avc_phantom_slice_first(ctx, pic_param, slice_param, gen7_mfd_context);
+
for (i = 0; i < decode_state->slice_params[j]->num_elements; i++) {
assert(slice_param->slice_data_flag == VA_SLICE_DATA_FLAG_ALL);
assert((slice_param->slice_type == SLICE_TYPE_I) ||
@@ -906,7 +904,7 @@ gen7_mfd_mpeg2_decode_init(VADriverContextP ctx,
/* Current decoded picture */
obj_surface = decode_state->render_object;
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
+ i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
dri_bo_unreference(gen7_mfd_context->pre_deblocking_output.bo);
gen7_mfd_context->pre_deblocking_output.bo = obj_surface->bo;
@@ -942,7 +940,7 @@ gen7_mfd_mpeg2_pic_state(VADriverContextP ctx,
assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer;
- if (IS_HASWELL(i965->intel.device_id)) {
+ if (IS_HASWELL(i965->intel.device_info)) {
/* XXX: disable concealment for now */
slice_concealment_disable_bit = 1;
}
@@ -1040,10 +1038,35 @@ gen7_mfd_mpeg2_qm_state(VADriverContextP ctx,
}
}
+uint32_t mpeg2_get_slice_data_length(dri_bo *slice_data_bo, VASliceParameterBufferMPEG2 *slice_param)
+{
+ uint8_t *buf;
+ uint32_t buf_offset = slice_param->slice_data_offset + (slice_param->macroblock_offset >> 3);
+ uint32_t buf_size = slice_param->slice_data_size - (slice_param->macroblock_offset >> 3);
+ uint32_t i;
+
+ dri_bo_map(slice_data_bo, 0);
+ buf = (uint8_t *)slice_data_bo->virtual + buf_offset;
+
+ for (i = 3; i < buf_size; i++) {
+ if (buf[i - 3] &&
+ !buf[i - 2] &&
+ !buf[i - 1] &&
+ !buf[i]) {
+ dri_bo_unmap(slice_data_bo);
+ return i - 3 + 1;
+ }
+ }
+
+ dri_bo_unmap(slice_data_bo);
+ return buf_size;
+}
+
static void
gen7_mfd_mpeg2_bsd_object(VADriverContextP ctx,
VAPictureParameterBufferMPEG2 *pic_param,
VASliceParameterBufferMPEG2 *slice_param,
+ dri_bo *slice_data_bo,
VASliceParameterBufferMPEG2 *next_slice_param,
struct gen7_mfd_context *gen7_mfd_context)
{
@@ -1074,7 +1097,7 @@ gen7_mfd_mpeg2_bsd_object(VADriverContextP ctx,
BEGIN_BCS_BATCH(batch, 5);
OUT_BCS_BATCH(batch, MFD_MPEG2_BSD_OBJECT | (5 - 2));
OUT_BCS_BATCH(batch,
- slice_param->slice_data_size - (slice_param->macroblock_offset >> 3));
+ mpeg2_get_slice_data_length(slice_data_bo, slice_param));
OUT_BCS_BATCH(batch,
slice_param->slice_data_offset + (slice_param->macroblock_offset >> 3));
OUT_BCS_BATCH(batch,
@@ -1086,7 +1109,7 @@ gen7_mfd_mpeg2_bsd_object(VADriverContextP ctx,
(slice_param->macroblock_offset & 0x7));
OUT_BCS_BATCH(batch,
(slice_param->quantiser_scale_code << 24) |
- (IS_HASWELL(i965->intel.device_id) ? (vpos1 << 8 | hpos1) : 0));
+ (IS_HASWELL(i965->intel.device_info) ? (vpos1 << 8 | hpos1) : 0));
ADVANCE_BCS_BATCH(batch);
}
@@ -1137,7 +1160,7 @@ gen7_mfd_mpeg2_decode_picture(VADriverContextP ctx,
else
next_slice_param = next_slice_group_param;
- gen7_mfd_mpeg2_bsd_object(ctx, pic_param, slice_param, next_slice_param, gen7_mfd_context);
+ gen7_mfd_mpeg2_bsd_object(ctx, pic_param, slice_param, slice_data_bo, next_slice_param, gen7_mfd_context);
slice_param++;
}
}
@@ -1247,7 +1270,7 @@ gen7_mfd_vc1_decode_init(VADriverContextP ctx,
/* Current decoded picture */
obj_surface = decode_state->render_object;
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
+ i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
gen7_mfd_init_vc1_surface(ctx, pic_param, obj_surface);
dri_bo_unreference(gen7_mfd_context->post_deblocking_output.bo);
@@ -1798,13 +1821,13 @@ gen7_mfd_jpeg_decode_init(VADriverContextP ctx,
struct object_surface *obj_surface;
VAPictureParameterBufferJPEGBaseline *pic_param;
int subsampling = SUBSAMPLE_YUV420;
- int fourcc = VA_FOURCC('I', 'M', 'C', '3');
+ int fourcc = VA_FOURCC_IMC3;
pic_param = (VAPictureParameterBufferJPEGBaseline *)decode_state->pic_param->buffer;
if (pic_param->num_components == 1) {
subsampling = SUBSAMPLE_YUV400;
- fourcc = VA_FOURCC('Y', '8', '0', '0');
+ fourcc = VA_FOURCC_Y800;
} else if (pic_param->num_components == 3) {
int h1 = pic_param->components[0].h_sampling_factor;
int h2 = pic_param->components[1].h_sampling_factor;
@@ -1816,31 +1839,31 @@ gen7_mfd_jpeg_decode_init(VADriverContextP ctx,
if (h1 == 2 && h2 == 1 && h3 == 1 &&
v1 == 2 && v2 == 1 && v3 == 1) {
subsampling = SUBSAMPLE_YUV420;
- fourcc = VA_FOURCC('I', 'M', 'C', '3');
+ fourcc = VA_FOURCC_IMC3;
} else if (h1 == 2 && h2 == 1 && h3 == 1 &&
v1 == 1 && v2 == 1 && v3 == 1) {
subsampling = SUBSAMPLE_YUV422H;
- fourcc = VA_FOURCC('4', '2', '2', 'H');
+ fourcc = VA_FOURCC_422H;
} else if (h1 == 1 && h2 == 1 && h3 == 1 &&
v1 == 1 && v2 == 1 && v3 == 1) {
subsampling = SUBSAMPLE_YUV444;
- fourcc = VA_FOURCC('4', '4', '4', 'P');
+ fourcc = VA_FOURCC_444P;
} else if (h1 == 4 && h2 == 1 && h3 == 1 &&
v1 == 1 && v2 == 1 && v3 == 1) {
subsampling = SUBSAMPLE_YUV411;
- fourcc = VA_FOURCC('4', '1', '1', 'P');
+ fourcc = VA_FOURCC_411P;
} else if (h1 == 1 && h2 == 1 && h3 == 1 &&
v1 == 2 && v2 == 1 && v3 == 1) {
subsampling = SUBSAMPLE_YUV422V;
- fourcc = VA_FOURCC('4', '2', '2', 'V');
+ fourcc = VA_FOURCC_422V;
} else if (h1 == 2 && h2 == 1 && h3 == 1 &&
v1 == 2 && v2 == 2 && v3 == 2) {
subsampling = SUBSAMPLE_YUV422H;
- fourcc = VA_FOURCC('4', '2', '2', 'H');
+ fourcc = VA_FOURCC_422H;
} else if (h2 == 2 && h2 == 2 && h3 == 2 &&
v1 == 2 && v2 == 1 && v3 == 1) {
subsampling = SUBSAMPLE_YUV422V;
- fourcc = VA_FOURCC('4', '2', '2', 'V');
+ fourcc = VA_FOURCC_422V;
} else
assert(0);
} else {
@@ -2091,18 +2114,6 @@ gen7_mfd_jpeg_bsd_object(VADriverContextP ctx,
/* Workaround for JPEG decoding on Ivybridge */
-VAStatus
-i965_DestroySurfaces(VADriverContextP ctx,
- VASurfaceID *surface_list,
- int num_surfaces);
-VAStatus
-i965_CreateSurfaces(VADriverContextP ctx,
- int width,
- int height,
- int format,
- int num_surfaces,
- VASurfaceID *surfaces);
-
static struct {
int width;
int height;
@@ -2145,7 +2156,7 @@ gen7_jpeg_wa_init(VADriverContextP ctx,
obj_surface = SURFACE(gen7_mfd_context->jpeg_wa_surface_id);
assert(obj_surface);
- i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
+ i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC_NV12, SUBSAMPLE_YUV420);
gen7_mfd_context->jpeg_wa_surface_object = obj_surface;
if (!gen7_mfd_context->jpeg_wa_slice_data_bo) {
@@ -2320,7 +2331,7 @@ gen7_jpeg_wa_avc_img_state(VADriverContextP ctx,
BEGIN_BCS_BATCH(batch, 16);
OUT_BCS_BATCH(batch, MFX_AVC_IMG_STATE | (16 - 2));
OUT_BCS_BATCH(batch,
- width_in_mbs * height_in_mbs);
+ (width_in_mbs * height_in_mbs - 1));
OUT_BCS_BATCH(batch,
((height_in_mbs - 1) << 16) |
((width_in_mbs - 1) << 0));
@@ -2614,9 +2625,10 @@ gen7_mfd_decode_picture(VADriverContextP ctx,
gen7_mfd_mpeg2_decode_picture(ctx, decode_state, gen7_mfd_context);
break;
- case VAProfileH264Baseline:
+ case VAProfileH264ConstrainedBaseline:
case VAProfileH264Main:
case VAProfileH264High:
+ case VAProfileH264StereoHigh:
gen7_mfd_avc_decode_picture(ctx, decode_state, gen7_mfd_context);
break;
@@ -2708,9 +2720,10 @@ gen7_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
gen7_mfd_mpeg2_context_init(ctx, gen7_mfd_context);
break;
- case VAProfileH264Baseline:
+ case VAProfileH264ConstrainedBaseline:
case VAProfileH264Main:
case VAProfileH264High:
+ case VAProfileH264StereoHigh:
gen7_mfd_avc_context_init(ctx, gen7_mfd_context);
break;
default: