diff options
author | gb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969> | 2010-03-12 23:47:47 +0000 |
---|---|---|
committer | gb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969> | 2010-03-12 23:47:47 +0000 |
commit | 809933a46ba7354824bb2a82cdb8e431217e201c (patch) | |
tree | 5597e923462f0ff58505c5177f87a8d4ab0ddcfc /gst-libs/gst/vaapi/gstvaapiimagepool.c | |
parent | 56827ae5b62cad497cf242a80ca16430e2ad0d08 (diff) |
Add GstVaapiImagePool and factor out GstVaapiSurfacePool from a base GstVaapiVideoPool.
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapiimagepool.c')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiimagepool.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiimagepool.c b/gst-libs/gst/vaapi/gstvaapiimagepool.c new file mode 100644 index 00000000..9d7170d8 --- /dev/null +++ b/gst-libs/gst/vaapi/gstvaapiimagepool.c @@ -0,0 +1,111 @@ +/* + * gstvaapiimagepool.c - Gst VA image pool + * + * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "gstvaapiimagepool.h" + +#define DEBUG 1 +#include "vaapi_debug.h" + +G_DEFINE_TYPE( + GstVaapiImagePool, + gst_vaapi_image_pool, + GST_VAAPI_TYPE_VIDEO_POOL); + +#define GST_VAAPI_IMAGE_POOL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + GST_VAAPI_TYPE_IMAGE_POOL, \ + GstVaapiImagePoolPrivate)) + +struct _GstVaapiImagePoolPrivate { + GstVaapiImageFormat format; + guint width; + guint height; +}; + +static void +gst_vaapi_image_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps) +{ + GstVaapiImagePoolPrivate * const priv = GST_VAAPI_IMAGE_POOL(pool)->priv; + GstStructure *structure; + gint width, height; + + structure = gst_caps_get_structure(caps, 0); + gst_structure_get_int(structure, "width", &width); + gst_structure_get_int(structure, "height", &height); + + priv->format = gst_vaapi_image_format_from_caps(caps); + priv->width = width; + priv->height = height; +} + +gpointer +gst_vaapi_image_pool_alloc_object( + GstVaapiVideoPool *pool, + GstVaapiDisplay *display +) +{ + GstVaapiImagePoolPrivate * const priv = GST_VAAPI_IMAGE_POOL(pool)->priv; + + return gst_vaapi_image_new(display, + priv->format, + priv->width, + priv->height); +} + +static void +gst_vaapi_image_pool_finalize(GObject *object) +{ + G_OBJECT_CLASS(gst_vaapi_image_pool_parent_class)->finalize(object); +} + +static void +gst_vaapi_image_pool_class_init(GstVaapiImagePoolClass *klass) +{ + GObjectClass * const object_class = G_OBJECT_CLASS(klass); + GstVaapiVideoPoolClass * const pool_class = GST_VAAPI_VIDEO_POOL_CLASS(klass); + + g_type_class_add_private(klass, sizeof(GstVaapiImagePoolPrivate)); + + object_class->finalize = gst_vaapi_image_pool_finalize; + + pool_class->set_caps = gst_vaapi_image_pool_set_caps; + pool_class->alloc_object = gst_vaapi_image_pool_alloc_object; +} + +static void +gst_vaapi_image_pool_init(GstVaapiImagePool *pool) +{ + GstVaapiImagePoolPrivate *priv = GST_VAAPI_IMAGE_POOL_GET_PRIVATE(pool); + + pool->priv = priv; + priv->format = 0; + priv->width = 0; + priv->height = 0; +} + +GstVaapiVideoPool * +gst_vaapi_image_pool_new(GstVaapiDisplay *display, GstCaps *caps) +{ + return g_object_new(GST_VAAPI_TYPE_IMAGE_POOL, + "display", display, + "caps", caps, + NULL); +} |