mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-09 05:38:58 +00:00
surface pool config based on video info
First added the function gst_vaapi_video_format_get_best_native(), which returns the best native format that matches a particular chroma type: YUV 4:2:0 -> NV12, YUV 4:2:2 -> YUY2, YUV 4:0:0 -> Y800 RGB32 chroma and encoded format map to NV12 too. That format is used to configure, initially, the surface's pool for the allocator. Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> https://bugzilla.gnome.org/show_bug.cgi?id=744042
This commit is contained in:
parent
940dc1a18e
commit
ceb70c3ca6
3 changed files with 38 additions and 1 deletions
|
@ -270,3 +270,35 @@ gst_vaapi_video_format_get_score (GstVideoFormat format)
|
|||
|
||||
return m ? (m - &gst_vaapi_video_formats[0]) : G_MAXUINT;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_video_format_get_best_native:
|
||||
* @format: a #GstVideoFormat
|
||||
*
|
||||
* Returns the best "native" pixel format that matches a particular
|
||||
* color-space.
|
||||
*
|
||||
* Returns: the #GstVideoFormat with the corresponding best native
|
||||
* format for #GstVaapiSurface
|
||||
**/
|
||||
GstVideoFormat
|
||||
gst_vaapi_video_format_get_best_native (GstVideoFormat format)
|
||||
{
|
||||
GstVaapiChromaType chroma_type;
|
||||
|
||||
if (format == GST_VIDEO_FORMAT_ENCODED)
|
||||
return GST_VIDEO_FORMAT_NV12;
|
||||
|
||||
chroma_type = gst_vaapi_video_format_get_chroma_type (format);
|
||||
switch (chroma_type) {
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV422:
|
||||
return GST_VIDEO_FORMAT_YUY2;
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV400:
|
||||
return GST_VIDEO_FORMAT_GRAY8;
|
||||
case GST_VAAPI_CHROMA_TYPE_YUV420:
|
||||
case GST_VAAPI_CHROMA_TYPE_RGB32: /* GstVideoGLTextureUploadMeta */
|
||||
return GST_VIDEO_FORMAT_NV12;
|
||||
default:
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ gst_vaapi_video_format_get_chroma_type (GstVideoFormat format);
|
|||
guint
|
||||
gst_vaapi_video_format_get_score (GstVideoFormat format);
|
||||
|
||||
GstVideoFormat
|
||||
gst_vaapi_video_format_get_best_native (GstVideoFormat format);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_VIDEO_FORMAT_H */
|
||||
|
|
|
@ -659,10 +659,12 @@ allocator_configure_surface_info (GstVaapiDisplay * display,
|
|||
GstVaapiSurface *surface = NULL;
|
||||
GstVaapiImage *image = NULL;
|
||||
gboolean updated;
|
||||
GstVideoFormat fmt;
|
||||
|
||||
vinfo = &allocator->video_info;
|
||||
|
||||
gst_video_info_set_format (&allocator->surface_info, GST_VIDEO_FORMAT_NV12,
|
||||
fmt = gst_vaapi_video_format_get_best_native (GST_VIDEO_INFO_FORMAT (vinfo));
|
||||
gst_video_info_set_format (&allocator->surface_info, fmt,
|
||||
GST_VIDEO_INFO_WIDTH (vinfo), GST_VIDEO_INFO_HEIGHT (vinfo));
|
||||
|
||||
/* nothing to configure */
|
||||
|
|
Loading…
Reference in a new issue