msdk: support for MFX_FOURCC_BGR4 frame allocation

MFX_FOURCC_BGR4 is mapped to VA_FOURCC_ABGR and JPEG encoder needs a
MFX_FOURCC_BGR4 frame for internal usage when the input format is
MFX_FOURCC_RGB4

This is a preparation for supporting native formats of JPEG encoder
This commit is contained in:
Haihao Xiang 2019-10-09 13:41:09 +08:00 committed by Víctor Manuel Jáquez Leal
parent ef16d7558f
commit afce02b392
2 changed files with 27 additions and 6 deletions

View file

@ -46,7 +46,8 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
guint format;
guint va_fourcc = 0;
VASurfaceID *surfaces = NULL;
VASurfaceAttrib attrib;
VASurfaceAttrib attribs[2];
guint num_attribs = 0;
mfxMemId *mids = NULL;
GstMsdkContext *context = (GstMsdkContext *) pthis;
GstMsdkMemoryID *msdk_mids = NULL;
@ -98,10 +99,21 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
(GstMsdkAllocResponse *) g_slice_alloc0 (sizeof (GstMsdkAllocResponse));
if (va_fourcc != VA_FOURCC_P208) {
attrib.type = VASurfaceAttribPixelFormat;
attrib.flags = VA_SURFACE_ATTRIB_SETTABLE;
attrib.value.type = VAGenericValueTypeInteger;
attrib.value.value.i = va_fourcc;
attribs[0].type = VASurfaceAttribPixelFormat;
attribs[0].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[0].value.type = VAGenericValueTypeInteger;
attribs[0].value.value.i = va_fourcc;
num_attribs = 1;
/* set VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER flag for encoding */
if ((req->Type & MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET) &&
(req->Type & MFX_MEMTYPE_FROM_ENCODE)) {
attribs[1].type = VASurfaceAttribUsageHint;
attribs[1].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[1].value.type = VAGenericValueTypeInteger;
attribs[1].value.value.i = VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER;
num_attribs = 2;
}
format =
gst_msdk_get_va_rt_format_from_mfx_rt_format (req->Info.ChromaFormat);
@ -127,7 +139,8 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
va_status = vaCreateSurfaces (gst_msdk_context_get_handle (context),
format,
req->Info.Width, req->Info.Height, surfaces, surfaces_num, &attrib, 1);
req->Info.Width, req->Info.Height, surfaces, surfaces_num, attribs,
num_attribs);
status = gst_msdk_get_mfx_status_from_va_status (va_status);
if (status != MFX_ERR_NONE) {
@ -385,6 +398,13 @@ gst_msdk_frame_lock (mfxHDL pthis, mfxMemId mid, mfxFrameData * data)
data->U = buf + mem_id->image.offsets[0]; /* data->Y410 */
break;
#endif
case VA_FOURCC_ABGR:
data->Pitch = mem_id->image.pitches[0];
data->R = buf + mem_id->image.offsets[0];
data->G = data->R + 1;
data->B = data->R + 2;
data->A = data->R + 3;
break;
default:
g_assert_not_reached ();

View file

@ -73,6 +73,7 @@ static const struct fourcc_map gst_msdk_fourcc_mfx_to_va[] = {
FOURCC_MFX_TO_VA (Y210, Y210),
FOURCC_MFX_TO_VA (Y410, Y410),
#endif
FOURCC_MFX_TO_VA (BGR4, ABGR),
{0, 0}
};