summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ce4ff1d)
raw | patch | inline | side by side (parent: ce4ff1d)
author | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Wed, 11 Jul 2012 16:13:57 +0000 (16:13 +0000) | ||
committer | Alessandro Decina <alessandro.decina@collabora.co.uk> | |
Mon, 16 Jul 2012 08:24:39 +0000 (08:24 +0000) |
src/gstducatividenc.c | patch | blob | history | |
src/gstducatividenc.h | patch | blob | history |
diff --git a/src/gstducatividenc.c b/src/gstducatividenc.c
index a4abe4d1ba090b9fd28d89147bd138c808bbc77e..56fc1d1e3a5f9aedbabe221bc47ae342ed3b5a63 100644 (file)
--- a/src/gstducatividenc.c
+++ b/src/gstducatividenc.c
#include "gstducati.h"
#include "gstducatividenc.h"
-#include <ti/sdo/codecs/mpeg4enc/impeg4enc.h>
+#include "gstducatibufferpriv.h"
#include <string.h>
const GValue * value, GParamSpec * pspec);
static void gst_ducati_videnc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+static GstDucatiBufferPriv *get_buffer_priv (GstDucatiVidEnc * self,
+ GstBuffer * buf, gint stride, gint height);
static gboolean gst_ducati_videnc_set_format (GstBaseVideoEncoder *
base_video_encoder, GstVideoState * state);
{
GST_DEBUG ("gst_ducati_videnc_init");
+ self->device = NULL;
self->engine = NULL;
self->codec = NULL;
self->params = NULL;
}
g_assert (self->input_pool == NULL);
- self->input_pool =
- gst_ducati_bufferpool_new (GST_ELEMENT (self), NULL,
- state->bytes_per_picture);
+ self->input_pool = gst_drm_buffer_pool_new (GST_ELEMENT (self),
+ dce_get_fd (), NULL, state->bytes_per_picture);
g_assert (self->output_pool == NULL);
- self->output_pool =
- gst_ducati_bufferpool_new (GST_ELEMENT (self), NULL, max_out_size);
+ self->output_pool = gst_drm_buffer_pool_new (GST_ELEMENT (self),
+ dce_get_fd (), NULL, max_out_size);
GST_INFO_OBJECT (self, "configured");
static gboolean
gst_ducati_videnc_open_engine (GstDucatiVidEnc * self)
{
- self->engine = Engine_open ((String) "ivahd_vidsvr", NULL, NULL);
+ int error_code;
+
+ if (self->device == NULL) {
+ self->device = dce_init ();
+ if (self->device == NULL)
+ return FALSE;
+ }
+
+ self->engine = Engine_open ((String) "ivahd_vidsvr", NULL, &error_code);
if (self->engine == NULL) {
GST_ERROR_OBJECT (self, "couldn't open engine");
return FALSE;
Engine_close (self->engine);
self->engine = NULL;
}
+
+ if (self->device) {
+ dce_deinit (self->device);
+ self->device = NULL;
+ }
}
gst_ducati_videnc_close_engine (self);
if (self->input_pool) {
- gst_ducati_bufferpool_destroy (self->input_pool);
+ gst_drm_buffer_pool_destroy (self->input_pool);
self->input_pool = NULL;
}
if (self->output_pool) {
- gst_ducati_bufferpool_destroy (self->output_pool);
+ gst_drm_buffer_pool_destroy (self->output_pool);
self->output_pool = NULL;
}
{
GstDucatiVidEnc *self = GST_DUCATIVIDENC (base_video_encoder);
GstBuffer *inbuf, *outbuf;
- guint8 *y_vaddr, *uv_vaddr;
- SSPtr y_paddr, uv_paddr, outbuf_paddr;
+ GstDucatiBufferPriv *priv_in, *priv_out;
XDAS_Int32 err;
- XDAS_Int16 y_type, uv_type;
const GstVideoState *state;
int i;
inbuf = gst_buffer_ref (frame->sink_buffer);
have_inbuf:
- y_vaddr = GST_BUFFER_DATA (inbuf);
- uv_vaddr = y_vaddr + gst_video_format_get_component_offset (state->format,
- 1, state->width, state->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);
- if (y_type < 0 || uv_type < 0) {
- GST_DEBUG_OBJECT (self, "memcpying input %d %d", y_type, uv_type);
+ priv_in = get_buffer_priv (self, inbuf, state->width, state->height);
+ if (priv_in == NULL) {
+ GST_DEBUG_OBJECT (self, "memcpying input");
gst_buffer_unref (inbuf);
- inbuf = GST_BUFFER (gst_ducati_bufferpool_get (self->input_pool, NULL));
+ inbuf = GST_BUFFER (gst_drm_buffer_pool_get (self->input_pool, FALSE));
memcpy (GST_BUFFER_DATA (inbuf), GST_BUFFER_DATA (frame->sink_buffer),
GST_BUFFER_SIZE (frame->sink_buffer));
goto have_inbuf;
}
- outbuf = GST_BUFFER (gst_ducati_bufferpool_get (self->output_pool, NULL));
-
- y_vaddr = GST_BUFFER_DATA (inbuf);
- uv_vaddr = y_vaddr + gst_video_format_get_component_offset (state->format,
- 1, state->width, state->height);
-
- y_paddr = TilerMem_VirtToPhys (y_vaddr);
- uv_paddr = TilerMem_VirtToPhys (uv_vaddr);
-
- outbuf_paddr = TilerMem_VirtToPhys (GST_BUFFER_DATA (outbuf));
+ outbuf = GST_BUFFER (gst_drm_buffer_pool_get (self->output_pool, FALSE));
+ priv_out = get_buffer_priv (self, outbuf, state->width, state->height);
- self->inBufs->planeDesc[0].buf = (XDAS_Int8 *) y_paddr;
- self->inBufs->planeDesc[0].memType = XDM_MEMTYPE_TILEDPAGE;
+ self->inBufs->planeDesc[0].buf = (XDAS_Int8 *) omap_bo_handle (priv_in->bo);
+ self->inBufs->planeDesc[0].memType = XDM_MEMTYPE_BO;
self->inBufs->planeDesc[0].bufSize.tileMem.width = state->width;
self->inBufs->planeDesc[0].bufSize.tileMem.height = state->height;
- self->inBufs->planeDesc[1].buf = (XDAS_Int8 *) uv_paddr;
- self->inBufs->planeDesc[1].memType = XDM_MEMTYPE_TILEDPAGE;
+ self->inBufs->planeDesc[1].buf = (XDAS_Int8 *) priv_in->uv_offset;
+ self->inBufs->planeDesc[1].memType = XDM_MEMTYPE_BO_OFFSET;
self->inBufs->planeDesc[1].bufSize.tileMem.width = state->width;
self->inBufs->planeDesc[1].bufSize.tileMem.height = state->height / 2;
/* setting imageRegion doesn't seem to be strictly needed if activeFrameRegion
self->inBufs->topFieldFirstFlag = TRUE;
self->outBufs->numBufs = 1;
- self->outBufs->descs[0].buf = (XDAS_Int8 *) outbuf_paddr;
+ self->outBufs->descs[0].buf = (XDAS_Int8 *) omap_bo_handle (priv_out->bo);
self->outBufs->descs[0].bufSize.bytes = GST_BUFFER_SIZE (outbuf);
+ self->outBufs->descs[0].memType = XDM_MEMTYPE_BO;
+
self->inArgs->inputID = GPOINTER_TO_INT (inbuf);
return handled;
}
+
+static GstDucatiBufferPriv *
+get_buffer_priv (GstDucatiVidEnc * self, GstBuffer * buf,
+ gint stride, gint height)
+{
+ GstDucatiBufferPriv *priv = gst_ducati_buffer_priv_get (buf);
+ if (!priv) {
+ GstVideoFormat format = GST_VIDEO_FORMAT_NV12;
+ GstDmaBuf *dmabuf = gst_buffer_get_dma_buf (buf);
+
+ /* if it isn't a dmabuf buffer that we can import, then there
+ * is nothing we can do with it:
+ */
+ if (!dmabuf) {
+ GST_DEBUG_OBJECT (self, "not importing non dmabuf buffer");
+ return NULL;
+ }
+
+ priv = gst_ducati_buffer_priv_new ();
+ priv->bo = omap_bo_from_dmabuf (self->device, gst_dma_buf_get_fd (dmabuf));
+
+ priv->uv_offset = gst_video_format_get_component_offset (format,
+ 1, stride, height);
+ priv->size = gst_video_format_get_size (format, stride, height);
+
+ gst_ducati_buffer_priv_set (buf, priv);
+ }
+ return priv;
+}
diff --git a/src/gstducatividenc.h b/src/gstducatividenc.h
index 11a3012f14ac27dba2a48288da73847c053f3a9d..c0feb8c1583788bf3ede68fbdcff4d5bbf67d616 100644 (file)
--- a/src/gstducatividenc.h
+++ b/src/gstducatividenc.h
#include <gst/video/video.h>
#include <gst/video/gstbasevideoencoder.h>
#include <gst/video/gstbasevideoutils.h>
+#include <gst/drm/gstdrmbufferpool.h>
#include <ti/sdo/ce/video2/videnc2.h>
-#include "gstducatibufferpool.h"
#define GST_TYPE_DUCATIVIDENC \
(gst_ducati_videnc_get_type())
GstPad *sinkpad;
GstPad *srcpad;
+ struct omap_device *device;
Engine_Handle engine;
VIDENC2_Handle codec;
IVIDENC2_Params *params;
IVIDENC2_InArgs *inArgs;
IVIDENC2_OutArgs *outArgs;
- GstDucatiBufferPool *input_pool;
- GstDucatiBufferPool *output_pool;
+ GstDRMBufferPool *input_pool;
+ GstDRMBufferPool *output_pool;
gboolean configure;
GstDucatiVideoRectangle rect;