summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-07-10 14:20:30 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-07-10 17:03:47 +0200
commit1c9ebecb77027b7012e87330552c2214e54e0bad (patch)
tree2eb2a5f487a592026d6389b12110811e388b0b77
parent8663ad9492513f8b7715373b8bdd42670950af23 (diff)
surface: fix surface pool creation with an explicit pixel format.
Fix creation of surface pool objects to honour explicit pixel format specification. If this operation is not supported, then fallback to the older interface with chroma format.
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurfacepool.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapisurfacepool.c b/gst-libs/gst/vaapi/gstvaapisurfacepool.c
index 7f691540..a5dbbe0f 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfacepool.c
+++ b/gst-libs/gst/vaapi/gstvaapisurfacepool.c
@@ -42,6 +42,7 @@ struct _GstVaapiSurfacePool {
GstVaapiVideoPool parent_instance;
GstVaapiChromaType chroma_type;
+ GstVideoFormat format;
guint width;
guint height;
};
@@ -49,9 +50,19 @@ struct _GstVaapiSurfacePool {
static gboolean
surface_pool_init(GstVaapiSurfacePool *pool, const GstVideoInfo *vip)
{
- pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
- pool->width = GST_VIDEO_INFO_WIDTH(vip);
- pool->height = GST_VIDEO_INFO_HEIGHT(vip);
+ pool->format = GST_VIDEO_INFO_FORMAT(vip);
+ pool->width = GST_VIDEO_INFO_WIDTH(vip);
+ pool->height = GST_VIDEO_INFO_HEIGHT(vip);
+
+ if (pool->format == GST_VIDEO_FORMAT_UNKNOWN)
+ return FALSE;
+
+ if (pool->format == GST_VIDEO_FORMAT_ENCODED)
+ pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
+ else
+ pool->chroma_type = gst_video_format_get_chroma_type(pool->format);
+ if (!pool->chroma_type)
+ return FALSE;
return TRUE;
}
@@ -60,6 +71,15 @@ gst_vaapi_surface_pool_alloc_object(GstVaapiVideoPool *base_pool)
{
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
+ /* Try to allocate a surface with an explicit pixel format first */
+ if (pool->format != GST_VIDEO_FORMAT_ENCODED) {
+ GstVaapiSurface * const surface = gst_vaapi_surface_new_with_format(
+ base_pool->display, pool->format, pool->width, pool->height);
+ if (surface)
+ return surface;
+ }
+
+ /* Otherwise, fallback to the original interface, based on chroma format */
return gst_vaapi_surface_new(base_pool->display,
pool->chroma_type, pool->width, pool->height);
}