Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a fork with many changes, including but not limited to:

The `NEWS` file contains a more detailed changelog.

[✻] Works on IVB and newer, broken on SNB and ILK (for now)
[✻] Works on IVB and newer, semi-broken on SNB and ILK, unsupported on CTG

# Release schedule

Expand Down
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ AC_ARG_ENABLE([hybrid-codec],
[build with hybrid codec support @<:@default=no@:>@])],
[], [enable_hybrid_codec="no"])

AC_ARG_ENABLE([h264-ctg],
[AC_HELP_STRING([--enable-h264-ctg],
[build with experimental H.264 support for G45 @<:@default=no@:>@])],
[], [enable_h264_ctg="no"])

AC_ARG_ENABLE([tests],
[AC_HELP_STRING([--enable-tests],
[build tests @<:@default=no@:>@])],
Expand Down Expand Up @@ -131,6 +136,10 @@ if test "$enable_hybrid_codec" = "yes"; then
AC_DEFINE([HAVE_HYBRID_CODEC], [1], [Defined to 1 if hybrid codec is needed])
fi

if test "$enable_h264_ctg" = "yes"; then
AC_DEFINE([I965_H264_ENABLE_CTG], [1], [Defined to 1 if H264 support on CTG is needed])
fi

AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" = "yes")

VA_VERSION=`$PKG_CONFIG --modversion libva`
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ option('driverdir', type : 'string', description : 'drivers path')
option('with_x11', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
option('with_wayland', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
option('enable_hybrid_codec', type : 'boolean', value : false)
option('enable_h264_ctg', type : 'boolean', value : false,
description: 'Enables shader-based H.264 decoding for GMA 4500 (M)HD hardware.')
option('enable_tests', type : 'boolean', value : false)
146 changes: 141 additions & 5 deletions src/i965_avc_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,12 @@ i965_avc_bsd_slice_state(VADriverContextP ctx,
slice_param->chroma_weight_l0[j][1] == 128)
i965_h264_context->weight128_chroma_l0 |= (1 << j);
} else {
/* FIXME: workaround for weight 128 */
/**
* FIXME: workaround for weight 128
*
* TODO(irql): There is an alternate version in the G4X patchset,
* we might have to switch to it, for now leave as is.
*/
if (slice_param->luma_weight_l0[j] == 128 ||
slice_param->chroma_weight_l0[j][0] == 128 ||
slice_param->chroma_weight_l0[j][1] == 128)
Expand Down Expand Up @@ -357,6 +362,10 @@ i965_avc_bsd_slice_state(VADriverContextP ctx,
slice_param->chroma_weight_l1[j][1] == 128)
i965_h264_context->weight128_chroma_l1 |= (1 << j);
} else {
/**
* TODO(irql): There is an alternate version in the G4X patchset,
* we might have to switch to it, for now leave as is.
*/
if (slice_param->luma_weight_l0[j] == 128 ||
slice_param->chroma_weight_l0[j][0] == 128 ||
slice_param->chroma_weight_l0[j][1] == 128)
Expand Down Expand Up @@ -610,7 +619,7 @@ g4x_avc_bsd_object(VADriverContextP ctx,
OUT_BCS_BATCH(batch, CMD_AVC_BSD_OBJECT | (8 - 2));
OUT_BCS_BATCH(batch, 0); /* indirect data length for phantom slice is 0 */
OUT_BCS_BATCH(batch, 0); /* indirect data start address for phantom slice is 0 */
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, slice_index);
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, 0);
OUT_BCS_BATCH(batch, width_in_mbs * height_in_mbs / (1 + !!pic_param->pic_fields.bits.field_pic_flag));
Expand Down Expand Up @@ -781,10 +790,132 @@ static void
i965_avc_bsd_phantom_slice(VADriverContextP ctx,
struct decode_state *decode_state,
VAPictureParameterBufferH264 *pic_param,
int prev_slice_type,
struct i965_h264_context *i965_h264_context)
{
i965_avc_bsd_object(ctx, decode_state, pic_param, NULL, 0, i965_h264_context);
i965_avc_bsd_object(ctx, decode_state, pic_param, NULL, prev_slice_type, i965_h264_context);
}

#if defined(I965_H264_ENABLE_CTG)

static int
i965_list_find_weight(short *list, int size, short value)
{
int i;

for (i = 0; i < size; i++)
{
if (list[i] == value)
return 1;
}

return 0;
}

static void
i965_weight128_workaround(VADriverContextP ctx, struct decode_state *decode_state, void *h264_context)
{
struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context;
VAPictureParameterBufferH264 *pic_param;
VASliceParameterBufferH264 *slice_param;
short weight128_offset0 = 0;
int i, j;

i965_h264_context->weight128_offset0_flag = 0;
i965_h264_context->weight128_offset0 = 0;

assert(decode_state->pic_param && decode_state->pic_param->buffer);
pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;

for (j = 0; j < decode_state->num_slice_params; j++)
{
assert(decode_state->slice_params && decode_state->slice_params[j]->buffer);
slice_param = (VASliceParameterBufferH264 *)decode_state->slice_params[j]->buffer;

for (i = 0; i < decode_state->slice_params[j]->num_elements; i++)
{

if ((slice_param->slice_type == SLICE_TYPE_P ||
slice_param->slice_type == SLICE_TYPE_SP) &&
(pic_param->pic_fields.bits.weighted_pred_flag == 1))
{
i965_h264_context->weight128_offset0_flag =
i965_list_find_weight(&slice_param->luma_weight_l0[0], 32, 128) ||
i965_list_find_weight(&slice_param->chroma_weight_l0[0][0], 64, 128);
}

if ((slice_param->slice_type == SLICE_TYPE_B) &&
(pic_param->pic_fields.bits.weighted_bipred_idc == 1))
{
i965_h264_context->weight128_offset0_flag =
i965_list_find_weight(&slice_param->luma_weight_l0[0], 32, 128) ||
i965_list_find_weight(&slice_param->chroma_weight_l0[0][0], 64, 128) ||
i965_list_find_weight(&slice_param->luma_weight_l1[0], 32, 128) ||
i965_list_find_weight(&slice_param->chroma_weight_l1[0][0], 64, 128);
}

if (i965_h264_context->weight128_offset0_flag)
break;

slice_param++;
}

if (i965_h264_context->weight128_offset0_flag)
break;
}

if (!i965_h264_context->weight128_offset0_flag)
return;

for (weight128_offset0 = 0; weight128_offset0 < 128; weight128_offset0++)
{
int bfound = 0;

for (j = 0; j < decode_state->num_slice_params; j++)
{
assert(decode_state->slice_params && decode_state->slice_params[j]->buffer);
slice_param = (VASliceParameterBufferH264 *)decode_state->slice_params[j]->buffer;

for (i = 0; i < decode_state->slice_params[j]->num_elements; i++)
{

if ((slice_param->slice_type == SLICE_TYPE_P ||
slice_param->slice_type == SLICE_TYPE_SP) &&
(pic_param->pic_fields.bits.weighted_pred_flag == 1))
{
bfound =
i965_list_find_weight(&slice_param->luma_weight_l0[0], 32, weight128_offset0) ||
i965_list_find_weight(&slice_param->chroma_weight_l0[0][0], 64, weight128_offset0);
}

if ((slice_param->slice_type == SLICE_TYPE_B) &&
(pic_param->pic_fields.bits.weighted_bipred_idc == 1))
{
bfound =
i965_list_find_weight(&slice_param->luma_weight_l0[0], 32, weight128_offset0) ||
i965_list_find_weight(&slice_param->chroma_weight_l0[0][0], 64, weight128_offset0) ||
i965_list_find_weight(&slice_param->luma_weight_l1[0], 32, weight128_offset0) ||
i965_list_find_weight(&slice_param->chroma_weight_l1[0][0], 64, weight128_offset0);
}

if (bfound)
break;

slice_param++;
}

if (bfound)
break;
}

if (!bfound)
{
i965_h264_context->weight128_offset0 = weight128_offset0;
break;
}
}
}
#endif

void
i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, void *h264_context)
Expand All @@ -793,13 +924,17 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, v
struct intel_batchbuffer *batch = i965_h264_context->batch;
VAPictureParameterBufferH264 *pic_param;
VASliceParameterBufferH264 *slice_param;
int i, j;
int i, j, prev_slice_type = SLICE_TYPE_I;

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,
i965_h264_context->fsid_list, &i965_h264_context->fs_ctx);

