plugins: fix gst_vaapi_video_meta_new_from_pool().

Since GST_VAAPI_IS_xxx_VIDEO_POOL() was only testing for NULL and not
the underlying object type, the gst_vaapi_video_meta_new_from_pool()
was hereby totally broken. Fixed this regression by using the newly
provided gst_vaapi_video_pool_get_object_type() function.
This commit is contained in:
Gwenole Beauchesne 2013-05-23 18:56:43 +02:00
parent e52ea35b11
commit 35eaa9e763

View file

@ -61,6 +61,19 @@ set_image(GstVaapiVideoMeta *meta, GstVaapiImage *image)
set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(image))); set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(image)));
} }
static gboolean
set_image_from_pool(GstVaapiVideoMeta *meta, GstVaapiVideoPool *pool)
{
GstVaapiImage *image;
image = gst_vaapi_video_pool_get_object(pool);
if (!image)
return FALSE;
set_image(meta, image);
meta->image_pool = gst_vaapi_video_pool_ref(pool);
return TRUE;
}
static inline void static inline void
set_surface(GstVaapiVideoMeta *meta, GstVaapiSurface *surface) set_surface(GstVaapiVideoMeta *meta, GstVaapiSurface *surface)
{ {
@ -68,6 +81,19 @@ set_surface(GstVaapiVideoMeta *meta, GstVaapiSurface *surface)
set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface))); set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface)));
} }
static gboolean
set_surface_from_pool(GstVaapiVideoMeta *meta, GstVaapiVideoPool *pool)
{
GstVaapiSurface *surface;
surface = gst_vaapi_video_pool_get_object(pool);
if (!surface)
return FALSE;
set_surface(meta, surface);
meta->surface_pool = gst_vaapi_video_pool_ref(pool);
return TRUE;
}
static void static void
gst_vaapi_video_meta_destroy_image(GstVaapiVideoMeta *meta) gst_vaapi_video_meta_destroy_image(GstVaapiVideoMeta *meta)
{ {
@ -252,18 +278,22 @@ gst_vaapi_video_meta_new_from_pool(GstVaapiVideoPool *pool)
{ {
GstVaapiVideoMeta *meta; GstVaapiVideoMeta *meta;
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL); g_return_val_if_fail(pool != NULL, NULL);
meta = _gst_vaapi_video_meta_new(); meta = _gst_vaapi_video_meta_new();
if (G_UNLIKELY(!meta)) if (G_UNLIKELY(!meta))
return NULL; return NULL;
if (!(GST_VAAPI_IS_IMAGE_POOL(pool) && switch (gst_vaapi_video_pool_get_object_type(pool)) {
gst_vaapi_video_meta_set_image_from_pool(meta, pool)) && case GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE:
!(GST_VAAPI_IS_SURFACE_POOL(pool) && if (!set_image_from_pool(meta, pool))
gst_vaapi_video_meta_set_surface_from_pool(meta, pool)))
goto error; goto error;
break;
case GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE:
if (!set_surface_from_pool(meta, pool))
goto error;
break;
}
set_display(meta, gst_vaapi_video_pool_get_display(pool)); set_display(meta, gst_vaapi_video_pool_get_display(pool));
return meta; return meta;
@ -492,21 +522,14 @@ gboolean
gst_vaapi_video_meta_set_image_from_pool(GstVaapiVideoMeta *meta, gst_vaapi_video_meta_set_image_from_pool(GstVaapiVideoMeta *meta,
GstVaapiVideoPool *pool) GstVaapiVideoPool *pool)
{ {
GstVaapiImage *image;
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_META(meta), FALSE); g_return_val_if_fail(GST_VAAPI_IS_VIDEO_META(meta), FALSE);
g_return_val_if_fail(GST_VAAPI_IS_IMAGE_POOL(pool), FALSE); g_return_val_if_fail(pool != NULL, FALSE);
g_return_val_if_fail(gst_vaapi_video_pool_get_object_type(pool) ==
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE, FALSE);
gst_vaapi_video_meta_destroy_image(meta); gst_vaapi_video_meta_destroy_image(meta);
if (pool) { return set_image_from_pool(meta, pool);
image = gst_vaapi_video_pool_get_object(pool);
if (!image)
return FALSE;
set_image(meta, image);
meta->image_pool = gst_vaapi_video_pool_ref(pool);
}
return TRUE;
} }
/** /**
@ -564,21 +587,14 @@ gboolean
gst_vaapi_video_meta_set_surface_from_pool(GstVaapiVideoMeta *meta, gst_vaapi_video_meta_set_surface_from_pool(GstVaapiVideoMeta *meta,
GstVaapiVideoPool *pool) GstVaapiVideoPool *pool)
{ {
GstVaapiSurface *surface;
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_META(meta), FALSE); g_return_val_if_fail(GST_VAAPI_IS_VIDEO_META(meta), FALSE);
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_POOL(pool), FALSE); g_return_val_if_fail(pool != NULL, FALSE);
g_return_val_if_fail(gst_vaapi_video_pool_get_object_type(pool) ==
GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_SURFACE, FALSE);
gst_vaapi_video_meta_destroy_surface(meta); gst_vaapi_video_meta_destroy_surface(meta);
if (pool) { return set_surface_from_pool(meta, pool);
surface = gst_vaapi_video_pool_get_object(pool);
if (!surface)
return FALSE;
set_surface(meta, surface);
meta->surface_pool = gst_vaapi_video_pool_ref(pool);
}
return TRUE;
} }
/** /**