summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9bf29a2)
raw | patch | inline | side by side (parent: 9bf29a2)
author | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Tue, 24 Apr 2012 15:07:15 +0000 (15:07 +0000) | ||
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Wed, 9 May 2012 18:40:47 +0000 (18:40 +0000) |
src/Makefile.am | patch | blob | history | |
src/gstducati.c | patch | blob | history | |
src/gstducati.h | patch | blob | history | |
src/gstducatibuffer.c | [new file with mode: 0644] | patch | blob |
src/gstducatibuffer.h | [new file with mode: 0644] | patch | blob |
src/gstducatibufferpool.c | patch | blob | history | |
src/gstducatibufferpool.h | patch | blob | history | |
src/gstducatidrmbuffer.c | [new file with mode: 0644] | patch | blob |
src/gstducatidrmbuffer.h | [new file with mode: 0644] | patch | blob |
src/gstducatividdec.c | patch | blob | history | |
src/gstducatividdec.h | patch | blob | history |
diff --git a/src/Makefile.am b/src/Makefile.am
index 6a942ada2438b1c244fca9e6dd254e46eee5f7d1..eaa8cf1c4ca12b5a42e2ec7c5a7b800dd995e5e7 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
gstducatimpeg4enc.h \
gstducatividenc.h \
gstducatibufferpool.h \
+ gstducatibuffer.h \
+ gstducatidrmbuffer.h \
gstducati.h
# sources used to compile this plug-in
gstducatih264dec.c \
gstducatividdec.c \
gstducatibufferpool.c \
+ gstducatibuffer.c \
+ gstducatidrmbuffer.c \
gstducati.c \
$(noinst_HEADERS)
diff --git a/src/gstducati.c b/src/gstducati.c
index c1fd4ec7eee427c326df7b292113d1a55366ab9d..41d4201a35945e7c32043c0eb6c316e0ea7ed2da 100644 (file)
--- a/src/gstducati.c
+++ b/src/gstducati.c
#endif
}
-void *
-gst_ducati_alloc_1d (gint sz)
-{
- MemAllocBlock block = {
- .pixelFormat = PIXEL_FMT_PAGE,
- .dim.len = sz,
- };
- return MemMgr_Alloc (&block, 1);
-}
-
-void *
-gst_ducati_alloc_2d (gint width, gint height, guint * sz)
-{
- MemAllocBlock block[] = { {
- .pixelFormat = PIXEL_FMT_8BIT,
- .dim = {.area = {
- .width = width,
- .height = ALIGN2 (height, 1),
- }},
- .stride = 4096}, {
- .pixelFormat = PIXEL_FMT_16BIT,
- .dim = {.area = {
- .width = width,
- .height = ALIGN2 (height, 1) / 2,
- }},
- .stride = 4096}
- };
- if (sz) {
- *sz = (4096 * ALIGN2 (height, 1) * 3) / 2;
- }
- return MemMgr_Alloc (block, 2);
-}
-
-XDAS_Int16
-gst_ducati_get_mem_type (SSPtr paddr)
-{
- XDAS_Int16 type = -1;
-
- if ((0x60000000 <= paddr) && (paddr < 0x68000000))
- type = XDM_MEMTYPE_TILED8;
- else if ((0x68000000 <= paddr) && (paddr < 0x70000000))
- type = XDM_MEMTYPE_TILED16;
- else if ((0x70000000 <= paddr) && (paddr < 0x78000000))
- type = XDM_MEMTYPE_TILED32;
- else if ((0x78000000 <= paddr) && (paddr < 0x80000000))
- type = XDM_MEMTYPE_TILEDPAGE;
-
- return type;
-}
-
/* PACKAGE: this is usually set by autotools depending on some _INIT macro
* in configure.ac and then written into and defined in config.h, but we can
* just set it ourselves here in case someone doesn't use autotools to
diff --git a/src/gstducati.h b/src/gstducati.h
index 157d2931733eed700f95915011883befa120b286..7223b8156257504997ace5b68b474e6697db0404 100644 (file)
--- a/src/gstducati.h
+++ b/src/gstducati.h
#include <stdint.h>
#include <string.h>
-#include <tiler.h>
-#include <tilermem.h>
-#include <memmgr.h>
#include <dce.h>
#include <xdc/std.h>
#include <ti/sdo/ce/Engine.h>
/* align x to next highest multiple of 2^n */
#define ALIGN2(x,n) (((x) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
-void * gst_ducati_alloc_1d (gint sz);
-void * gst_ducati_alloc_2d (gint width, gint height, guint * sz);
-XDAS_Int16 gst_ducati_get_mem_type (SSPtr paddr);
-
G_END_DECLS
#endif /* __GST_DUCATI_H__ */
diff --git a/src/gstducatibuffer.c b/src/gstducatibuffer.c
--- /dev/null
+++ b/src/gstducatibuffer.c
@@ -0,0 +1,138 @@
+/*
+ * GStreamer
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Copyright (C) 2012 Collabora Ltd
+ *
+ * Authors:
+ * Alessandro Decina <alessandro.decina@collabora.co.uk>
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * 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
+ */
+
+#include "gstducatibuffer.h"
+#include "gstducatibufferpool.h"
+
+G_DEFINE_TYPE (GstDucatiBuffer, gst_ducati_buffer, GST_TYPE_BUFFER);
+G_DEFINE_TYPE (GstDucatiBufferAllocator, gst_ducati_buffer_allocator,
+ GST_TYPE_MINI_OBJECT);
+
+GstDucatiBuffer *
+gst_ducati_buffer_new (GstDucatiBufferPool * pool)
+{
+ GstDucatiBuffer *self = (GstDucatiBuffer *)
+ gst_mini_object_new (GST_TYPE_DUCATI_BUFFER);
+ gst_ducati_buffer_set_pool (self, pool);
+
+ return self;
+}
+
+void
+gst_ducati_buffer_set_pool (GstDucatiBuffer * self, GstDucatiBufferPool * pool)
+{
+
+ GST_LOG_OBJECT (pool->element, "creating buffer %p in pool %p", self, pool);
+
+ self->pool = (GstDucatiBufferPool *)
+ gst_mini_object_ref (GST_MINI_OBJECT (pool));
+ self->remove_from_pool = FALSE;
+
+ if (pool->caps)
+ gst_buffer_set_caps (GST_BUFFER (self), pool->caps);
+}
+
+static void
+gst_ducati_buffer_finalize (GstDucatiBuffer * self)
+{
+ GstDucatiBufferPool *pool = self->pool;
+ gboolean resuscitated = FALSE;
+
+ GST_LOG_OBJECT (pool->element, "finalizing buffer %p", self);
+
+ resuscitated = gst_ducati_buffer_pool_put (pool, self);
+ if (resuscitated)
+ return;
+
+ if (self->orig) {
+ gst_buffer_unref (self->orig);
+ self->orig = NULL;
+ }
+
+ GST_BUFFER_DATA (self) = NULL;
+ gst_mini_object_unref (GST_MINI_OBJECT (pool));
+
+ GST_MINI_OBJECT_CLASS (gst_ducati_buffer_parent_class)->finalize
+ (GST_MINI_OBJECT (self));
+}
+
+static void
+gst_ducati_buffer_class_init (GstDucatiBufferClass * klass)
+{
+ GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass);
+
+ mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
+ GST_DEBUG_FUNCPTR (gst_ducati_buffer_finalize);
+}
+
+static void
+gst_ducati_buffer_init (GstDucatiBuffer * buffer)
+{
+}
+
+/* Get the original buffer, or whatever is the best output buffer.
+ * Consumes the input reference, produces the output reference
+ */
+GstBuffer *
+gst_ducati_buffer_get (GstDucatiBuffer * self)
+{
+ if (self->orig) {
+ // TODO copy to orig buffer.. if needed.
+ gst_buffer_unref (self->orig);
+ self->orig = NULL;
+ }
+ return GST_BUFFER (self);
+}
+
+/* GstDucatiBufferAllocator */
+
+GstDucatiBufferAllocator *
+gst_ducati_buffer_allocator_new (void)
+{
+ GstDucatiBufferAllocator *self = (GstDucatiBufferAllocator *)
+ gst_mini_object_new (GST_TYPE_DUCATI_BUFFER_ALLOCATOR);
+
+ return self;
+}
+
+static void
+gst_ducati_buffer_allocator_finalize (GstDucatiBufferAllocator * self)
+{
+ GST_MINI_OBJECT_CLASS (gst_ducati_buffer_allocator_parent_class)->finalize
+ (GST_MINI_OBJECT (self));
+}
+
+static void
+gst_ducati_buffer_allocator_class_init (GstDucatiBufferAllocatorClass * klass)
+{
+ GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass);
+
+ mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
+ GST_DEBUG_FUNCPTR (gst_ducati_buffer_allocator_finalize);
+}
+
+static void
+gst_ducati_buffer_allocator_init (GstDucatiBufferAllocator * buffer)
+{
+}
diff --git a/src/gstducatibuffer.h b/src/gstducatibuffer.h
--- /dev/null
+++ b/src/gstducatibuffer.h
@@ -0,0 +1,92 @@
+/*
+ * GStreamer
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Copyright (C) 2012 Collabora Ltd
+ *
+ * Authors:
+ * Alessandro Decina <alessandro.decina@collabora.co.uk>
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * 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
+ */
+
+#ifndef __GSTDUCATIBUFFER_H__
+#define __GSTDUCATIBUFFER_H__
+
+#include "gstducati.h"
+#include <gst/video/video.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_DUCATI_BUFFER (gst_ducati_buffer_get_type())
+#define GST_IS_DUCATI_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATI_BUFFER))
+#define GST_DUCATI_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATI_BUFFER, GstDucatiBuffer))
+
+#define GST_TYPE_DUCATI_BUFFER_ALLOCATOR (gst_ducati_buffer_allocator_get_type())
+#define GST_IS_DUCATI_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATI_BUFFER_ALLOCATOR))
+#define GST_DUCATI_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATI_BUFFER_ALLOCATOR, GstDucatiBufferAllocator))
+#define GST_DUCATI_BUFFER_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DUCATI_BUFFER_ALLOCATOR, GstDucatiBufferAllocatorClass))
+#define GST_DUCATI_BUFFER_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DUCATI_BUFFER_ALLOCATOR, GstDucatiBufferAllocatorClass))
+
+typedef struct _GstDucatiBufferAllocator GstDucatiBufferAllocator;
+typedef struct _GstDucatiBufferAllocatorClass GstDucatiBufferAllocatorClass;
+typedef struct _GstDucatiBuffer GstDucatiBuffer;
+typedef struct _GstDucatiBufferClass GstDucatiBufferClass;
+
+/* forward declaration */
+struct _GstDucatiBufferPool;
+
+struct _GstDucatiBufferAllocator
+{
+ GstMiniObject mini_object;
+};
+
+struct _GstDucatiBufferAllocatorClass
+{
+ GstMiniObjectClass klass;
+
+ GstBuffer *(*alloc) (GstDucatiBufferAllocator * self,
+ struct _GstDucatiBufferPool * pool);
+ gboolean (*check_compatible) (GstDucatiBufferAllocator * allocator,
+ GstBuffer * buffer);
+ void (*setup_codec_output_buffers) (GstDucatiBufferAllocator * allocator,
+ GstVideoFormat format, int width, int height, int stride, GstBuffer * buf,
+ XDM2_BufDesc * bufs);
+};
+
+struct _GstDucatiBuffer {
+ GstBuffer parent;
+
+ struct _GstDucatiBufferPool *pool; /* buffer-pool that this buffer belongs to */
+ GstBuffer *orig; /* original buffer, if we need to copy output */
+ GstDucatiBuffer *next; /* next in freelist, if not in use */
+ gboolean remove_from_pool;
+};
+
+struct _GstDucatiBufferClass {
+ GstBufferClass klass;
+};
+
+GType gst_ducati_buffer_allocator_get_type (void);
+GstDucatiBufferAllocator *gst_ducati_buffer_allocator_new (void);
+
+GType gst_ducati_buffer_get_type (void);
+GstDucatiBuffer *gst_ducati_buffer_new (struct _GstDucatiBufferPool * pool);
+void gst_ducati_buffer_set_pool (GstDucatiBuffer * self, struct _GstDucatiBufferPool * pool);
+GstBuffer * gst_ducati_buffer_get (GstDucatiBuffer * self);
+
+G_END_DECLS
+
+#endif /* __GSTDUCATIBUFFER_H__ */
index 6e8b3db15a6108d11c25c81905c92957f02417c6..e815a31f6b4259af3337354c7e1c3b3c0b7fb901 100644 (file)
*/
#include "gstducatibufferpool.h"
+#include <string.h>
-/*
- * GstDucatiBuffer
- */
-
-static GstBufferClass *buffer_parent_class;
-
-/* Get the original buffer, or whatever is the best output buffer.
- * Consumes the input reference, produces the output reference
- */
-GstBuffer *
-gst_ducati_buffer_get (GstDucatiBuffer * self)
-{
- if (self->orig) {
- // TODO copy to orig buffer.. if needed.
- gst_buffer_unref (self->orig);
- self->orig = NULL;
- }
- return GST_BUFFER (self);
-}
-
-static GstDucatiBuffer *
-gst_ducati_buffer_new (GstDucatiBufferPool * pool)
-{
- GstDucatiBuffer *self = (GstDucatiBuffer *)
- gst_mini_object_new (GST_TYPE_DUCATIBUFFER);
- guint sz;
- void *buf;
-
- GST_LOG_OBJECT (pool->element, "creating buffer %p in pool %p", self, pool);
-
- self->pool = (GstDucatiBufferPool *)
- gst_mini_object_ref (GST_MINI_OBJECT (pool));
-
- if (pool->strided) {
- buf = gst_ducati_alloc_2d (pool->padded_width, pool->padded_height, &sz);
- } else {
- sz = pool->size;
- buf = gst_ducati_alloc_1d (sz);
- }
-
- GST_BUFFER_DATA (self) = buf;
- GST_BUFFER_SIZE (self) = sz;
-
- if (pool->caps)
- gst_buffer_set_caps (GST_BUFFER (self), pool->caps);
-
- return self;
-}
-
-static void
-gst_ducati_buffer_finalize (GstDucatiBuffer * self)
-{
- GstDucatiBufferPool *pool = self->pool;
- gboolean resuscitated = FALSE;
-
- GST_LOG_OBJECT (pool->element, "finalizing buffer %p", self);
-
- if (self->orig) {
- gst_buffer_unref (self->orig);
- self->orig = NULL;
- }
-
- GST_DUCATI_BUFFERPOOL_LOCK (pool);
- if (pool->running) {
- resuscitated = TRUE;
-
- GST_LOG_OBJECT (pool->element, "reviving buffer %p", self);
- gst_buffer_ref (GST_BUFFER (self));
-
- /* insert self into freelist */
- self->next = pool->freelist;
- pool->freelist = self;
- } else {
- GST_LOG_OBJECT (pool->element, "the pool is shutting down");
- }
- GST_DUCATI_BUFFERPOOL_UNLOCK (pool);
-
- if (!resuscitated) {
- GST_LOG_OBJECT (pool->element,
- "buffer %p (data %p, len %u) not recovered, freeing",
- self, GST_BUFFER_DATA (self), GST_BUFFER_SIZE (self));
- MemMgr_Free ((void *) GST_BUFFER_DATA (self));
- GST_BUFFER_DATA (self) = NULL;
- gst_mini_object_unref (GST_MINI_OBJECT (pool));
- GST_MINI_OBJECT_CLASS (buffer_parent_class)->finalize (GST_MINI_OBJECT
- (self));
- }
-}
-
-static void
-gst_ducati_buffer_class_init (gpointer g_class, gpointer class_data)
-{
- GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
+G_DEFINE_TYPE (GstDucatiBufferPool, gst_ducati_buffer_pool,
+ GST_TYPE_MINI_OBJECT);
- buffer_parent_class = g_type_class_peek_parent (g_class);
-
- mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
- GST_DEBUG_FUNCPTR (gst_ducati_buffer_finalize);
-}
-
-GType
-gst_ducati_buffer_get_type (void)
-{
- static GType type;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo info = {
- .class_size = sizeof (GstBufferClass),
- .class_init = gst_ducati_buffer_class_init,
- .instance_size = sizeof (GstDucatiBuffer),
- };
- type = g_type_register_static (GST_TYPE_BUFFER,
- "GstDucatiBuffer", &info, 0);
- }
- return type;
-}
-
-/*
- * GstDucatiBufferPool
- */
-
-static GstMiniObjectClass *bufferpool_parent_class = NULL;
-
-/** create new bufferpool */
GstDucatiBufferPool *
-gst_ducati_bufferpool_new (GstElement * element, GstCaps * caps, guint size)
+gst_ducati_buffer_pool_new (GstElement * element,
+ GstDucatiBufferAllocator * allocator, GstCaps * caps, guint size)
{
GstDucatiBufferPool *self = (GstDucatiBufferPool *)
- gst_mini_object_new (GST_TYPE_DUCATIBUFFERPOOL);
+ gst_mini_object_new (GST_TYPE_DUCATI_BUFFER_POOL);
+ int i;
self->element = gst_object_ref (element);
+ self->allocator =
+ GST_DUCATI_BUFFER_ALLOCATOR (gst_mini_object_ref (GST_MINI_OBJECT
+ (allocator)));
self->caps = NULL;
- gst_ducati_bufferpool_set_caps (self, caps);
+ gst_ducati_buffer_pool_set_caps (self, caps);
self->size = size;
- self->freelist = NULL;
+ self->head = NULL;
+ self->tail = NULL;
self->lock = g_mutex_new ();
self->running = TRUE;
+
+ for (i = 0; i < 5; i++) {
+ GstDucatiBuffer *tmp = gst_ducati_buffer_pool_get (self, NULL, TRUE);
+ gst_buffer_unref (GST_BUFFER_CAST (tmp));
+ }
+
return self;
}
void
-gst_ducati_bufferpool_set_caps (GstDucatiBufferPool * self, GstCaps * caps)
+gst_ducati_buffer_pool_set_caps (GstDucatiBufferPool * self, GstCaps * caps)
{
gst_caps_replace (&self->caps, caps);
if (caps) {
/** destroy existing bufferpool */
void
-gst_ducati_bufferpool_destroy (GstDucatiBufferPool * self)
+gst_ducati_buffer_pool_destroy (GstDucatiBufferPool * self)
{
g_return_if_fail (self);
- GST_DUCATI_BUFFERPOOL_LOCK (self);
+ GST_DUCATI_BUFFER_POOL_LOCK (self);
self->running = FALSE;
GST_DEBUG_OBJECT (self->element, "destroy pool");
/* free all buffers on the freelist */
- while (self->freelist) {
- GstDucatiBuffer *buf = self->freelist;
- self->freelist = buf->next;
+ while (self->head) {
+ GstDucatiBuffer *buf = self->head;
+ self->head = buf->next;
buf->next = NULL;
GST_DEBUG_OBJECT (self, "unreffing %p from freelist", buf);
- GST_DUCATI_BUFFERPOOL_UNLOCK (self);
+ GST_DUCATI_BUFFER_POOL_UNLOCK (self);
gst_buffer_unref (GST_BUFFER (buf));
- GST_DUCATI_BUFFERPOOL_LOCK (self);
+ GST_DUCATI_BUFFER_POOL_LOCK (self);
}
- GST_DUCATI_BUFFERPOOL_UNLOCK (self);
+ self->tail = NULL;
+ GST_DUCATI_BUFFER_POOL_UNLOCK (self);
gst_mini_object_unref (GST_MINI_OBJECT (self));
}
+#if 0
+static void
+dump_list (GstDucatiBufferPool * pool, GstDucatiBuffer * buf)
+{
+ GST_ERROR_OBJECT (pool->element, "LIST");
+ while (buf) {
+ GST_ERROR_OBJECT (pool->element, "BUF: %p", buf);
+ buf = buf->next;
+ }
+}
+#endif
+
/** get buffer from bufferpool, allocate new buffer if needed */
GstDucatiBuffer *
-gst_ducati_bufferpool_get (GstDucatiBufferPool * self, GstBuffer * orig)
+gst_ducati_buffer_pool_get (GstDucatiBufferPool * self, GstBuffer * orig,
+ gboolean force_alloc)
{
GstDucatiBuffer *buf = NULL;
g_return_val_if_fail (self, NULL);
- GST_DUCATI_BUFFERPOOL_LOCK (self);
+ GST_DUCATI_BUFFER_POOL_LOCK (self);
if (self->running) {
/* re-use a buffer off the freelist if any are available
*/
- if (self->freelist) {
- buf = self->freelist;
- self->freelist = buf->next;
+ if (!force_alloc && self->head) {
+// dump_list (self, self->head);
+ buf = self->head;
+ self->head = buf->next;
+ if (self->head == NULL)
+ self->tail = NULL;
} else {
- buf = gst_ducati_buffer_new (self);
+ GstDucatiBufferAllocatorClass *alloc_class;
+
+ alloc_class = GST_DUCATI_BUFFER_ALLOCATOR_GET_CLASS (self->allocator);
+ buf = GST_DUCATI_BUFFER (alloc_class->alloc (self->allocator, self));
}
buf->orig = orig;
if (self->caps)
gst_buffer_set_caps (GST_BUFFER (buf), self->caps);
}
- GST_DUCATI_BUFFERPOOL_UNLOCK (self);
+ GST_DUCATI_BUFFER_POOL_UNLOCK (self);
if (buf && orig) {
GST_BUFFER_TIMESTAMP (buf) = GST_BUFFER_TIMESTAMP (orig);
GST_BUFFER_DURATION (buf) = GST_BUFFER_DURATION (orig);
}
+ GST_LOG_OBJECT (self->element, "returning buf %p", buf);
+
return buf;
}
+gboolean
+gst_ducati_buffer_pool_put (GstDucatiBufferPool * self, GstDucatiBuffer * buf)
+{
+ gboolean reuse = FALSE;
+
+ if (buf->remove_from_pool)
+ return FALSE;
+
+ GST_DUCATI_BUFFER_POOL_LOCK (self);
+ if (self->running) {
+ reuse = TRUE;
+
+ GST_LOG_OBJECT (self->element, "reviving buffer %p", buf);
+ gst_buffer_ref (GST_BUFFER (buf));
+
+ buf->next = NULL;
+ if (self->tail)
+ self->tail->next = buf;
+ self->tail = buf;
+ if (self->head == NULL)
+ self->head = self->tail;
+ buf->remove_from_pool = FALSE;
+ } else {
+ GST_INFO_OBJECT (self->element, "the pool is shutting down");
+ buf->remove_from_pool = TRUE;
+ }
+ GST_DUCATI_BUFFER_POOL_UNLOCK (self);
+
+ return reuse;
+}
static void
-gst_ducati_bufferpool_finalize (GstDucatiBufferPool * self)
+gst_ducati_buffer_pool_finalize (GstDucatiBufferPool * self)
{
g_mutex_free (self->lock);
if (self->caps)
gst_caps_unref (self->caps);
gst_object_unref (self->element);
- GST_MINI_OBJECT_CLASS (bufferpool_parent_class)->finalize (GST_MINI_OBJECT
- (self));
+ gst_mini_object_unref (GST_MINI_OBJECT (self->allocator));
+ GST_MINI_OBJECT_CLASS (gst_ducati_buffer_pool_parent_class)->finalize
+ (GST_MINI_OBJECT (self));
}
static void
-gst_ducati_bufferpool_class_init (gpointer g_class, gpointer class_data)
+gst_ducati_buffer_pool_class_init (GstDucatiBufferPoolClass * klass)
{
- GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
-
- bufferpool_parent_class = g_type_class_peek_parent (g_class);
+ GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass);
mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
- GST_DEBUG_FUNCPTR (gst_ducati_bufferpool_finalize);
+ GST_DEBUG_FUNCPTR (gst_ducati_buffer_pool_finalize);
}
-GType
-gst_ducati_bufferpool_get_type (void)
+static void
+gst_ducati_buffer_pool_init (GstDucatiBufferPool * self)
{
- static GType type;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo info = {
- .class_size = sizeof (GstMiniObjectClass),
- .class_init = gst_ducati_bufferpool_class_init,
- .instance_size = sizeof (GstDucatiBufferPool),
- };
- type = g_type_register_static (GST_TYPE_MINI_OBJECT,
- "GstDucatiBufferPool", &info, 0);
- }
- return type;
}
index 45e749a9b6452f127a2cb06369d884637620b609..30d5381fed5deb824c165a3b944dd9bc595ca294 100644 (file)
#ifndef __GSTDUCATIBUFFERPOOL_H__
#define __GSTDUCATIBUFFERPOOL_H__
-#include "gstducati.h"
+#include "gstducatibuffer.h"
G_BEGIN_DECLS
-GType gst_ducati_buffer_get_type (void);
-#define GST_TYPE_DUCATIBUFFER (gst_ducati_buffer_get_type())
-#define GST_IS_DUCATIBUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATIBUFFER))
-#define GST_DUCATIBUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATIBUFFER, GstDucatiBuffer))
+#define GST_TYPE_DUCATI_BUFFER_POOL (gst_ducati_buffer_pool_get_type())
+#define GST_IS_DUCATI_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATI_BUFFER_POOL))
+#define GST_DUCATI_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATI_BUFFER_POOL, GstDucatiBufferPool))
-GType gst_ducati_bufferpool_get_type (void);
-#define GST_TYPE_DUCATIBUFFERPOOL (gst_ducati_bufferpool_get_type())
-#define GST_IS_DUCATIBUFFERPOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATIBUFFERPOOL))
-#define GST_DUCATIBUFFERPOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATIBUFFERPOOL, GstDucatiBufferPool))
+#define GST_DUCATI_BUFFER_POOL_LOCK(self) g_mutex_lock ((self)->lock)
+#define GST_DUCATI_BUFFER_POOL_UNLOCK(self) g_mutex_unlock ((self)->lock)
typedef struct _GstDucatiBufferPool GstDucatiBufferPool;
-typedef struct _GstDucatiBuffer GstDucatiBuffer;
+typedef struct _GstDucatiBufferPoolClass GstDucatiBufferPoolClass;
struct _GstDucatiBufferPool
{
GstMiniObject parent;
+ GstDucatiBufferAllocator *allocator;
+
/* output (padded) size including any codec padding: */
gint padded_width, padded_height;
GMutex *lock;
gboolean running; /* with lock */
GstElement *element; /* the element that owns us.. */
- GstDucatiBuffer *freelist; /* list of available buffers */
+ GstDucatiBuffer *head; /* list of available buffers */
+ GstDucatiBuffer *tail;
guint size;
};
-GstDucatiBufferPool * gst_ducati_bufferpool_new (GstElement * element, GstCaps * caps, guint size);
-void gst_ducati_bufferpool_destroy (GstDucatiBufferPool * pool);
-void gst_ducati_bufferpool_set_caps (GstDucatiBufferPool * self, GstCaps * caps);
-GstDucatiBuffer * gst_ducati_bufferpool_get (GstDucatiBufferPool * self, GstBuffer * orig);
-
-#define GST_DUCATI_BUFFERPOOL_LOCK(self) g_mutex_lock ((self)->lock)
-#define GST_DUCATI_BUFFERPOOL_UNLOCK(self) g_mutex_unlock ((self)->lock)
-
-struct _GstDucatiBuffer {
- GstBuffer parent;
-
- GstDucatiBufferPool *pool; /* buffer-pool that this buffer belongs to */
- GstBuffer *orig; /* original buffer, if we need to copy output */
- GstDucatiBuffer *next; /* next in freelist, if not in use */
+struct _GstDucatiBufferPoolClass
+{
+ GstMiniObjectClass klass;
};
-GstBuffer * gst_ducati_buffer_get (GstDucatiBuffer * self);
+GType gst_ducati_buffer_pool_get_type (void);
+GstDucatiBufferPool * gst_ducati_buffer_pool_new (GstElement * element,
+ GstDucatiBufferAllocator * allocator, GstCaps * caps, guint size);
+void gst_ducati_buffer_pool_destroy (GstDucatiBufferPool * pool);
+void gst_ducati_buffer_pool_set_caps (GstDucatiBufferPool * self, GstCaps * caps);
+GstDucatiBuffer * gst_ducati_buffer_pool_get (GstDucatiBufferPool * self,
+ GstBuffer * orig, gboolean force_alloc);
+gboolean gst_ducati_buffer_pool_put (GstDucatiBufferPool * self, GstDucatiBuffer * buf);
G_END_DECLS
diff --git a/src/gstducatidrmbuffer.c b/src/gstducatidrmbuffer.c
--- /dev/null
+++ b/src/gstducatidrmbuffer.c
@@ -0,0 +1,204 @@
+/*
+ * GStreamer
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Copyright (C) 2012 Collabora Ltd
+ *
+ * Authors:
+ * Alessandro Decina <alessandro.decina@collabora.co.uk>
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * 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
+ */
+
+#include "gstducatidrmbuffer.h"
+#include "gstducatibufferpool.h"
+#include <omap_drm.h>
+#include <omap_drmif.h>
+
+G_DEFINE_TYPE (GstDucatiDRMBuffer, gst_ducati_drm_buffer,
+ GST_TYPE_DUCATI_BUFFER);
+G_DEFINE_TYPE (GstDucatiDRMBufferAllocator, gst_ducati_drm_buffer_allocator,
+ GST_TYPE_DUCATI_BUFFER_ALLOCATOR);
+
+static GstDucatiDRMBuffer *
+gst_ducati_drm_buffer_new (GstDucatiBufferPool * pool,
+ struct omap_device *device)
+{
+ GstDucatiDRMBuffer *self = (GstDucatiDRMBuffer *)
+ gst_mini_object_new (GST_TYPE_DUCATI_DRM_BUFFER);
+
+ self->device = device;
+ gst_ducati_buffer_set_pool (GST_DUCATI_BUFFER (self), pool);
+ gst_ducati_drm_buffer_setup_bos (self);
+
+ return self;
+}
+
+void
+gst_ducati_drm_buffer_setup_bos (GstDucatiDRMBuffer * self)
+{
+ GstDucatiBufferPool *pool = GST_DUCATI_BUFFER (self)->pool;
+
+ if (pool->strided)
+ g_assert (FALSE);
+
+ self->bo[0] = omap_bo_new (self->device, pool->size, OMAP_BO_WC);
+ self->bo[1] = 0;
+ self->bo[2] = 0;
+ self->bo[3] = 0;
+
+ self->handles[0] = omap_bo_handle (self->bo[0]);
+ self->handles[1] = self->handles[0];
+ self->handles[2] = 0;
+ self->handles[3] = 0;
+
+ self->pitches[0] = pool->padded_width;
+ self->pitches[1] = pool->padded_width;
+ self->pitches[2] = 0;
+ self->pitches[3] = 0;
+
+ self->offsets[0] = 0;
+ self->offsets[1] = self->pitches[0] * pool->padded_height;
+ self->offsets[2] = 0;
+ self->offsets[3] = 0;
+
+ GST_BUFFER_DATA (self) = omap_bo_map (self->bo[0]);
+ GST_BUFFER_SIZE (self) = pool->size;
+}
+
+static void
+gst_ducati_drm_buffer_finalize (GstDucatiDRMBuffer * self)
+{
+ GstDucatiBuffer *ducati_buf = (GstDucatiBuffer *) self;
+ GstDucatiBufferPool *pool = ducati_buf->pool;
+ gboolean resuscitated = FALSE;
+ int i;
+
+ GST_LOG_OBJECT (pool->element, "finalizing buffer %p", self);
+
+ resuscitated = gst_ducati_buffer_pool_put (pool, ducati_buf);
+ if (resuscitated)
+ return;
+
+ GST_LOG_OBJECT (pool->element,
+ "buffer %p (data %p, len %u) not recovered, freeing",
+ self, GST_BUFFER_DATA (self), GST_BUFFER_SIZE (self));
+
+ for (i = 0; i < G_N_ELEMENTS (self->bo); i++) {
+ if (self->bo[i]) {
+ omap_bo_del (self->bo[i]);
+ self->bo[i] = 0;
+ }
+ }
+
+ /* only chain up if the buffer isn't being reused */
+ GST_MINI_OBJECT_CLASS (gst_ducati_drm_buffer_parent_class)->finalize
+ (GST_MINI_OBJECT (self));
+}
+
+static void
+gst_ducati_drm_buffer_class_init (GstDucatiDRMBufferClass * klass)
+{
+ GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass);
+
+ mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
+ GST_DEBUG_FUNCPTR (gst_ducati_drm_buffer_finalize);
+}
+
+static void
+gst_ducati_drm_buffer_init (GstDucatiDRMBuffer * buffer)
+{
+}
+
+GstDucatiDRMBufferAllocator *
+gst_ducati_drm_buffer_allocator_new (struct omap_device *device)
+{
+ GstDucatiDRMBufferAllocator *self = (GstDucatiDRMBufferAllocator *)
+ gst_mini_object_new (GST_TYPE_DUCATI_DRM_BUFFER_ALLOCATOR);
+ self->device = device;
+
+ return self;
+}
+
+static void
+gst_ducati_drm_buffer_allocator_finalize (GstDucatiDRMBufferAllocator * self)
+{
+ GST_MINI_OBJECT_CLASS (gst_ducati_drm_buffer_allocator_parent_class)->finalize
+ (GST_MINI_OBJECT (self));
+}
+
+static GstBuffer *
+allocator_alloc (GstDucatiBufferAllocator * allocator,
+ GstDucatiBufferPool * pool)
+{
+ GstDucatiDRMBufferAllocator *self =
+ GST_DUCATI_DRM_BUFFER_ALLOCATOR (allocator);
+ GstDucatiDRMBuffer *buf = gst_ducati_drm_buffer_new (pool, self->device);
+ return GST_BUFFER_CAST (buf);
+}
+
+static gboolean
+allocator_check_compatible (GstDucatiBufferAllocator * allocator,
+ GstBuffer * buffer)
+{
+ static GType kms_type = -1;
+ if (kms_type == -1)
+ kms_type = g_type_from_name ("GstDucatiKMSBuffer");
+
+ return GST_IS_DUCATI_DRM_BUFFER (buffer) ||
+ (kms_type != -1 && G_TYPE_CHECK_INSTANCE_TYPE (buffer, kms_type));
+}
+
+static void
+allocator_setup_codec_output_buffers (GstDucatiBufferAllocator * allocator,
+ GstVideoFormat format, int width, int height, int stride,
+ GstBuffer * buffer, XDM2_BufDesc * bufs)
+{
+ GstDucatiDRMBuffer *drmbuf = (GstDucatiDRMBuffer *) buffer;
+ int uv_offset, size;
+
+ uv_offset = gst_video_format_get_component_offset (format, 1, stride, height);
+ size = gst_video_format_get_size (format, stride, height);
+
+ bufs->numBufs = 2;
+ bufs->descs[0].memType = XDM_MEMTYPE_BO;
+ bufs->descs[0].buf = (XDAS_Int8 *) omap_bo_handle (drmbuf->bo[0]);
+ bufs->descs[0].bufSize.bytes = uv_offset;
+ bufs->descs[1].memType = XDM_MEMTYPE_BO_OFFSET;
+ bufs->descs[1].buf = (XDAS_Int8 *) uv_offset;
+ bufs->descs[1].bufSize.bytes = size - uv_offset;
+}
+
+static void
+gst_ducati_drm_buffer_allocator_class_init (GstDucatiDRMBufferAllocatorClass *
+ klass)
+{
+ GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass);
+ GstDucatiBufferAllocatorClass *buffer_allocator_class =
+ GST_DUCATI_BUFFER_ALLOCATOR_CLASS (klass);
+
+ mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
+ GST_DEBUG_FUNCPTR (gst_ducati_drm_buffer_allocator_finalize);
+
+ buffer_allocator_class->alloc = allocator_alloc;
+ buffer_allocator_class->check_compatible = allocator_check_compatible;
+ buffer_allocator_class->setup_codec_output_buffers =
+ allocator_setup_codec_output_buffers;
+}
+
+static void
+gst_ducati_drm_buffer_allocator_init (GstDucatiDRMBufferAllocator * allocator)
+{
+}
diff --git a/src/gstducatidrmbuffer.h b/src/gstducatidrmbuffer.h
--- /dev/null
+++ b/src/gstducatidrmbuffer.h
@@ -0,0 +1,82 @@
+/*
+ * GStreamer
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Copyright (C) 2012 Collabora Ltd
+ *
+ * Authors:
+ * Alessandro Decina <alessandro.decina@collabora.co.uk>
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * 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
+ */
+
+#ifndef __GSTDUCATIBUFFERDRM_H__
+#define __GSTDUCATIBUFFERDRM_H__
+
+#include <stdint.h>
+
+#include "gstducatibuffer.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_DUCATI_DRM_BUFFER (gst_ducati_drm_buffer_get_type())
+#define GST_IS_DUCATI_DRM_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATI_DRM_BUFFER))
+#define GST_DUCATI_DRM_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATI_DRM_BUFFER, GstDucatiDRMBuffer))
+
+#define GST_TYPE_DUCATI_DRM_BUFFER_ALLOCATOR (gst_ducati_drm_buffer_allocator_get_type())
+#define GST_IS_DUCATI_DRM_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DUCATI_DRM_BUFFER_ALLOCATOR))
+#define GST_DUCATI_DRM_BUFFER_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DUCATI_DRM_BUFFER_ALLOCATOR, GstDucatiDRMBufferAllocator))
+
+typedef struct _GstDucatiDRMBufferAllocator GstDucatiDRMBufferAllocator;
+typedef struct _GstDucatiDRMBufferAllocatorClass GstDucatiDRMBufferAllocatorClass;
+typedef struct _GstDucatiDRMBuffer GstDucatiDRMBuffer;
+typedef struct _GstDucatiDRMBufferClass GstDucatiDRMBufferClass;
+typedef struct _GstDucatiDRMBufferAllocator GstDucatiDRMBufferAllocator;
+typedef struct _GstDucatiDRMBufferAllocatorClass GstDucatiDRMBufferAllocatorClass;
+
+struct _GstDucatiDRMBuffer
+{
+ GstDucatiBuffer parent;
+ struct omap_bo *bo[4];
+ uint32_t handles[4];
+ uint32_t pitches[4];
+ uint32_t offsets[4];
+ struct omap_device *device;
+};
+
+struct _GstDucatiDRMBufferClass
+{
+ GstDucatiBufferClass parent_class;
+};
+
+struct _GstDucatiDRMBufferAllocator
+{
+ GstDucatiBufferAllocator parent;
+ struct omap_device *device;
+};
+
+struct _GstDucatiDRMBufferAllocatorClass
+{
+ GstDucatiBufferAllocatorClass parent_class;
+};
+
+GType gst_ducati_drm_buffer_get_type (void);
+void gst_ducati_drm_buffer_setup_bos (GstDucatiDRMBuffer *self);
+
+GType gst_ducati_drm_buffer_allocator_get_type (void);
+GstDucatiDRMBufferAllocator * gst_ducati_drm_buffer_allocator_new (struct omap_device *device);
+G_END_DECLS
+
+#endif /* __GSTDUCATIBUFFERDRM_H__ */
diff --git a/src/gstducatividdec.c b/src/gstducatividdec.c
index 0b5c8fec8e5b249f35791f88a997b6edac5c9087..4c961b06049a70d7e88d923995c17b89b1aa379b 100644 (file)
--- a/src/gstducatividdec.c
+++ b/src/gstducatividdec.c
#endif
#include "gstducatividdec.h"
+#include "gstducatidrmbuffer.h"
GST_BOILERPLATE (GstDucatiVidDec, gst_ducati_viddec, GstElement,
GST_TYPE_ELEMENT);
dce_free (self->outArgs);
self->outArgs = NULL;
}
+
+ if (self->allocator) {
+ gst_mini_object_unref (GST_MINI_OBJECT (self->allocator));
+ self->allocator = NULL;
+ }
+
+ if (self->device) {
+ dce_deinit (self->device);
+ self->device = NULL;
+ }
}
static gboolean
engine_open (GstDucatiVidDec * self)
{
gboolean ret;
+ int ec;
if (G_UNLIKELY (self->engine)) {
return TRUE;
}
+ if (self->device == NULL) {
+ self->device = dce_init ();
+ if (self->device == NULL) {
+ GST_ERROR_OBJECT (self, "dce_init() failed");
+ return FALSE;
+ }
+
+ self->allocator =
+ GST_DUCATI_BUFFER_ALLOCATOR (gst_ducati_drm_buffer_allocator_new
+ (self->device));
+ }
+
GST_DEBUG_OBJECT (self, "opening engine");
- self->engine = Engine_open ((String) "ivahd_vidsvr", NULL, NULL);
+ self->engine = Engine_open ((String) "ivahd_vidsvr", NULL, &ec);
if (G_UNLIKELY (!self->engine)) {
GST_ERROR_OBJECT (self, "could not create engine");
return FALSE;
codec_delete (GstDucatiVidDec * self)
{
if (self->pool) {
- gst_ducati_bufferpool_destroy (self->pool);
+ gst_ducati_buffer_pool_destroy (self->pool);
self->pool = NULL;
}
self->codec = NULL;
}
- if (self->input) {
- MemMgr_Free (self->input);
- self->input = NULL;
+ if (self->input_bo) {
+ omap_bo_del (self->input_bo);
+ self->input_bo = NULL;
}
}
self->first_out_buffer = TRUE;
/* allocate input buffer and initialize inBufs: */
+ self->input_bo = omap_bo_new (self->device,
+ self->width * self->height, OMAP_BO_WC);
+ self->input = omap_bo_map (self->input_bo);
self->inBufs->numBufs = 1;
- self->input = gst_ducati_alloc_1d (self->width * self->height);
- self->inBufs->descs[0].buf = (XDAS_Int8 *) TilerMem_VirtToPhys (self->input);
- self->inBufs->descs[0].memType = XDM_MEMTYPE_RAW;
+ self->inBufs->descs[0].buf = (XDAS_Int8 *) omap_bo_handle (self->input_bo);
return TRUE;
}
static inline GstBuffer *
-codec_bufferpool_get (GstDucatiVidDec * self, GstBuffer * buf)
+codec_buffer_pool_get (GstDucatiVidDec * self, GstBuffer * buf)
{
if (G_UNLIKELY (!self->pool)) {
- guint size;
-
- size = gst_video_format_get_size (GST_VIDEO_FORMAT_NV12,
+ guint size = gst_video_format_get_size (GST_VIDEO_FORMAT_NV12,
self->padded_width, self->padded_height);
+
GST_DEBUG_OBJECT (self, "creating bufferpool");
- self->pool = gst_ducati_bufferpool_new (GST_ELEMENT (self),
- GST_PAD_CAPS (self->srcpad), size);
+ self->pool = gst_ducati_buffer_pool_new (GST_ELEMENT (self),
+ self->allocator, GST_PAD_CAPS (self->srcpad), size);
}
- return GST_BUFFER (gst_ducati_bufferpool_get (self->pool, buf));
+ return GST_BUFFER (gst_ducati_buffer_pool_get (self->pool, buf, FALSE));
}
static XDAS_Int32
codec_prepare_outbuf (GstDucatiVidDec * self, GstBuffer ** buf,
gboolean force_internal)
{
- XDAS_Int16 y_type, uv_type;
- guint8 *y_vaddr, *uv_vaddr;
- SSPtr y_paddr, uv_paddr;
+ GstDucatiBufferAllocatorClass *alloc_class;
if (force_internal) {
GstBuffer *orig = *buf;
GST_DEBUG_OBJECT (self, "internal bufferpool forced");
- *buf = codec_bufferpool_get (self, NULL);
+ *buf = codec_buffer_pool_get (self, NULL);
GST_BUFFER_TIMESTAMP (*buf) = GST_BUFFER_TIMESTAMP (orig);
GST_BUFFER_DURATION (*buf) = GST_BUFFER_DURATION (orig);
gst_buffer_unref (orig);
return codec_prepare_outbuf (self, buf, FALSE);
}
- y_vaddr = GST_BUFFER_DATA (*buf);
- uv_vaddr = y_vaddr + self->stride * self->padded_height;
-
- y_paddr = TilerMem_VirtToPhys (y_vaddr);
- uv_paddr = TilerMem_VirtToPhys (uv_vaddr);
-
- y_type = gst_ducati_get_mem_type (y_paddr);
- uv_type = gst_ducati_get_mem_type (uv_paddr);
- /* FIXME: workaround for the vc1 codec expecting _RAW when it's actually
- * _TILEDPAGE... should be removed once the codec is fixed */
- if (y_type == XDM_MEMTYPE_TILEDPAGE && self->pageMemType != y_type)
- y_type = self->pageMemType;
- if (uv_type == XDM_MEMTYPE_TILEDPAGE && self->pageMemType != uv_type)
- uv_type = self->pageMemType;
-
- if (y_type < 0 || uv_type < 0) {
- GST_DEBUG_OBJECT (self, "non TILER buffer, fallback to bufferpool");
- *buf = codec_bufferpool_get (self, *buf);
+ alloc_class = GST_DUCATI_BUFFER_ALLOCATOR_GET_CLASS (self->allocator);
+ if (!alloc_class->check_compatible (self->allocator, *buf)) {
+ GST_DEBUG_OBJECT (self, "non-ducati buffer, fallback to bufferpool");
+ *buf = codec_buffer_pool_get (self, *buf);
return codec_prepare_outbuf (self, buf, FALSE);
}
- if (!self->outBufs->numBufs) {
- /* initialize output buffer type */
- self->outBufs->numBufs = 2;
- self->outBufs->descs[0].memType = y_type;
- self->outBufs->descs[1].memType = uv_type;
- if (y_type == XDM_MEMTYPE_RAW || y_type == XDM_MEMTYPE_TILEDPAGE) {
- self->outBufs->descs[0].bufSize.bytes =
- self->stride * self->padded_height;
- self->outBufs->descs[1].bufSize.bytes =
- self->stride * self->padded_height / 2;
- } else {
- self->outBufs->descs[0].bufSize.tileMem.width = self->padded_width;
- self->outBufs->descs[0].bufSize.tileMem.height = self->padded_height;
- /* note that UV interleaved width is same a Y: */
- self->outBufs->descs[1].bufSize.tileMem.width = self->padded_width;
- self->outBufs->descs[1].bufSize.tileMem.height = self->padded_height / 2;
- }
- } else {
- /* verify output buffer type matches what we've already given
- * to the codec
- */
- if ((self->outBufs->descs[0].memType != y_type) ||
- (self->outBufs->descs[1].memType != uv_type)) {
- GST_DEBUG_OBJECT (self, "buffer mismatch, fallback to bufferpool");
- *buf = codec_bufferpool_get (self, *buf);
- return codec_prepare_outbuf (self, buf, FALSE);
- }
- }
-
- self->outBufs->descs[0].buf = (XDAS_Int8 *) y_paddr;
- self->outBufs->descs[1].buf = (XDAS_Int8 *) uv_paddr;
+ alloc_class->setup_codec_output_buffers (self->allocator,
+ GST_VIDEO_FORMAT_NV12, self->padded_width, self->padded_height,
+ self->stride, *buf, self->outBufs);
return (XDAS_Int32) * buf; // XXX use lookup table
}
GST_INFO_OBJECT (self, "changing interlace field in caps");
gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
NULL);
- gst_ducati_bufferpool_set_caps (self->pool, caps);
+ gst_ducati_buffer_pool_set_caps (self->pool, caps);
if (!gst_pad_set_caps (self->srcpad, caps)) {
GST_ERROR_OBJECT (self,
"downstream didn't want to change interlace mode");
*/
pool = self->pool;
self->pool = NULL;
- gst_ducati_bufferpool_destroy (pool);
+ gst_ducati_buffer_pool_destroy (pool);
}
if (send) {
GstClockTime ts;
- if (GST_IS_DUCATIBUFFER (outbuf)) {
- outbuf = gst_ducati_buffer_get (GST_DUCATIBUFFER (outbuf));
+ if (GST_IS_DUCATI_BUFFER (outbuf)) {
+ outbuf = gst_ducati_buffer_get (GST_DUCATI_BUFFER (outbuf));
}
ts = GST_BUFFER_TIMESTAMP (outbuf);
self->inArgs->numBytes = self->in_size;
self->inBufs->descs[0].bufSize.bytes = self->in_size;
+ self->inBufs->descs[0].memType = XDM_MEMTYPE_BO;
err = codec_process (self, TRUE, FALSE, &ret);
if (err) {
{
GstDucatiVidDec *self = GST_DUCATIVIDDEC (obj);
+
switch (prop_id) {
case PROP_VERSION:{
int err;
- char *version = gst_ducati_alloc_1d (VERSION_LENGTH);
-
- /* in case something fails: */
- snprintf (version, VERSION_LENGTH, "unsupported");
+ char *version = NULL;
if (!self->engine)
engine_open (self);
codec_create (self);
if (self->codec) {
- self->status->data.buf = (XDAS_Int8 *) TilerMem_VirtToPhys (version);
+ version = dce_alloc (VERSION_LENGTH);
+ self->status->data.buf = (XDAS_Int8 *) version;
self->status->data.bufSize = VERSION_LENGTH;
err = VIDDEC3_control (self->codec, XDM_GETVERSION,
}
g_value_set_string (value, version);
-
- MemMgr_Free (version);
+ if (version)
+ dce_free (version);
break;
}
self->wait_keyframe = TRUE;
self->need_out_buf = TRUE;
+ self->device = NULL;
+ self->input_bo = NULL;
}
diff --git a/src/gstducatividdec.h b/src/gstducatividdec.h
index 5b64b20d8b04b5292262923dacf9515e85f39425..527e1e19d3cfbea59e2969d085e044f52b1f59f2 100644 (file)
--- a/src/gstducatividdec.h
+++ b/src/gstducatividdec.h
#ifndef __GST_DUCATIVIDDEC_H__
#define __GST_DUCATIVIDDEC_H__
+#include <stdint.h>
+#include <stddef.h>
+#include <omap_drm.h>
+#include <omap_drmif.h>
+
#include "gstducati.h"
#include "gstducatibufferpool.h"
G_BEGIN_DECLS
-
#define GST_TYPE_DUCATIVIDDEC (gst_ducati_viddec_get_type())
#define GST_DUCATIVIDDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDec))
#define GST_DUCATIVIDDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDecClass))
GstPad *sinkpad, *srcpad;
+ GstDucatiBufferAllocator *allocator;
GstDucatiBufferPool *pool;
/* minimum output size required by the codec: */
gboolean interlaced;
+ struct omap_bo *input_bo;
/* input buffer, allocated when codec is created: */
guint8 *input;
VIDDEC3_OutArgs *outArgs;
XDAS_Int16 pageMemType;
+ struct omap_device *device;
};
struct _GstDucatiVidDecClass