#if defined(I965_H264_ENABLE_CTG)
i965_weight128_workaround(ctx, decode_state, h264_context);
#endif

i965_h264_context->enable_avc_ildb = 0;
i965_h264_context->picture.i_flag = 1;

Expand All @@ -820,6 +955,7 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, v
break;
}

prev_slice_type = slice_param->slice_type;
slice_param++;
}
}
Expand Down Expand Up @@ -855,7 +991,7 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, v
}
}

i965_avc_bsd_phantom_slice(ctx, decode_state, pic_param, i965_h264_context);
i965_avc_bsd_phantom_slice(ctx, decode_state, pic_param, prev_slice_type, i965_h264_context);
intel_batchbuffer_emit_mi_flush(batch);
intel_batchbuffer_end_atomic(batch);
intel_batchbuffer_flush(batch);
Expand Down
3 changes: 3 additions & 0 deletions src/i965_avc_ildb.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,11 @@ i965_avc_ildb_decode_init(VADriverContextP ctx, void *h264_context)
avc_ildb_context->urb.vfe_start = 0;
avc_ildb_context->urb.cs_start = avc_ildb_context->urb.vfe_start +
avc_ildb_context->urb.num_vfe_entries * avc_ildb_context->urb.size_vfe_entry;

#if !defined(I965_H264_ENABLE_CTG)
assert(avc_ildb_context->urb.cs_start +
avc_ildb_context->urb.num_cs_entries * avc_ildb_context->urb.size_cs_entry <= i965->intel.device_info->urb_size);
#endif

