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;
+ };
+}
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 */