libs: port to new video format API.

This commit is contained in:
Gwenole Beauchesne 2013-07-09 14:03:01 +02:00
parent 430598cf00
commit e61c5fc3d1
6 changed files with 84 additions and 84 deletions

View file

@ -59,7 +59,7 @@ struct _GstVaapiProperty {
typedef struct _GstVaapiFormatInfo GstVaapiFormatInfo;
struct _GstVaapiFormatInfo {
GstVaapiImageFormat format;
GstVideoFormat format;
guint flags;
};
@ -174,9 +174,9 @@ gst_vaapi_display_type_get_type(void)
return g_type;
}
/* Append GstVaapiImageFormat to formats array */
/* Append GstVideoFormat to formats array */
static inline void
append_format(GArray *formats, GstVaapiImageFormat format, guint flags)
append_format(GArray *formats, GstVideoFormat format, guint flags)
{
GstVaapiFormatInfo fi;
@ -190,7 +190,7 @@ static void
append_formats(GArray *formats, const VAImageFormat *va_formats,
guint *flags, guint n)
{
GstVaapiImageFormat format;
GstVideoFormat format;
const GstVaapiFormatInfo *YV12_fip = NULL;
const GstVaapiFormatInfo *I420_fip = NULL;
guint i;
@ -199,8 +199,8 @@ append_formats(GArray *formats, const VAImageFormat *va_formats,
const VAImageFormat * const va_format = &va_formats[i];
const GstVaapiFormatInfo **fipp;
format = gst_vaapi_image_format(va_format);
if (!format) {
format = gst_video_format_from_va_format(va_format);
if (format == GST_VIDEO_FORMAT_UNKNOWN) {
GST_DEBUG("unsupported format %" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS(va_format->fourcc));
continue;
@ -208,10 +208,10 @@ append_formats(GArray *formats, const VAImageFormat *va_formats,
append_format(formats, format, flags ? flags[i] : 0);
switch (format) {
case GST_VAAPI_IMAGE_YV12:
case GST_VIDEO_FORMAT_YV12:
fipp = &YV12_fip;
break;
case GST_VAAPI_IMAGE_I420:
case GST_VIDEO_FORMAT_I420:
fipp = &I420_fip;
break;
default:
@ -226,43 +226,43 @@ append_formats(GArray *formats, const VAImageFormat *va_formats,
/* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
supported by the underlying driver */
if (YV12_fip && !I420_fip)
append_format(formats, GST_VAAPI_IMAGE_I420, YV12_fip->flags);
append_format(formats, GST_VIDEO_FORMAT_I420, YV12_fip->flags);
else if (I420_fip && !YV12_fip)
append_format(formats, GST_VAAPI_IMAGE_YV12, I420_fip->flags);
append_format(formats, GST_VIDEO_FORMAT_YV12, I420_fip->flags);
}
/* Sort image formats. Prefer YUV formats first */
static gint
compare_yuv_formats(gconstpointer a, gconstpointer b)
{
const GstVaapiImageFormat fmt1 = ((GstVaapiFormatInfo *)a)->format;
const GstVaapiImageFormat fmt2 = ((GstVaapiFormatInfo *)b)->format;
const GstVideoFormat fmt1 = ((GstVaapiFormatInfo *)a)->format;
const GstVideoFormat fmt2 = ((GstVaapiFormatInfo *)b)->format;
const gboolean is_fmt1_yuv = gst_vaapi_image_format_is_yuv(fmt1);
const gboolean is_fmt2_yuv = gst_vaapi_image_format_is_yuv(fmt2);
const gboolean is_fmt1_yuv = gst_video_format_is_yuv(fmt1);
const gboolean is_fmt2_yuv = gst_video_format_is_yuv(fmt2);
if (is_fmt1_yuv != is_fmt2_yuv)
return is_fmt1_yuv ? -1 : 1;
return ((gint)gst_vaapi_image_format_get_score(fmt1) -
(gint)gst_vaapi_image_format_get_score(fmt2));
return ((gint)gst_video_format_get_score(fmt1) -
(gint)gst_video_format_get_score(fmt2));
}
/* Sort subpicture formats. Prefer RGB formats first */
static gint
compare_rgb_formats(gconstpointer a, gconstpointer b)
{
const GstVaapiImageFormat fmt1 = ((GstVaapiFormatInfo *)a)->format;
const GstVaapiImageFormat fmt2 = ((GstVaapiFormatInfo *)b)->format;
const GstVideoFormat fmt1 = ((GstVaapiFormatInfo *)a)->format;
const GstVideoFormat fmt2 = ((GstVaapiFormatInfo *)b)->format;
const gboolean is_fmt1_rgb = gst_vaapi_image_format_is_rgb(fmt1);
const gboolean is_fmt2_rgb = gst_vaapi_image_format_is_rgb(fmt2);
const gboolean is_fmt1_rgb = gst_video_format_is_rgb(fmt1);
const gboolean is_fmt2_rgb = gst_video_format_is_rgb(fmt2);
if (is_fmt1_rgb != is_fmt2_rgb)
return is_fmt1_rgb ? -1 : 1;
return ((gint)gst_vaapi_image_format_get_score(fmt1) -
(gint)gst_vaapi_image_format_get_score(fmt2));
return ((gint)gst_video_format_get_score(fmt1) -
(gint)gst_video_format_get_score(fmt2));
}
/* Check if configs array contains profile at entrypoint */
@ -343,7 +343,7 @@ get_profile_caps(GArray *configs)
/* Find format info */
static const GstVaapiFormatInfo *
find_format_info(GArray *formats, GstVaapiImageFormat format)
find_format_info(GArray *formats, GstVideoFormat format)
{
const GstVaapiFormatInfo *fip;
guint i;
@ -358,7 +358,7 @@ find_format_info(GArray *formats, GstVaapiImageFormat format)
/* Check if formats array contains format */
static inline gboolean
find_format(GArray *formats, GstVaapiImageFormat format)
find_format(GArray *formats, GstVideoFormat format)
{
return find_format_info(formats, format) != NULL;
}
@ -377,7 +377,7 @@ get_format_caps(GArray *formats)
for (i = 0; i < formats->len; i++) {
fip = &g_array_index(formats, GstVaapiFormatInfo, i);
caps = gst_vaapi_image_format_get_caps(fip->format);
caps = gst_video_format_to_caps(fip->format);
if (caps)
gst_caps_append(out_caps, caps);
}
@ -1360,7 +1360,7 @@ gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
/**
* gst_vaapi_display_has_image_format:
* @display: a #GstVaapiDisplay
* @format: a #GstVaapiFormat
* @format: a #GstVideoFormat
*
* Returns whether VA @display supports @format image format.
*
@ -1369,7 +1369,7 @@ gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
gboolean
gst_vaapi_display_has_image_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format
GstVideoFormat format
)
{
g_return_val_if_fail(display != NULL, FALSE);
@ -1412,7 +1412,7 @@ gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
/**
* gst_vaapi_display_has_subpicture_format:
* @display: a #GstVaapiDisplay
* @format: a #GstVaapiFormat
* @format: a #GstVideoFormat
* @flags_ptr: pointer to #GstVaapiSubpictureFlags, or zero
*
* Returns whether VA @display supports @format subpicture format with
@ -1423,7 +1423,7 @@ gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
gboolean
gst_vaapi_display_has_subpicture_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format,
GstVideoFormat format,
guint *flags_ptr
)
{

View file

@ -26,8 +26,8 @@
#include <va/va.h>
#include <gst/gst.h>
#include <gst/vaapi/gstvaapitypes.h>
#include <gst/vaapi/gstvaapiimageformat.h>
#include <gst/vaapi/gstvaapiprofile.h>
#include <gst/vaapi/video-format.h>
G_BEGIN_DECLS
@ -161,7 +161,7 @@ gst_vaapi_display_get_image_caps(GstVaapiDisplay *display);
gboolean
gst_vaapi_display_has_image_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format
GstVideoFormat format
);
GstCaps *
@ -170,7 +170,7 @@ gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display);
gboolean
gst_vaapi_display_has_subpicture_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format,
GstVideoFormat format,
guint *flags_ptr
);

View file

@ -49,8 +49,8 @@ struct _GstVaapiImage {
VAImage internal_image;
VAImage image;
guchar *image_data;
GstVaapiImageFormat internal_format;
GstVaapiImageFormat format;
GstVideoFormat internal_format;
GstVideoFormat format;
guint width;
guint height;
guint is_linear : 1;
@ -143,7 +143,7 @@ gst_vaapi_image_destroy(GstVaapiImage *image)
}
static gboolean
_gst_vaapi_image_create(GstVaapiImage *image, GstVaapiImageFormat format)
_gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format)
{
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_DISPLAY(image);
const VAImageFormat *va_format;
@ -152,7 +152,7 @@ _gst_vaapi_image_create(GstVaapiImage *image, GstVaapiImageFormat format)
if (!gst_vaapi_display_has_image_format(display, format))
return FALSE;
va_format = gst_vaapi_image_format_get_va_format(format);
va_format = gst_video_format_to_va_format(format);
if (!va_format)
return FALSE;
@ -174,7 +174,7 @@ _gst_vaapi_image_create(GstVaapiImage *image, GstVaapiImageFormat format)
}
static gboolean
gst_vaapi_image_create(GstVaapiImage *image, GstVaapiImageFormat format,
gst_vaapi_image_create(GstVaapiImage *image, GstVideoFormat format,
guint width, guint height)
{
const VAImageFormat *va_format;
@ -186,11 +186,11 @@ gst_vaapi_image_create(GstVaapiImage *image, GstVaapiImageFormat format,
if (!_gst_vaapi_image_create(image, format)) {
switch (format) {
case GST_VAAPI_IMAGE_I420:
format = GST_VAAPI_IMAGE_YV12;
case GST_VIDEO_FORMAT_I420:
format = GST_VIDEO_FORMAT_YV12;
break;
case GST_VAAPI_IMAGE_YV12:
format = GST_VAAPI_IMAGE_I420;
case GST_VIDEO_FORMAT_YV12:
format = GST_VIDEO_FORMAT_I420;
break;
default:
format = 0;
@ -204,9 +204,9 @@ gst_vaapi_image_create(GstVaapiImage *image, GstVaapiImageFormat format,
if (image->format != image->internal_format) {
switch (image->format) {
case GST_VAAPI_IMAGE_YV12:
case GST_VAAPI_IMAGE_I420:
va_format = gst_vaapi_image_format_get_va_format(image->format);
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_I420:
va_format = gst_video_format_to_va_format(image->format);
if (!va_format)
return FALSE;
image->image.format = *va_format;
@ -251,7 +251,7 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
/**
* gst_vaapi_image_new:
* @display: a #GstVaapiDisplay
* @format: a #GstVaapiImageFormat
* @format: a #GstVideoFormat
* @width: the requested image width
* @height: the requested image height
*
@ -263,7 +263,7 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE(
GstVaapiImage *
gst_vaapi_image_new(
GstVaapiDisplay *display,
GstVaapiImageFormat format,
GstVideoFormat format,
guint width,
guint height
)
@ -381,12 +381,12 @@ gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image)
gboolean
_gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
{
GstVaapiImageFormat format;
GstVideoFormat format;
VAImage alt_va_image;
const VAImageFormat *alt_va_format;
format = gst_vaapi_image_format(&va_image->format);
if (!format)
format = gst_video_format_from_va_format(&va_image->format);
if (format == GST_VIDEO_FORMAT_UNKNOWN)
return FALSE;
image->internal_image = *va_image;
@ -402,18 +402,18 @@ _gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
/* Try to linearize image */
if (!image->is_linear) {
switch (format) {
case GST_VAAPI_IMAGE_I420:
format = GST_VAAPI_IMAGE_YV12;
case GST_VIDEO_FORMAT_I420:
format = GST_VIDEO_FORMAT_YV12;
break;
case GST_VAAPI_IMAGE_YV12:
format = GST_VAAPI_IMAGE_I420;
case GST_VIDEO_FORMAT_YV12:
format = GST_VIDEO_FORMAT_I420;
break;
default:
format = 0;
break;
}
if (format &&
(alt_va_format = gst_vaapi_image_format_get_va_format(format))) {
(alt_va_format = gst_video_format_to_va_format(format))) {
alt_va_image = *va_image;
alt_va_image.format = *alt_va_format;
SWAP_UINT(alt_va_image.offsets[1], alt_va_image.offsets[2]);
@ -434,11 +434,11 @@ _gst_vaapi_image_set_image(GstVaapiImage *image, const VAImage *va_image)
* gst_vaapi_image_get_format:
* @image: a #GstVaapiImage
*
* Returns the #GstVaapiImageFormat the @image was created with.
* Returns the #GstVideoFormat the @image was created with.
*
* Return value: the #GstVaapiImageFormat
* Return value: the #GstVideoFormat
*/
GstVaapiImageFormat
GstVideoFormat
gst_vaapi_image_get_format(GstVaapiImage *image)
{
g_return_val_if_fail(image != NULL, 0);
@ -737,7 +737,7 @@ init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
{
GstStructure *structure;
GstCaps *caps;
GstVaapiImageFormat format;
GstVideoFormat format;
guint width2, height2, size2;
gint width, height;
guchar *data;
@ -750,7 +750,7 @@ init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
if (!caps)
return FALSE;
format = gst_vaapi_image_format_from_caps(caps);
format = gst_video_format_from_caps(caps);
structure = gst_caps_get_structure(caps, 0);
gst_structure_get_int(structure, "width", &width);
@ -764,7 +764,7 @@ init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
height2 = (height + 1) / 2;
size2 = 0;
switch (format) {
case GST_VAAPI_IMAGE_NV12:
case GST_VIDEO_FORMAT_NV12:
raw_image->num_planes = 2;
raw_image->pixels[0] = data;
raw_image->stride[0] = GST_ROUND_UP_4(width);
@ -773,8 +773,8 @@ init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
raw_image->stride[1] = raw_image->stride[0];
size2 += height2 * raw_image->stride[1];
break;
case GST_VAAPI_IMAGE_YV12:
case GST_VAAPI_IMAGE_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_I420:
raw_image->num_planes = 3;
raw_image->pixels[0] = data;
raw_image->stride[0] = GST_ROUND_UP_4(width);
@ -786,10 +786,10 @@ init_image_from_buffer(GstVaapiImageRaw *raw_image, GstBuffer *buffer)
raw_image->stride[2] = raw_image->stride[1];
size2 += height2 * raw_image->stride[2];
break;
case GST_VAAPI_IMAGE_ARGB:
case GST_VAAPI_IMAGE_RGBA:
case GST_VAAPI_IMAGE_ABGR:
case GST_VAAPI_IMAGE_BGRA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_ABGR:
case GST_VIDEO_FORMAT_BGRA:
raw_image->num_planes = 1;
raw_image->pixels[0] = data;
raw_image->stride[0] = width * 4;
@ -937,17 +937,17 @@ copy_image(
}
switch (dst_image->format) {
case GST_VAAPI_IMAGE_NV12:
case GST_VIDEO_FORMAT_NV12:
copy_image_NV12(dst_image, src_image, rect);
break;
case GST_VAAPI_IMAGE_YV12:
case GST_VAAPI_IMAGE_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_I420:
copy_image_YV12(dst_image, src_image, rect);
break;
case GST_VAAPI_IMAGE_ARGB:
case GST_VAAPI_IMAGE_RGBA:
case GST_VAAPI_IMAGE_ABGR:
case GST_VAAPI_IMAGE_BGRA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_ABGR:
case GST_VIDEO_FORMAT_BGRA:
copy_image_RGBA(dst_image, src_image, rect);
break;
default:

View file

@ -26,7 +26,7 @@
#include <gst/gstbuffer.h>
#include <gst/vaapi/gstvaapiobject.h>
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapiimageformat.h>
#include <gst/vaapi/video-format.h>
G_BEGIN_DECLS
@ -37,7 +37,7 @@ G_BEGIN_DECLS
* GST_VAAPI_IMAGE_FORMAT:
* @image: a #GstVaapiImage
*
* Macro that evaluates to the #GstVaapiImageFormat of @image.
* Macro that evaluates to the #GstVideoFormat of @image.
*/
#define GST_VAAPI_IMAGE_FORMAT(image) gst_vaapi_image_get_format(image)
@ -67,7 +67,7 @@ typedef struct _GstVaapiImageRaw GstVaapiImageRaw;
* the fields with sensible values.
*/
struct _GstVaapiImageRaw {
GstVaapiImageFormat format;
GstVideoFormat format;
guint width;
guint height;
guint num_planes;
@ -78,7 +78,7 @@ struct _GstVaapiImageRaw {
GstVaapiImage *
gst_vaapi_image_new(
GstVaapiDisplay *display,
GstVaapiImageFormat format,
GstVideoFormat format,
guint width,
guint height
);
@ -92,7 +92,7 @@ gst_vaapi_image_get_id(GstVaapiImage *image);
gboolean
gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image);
GstVaapiImageFormat
GstVideoFormat
gst_vaapi_image_get_format(GstVaapiImage *image);
guint

View file

@ -41,7 +41,7 @@ struct _GstVaapiImagePool {
/*< private >*/
GstVaapiVideoPool parent_instance;
GstVaapiImageFormat format;
GstVideoFormat format;
guint width;
guint height;
};
@ -55,7 +55,7 @@ gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *base_pool, GstCaps *caps)
if (!gst_video_info_from_caps(&vi, caps))
return FALSE;
pool->format = gst_vaapi_image_format_from_video(GST_VIDEO_INFO_FORMAT(&vi));
pool->format = GST_VIDEO_INFO_FORMAT(&vi);
pool->width = GST_VIDEO_INFO_WIDTH(&vi);
pool->height = GST_VIDEO_INFO_HEIGHT(&vi);
return TRUE;

View file

@ -132,7 +132,7 @@ gst_vaapi_subpicture_new(GstVaapiImage *image, guint flags)
{
GstVaapiSubpicture *subpicture;
GstVaapiDisplay *display;
GstVaapiImageFormat format;
GstVideoFormat format;
guint va_flags;
g_return_val_if_fail(image != NULL, NULL);
@ -180,7 +180,7 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
)
{
GstVaapiSubpicture *subpicture;
GstVaapiImageFormat format;
GstVideoFormat format;
GstVaapiImage *image;
GstVaapiImageRaw raw_image;
GstBuffer *buffer;
@ -197,9 +197,9 @@ gst_vaapi_subpicture_new_from_overlay_rectangle(
/* XXX: use gst_vaapi_image_format_from_video() */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
format = GST_VAAPI_IMAGE_BGRA;
format = GST_VIDEO_FORMAT_BGRA;
#else
format = GST_VAAPI_IMAGE_ARGB;
format = GST_VIDEO_FORMAT_ARGB;
#endif
if (!gst_vaapi_display_has_subpicture_format(display, format, &hw_flags))
return NULL;