for (i = 0; i < NUM_AVC_ILDB_SURFACES; i++) {
dri_bo_unreference(avc_ildb_context->surface[i].s_bo);
Expand Down
1 change: 1 addition & 0 deletions src/i965_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define CMD_MEDIA_INTERFACE_DESCRIPTOR_LOAD CMD(2, 0, 2)
#define CMD_MEDIA_GATEWAY_STATE CMD(2, 0, 3)
#define CMD_MEDIA_STATE_FLUSH CMD(2, 0, 4)
#define CMD_MEDIA_OBJECT_PRT CMD(2, 1, 2)
#define CMD_MEDIA_OBJECT_WALKER CMD(2, 1, 3)

#define CMD_PIPELINED_POINTERS CMD(3, 0, 0)
Expand Down
3 changes: 3 additions & 0 deletions src/i965_device_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ static struct hw_codec_info g4x_hw_codec_info = {
.min_linear_hpitch = 4,

.has_mpeg2_decoding = 1,
#if defined(I965_H264_ENABLE_CTG)
.has_h264_decoding = 1,
#endif

.num_filters = 0,
};
Expand Down
31 changes: 28 additions & 3 deletions src/i965_drv_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -6274,7 +6274,17 @@ i965_GetSurfaceAttributes(
if (obj_config->profile == VAProfileMPEG2Simple ||
obj_config->profile == VAProfileMPEG2Main) {
attrib_list[i].value.value.i = VA_FOURCC_I420;
} else {
}
#if defined(I965_H264_ENABLE_CTG)
else if (obj_config->profile == VAProfileH264ConstrainedBaseline ||
obj_config->profile == VAProfileH264Main ||
obj_config->profile == VAProfileH264High)
{
attrib_list[i].value.value.i = VA_FOURCC_NV12;
}
#endif
else
{
assert(0);
attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
}
Expand Down Expand Up @@ -6306,12 +6316,27 @@ i965_GetSurfaceAttributes(
} else {
if (IS_G4X(i965->intel.device_info)) {
if (obj_config->profile == VAProfileMPEG2Simple ||
obj_config->profile == VAProfileMPEG2Main) {
obj_config->profile == VAProfileMPEG2Main)
{
if (attrib_list[i].value.value.i != VA_FOURCC_I420) {
attrib_list[i].value.value.i = 0;
attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
}
} else {
}
#if defined(I965_H264_ENABLE_CTG)
else if (obj_config->profile == VAProfileH264ConstrainedBaseline ||
obj_config->profile == VAProfileH264Main ||
obj_config->profile == VAProfileH264High)
{
if (attrib_list[i].value.value.i != VA_FOURCC_NV12)
{
attrib_list[i].value.value.i = 0;
attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
}
}
#endif
else
{
assert(0);
attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
}
Expand Down
4 changes: 4 additions & 0 deletions src/i965_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ g4x_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
case VAProfileH264ConstrainedBaseline:
case VAProfileH264Main:
case VAProfileH264High:
#if defined(I965_H264_ENABLE_CTG)
i965_media_h264_dec_context_init(ctx, media_context);
break;
#endif
case VAProfileVC1Simple:
case VAProfileVC1Main:
case VAProfileVC1Advanced:
Expand Down
5 changes: 5 additions & 0 deletions src/i965_media.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@

#include "i965_structs.h"

#if defined(I965_H264_ENABLE_CTG)
#define MAX_INTERFACE_DESC 32
#else
#define MAX_INTERFACE_DESC 16
#endif

#define MAX_MEDIA_SURFACES 34

struct decode_state;
Expand Down
Loading