2010-03-12 17:45:18 +00:00
|
|
|
/*
|
|
|
|
* gstvaapisurfacepool.c - Gst VA surface pool
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-01-29 13:00:04 +00:00
|
|
|
* Copyright (C) 2012 Intel Corporation
|
2010-03-12 17:45:18 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-03-12 17:45:18 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-12 17:45:18 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-06-14 11:51:41 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-12 17:45:18 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
2010-03-12 17:45:18 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-19 16:08:48 +00:00
|
|
|
/**
|
2010-03-24 08:16:32 +00:00
|
|
|
* SECTION:gstvaapisurfacepool
|
|
|
|
* @short_description: VA surface pool
|
2010-03-19 16:08:48 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2010-03-12 17:45:18 +00:00
|
|
|
#include "gstvaapisurfacepool.h"
|
2013-05-03 09:01:12 +00:00
|
|
|
#include "gstvaapivideopool_priv.h"
|
2010-03-12 17:45:18 +00:00
|
|
|
|
|
|
|
#define DEBUG 1
|
2010-03-16 09:17:41 +00:00
|
|
|
#include "gstvaapidebug.h"
|
2010-03-12 17:45:18 +00:00
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
/**
|
|
|
|
* GstVaapiSurfacePool:
|
|
|
|
*
|
|
|
|
* A pool of lazily allocated #GstVaapiSurface objects.
|
|
|
|
*/
|
|
|
|
struct _GstVaapiSurfacePool {
|
|
|
|
/*< private >*/
|
|
|
|
GstVaapiVideoPool parent_instance;
|
2010-03-12 17:45:18 +00:00
|
|
|
|
|
|
|
GstVaapiChromaType chroma_type;
|
|
|
|
guint width;
|
|
|
|
guint height;
|
|
|
|
};
|
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *base_pool, GstCaps *caps)
|
2010-03-12 17:45:18 +00:00
|
|
|
{
|
2013-05-03 09:01:12 +00:00
|
|
|
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
2010-03-12 23:47:47 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
gint width, height;
|
2010-03-12 17:45:18 +00:00
|
|
|
|
2010-03-12 23:47:47 +00:00
|
|
|
structure = gst_caps_get_structure(caps, 0);
|
|
|
|
gst_structure_get_int(structure, "width", &width);
|
|
|
|
gst_structure_get_int(structure, "height", &height);
|
2010-03-12 17:45:18 +00:00
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
pool->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
|
|
|
pool->width = width;
|
|
|
|
pool->height = height;
|
|
|
|
return TRUE;
|
2010-03-12 17:45:18 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
static gpointer
|
|
|
|
gst_vaapi_surface_pool_alloc_object(GstVaapiVideoPool *base_pool)
|
2010-03-12 17:45:18 +00:00
|
|
|
{
|
2013-05-03 09:01:12 +00:00
|
|
|
GstVaapiSurfacePool * const pool = GST_VAAPI_SURFACE_POOL(base_pool);
|
2010-03-12 17:45:18 +00:00
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
return gst_vaapi_surface_new(base_pool->display,
|
|
|
|
pool->chroma_type, pool->width, pool->height);
|
2010-03-12 17:45:18 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
static inline const GstVaapiMiniObjectClass *
|
|
|
|
gst_vaapi_surface_pool_class(void)
|
2010-03-12 17:45:18 +00:00
|
|
|
{
|
2013-05-03 09:01:12 +00:00
|
|
|
static const GstVaapiVideoPoolClass GstVaapiSurfacePoolClass = {
|
|
|
|
{ sizeof(GstVaapiSurfacePool),
|
|
|
|
(GDestroyNotify)gst_vaapi_video_pool_finalize },
|
2010-03-12 17:45:18 +00:00
|
|
|
|
2013-05-03 09:01:12 +00:00
|
|
|
.alloc_object = gst_vaapi_surface_pool_alloc_object
|
|
|
|
};
|
|
|
|
return GST_VAAPI_MINI_OBJECT_CLASS(&GstVaapiSurfacePoolClass);
|
2010-03-12 17:45:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 16:08:48 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_surface_pool_new:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @caps: a #GstCaps
|
|
|
|
*
|
|
|
|
* Creates a new #GstVaapiVideoPool of #GstVaapiSurface with the
|
|
|
|
* specified dimensions in @caps.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiVideoPool
|
|
|
|
*/
|
2010-03-12 23:47:47 +00:00
|
|
|
GstVaapiVideoPool *
|
2010-03-12 17:45:18 +00:00
|
|
|
gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
|
|
|
|
{
|
2013-05-03 09:01:12 +00:00
|
|
|
GstVaapiVideoPool *pool;
|
|
|
|
|
|
|
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
|
|
|
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
|
|
|
|
|
|
|
|
pool = (GstVaapiVideoPool *)
|
|
|
|
gst_vaapi_mini_object_new(gst_vaapi_surface_pool_class());
|
|
|
|
if (!pool)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
gst_vaapi_video_pool_init(pool, display);
|
|
|
|
if (!gst_vaapi_surface_pool_set_caps(pool, caps))
|
|
|
|
goto error;
|
|
|
|
return pool;
|
|
|
|
|
|
|
|
error:
|
|
|
|
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(pool));
|
|
|
|
return NULL;
|
2010-03-12 17:45:18 +00:00
|
|
|
}
|