surface: add new chroma formats.

Add new chroma formats available with VA-API >= 0.34.0. In particular,
this includes "RGB" chroma formats, and more YUV subsampled formats.
Also add a new from_GstVaapiChromaType() helper function to convert
libgstvaapi chroma type to VA chroma format.
This commit is contained in:
Gwenole Beauchesne 2013-07-09 19:13:39 +02:00
parent 60b003709f
commit d633e0d072
4 changed files with 71 additions and 17 deletions

View file

@ -102,27 +102,16 @@ gst_vaapi_surface_create(GstVaapiSurface *surface,
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(surface);
VASurfaceID surface_id;
VAStatus status;
guint format;
guint va_chroma_format;
switch (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", chroma_type);
return FALSE;
}
va_chroma_format = from_GstVaapiChromaType(chroma_type);
if (!va_chroma_format)
goto error_unsupported_chroma_type;
GST_VAAPI_DISPLAY_LOCK(display);
status = vaCreateSurfaces(
GST_VAAPI_DISPLAY_VADISPLAY(display),
width, height, format,
width, height, va_chroma_format,
1, &surface_id
);
GST_VAAPI_DISPLAY_UNLOCK(display);
@ -136,6 +125,11 @@ gst_vaapi_surface_create(GstVaapiSurface *surface,
GST_DEBUG("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(surface_id));
GST_VAAPI_OBJECT_ID(surface) = surface_id;
return TRUE;
/* ERRORS */
error_unsupported_chroma_type:
GST_ERROR("unsupported chroma-type %u", chroma_type);
return FALSE;
}
#define gst_vaapi_surface_finalize gst_vaapi_surface_destroy

View file

@ -56,13 +56,26 @@ G_BEGIN_DECLS
* @GST_VAAPI_CHROMA_TYPE_YUV420: 4:2:0 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV422: 4:2:2 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV444: 4:4:4 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV420: YUV 4:2:0 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV422: YUV 4:2:2 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV444: YUV 4:4:4 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV411: YUV 4:1:1 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV410: YUV 4:1:0 chroma format
* @GST_VAAPI_CHROMA_TYPE_YUV400: YUV 4:0:0 chroma format (grayscale)
* @GST_VAAPI_CHROMA_TYPE_RGB32: 32-bit RGB chroma format
* @GST_VAAPI_CHROMA_TYPE_RGB16: 16-bit RGB chroma format
*
* The set of all chroma types for #GstVaapiSurface.
*/
typedef enum {
GST_VAAPI_CHROMA_TYPE_YUV420 = 1,
GST_VAAPI_CHROMA_TYPE_YUV422,
GST_VAAPI_CHROMA_TYPE_YUV444
GST_VAAPI_CHROMA_TYPE_YUV444,
GST_VAAPI_CHROMA_TYPE_YUV411,
GST_VAAPI_CHROMA_TYPE_YUV410,
GST_VAAPI_CHROMA_TYPE_YUV400,
GST_VAAPI_CHROMA_TYPE_RGB32,
GST_VAAPI_CHROMA_TYPE_RGB16
} GstVaapiChromaType;
/**

View file

@ -203,6 +203,49 @@ string_of_VADisplayAttributeType(VADisplayAttribType attribute_type)
return "<unknown>";
}
/**
* from_GstVaapiChromaType:
* @chroma_type: the #GstVaapiChromaType
*
* Converts #GstVaapiChromaType to a chroma format suitable for
* vaCreateSurfaces().
*/
guint
from_GstVaapiChromaType(guint chroma_type)
{
guint format;
switch (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;
#if VA_CHECK_VERSION(0,34,0)
case GST_VAAPI_CHROMA_TYPE_YUV411:
format = VA_RT_FORMAT_YUV411;
break;
case GST_VAAPI_CHROMA_TYPE_YUV400:
format = VA_RT_FORMAT_YUV400;
break;
case GST_VAAPI_CHROMA_TYPE_RGB32:
format = VA_RT_FORMAT_RGB32;
break;
case GST_VAAPI_CHROMA_TYPE_RGB16:
format = VA_RT_FORMAT_RGB16;
break;
#endif
default:
format = 0;
break;
}
return format;
}
/**
* from_GstVaapiSubpictureFlags:
* @flags: the #GstVaapiSubpictureFlags

View file

@ -73,6 +73,10 @@ G_GNUC_INTERNAL
const char *
string_of_VADisplayAttributeType(VADisplayAttribType attribute_type);
G_GNUC_INTERNAL
guint
from_GstVaapiChromaType(guint chroma_type);
G_GNUC_INTERNAL
guint
from_GstVaapiSubpictureFlags(guint flags);