summaryrefslogtreecommitdiff
authorCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>2010-07-30 09:06:17 (GMT)
committer Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>2010-07-30 09:33:13 (GMT)
commit2d9132c590ca2ee54a03b44733a4d0544cb7ec6c (patch) (side-by-side diff)
treef2a544ec425ea7d5a68f139f91554ea90af2fa79
parentd82c4acd8a6f7580c3ff69a356920e51a8096423 (diff)
downloadgst-plugins-bad-2d9132c590ca2ee54a03b44733a4d0544cb7ec6c.zip
gst-plugins-bad-2d9132c590ca2ee54a03b44733a4d0544cb7ec6c.tar.gz
vdpau: add GstVdpOutputBufferPool
GstVdpVideoOutputPool is a subclass of GstVdpBufferPool that caches GstVdpOutputBuffers
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--sys/vdpau/gstvdp/Makefile.am2
-rw-r--r--sys/vdpau/gstvdp/gstvdpoutputbuffer.c21
-rw-r--r--sys/vdpau/gstvdp/gstvdpoutputbuffer.h5
-rw-r--r--sys/vdpau/gstvdp/gstvdpoutputbufferpool.c146
-rw-r--r--sys/vdpau/gstvdp/gstvdpoutputbufferpool.h50
-rw-r--r--sys/vdpau/gstvdp/gstvdpoutputsrcpad.c2
-rw-r--r--sys/vdpau/gstvdpsink.c2
7 files changed, 216 insertions, 12 deletions
diff --git a/sys/vdpau/gstvdp/Makefile.am b/sys/vdpau/gstvdp/Makefile.am
index c79ca55..3759690 100644
--- a/sys/vdpau/gstvdp/Makefile.am
+++ b/sys/vdpau/gstvdp/Makefile.am
@@ -8,6 +8,7 @@ libgstvdp_@GST_MAJORMINOR@_la_SOURCES = \
gstvdpvideobuffer.c \
gstvdpvideobufferpool.c \
gstvdpoutputbuffer.c \
+ gstvdpoutputbufferpool.c \
gstvdpvideosrcpad.c \
gstvdpoutputsrcpad.c \
gstvdpdecoder.c \
@@ -22,6 +23,7 @@ libgstvdp_@GST_MAJORMINOR@include_HEADERS = \
gstvdpvideobuffer.h \
gstvdpvideobufferpool.h \
gstvdpoutputbuffer.h \
+ gstvdpoutputbufferpool.h \
gstvdpvideosrcpad.h \
gstvdpoutputsrcpad.h \
gstvdpdecoder.h \
diff --git a/sys/vdpau/gstvdp/gstvdpoutputbuffer.c b/sys/vdpau/gstvdp/gstvdpoutputbuffer.c
index 04a3cb5..68c0cd0 100644
--- a/sys/vdpau/gstvdp/gstvdpoutputbuffer.c
+++ b/sys/vdpau/gstvdp/gstvdpoutputbuffer.c
@@ -32,7 +32,7 @@ GST_DEBUG_CATEGORY_INIT (gst_vdp_output_buffer_debug, "vdpoutputbuffer", 0, "VDP
GstVdpOutputBuffer *
gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
- gint width, gint height)
+ gint width, gint height, GError ** error)
{
GstVdpOutputBuffer *buffer;
VdpStatus status;
@@ -41,12 +41,8 @@ gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
status =
device->vdp_output_surface_create (device->device, rgba_format, width,
height, &surface);
- if (status != VDP_STATUS_OK) {
- GST_ERROR ("Couldn't create a VdpOutputSurface, error returned was: %s",
- device->vdp_get_error_string (status));
- return NULL;
- }
-
+ if (status != VDP_STATUS_OK)
+ goto create_error;
buffer =
(GstVdpOutputBuffer *) gst_mini_object_new (GST_TYPE_VDP_OUTPUT_BUFFER);
@@ -59,6 +55,12 @@ gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
buffer->surface = surface;
return buffer;
+
+create_error:
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
+ "Couldn't create a VdpOutputSurface, error returned from vdpau was: %s",
+ device->vdp_get_error_string (status));
+ return NULL;
}
static GObjectClass *gst_vdp_output_buffer_parent_class;
@@ -69,6 +71,9 @@ gst_vdp_output_buffer_finalize (GstVdpOutputBuffer * buffer)
GstVdpDevice *device;
VdpStatus status;
+ if (gst_vdp_buffer_revive (GST_VDP_BUFFER_CAST (buffer)))
+ return;
+
device = buffer->device;
status = device->vdp_output_surface_destroy (buffer->surface);
@@ -120,7 +125,7 @@ gst_vdp_output_buffer_get_type (void)
(GInstanceInitFunc) gst_vdp_output_buffer_init,
NULL
};
- _gst_vdp_output_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
+ _gst_vdp_output_buffer_type = g_type_register_static (GST_TYPE_VDP_BUFFER,
"GstVdpOutputBuffer", &info, 0);
DEBUG_INIT ();
diff --git a/sys/vdpau/gstvdp/gstvdpoutputbuffer.h b/sys/vdpau/gstvdp/gstvdpoutputbuffer.h
index be6a30e..4f2e561 100644
--- a/sys/vdpau/gstvdp/gstvdpoutputbuffer.h
+++ b/sys/vdpau/gstvdp/gstvdpoutputbuffer.h
@@ -23,6 +23,7 @@
#include <gst/gst.h>
+#include "gstvdpbuffer.h"
#include "gstvdpdevice.h"
typedef struct _GstVdpOutputBuffer GstVdpOutputBuffer;
@@ -32,7 +33,7 @@ typedef struct _GstVdpOutputBuffer GstVdpOutputBuffer;
#define GST_VDP_OUTPUT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_OUTPUT_BUFFER, GstVdpOutputBuffer))
struct _GstVdpOutputBuffer {
- GstBuffer buffer;
+ GstVdpBuffer vdp_buffer;
GstVdpDevice *device;
VdpRGBAFormat rgba_format;
@@ -43,7 +44,7 @@ struct _GstVdpOutputBuffer {
GType gst_vdp_output_buffer_get_type (void);
-GstVdpOutputBuffer* gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format, gint width, gint height);
+GstVdpOutputBuffer* gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format, gint width, gint height, GError **error);
GstCaps *gst_vdp_output_buffer_get_template_caps (void);
GstCaps *gst_vdp_output_buffer_get_allowed_caps (GstVdpDevice *device);
diff --git a/sys/vdpau/gstvdp/gstvdpoutputbufferpool.c b/sys/vdpau/gstvdp/gstvdpoutputbufferpool.c
new file mode 100644
index 0000000..826ef21
--- a/dev/null
+++ b/sys/vdpau/gstvdp/gstvdpoutputbufferpool.c
@@ -0,0 +1,146 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * gst-plugins-bad
+ * Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
+ *
+ * gst-plugins-bad 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gst-plugins-bad 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gstvdpdevice.h"
+#include "gstvdpoutputbuffer.h"
+
+#include "gstvdpoutputbufferpool.h"
+
+
+struct _GstVdpOutputBufferPool
+{
+ GstVdpBufferPool buffer_pool;
+
+ VdpRGBAFormat rgba_format;
+ guint width, height;
+};
+
+G_DEFINE_TYPE (GstVdpOutputBufferPool, gst_vdp_output_buffer_pool,
+ GST_TYPE_VDP_BUFFER_POOL);
+
+GstVdpBufferPool *
+gst_vdp_output_buffer_pool_new (GstVdpDevice * device)
+{
+ g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL);
+
+ return g_object_new (GST_TYPE_VDP_OUTPUT_BUFFER_POOL, "device", device, NULL);
+}
+
+static gboolean
+parse_caps (const GstCaps * caps, VdpChromaType * rgba_format, gint * width,
+ gint * height)
+{
+ GstStructure *structure;
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ if (!gst_structure_get_int (structure, "rgba-format", (gint *) rgba_format))
+ return FALSE;
+ if (!gst_structure_get_int (structure, "width", width))
+ return FALSE;
+ if (!gst_structure_get_int (structure, "height", height))
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+gst_vdp_output_buffer_pool_check_caps (GstVdpBufferPool * bpool,
+ const GstCaps * caps)
+{
+ GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool);
+
+ VdpChromaType rgba_format;
+ gint width, height;
+
+ if (!parse_caps (caps, &rgba_format, &width, &height))
+ return FALSE;
+
+ if (rgba_format != opool->rgba_format || width != opool->width ||
+ height != opool->height)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+gst_vdp_output_buffer_pool_set_caps (GstVdpBufferPool * bpool,
+ const GstCaps * caps, gboolean * clear_bufs)
+{
+ GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool);
+
+ VdpChromaType rgba_format;
+ gint width, height;
+
+ if (!parse_caps (caps, &rgba_format, &width, &height))
+ return FALSE;
+
+ if (rgba_format != opool->rgba_format || width != opool->width ||
+ height != opool->height)
+ *clear_bufs = TRUE;
+ else
+ *clear_bufs = FALSE;
+
+ opool->rgba_format = rgba_format;
+ opool->width = width;
+ opool->height = height;
+
+ return TRUE;
+}
+
+static GstVdpBuffer *
+gst_vdp_output_buffer_pool_alloc_buffer (GstVdpBufferPool * bpool,
+ GError ** error)
+{
+ GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool);
+ GstVdpDevice *device;
+
+ device = gst_vdp_buffer_pool_get_device (bpool);
+ return GST_VDP_BUFFER_CAST (gst_vdp_output_buffer_new (device,
+ opool->rgba_format, opool->width, opool->height, error));
+}
+
+static void
+gst_vdp_output_buffer_pool_finalize (GObject * object)
+{
+ /* TODO: Add deinitalization code here */
+
+ G_OBJECT_CLASS (gst_vdp_output_buffer_pool_parent_class)->finalize (object);
+}
+
+static void
+gst_vdp_output_buffer_pool_init (GstVdpOutputBufferPool * opool)
+{
+ opool->rgba_format = -1;
+ opool->width = 0;
+ opool->height = 0;
+}
+
+static void
+gst_vdp_output_buffer_pool_class_init (GstVdpOutputBufferPoolClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GstVdpBufferPoolClass *buffer_pool_class = GST_VDP_BUFFER_POOL_CLASS (klass);
+
+ buffer_pool_class->alloc_buffer = gst_vdp_output_buffer_pool_alloc_buffer;
+ buffer_pool_class->set_caps = gst_vdp_output_buffer_pool_set_caps;
+ buffer_pool_class->check_caps = gst_vdp_output_buffer_pool_check_caps;
+
+ object_class->finalize = gst_vdp_output_buffer_pool_finalize;
+}
diff --git a/sys/vdpau/gstvdp/gstvdpoutputbufferpool.h b/sys/vdpau/gstvdp/gstvdpoutputbufferpool.h
new file mode 100644
index 0000000..354461c
--- a/dev/null
+++ b/sys/vdpau/gstvdp/gstvdpoutputbufferpool.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * gst-plugins-bad
+ * Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
+ *
+ * gst-plugins-bad 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gst-plugins-bad 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GST_VDP_OUTPUT_BUFFER_POOL_H_
+#define _GST_VDP_OUTPUT_BUFFER_POOL_H_
+
+#include <gst/gst.h>
+
+#include "gstvdpbufferpool.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VDP_OUTPUT_BUFFER_POOL (gst_vdp_output_buffer_pool_get_type ())
+#define GST_VDP_OUTPUT_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPool))
+#define GST_VDP_OUTPUT_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPoolClass))
+#define GST_IS_VDP_OUTPUT_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL))
+#define GST_IS_VDP_OUTPUT_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_OUTPUT_BUFFER_POOL))
+#define GST_VDP_OUTPUT_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPoolClass))
+
+typedef struct _GstVdpOutputBufferPool GstVdpOutputBufferPool;
+typedef struct _GstVdpOutputBufferPoolClass GstVdpOutputBufferPoolClass;
+
+struct _GstVdpOutputBufferPoolClass
+{
+ GstVdpBufferPoolClass buffer_pool_class;
+};
+
+GstVdpBufferPool *gst_vdp_output_buffer_pool_new (GstVdpDevice *device);
+
+GType gst_vdp_output_buffer_pool_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* _GST_VDP_OUTPUT_BUFFER_POOL_H_ */
diff --git a/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c b/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c
index f2b3842..9813f68 100644
--- a/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c
+++ b/sys/vdpau/gstvdp/gstvdpoutputsrcpad.c
@@ -156,7 +156,7 @@ gst_vdp_output_src_pad_create_buffer (GstVdpOutputSrcPad * vdp_pad,
}
*output_buf = gst_vdp_output_buffer_new (vdp_pad->device,
- vdp_pad->rgba_format, vdp_pad->width, vdp_pad->height);
+ vdp_pad->rgba_format, vdp_pad->width, vdp_pad->height, NULL);
if (!*output_buf)
goto output_buf_error;
diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c
index 815c74d..933990f 100644
--- a/sys/vdpau/gstvdpsink.c
+++ b/sys/vdpau/gstvdpsink.c
@@ -912,7 +912,7 @@ gst_vdp_sink_get_output_buffer (VdpSink * vdp_sink, GstCaps * caps,
}
*buf = GST_BUFFER (gst_vdp_output_buffer_new (vdp_sink->device,
- rgba_format, width, height));
+ rgba_format, width, height, NULL));
if (*buf == NULL) {
return GST_FLOW_ERROR;
}