gstmsdkvpp: add RGBP and BGRP in src pad

It requires MFX version 2.4+

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2234>
This commit is contained in:
Haihao Xiang 2021-05-11 14:07:14 +08:00
parent d4f8e3cf53
commit 04de66ee7b
6 changed files with 75 additions and 1 deletions

View file

@ -151,6 +151,12 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
format = VA_RT_FORMAT_YUV444_12;
#endif
#if (MFX_VERSION >= 2004)
if (format == VA_RT_FORMAT_YUV444 && (va_fourcc == VA_FOURCC_RGBP
|| va_fourcc == VA_FOURCC_BGRP))
format = VA_RT_FORMAT_RGBP;
#endif
va_status = vaCreateSurfaces (gst_msdk_context_get_handle (context),
format,
req->Info.Width, req->Info.Height, surfaces, surfaces_num, attribs,
@ -437,6 +443,21 @@ gst_msdk_frame_lock (mfxHDL pthis, mfxMemId mid, mfxFrameData * data)
data->A = data->R + 3;
break;
#if (MFX_VERSION >= 2004)
case VA_FOURCC_RGBP:
data->Pitch = mem_id->image.pitches[0];
data->R = buf + mem_id->image.offsets[0];
data->G = buf + mem_id->image.offsets[1];
data->B = buf + mem_id->image.offsets[2];
break;
case VA_FOURCC_BGRP:
data->Pitch = mem_id->image.pitches[0];
data->B = buf + mem_id->image.offsets[0];
data->G = buf + mem_id->image.offsets[1];
data->R = buf + mem_id->image.offsets[2];
break;
#endif
default:
g_assert_not_reached ();
break;
@ -619,6 +640,16 @@ gst_msdk_export_dmabuf_to_vasurface (GstMsdkContext * context,
va_chroma = VA_RT_FORMAT_YUV444_12;
va_fourcc = VA_FOURCC_Y416;
break;
#endif
#if (MFX_VERSION >= 2004)
case GST_VIDEO_FORMAT_RGBP:
va_chroma = VA_RT_FORMAT_RGBP;
va_fourcc = VA_FOURCC_RGBP;
break;
case GST_VIDEO_FORMAT_BGRP:
va_chroma = VA_RT_FORMAT_RGBP;
va_fourcc = VA_FOURCC_BGRP;
break;
#endif
default:
goto error_unsupported_format;

View file

@ -160,6 +160,20 @@ ensure_data (GstMsdkSystemMemory * mem)
mem->surface->Data.A = mem->surface->Data.U + 6;
mem->surface->Data.Pitch = mem->destination_pitches[0];
break;
#if (MFX_VERSION >= 2004)
case GST_VIDEO_FORMAT_RGBP:
mem->surface->Data.Pitch = mem->destination_pitches[0];
mem->surface->Data.R = mem->cached_data[0];
mem->surface->Data.G = mem->cached_data[1];
mem->surface->Data.B = mem->cached_data[2];
break;
case GST_VIDEO_FORMAT_BGRP:
mem->surface->Data.Pitch = mem->destination_pitches[0];
mem->surface->Data.B = mem->cached_data[0];
mem->surface->Data.G = mem->cached_data[1];
mem->surface->Data.R = mem->cached_data[2];
break;
#endif
default:
g_assert_not_reached ();
@ -266,6 +280,14 @@ gst_msdk_system_memory_map_full (GstMemory * base_mem, GstMapInfo * info,
return mem->surface->Data.U; /* The first channel is U */
#endif
#if (MFX_VERSION >= 2004)
case MFX_FOURCC_RGBP:
return mem->surface->Data.R;
case MFX_FOURCC_BGRP:
return mem->surface->Data.B;
#endif
default:
return mem->surface->Data.Y;
}

View file

@ -332,6 +332,14 @@ gst_msdk_video_memory_map_full (GstMemory * base_mem, GstMapInfo * info,
return mem->surface->Data.U;
#endif
#if (MFX_VERSION >= 2004)
case MFX_FOURCC_RGBP:
return mem->surface->Data.R;
case MFX_FOURCC_BGRP:
return mem->surface->Data.B;
#endif
default:
return mem->surface->Data.Y;
}

View file

@ -70,7 +70,10 @@
#endif
#endif
#if (MFX_VERSION >= 1032)
#if (MFX_VERSION >= 2004)
#define EXT_SINK_FORMATS ", RGB16, Y410, Y210"
#define EXT_SRC_FORMATS ", YV12, Y410, Y210, RGBP, BGRP"
#elif (MFX_VERSION >= 1032)
#define EXT_SINK_FORMATS ", RGB16, Y410, Y210"
#define EXT_SRC_FORMATS ", YV12, Y410, Y210"
#elif (MFX_VERSION >= 1028)

View file

@ -74,6 +74,10 @@ static const struct map gst_msdk_video_format_to_mfx_map[] = {
GST_VIDEO_INFO_TO_MFX_MAP (Y212_LE, YUV422, Y216),
/* Y416 is used for 12bit 4:4:4:4 format in MSDK */
GST_VIDEO_INFO_TO_MFX_MAP (Y412_LE, YUV444, Y416),
#endif
#if (MFX_VERSION >=2004)
GST_VIDEO_INFO_TO_MFX_MAP (RGBP, YUV444, RGBP),
GST_VIDEO_INFO_TO_MFX_MAP (BGRP, YUV444, BGRP),
#endif
{0, 0, 0}
};

View file

@ -79,6 +79,12 @@ static const struct fourcc_map gst_msdk_fourcc_mfx_to_va[] = {
FOURCC_MFX_TO_VA (Y410, Y410),
#endif
FOURCC_MFX_TO_VA (BGR4, ABGR),
#if (MFX_VERSION >= 2004)
FOURCC_MFX_TO_VA (RGBP, RGBP),
FOURCC_MFX_TO_VA (BGRP, BGRP),
#endif
{0, 0}
};