guint width;
guint height;
GstVaapiChromaType chroma_type;
+ guint32 fourcc;
GPtrArray *subpictures;
GstVaapiContext *parent_context;
};
PROP_WIDTH,
PROP_HEIGHT,
PROP_CHROMA_TYPE,
+ PROP_FOURCC,
PROP_PARENT_CONTEXT
};
VAStatus status;
guint format;
- switch (priv->chroma_type) {
- case GST_VAAPI_CHROMA_TYPE_YUV420:
+ switch (priv->fourcc) {
+ case VA_FOURCC_NV12:
+ case VA_FOURCC_YV12:
format = VA_RT_FORMAT_YUV420;
break;
- case GST_VAAPI_CHROMA_TYPE_YUV422:
+ case VA_FOURCC_YUY2:
+ case VA_FOURCC_UYVY:
format = VA_RT_FORMAT_YUV422;
break;
- case GST_VAAPI_CHROMA_TYPE_YUV444:
+ case VA_FOURCC_AYUV:
format = VA_RT_FORMAT_YUV444;
break;
+ case 0:
+ switch (priv->chroma_type) {
+ case GST_VAAPI_CHROMA_TYPE_YUV420:
+ format = VA_RT_FORMAT_YUV420;
+ break;
+ case GST_VAAPI_CHROMA_TYPE_YUV422:
+ format = VA_RT_FORMAT_YUV422;
+ break;
+ case GST_VAAPI_CHROMA_TYPE_YUV444:
+ format = VA_RT_FORMAT_YUV444;
+ break;
+ default:
+ GST_DEBUG("unsupported chroma-type %u\n", priv->chroma_type);
+ return FALSE;
+ }
+ break;
default:
- GST_DEBUG("unsupported chroma-type %u\n", priv->chroma_type);
- return FALSE;
+ break;
}
GST_VAAPI_DISPLAY_LOCK(display);
+#if VA_CHECK_VERSION(0,34,0)
+ VASurfaceAttrib *p_attrib = NULL;
+ int num_attrib = 0;
+ if(priv->fourcc) {
+ VASurfaceAttrib attrib;
+ attrib.flags = VA_SURFACE_ATTRIB_SETTABLE;
+ attrib.type = VASurfaceAttribPixelFormat;
+ attrib.value.type = VAGenericValueTypeInteger;
+ attrib.value.value.i = priv->fourcc;
+ p_attrib = &attrib;
+ num_attrib = 1;
+ }
+ status = vaCreateSurfaces(
+ GST_VAAPI_DISPLAY_VADISPLAY(display),
+ format,
+ priv->width,
+ priv->height,
+ &surface_id, 1,
+ p_attrib, num_attrib);
+#else
+ // I don't add VA_CHECK_VERSION for each place where fourcc is mentioned, but leave
+ // a warning here if it is used by mistake.
+ if (priv->fourcc) {
+ GST_WARNING("surface format are specified but not supported on your version of libva");
+ }
status = vaCreateSurfaces(
GST_VAAPI_DISPLAY_VADISPLAY(display),
priv->width,
priv->height,
format,
- 1, &surface_id
- );
+ 1, &surface_id);
+#endif
GST_VAAPI_DISPLAY_UNLOCK(display);
if (!vaapi_check_status(status, "vaCreateSurfaces()"))
return FALSE;
case PROP_CHROMA_TYPE:
priv->chroma_type = g_value_get_uint(value);
break;
+ case PROP_FOURCC:
+ priv->fourcc= g_value_get_uint(value);
+ break;
case PROP_PARENT_CONTEXT:
gst_vaapi_surface_set_parent_context(surface, g_value_get_object(value));
break;
g_object_class_install_property
(object_class,
+ PROP_FOURCC,
+ g_param_spec_uint("fourcc",
+ "fourcc",
+ "fourcc of the surface",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class,
PROP_PARENT_CONTEXT,
g_param_spec_object("parent-context",
"Parent Context",
"chroma-type", chroma_type,
NULL);
}
+/**
+ * gst_vaapi_surface_new_with_fourcc:
+ * @display: a #GstVaapiDisplay
+ * @fourcc: surface format
+ * @width: the requested surface width
+ * @height: the requested surface height
+ *
+ * Creates a new #GstVaapiSurface with the specified fourcc and
+ * dimensions.
+ *
+ * Return value: the newly allocated #GstVaapiSurface object
+ */
+GstVaapiSurface *
+gst_vaapi_surface_new_with_fourcc(
+ GstVaapiDisplay *display,
+ guint32 fourcc,
+ guint width,
+ guint height
+)
+{
+ GST_DEBUG("size %ux%u, fourcc 0x%x ", width, height, fourcc);
+
+ return g_object_new(GST_VAAPI_TYPE_SURFACE,
+ "display", display,
+ "id", GST_VAAPI_ID(VA_INVALID_ID),
+ "width", width,
+ "height", height,
+ "fourcc", fourcc,
+ NULL);
+}
/**
* gst_vaapi_surface_get_id: