2 * gstvaapisurfacepool.c - Gst VA surface pool
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
23 * SECTION:gstvaapisurfacepool
24 * @short_description: VA surface pool
28 #include "gstvaapisurfacepool.h"
29 #include "gstvaapisurface_userptr.h"
32 #include "gstvaapidebug.h"
36 gst_vaapi_surface_pool,
37 GST_VAAPI_TYPE_VIDEO_POOL);
39 #define GST_VAAPI_SURFACE_POOL_GET_PRIVATE(obj) \
40 (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
41 GST_VAAPI_TYPE_SURFACE_POOL, \
42 GstVaapiSurfacePoolPrivate))
44 struct _GstVaapiSurfacePoolPrivate {
45 GstVaapiChromaType chroma_type;
48 gboolean is_shared_buffer;
52 gst_vaapi_surface_pool_set_caps(GstVaapiVideoPool *pool, GstCaps *caps)
54 GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL(pool)->priv;
55 GstStructure *structure;
58 structure = gst_caps_get_structure(caps, 0);
59 gst_structure_get_int(structure, "width", &width);
60 gst_structure_get_int(structure, "height", &height);
62 if (gst_structure_has_name(structure, GST_VAAPI_BUFFER_SHARING_CAPS_NAME))
63 priv->is_shared_buffer = TRUE;
65 priv->is_shared_buffer = FALSE;
67 priv->chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
69 priv->height = height;
73 gst_vaapi_surface_pool_alloc_object(
74 GstVaapiVideoPool *pool,
75 GstVaapiDisplay *display
78 GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL(pool)->priv;
80 if (priv->is_shared_buffer)
81 return gst_vaapi_surface_userptr_new(display,
87 return gst_vaapi_surface_new(display,
94 gst_vaapi_surface_pool_finalize(GObject *object)
96 G_OBJECT_CLASS(gst_vaapi_surface_pool_parent_class)->finalize(object);
100 gst_vaapi_surface_pool_class_init(GstVaapiSurfacePoolClass *klass)
102 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
103 GstVaapiVideoPoolClass * const pool_class = GST_VAAPI_VIDEO_POOL_CLASS(klass);
105 g_type_class_add_private(klass, sizeof(GstVaapiSurfacePoolPrivate));
107 object_class->finalize = gst_vaapi_surface_pool_finalize;
109 pool_class->set_caps = gst_vaapi_surface_pool_set_caps;
110 pool_class->alloc_object = gst_vaapi_surface_pool_alloc_object;
114 gst_vaapi_surface_pool_init(GstVaapiSurfacePool *pool)
116 GstVaapiSurfacePoolPrivate *priv = GST_VAAPI_SURFACE_POOL_GET_PRIVATE(pool);
119 priv->chroma_type = 0;
122 priv->is_shared_buffer = FALSE;
126 * gst_vaapi_surface_pool_new:
127 * @display: a #GstVaapiDisplay
130 * Creates a new #GstVaapiVideoPool of #GstVaapiSurface with the
131 * specified dimensions in @caps.
133 * Return value: the newly allocated #GstVaapiVideoPool
136 gst_vaapi_surface_pool_new(GstVaapiDisplay *display, GstCaps *caps)
138 return g_object_new(GST_VAAPI_TYPE_SURFACE_POOL,