mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
plugins: allow creation of VA surfaces with explicit pixel format.
Adapt GstVaapiVideoMemory allocator to support creation of VA surfaces with an explicit pixel format. This allows for direct rendering to VA surface memory from a software decoder.
This commit is contained in:
parent
1c9ebecb77
commit
1cfe03ee52
1 changed files with 17 additions and 2 deletions
|
@ -67,9 +67,18 @@ ensure_image(GstVaapiVideoMemory *mem)
|
||||||
static GstVaapiSurface *
|
static GstVaapiSurface *
|
||||||
new_surface(GstVaapiDisplay *display, const GstVideoInfo *vip)
|
new_surface(GstVaapiDisplay *display, const GstVideoInfo *vip)
|
||||||
{
|
{
|
||||||
|
GstVaapiSurface *surface;
|
||||||
|
|
||||||
|
/* Try with explicit format first */
|
||||||
|
surface = gst_vaapi_surface_new_with_format(display,
|
||||||
|
GST_VIDEO_INFO_FORMAT(vip), GST_VIDEO_INFO_WIDTH(vip),
|
||||||
|
GST_VIDEO_INFO_HEIGHT(vip));
|
||||||
|
if (surface)
|
||||||
|
return surface;
|
||||||
|
|
||||||
|
/* Try to pick something compatible. Best bet: NV12 (YUV 4:2:0) */
|
||||||
if (GST_VIDEO_INFO_FORMAT(vip) != GST_VIDEO_FORMAT_NV12)
|
if (GST_VIDEO_INFO_FORMAT(vip) != GST_VIDEO_FORMAT_NV12)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return gst_vaapi_surface_new(display, GST_VAAPI_CHROMA_TYPE_YUV420,
|
return gst_vaapi_surface_new(display, GST_VAAPI_CHROMA_TYPE_YUV420,
|
||||||
GST_VIDEO_INFO_WIDTH(vip), GST_VIDEO_INFO_HEIGHT(vip));
|
GST_VIDEO_INFO_WIDTH(vip), GST_VIDEO_INFO_HEIGHT(vip));
|
||||||
}
|
}
|
||||||
|
@ -383,8 +392,14 @@ gst_vaapi_video_allocator_init(GstVaapiVideoAllocator *allocator)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_video_info_update_from_image(GstVideoInfo *vip, GstVaapiImage *image)
|
gst_video_info_update_from_image(GstVideoInfo *vip, GstVaapiImage *image)
|
||||||
{
|
{
|
||||||
|
GstVideoFormat format;
|
||||||
const guchar *data;
|
const guchar *data;
|
||||||
guint i, num_planes, data_size;
|
guint i, num_planes, data_size, width, height;
|
||||||
|
|
||||||
|
/* Reset format from image */
|
||||||
|
format = gst_vaapi_image_get_format(image);
|
||||||
|
gst_vaapi_image_get_size(image, &width, &height);
|
||||||
|
gst_video_info_set_format(vip, format, width, height);
|
||||||
|
|
||||||
num_planes = gst_vaapi_image_get_plane_count(image);
|
num_planes = gst_vaapi_image_get_plane_count(image);
|
||||||
g_return_val_if_fail(num_planes == GST_VIDEO_INFO_N_PLANES(vip), FALSE);
|
g_return_val_if_fail(num_planes == GST_VIDEO_INFO_N_PLANES(vip), FALSE);
|
||||||
|
|
Loading…
Reference in a new issue