Apply tizenbufferpool to decoder 17/182717/14
authorSejun Park <sejun79.park@samsung.com>
Wed, 27 Jun 2018 09:30:36 +0000 (18:30 +0900)
committerSejun Park <sejun79.park@samsung.com>
Wed, 11 Jul 2018 08:13:39 +0000 (17:13 +0900)
Change-Id: I4b6669dcd6a64a5405b1c66a235c120f1ea0b464

configure.ac
omx/Makefile.am
omx/gstomx.c
omx/gstomx.h
omx/gstomxbufferpool.c
omx/gstomxbufferpool.h
omx/gstomxvideodec.c
omx/gstomxvideodec.h
omx/gstomxvideoenc.c
omx/gstomxvideoenc.h
packaging/gst-omx.spec

index 11108c9..d48c1cb 100755 (executable)
@@ -155,6 +155,7 @@ PKG_CHECK_MODULES([GST_GL], [gstreamer-gl-1.0 >= 1.4.0], [
   GST_GL=yes
 ], [GST_GL=no])
 AM_CONDITIONAL(HAVE_GST_GL, test "x$GST_GL" = "xyes")
+PKG_CHECK_MODULES([GST_ALLOCATORS], [gstreamer-allocators-1.0])
 
 dnl Check for documentation xrefs
 GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
index 23742f3..79e0969 100755 (executable)
@@ -92,9 +92,10 @@ libgstomx_la_CFLAGS = \
        $(GST_PLUGINS_BASE_CFLAGS) \
        $(GST_BASE_CFLAGS) \
        $(GST_CFLAGS) \
+       $(GST_ALLOCATORS_CFLAGS) \
        $(TBM_CFLAGS) \
        $(GMODULE_NO_EXPORT_CFLAGS) \
-        $(MM_COMMON_CFLAGS)
+       $(MM_COMMON_CFLAGS)
 
 libgstomx_la_LIBADD = \
        $(GST_GL_LIBS) \
@@ -104,6 +105,7 @@ libgstomx_la_LIBADD = \
        -lgstvideo-@GST_API_VERSION@ \
        $(GST_BASE_LIBS) \
        $(GST_LIBS) \
+       $(GST_ALLOCATORS_LIBS) \
        $(TBM_LIBS) \
        $(GMODULE_NO_EXPORT_LIBS) \
        $(MM_COMMON_LIBS)
index 8f1201d..6b1a23e 100755 (executable)
@@ -1494,13 +1494,11 @@ gst_omx_port_release_buffer (GstOMXPort * port, GstOMXBuffer * buf)
   buf->used = TRUE;
 
   if (port->port_def.eDir == OMX_DirInput) {
-    GST_LOG_OBJECT (comp->parent, "Calling OMX_EmptyThisBuffer. dmabuf_fd : [%u(%p)0x%02x, 0x%02x], nFilledLen : %lu\n",
-        buf->mm_vbuffer ? buf->mm_vbuffer->handle.dmabuf_fd[0] : 0, buf, buf->omx_buf->pBuffer[4],
-        buf->omx_buf->pBuffer[10], buf->omx_buf->nFilledLen);
+    GST_LOG_OBJECT (comp->parent, "Calling OMX_EmptyThisBuffer. NalType : [(%p)0x%02x, 0x%02x], nFilledLen : %lu",
+        buf, buf->omx_buf->pBuffer[4], buf->omx_buf->pBuffer[10], buf->omx_buf->nFilledLen);
     err = OMX_EmptyThisBuffer (comp->handle, buf->omx_buf);
   } else {
-    GST_LOG_OBJECT (comp->parent, "Calling OMX_FillThisBuffer. dmabuf_fd : [%u(%p)]\n",
-        buf->mm_vbuffer ? buf->mm_vbuffer->handle.dmabuf_fd[0] : 0, buf);
+    GST_LOG_OBJECT (comp->parent, "Calling OMX_FillThisBuffer. pBuffer : [%p]", buf->omx_buf->pBuffer);
     err = OMX_FillThisBuffer (comp->handle, buf->omx_buf);
   }
   GST_DEBUG_OBJECT (comp->parent, "Released buffer %p to %s port %u: %s "
@@ -1730,12 +1728,6 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port,
     buf->port = port;
     buf->used = FALSE;
     buf->settings_cookie = port->settings_cookie;
-
-#ifdef TIZEN_FEATURE_OMX
-    if (buffers)
-      buf->mm_vbuffer = (MMVideoBuffer*) l->data;
-#endif
-
     g_ptr_array_add (port->buffers, buf);
 
     if (buffers) {
@@ -1806,22 +1798,17 @@ gst_omx_port_allocate_buffers (GstOMXPort * port)
 #ifdef TIZEN_FEATURE_OMX
 /* NOTE: Uses comp->lock and comp->messages_lock */
 OMX_ERRORTYPE
-gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr bufmgr, gboolean use_buffer)
+gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port)
 {
   guint n = 0;
   gint num = 0;
   gint i = 0 , j = 0;
-  gint planes[MAX_BUFFER_PLANE] = {0, };
-  gint stride[MAX_BUFFER_PLANE] = {0, };
   GList *buffers = NULL;
-  MMVideoBuffer *mm_vbuffer[MAX_INPUT_BUFFER];
-  tbm_bo_handle handle_bo;
+  tbm_surface_h surface[MAX_INPUT_BUFFER];
   GstOMXComponent *comp;
   OMX_ERRORTYPE err = OMX_ErrorNone;
   OMX_CONFIG_RECTTYPE rect;
-  tbm_surface_h surface;
-  tbm_surface_info_s info;
-  int ret;
+  gpointer buffer;
 
   g_return_val_if_fail (port != NULL, OMX_ErrorUndefined);
 
@@ -1846,117 +1833,55 @@ gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr bufmgr, gbo
   if (port->buffers)
       gst_omx_port_deallocate_buffers (port);
 
-  if (use_buffer) {
-    n = port->port_def.nBufferCountActual;
-
-    if (port->index == 1) {
-      surface = tbm_surface_create (rect.nWidth, rect.nHeight, TBM_FORMAT_NV12);
-      ret = tbm_surface_get_info (surface, &info);
-      if (ret != TBM_SURFACE_ERROR_NONE) {
-        tbm_surface_destroy (surface);
+  if (port->use_buffer) {
+    for (i = 0; i < port->port_def.nBufferCountActual; i++) {
+      surface[i] = tbm_surface_create (rect.nWidth, rect.nHeight, TBM_FORMAT_NV12);
+      if (!surface[i]) {
         g_mutex_unlock (&port->comp->lock);
-        return OMX_ErrorUndefined;
-      }
-
-      planes[0] = info.planes[0].size;
-      stride[0] = info.planes[0].stride;
-      planes[1] = info.planes[1].size;
-      stride[1] = info.planes[1].stride;
-      tbm_surface_destroy (surface);
-
-      if ((planes[0] <= 0) || (planes[1] <= 0) || (stride[0] <= 0) || (stride[1] <= 0))
-        return OMX_ErrorUndefined;
-    }
-
-    for (i = 0; i < n; i++) {
-      mm_vbuffer[i] = (MMVideoBuffer*) malloc(sizeof (MMVideoBuffer));
-      memset (mm_vbuffer[i], 0, sizeof (MMVideoBuffer));
-
-      if (port->index == 0) {
-        mm_vbuffer[i]->handle.bo[0] = tbm_bo_alloc (bufmgr, port->port_def.nBufferSize, TBM_BO_WC);
-        mm_vbuffer[i]->size[0] = port->port_def.nBufferSize;
-        mm_vbuffer[i]->plane_num = 1;
-      } else {
-        mm_vbuffer[i]->handle.bo[0] = tbm_bo_alloc (bufmgr, planes[0], TBM_BO_WC);
-        mm_vbuffer[i]->size[0] = port->port_def.format.video.nFrameWidth * port->port_def.format.video.nFrameHeight;
-        mm_vbuffer[i]->handle_size[0] = planes[0];
-        mm_vbuffer[i]->width[0] = rect.nWidth;
-        mm_vbuffer[i]->height[0] = rect.nHeight;
-        mm_vbuffer[i]->stride_width[0] = stride[0];
-        mm_vbuffer[i]->stride_height[0] = planes[0] / stride[0];
-
-        mm_vbuffer[i]->handle.bo[1] = tbm_bo_alloc (bufmgr, planes[1], TBM_BO_WC);
-        mm_vbuffer[i]->size[1] = mm_vbuffer[i]->size[0]>>1;
-        mm_vbuffer[i]->handle_size[1] = planes[1];
-        mm_vbuffer[i]->width[1] = rect.nWidth;
-        mm_vbuffer[i]->height[1] = rect.nHeight>>1;
-        mm_vbuffer[i]->stride_width[1] = stride[1];
-        mm_vbuffer[i]->stride_height[1] = planes[1] / stride[1];
-        mm_vbuffer[i]->plane_num = 2;
-        mm_vbuffer[i]->handle_num = 2;
-        mm_vbuffer[i]->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
-        mm_vbuffer[i]->crop.x = rect.nLeft;
-        mm_vbuffer[i]->crop.y = rect.nTop;
-        mm_vbuffer[i]->crop.width = rect.nWidth;
-        mm_vbuffer[i]->crop.height = rect.nHeight;
+        goto error;
       }
 
-      for (j = 0; j < port->index + 1; j++) {
-        handle_bo = tbm_bo_get_handle (mm_vbuffer[i]->handle.bo[j], TBM_DEVICE_MM);
-        if (handle_bo.ptr == NULL) {
-          g_mutex_unlock (&port->comp->lock);
-          goto error;
-        }
-        mm_vbuffer[i]->handle.dmabuf_fd[j] = handle_bo.u32;
-
-        handle_bo = tbm_bo_get_handle (mm_vbuffer[i]->handle.bo[j], TBM_DEVICE_CPU);
-        if (handle_bo.ptr == NULL) {
-          g_mutex_unlock (&port->comp->lock);
-          goto error;
-        }
-        mm_vbuffer[i]->data[j] = handle_bo.ptr;
-      }
+      if (port->index == 0)
+        buffer = tbm_bo_get_handle (tbm_surface_internal_get_bo (surface[i], 0), TBM_DEVICE_CPU).ptr;
+      else
+        buffer = surface[i];
+      buffers = g_list_append (buffers, (gpointer) buffer);
 
       GST_INFO_OBJECT (comp->parent,
-        "Allocating %d buffer bo[0]:%p bo[1]:%p fd[0]:%d fd[1]:%d size[0]:%d size[1]:%d for %s port %u", i,
-        mm_vbuffer[i]->handle.bo[0], mm_vbuffer[i]->handle.bo[1], mm_vbuffer[i]->handle.dmabuf_fd[0], mm_vbuffer[i]->handle.dmabuf_fd[1],
-        mm_vbuffer[i]->size[0], mm_vbuffer[i]->size[1], comp->name, (guint) port->index);
-
-      buffers = g_list_append (buffers, (gpointer) mm_vbuffer[i]);
+          "Allocating %d buffer surface : %p for %s port %u",
+          i, buffer, comp->name, (guint) port->index);
     }
   }
 
-  num = use_buffer ? g_list_length ((GList *) buffers) : -1;
+  num = port->use_buffer ? g_list_length ((GList *) buffers) : -1;
   err = gst_omx_port_allocate_buffers_unlocked (port, buffers, NULL, num);
 
+  g_list_free (buffers);
   g_mutex_unlock (&port->comp->lock);
 
   return err;
 
 error:
   for (i = 0; i < port->port_def.nBufferCountActual; i++) {
-    for (j = 0; j < port->index + 1; j++) {
-      if (mm_vbuffer[i]->handle.bo[j]) {
-        tbm_bo_unref (mm_vbuffer[i]->handle.bo[j]);
-        mm_vbuffer[i]->handle.bo[j] = NULL;
-        g_free (mm_vbuffer[i]);
-      }
+    if (surface[i]) {
+      tbm_surface_destroy (surface[i]);
+      surface[i] = NULL;
     }
   }
+  g_list_free (buffers);
   return OMX_ErrorInsufficientResources;
 }
 
 /* NOTE: Uses comp->lock and comp->messages_lock */
 OMX_ERRORTYPE
-gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr bufmgr, gboolean use_buffer)
+gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port)
 {
   OMX_ERRORTYPE err = OMX_ErrorNone;
   gint i = 0;
-  guint n = 0;
   gint num = 0;
   GList *buffers = NULL;
   tbm_bo_handle handle_bo;
-  MMVideoBuffer *mm_vbuffer[MAX_INPUT_BUFFER];
+  tbm_surface_h surface[MAX_INPUT_BUFFER];
 
   g_return_val_if_fail (port != NULL, OMX_ErrorUndefined);
 
@@ -1965,50 +1890,34 @@ gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr bufmgr, gbo
   /*deallocate previous allocated buffers...*/
   if (port->buffers)
     gst_omx_port_deallocate_buffers (port);
-  n = port->port_def.nBufferCountActual;
-
-  if (use_buffer) {
-    for (i = 0; i < n; i++) {
-      mm_vbuffer[i] = (MMVideoBuffer *) malloc (sizeof (MMVideoBuffer));
-      memset (mm_vbuffer[i], 0, sizeof (MMVideoBuffer));
-
-      if (port->index == 1) {
-        mm_vbuffer[i]->handle.bo[0] = tbm_bo_alloc (bufmgr, port->port_def.nBufferSize, TBM_BO_WC);
-        handle_bo = tbm_bo_get_handle (mm_vbuffer[i]->handle.bo[0], TBM_DEVICE_MM);
-        if (handle_bo.ptr == NULL) {
-          g_mutex_unlock (&port->comp->lock);
-          goto error;
-        }
-        mm_vbuffer[i]->handle.dmabuf_fd[0] = handle_bo.u32;
 
-        handle_bo = tbm_bo_get_handle (mm_vbuffer[i]->handle.bo[0], TBM_DEVICE_CPU);
-        if (handle_bo.ptr == NULL) {
-          g_mutex_unlock (&port->comp->lock);
-          goto error;
-        }
-        mm_vbuffer[i]->data[0] = handle_bo.ptr;
-        mm_vbuffer[i]->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
-        mm_vbuffer[i]->size[0] = port->port_def.nBufferSize;
-        mm_vbuffer[i]->handle_num = 1;
+  if (port->use_buffer) {
+    for (i = 0; i < port->port_def.nBufferCountActual; i++) {
+      surface[i] = tbm_surface_create (port->port_def.format.video.nFrameWidth, port->port_def.format.video.nFrameHeight, TBM_FORMAT_NV12);
+      if (!surface[i]) {
+        g_mutex_unlock (&port->comp->lock);
+        goto error;
       }
-      buffers = g_list_append (buffers, (gpointer)mm_vbuffer[i]);
+      buffers = g_list_append (buffers, (gpointer) surface[i]);
     }
   }
 
-  num = use_buffer ? g_list_length ((GList *) buffers) : -1;
+  num = port->use_buffer ? g_list_length ((GList *) buffers) : -1;
   err = gst_omx_port_allocate_buffers_unlocked (port, buffers, NULL, num);
+
+  g_list_free (buffers);
   g_mutex_unlock (&port->comp->lock);
 
   return err;
 
 error:
   for (i = 0; i < port->port_def.nBufferCountActual; i++) {
-    if (mm_vbuffer[i]->handle.bo[0]) {
-      tbm_bo_unref (mm_vbuffer[i]->handle.bo[0]);
-      mm_vbuffer[i]->handle.bo[0] = NULL;
-      g_free (mm_vbuffer[i]);
+    if (surface[i]) {
+      tbm_surface_destroy (surface[i]);
+      surface[i] = NULL;
     }
   }
+  g_list_free (buffers);
   return OMX_ErrorInsufficientResources;
 }
 #endif
@@ -2089,16 +1998,6 @@ gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * port)
           "port %u", buf, comp->name, port->index);
     }
 
-#ifdef TIZEN_FEATURE_OMX
-    /* deallocate tbm buffers */
-    if(buf->mm_vbuffer != NULL) {
-        tbm_bo_unref(buf->mm_vbuffer->handle.bo[0]);
-        if(port->index == 1) /* output port */
-            tbm_bo_unref(buf->mm_vbuffer->handle.bo[1]);
-        g_free(buf->mm_vbuffer);
-        buf->mm_vbuffer = NULL;
-    }
-#endif
     /* omx_buf can be NULL if allocation failed earlier
      * and we're just shutting down
      *
index 97141bc..4a6641d 100755 (executable)
@@ -26,7 +26,6 @@
 #include <gmodule.h>
 #include <gst/gst.h>
 #include <string.h>
-#include <mm_types.h>
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -172,33 +171,8 @@ typedef enum GOmxVendor GOmxVendor; /* check omx vender */
 
 #define ALIGN(x, a)       (((x) + (a) - 1) & ~((a) - 1))
 
-typedef struct _TBMBuffer TBMBuffer;
-typedef struct _TBMInputBuffer TBMInputBuffer;
-typedef struct _TBMOutputBuffer TBMOutputBuffer;
 typedef struct _EnableGemBuffersParams EnableGemBuffersParams;
 
-struct _TBMBuffer
-{
-   OMX_U32 mBufFD;
-   tbm_bo  mBo;
-   OMX_PTR mPtr;
-   OMX_U32 nAllocLen;
-};
-
-struct _TBMInputBuffer
-{
-    struct _TBMBuffer tbmBuffer[MAX_INPUT_BUFFER];
-    OMX_U32 allocatedCount;
-    GList *buffers;
-};
-
-struct _TBMOutputBuffer
-{
-    MMVideoBuffer *tbmBuffer[MAX_OUTPUT_BUFFER];
-    OMX_U32 allocatedCount;
-    GList *buffers;
-};
-
 struct _EnableGemBuffersParams
 {
   OMX_U32 nSize;
@@ -365,11 +339,6 @@ struct _GstOMXBuffer {
 
   /* TRUE if this is an EGLImage */
   gboolean eglimage;
-
-#ifdef TIZEN_FEATURE_OMX
-  /* MMVideoBuffer array to use TBM buffers */
-   MMVideoBuffer *mm_vbuffer;
-#endif
 };
 
 struct _GstOMXClassData {
@@ -435,8 +404,8 @@ gboolean          gst_omx_port_is_flushing (GstOMXPort *port);
 
 OMX_ERRORTYPE     gst_omx_port_allocate_buffers (GstOMXPort *port);
 #ifdef TIZEN_FEATURE_OMX
-OMX_ERRORTYPE     gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr  bufmgr, gboolean use_buffer);
-OMX_ERRORTYPE     gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr  bufmgr, gboolean use_buffer);
+OMX_ERRORTYPE     gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port);
+OMX_ERRORTYPE     gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port);
 OMX_ERRORTYPE     gst_omx_component_get_extension_index (GstOMXComponent * comp, OMX_STRING name, gpointer index);
 void              gst_omx_port_flush_start (GstOMXPort * port, gboolean flush);
 #endif
index 460c7c2..55d5008 100755 (executable)
@@ -25,6 +25,9 @@
 #endif
 
 #include "gstomxbufferpool.h"
+#ifdef TIZEN_FEATURE_OMX
+#include <gst/allocators/gsttizenmemory.h>
+#endif
 
 GST_DEBUG_CATEGORY_STATIC (gst_omx_buffer_pool_debug_category);
 #define GST_CAT_DEFAULT gst_omx_buffer_pool_debug_category
@@ -93,6 +96,59 @@ gst_omx_memory_share (GstMemory * mem, gssize offset, gssize size)
   return NULL;
 }
 
+#ifdef TIZEN_FEATURE_OMX
+gboolean
+gst_omx_video_memory_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
+    gpointer * data, gint * stride, GstMapFlags flags)
+{
+  gint err;
+  gint bo_idx;
+  tbm_surface_info_s surface_info;
+  GstBuffer *buffer = meta->buffer;
+  GstMemory *mem = gst_buffer_get_memory (buffer, 0);
+
+  if (!gst_is_tizen_memory (mem)) {
+    GST_ERROR ("Invalid memory");
+    return FALSE;
+  }
+
+  err = tbm_surface_map (((GstTizenMemory *)mem)->surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &surface_info);
+  if (err != TBM_SURFACE_ERROR_NONE) {
+    GST_ERROR ("Failed to map memory");
+    return FALSE;
+  }
+
+  if (surface_info.num_planes <= plane) {
+    GST_ERROR ("Invalid format");
+    return FALSE;
+  }
+
+  *data = surface_info.planes[plane].ptr;
+  *stride = surface_info.planes[plane].stride;
+
+  GST_DEBUG ("_video_memory_map -> plane : %d, data : %p, stride : %d",
+      plane, *data, *stride);
+
+  return TRUE;
+}
+
+gboolean
+gst_omx_video_memory_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info)
+{
+  GstBuffer *buffer = meta->buffer;
+  GstMemory *mem = gst_buffer_get_memory (buffer, 0);
+
+  if (!gst_is_tizen_memory (mem)) {
+    GST_ERROR ("Invalid memory");
+    return FALSE;
+  }
+
+  tbm_surface_unmap (((GstTizenMemory *)mem)->surface);
+  GST_DEBUG ("_video_memory_unmap -> plane : %d", plane);
+  return TRUE;
+}
+#endif
+
 GType gst_omx_memory_allocator_get_type (void);
 G_DEFINE_TYPE (GstOMXMemoryAllocator, gst_omx_memory_allocator,
     GST_TYPE_ALLOCATOR);
@@ -379,6 +435,12 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
             GST_VIDEO_INFO_WIDTH (&pool->video_info),
             GST_VIDEO_INFO_HEIGHT (&pool->video_info));
       }
+#ifdef TIZEN_FEATURE_OMX
+      meta->map = gst_omx_video_memory_map;
+      meta->unmap = gst_omx_video_memory_unmap;
+
+      GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
+#endif
     }
 
     pool->need_copy = FALSE;
@@ -389,7 +451,16 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
     gsize offset[GST_VIDEO_MAX_PLANES] = { 0, };
     gint stride[GST_VIDEO_MAX_PLANES] = { nstride, 0, };
 
+#ifdef TIZEN_FEATURE_OMX
+    tbm_surface_h surface;
+    GstMapInfo map;
+
+    surface = (tbm_surface_h) omx_buf->omx_buf->pBuffer;
+
+    mem = gst_tizen_allocator_alloc_surface (pool->allocator, &pool->video_info, surface, NULL, NULL);
+#else
     mem = gst_omx_memory_allocator_alloc (pool->allocator, 0, omx_buf);
+#endif
     buf = gst_buffer_new ();
     gst_buffer_append_memory (buf, mem);
     g_ptr_array_add (pool->buffers, buf);
@@ -520,11 +591,29 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool,
     /* If it's our own memory we have to set the sizes */
     if (!pool->other_pool) {
       GstMemory *mem = gst_buffer_peek_memory (*buffer, 0);
+#ifdef TIZEN_FEATURE_OMX
+      GstOMXBuffer *omx_buf;
+
+      if (pool->output_mode == GST_OMX_BUFFER_MODE_TBM) {
+        omx_buf =
+            gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buf),
+            gst_omx_buffer_data_quark);
+      } else {
+        g_assert (mem
+          && g_strcmp0 (mem->allocator->mem_type, GST_OMX_MEMORY_TYPE) == 0);
+        /* We already have a pointer to the GstOMXBuffer, no need to retrieve it
+           from the qdata */
+        omx_buf = ((GstOMXMemory *) mem)->buf;
+      }
 
+      mem->size = omx_buf->omx_buf->nFilledLen;
+      mem->offset = omx_buf->omx_buf->nOffset;
+#else
       g_assert (mem
           && g_strcmp0 (mem->allocator->mem_type, GST_OMX_MEMORY_TYPE) == 0);
       mem->size = ((GstOMXMemory *) mem)->buf->omx_buf->nFilledLen;
       mem->offset = ((GstOMXMemory *) mem)->buf->omx_buf->nOffset;
+#endif
     }
   } else {
     /* Acquire any buffer that is available to be filled by upstream */
@@ -632,9 +721,42 @@ static void
 gst_omx_buffer_pool_init (GstOMXBufferPool * pool)
 {
   pool->buffers = g_ptr_array_new ();
+#ifndef TIZEN_FEATURE_OMX
   pool->allocator = g_object_new (gst_omx_memory_allocator_get_type (), NULL);
+#endif
 }
 
+#ifdef TIZEN_FEATURE_OMX
+GstBufferPool *
+gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component,
+    GstOMXPort * port, GstOMXBufferMode output_mode)
+{
+  GstOMXBufferPool *pool;
+
+  pool = g_object_new (gst_omx_buffer_pool_get_type (), NULL);
+  pool->element = gst_object_ref (element);
+  pool->component = component;
+  pool->port = port;
+  pool->output_mode = output_mode;
+
+  switch (output_mode) {
+    case GST_OMX_BUFFER_MODE_DMABUF:
+      pool->allocator = gst_dmabuf_allocator_new ();
+      break;
+    case GST_OMX_BUFFER_MODE_SYSTEM_MEMORY:
+      pool->allocator =
+          g_object_new (gst_omx_memory_allocator_get_type (), NULL);
+      break;
+    case GST_OMX_BUFFER_MODE_TBM:
+      pool->allocator = gst_tizen_allocator_new ();
+      break;
+    default:
+      g_assert_not_reached ();
+  }
+
+  return GST_BUFFER_POOL (pool);
+}
+#else
 GstBufferPool *
 gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component,
     GstOMXPort * port)
@@ -648,3 +770,4 @@ gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component,
 
   return GST_BUFFER_POOL (pool);
 }
+#endif
index 87b27d3..7f14bfe 100755 (executable)
@@ -43,6 +43,14 @@ G_BEGIN_DECLS
 typedef struct _GstOMXBufferPool GstOMXBufferPool;
 typedef struct _GstOMXBufferPoolClass GstOMXBufferPoolClass;
 
+#ifdef TIZEN_FEATURE_OMX
+typedef enum {
+  GST_OMX_BUFFER_MODE_SYSTEM_MEMORY,
+  GST_OMX_BUFFER_MODE_DMABUF,
+  GST_OMX_BUFFER_MODE_TBM
+} GstOMXBufferMode;
+#endif
+
 struct _GstOMXBufferPool
 {
   GstVideoBufferPool parent;
@@ -80,6 +88,8 @@ struct _GstOMXBufferPool
   gint current_buffer_index;
 #ifdef TIZEN_FEATURE_OMX
   gint num_buffers;
+  /* The type of buffers produced by the decoder */
+  GstOMXBufferMode output_mode;
 #endif
 };
 
@@ -90,7 +100,12 @@ struct _GstOMXBufferPoolClass
 
 GType gst_omx_buffer_pool_get_type (void);
 
+#ifdef TIZEN_FEATURE_OMX
+GstBufferPool *gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component, GstOMXPort * port,
+  GstOMXBufferMode output_mode);
+#else
 GstBufferPool *gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component, GstOMXPort * port);
+#endif
 
 G_END_DECLS
 
index d04daf7..0e546b6 100755 (executable)
@@ -38,7 +38,7 @@
 
 #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
 #include <gst/gl/gl.h>
-#include <gst/gl/egl/gsteglimagememory.h>
+#include <gst/gl/egl/gstglmemoryegl.h>
 #endif
 
 #if defined (USE_OMX_TARGET_RPI) && defined(__GNUC__)
@@ -86,7 +86,6 @@ static OMX_ERRORTYPE gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec
     * self);
 
 #ifdef TIZEN_FEATURE_OMX
-static gboolean gst_omx_video_dec_acquire_request_flush_buffer (GstOMXVideoDec * self, GstBuffer ** flush_request_buffer);
 static gboolean gst_omx_video_dec_handle_event (GstVideoDecoder * decoder, GstEvent *event);
 #endif
 
@@ -127,6 +126,7 @@ gst_omx_video_dec_class_init (GstOMXVideoDecClass * klass)
   video_decoder_class->handle_frame =
       GST_DEBUG_FUNCPTR (gst_omx_video_dec_handle_frame);
   video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_omx_video_dec_finish);
+  video_decoder_class->drain = GST_DEBUG_FUNCPTR (gst_omx_video_dec_drain);
   video_decoder_class->decide_allocation =
       GST_DEBUG_FUNCPTR (gst_omx_video_dec_decide_allocation);
 
@@ -137,7 +137,7 @@ gst_omx_video_dec_class_init (GstOMXVideoDecClass * klass)
   klass->cdata.type = GST_OMX_COMPONENT_TYPE_FILTER;
   klass->cdata.default_src_template_caps =
 #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
-      GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_EGL_IMAGE,
+      GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
       "RGBA") "; "
 #endif
       "video/x-raw, "
@@ -156,11 +156,6 @@ gst_omx_video_dec_init (GstOMXVideoDec * self)
 
   g_mutex_init (&self->drain_lock);
   g_cond_init (&self->drain_cond);
-
-#ifdef TIZEN_FEATURE_OMX
-  self->bufmgr = NULL;
-  self->drm_fd = -1;
-#endif
 }
 
 static gboolean
@@ -210,20 +205,12 @@ gst_omx_video_dec_open (GstVideoDecoder * decoder)
       out_port_index = param.nStartPortNumber + 1;
     }
   }
-
   self->dec_in_port = gst_omx_component_add_port (self->dec, in_port_index);
   self->dec_out_port = gst_omx_component_add_port (self->dec, out_port_index);
 
   if (!self->dec_in_port || !self->dec_out_port)
     return FALSE;
 
-#ifdef TIZEN_FEATURE_OMX
-  self->bufmgr = tbm_bufmgr_init(self->drm_fd);
-  if (self->bufmgr == NULL) {
-    GST_ERROR_OBJECT (self, "TBM initialization failed.");
-    return FALSE;
-  }
-
 #if defined(USE_OMX_TARGET_EXYNOS) || defined(USE_OMX_TARGET_EXYNOS64)
   {
     /* set plateform specific gem buffer settings. */
@@ -251,7 +238,6 @@ gst_omx_video_dec_open (GstVideoDecoder * decoder)
     self->dec_out_port->use_buffer = klass->cdata.out_port_usebuffer;
   }
 #endif
-#endif
 
   GST_DEBUG_OBJECT (self, "Opened decoder");
 
@@ -350,20 +336,6 @@ gst_omx_video_dec_shutdown (GstOMXVideoDec * self)
       gst_omx_component_get_state (self->dec, 5 * GST_SECOND);
   }
 
-#ifdef TIZEN_FEATURE_OMX
-   /* uninitialize tbm buffer manager */
-   if(self->bufmgr != NULL){
-    tbm_bufmgr_deinit(self->bufmgr);
-    self->bufmgr = NULL;
-   }
-
-   if(self->drm_fd != -1) {
-       GST_DEBUG_OBJECT (self, "close drm fd");
-       close(self->drm_fd);
-       self->drm_fd = -1;
-   }
-#endif
-
   return TRUE;
 }
 
@@ -476,20 +448,17 @@ gst_omx_video_dec_change_state (GstElement * element, GstStateChange transition)
   return ret;
 }
 
-#ifdef CODEC_DEC_INTPUT_DUMP /* for decoder input dump */
+#ifdef CODEC_DEC_INTPUT_DUMP
 static inline void
 decoder_input_dump (GstOMXBuffer * buf, gboolean use_buffer)
 {
-  gchar *temp;
   gchar filename[100]={0};
   FILE *fp = NULL;
 
-  temp = use_buffer ? buf->mm_vbuffer->data[0] : buf->omx_buf->pBuffer;
+  sprintf (filename, "/tmp/dec_input_dump.out");
+  fp = fopen (filename, "ab");
 
-  sprintf(filename, "/tmp/dec_input_dump.out");
-  fp = fopen(filename, "ab");
-
-  fwrite(temp, buf->omx_buf->nFilledLen, 1, fp);
+  fwrite (buf->omx_buf->pBuffer, buf->omx_buf->nFilledLen, 1, fp);
 
   fclose(fp);
 }
@@ -497,33 +466,47 @@ decoder_input_dump (GstOMXBuffer * buf, gboolean use_buffer)
 
 #ifdef CODEC_DEC_OUTPUT_DUMP /* for decoder output dump */
 static inline void
-decoder_output_dump(GstOMXVideoDec *self, MMVideoBuffer *outbuf)
+decoder_output_dump (GstOMXVideoDec *self, Gstbuffer *buffer)
 {
-  char *temp = (char *)outbuf->data[0];
   int i = 0;
   char filename[100]={0};
-  FILE *fp = NULL;
-  int ret =0;
+  FILE *fp = null;
+  tbm_surface_h surface;
+  tbm_surface_info_s info;
+  gstmemory *mem = gst_buffer_peek_memory (buffer, 0);
+  unsigned char *temp;
 
-  GST_ERROR_OBJECT (self, "codec dec output dump start. w = %d, h = %d", outbuf->width[0], outbuf->height[0]);
+  surface = gst_tizen_memory_get_surface (mem);
 
-  sprintf(filename, "/tmp/dec_output_dump_%d_%d.yuv", outbuf->width[0], outbuf->height[0]);
-  fp = fopen(filename, "ab");
+  tbm_surface_get_info (surface, &info);
+
+  GST_ERROR_OBJECT (self, "codec dec output dump start. stride width=%d, size=%d",
+    info.planes[0].stride, info.planes[0].size);
+
+  temp = info.planes[0].ptr;
+
+  sprintf (filename, "/tmp/dec_output_dump_%d_%d.yuv", info.width, info.height);
+  fp = fopen (filename, "ab");
+
+  if (!fp) {
+    GST_ERROR_OBJECT (self, "%s open failed", filename);
+    return;
+  }
 
-  for (i = 0; i < outbuf->height[0]; i++) {
-    ret = fwrite(temp, outbuf->width[0], 1, fp);
-    temp += outbuf->stride_width[0];
+  for (i = 0; i < info.hkeight; i++) {
+    fwrite (temp, info.width, 1, fp);
+    temp += info.planes[0].stride;
   }
 
-  temp = (char *)outbuf->data[1];
+  temp = info.planes[1].ptr;
 
-  for(i = 0; i < outbuf->height[1]; i++) {
-   ret = fwrite(temp, outbuf->width[1], 1, fp);
-    temp += outbuf->stride_width[1];
+  for (i = 0; i < info.height/2 ; i++) {
+    fwrite (temp, info.width, 1, fp);
+    temp += info.planes[1].stride;
   }
 
   GST_ERROR_OBJECT (self,"codec dec output dumped!! ret = %d", ret);
-  fclose(fp);
+  fclose (fp);
 }
 #endif
 
@@ -626,43 +609,10 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
 #endif
 #ifdef TIZEN_FEATURE_OMX
     case GST_VIDEO_FORMAT_SN12:
-    case GST_VIDEO_FORMAT_ST12: {
-      GstMemory *mem = NULL;
-      void *data = NULL;
-      MMVideoBuffer *mm_vbuffer = NULL;
-      mm_vbuffer = (MMVideoBuffer*)(inbuf->omx_buf->pBuffer);
-
-      if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
-        GST_LOG_OBJECT (self, "dec output buf: bo[0] :%p, bo[1] : %p, fd[0]:%d  fd[1]:%d fd[2]:%d  w[0]:%d h[0]:%d  buf_share_method:%d",
-            mm_vbuffer->handle.bo[0], mm_vbuffer->handle.bo[1], mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->handle.dmabuf_fd[2],
-            mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->type);
-      } else if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS) {
-        GST_LOG_OBJECT (self, "dec output uses hw addr");
-      } else {
-        GST_WARNING_OBJECT (self, "dec output buf has TBM_BO buf_share_method");
-      }
-#ifdef CODEC_DEC_OUTPUT_DUMP
-     decoder_output_dump(self, mm_vbuffer);
-#endif
-      if (gst_buffer_n_memory (outbuf) < 2) {
-        data = g_malloc0 (sizeof (MMVideoBuffer));
-        mem = gst_memory_new_wrapped (0, data, sizeof (MMVideoBuffer), 0, sizeof (MMVideoBuffer), data, g_free);
-        gst_buffer_append_memory (outbuf, mem);
-      } else {
-        GstMapInfo info = GST_MAP_INFO_INIT;
-
-        mem = gst_buffer_peek_memory (outbuf, 1);
-        gst_memory_map (mem, &info, GST_MAP_WRITE);
-        data = info.data;
-        gst_memory_unmap (mem, &info);
-      }
-      memcpy (data, mm_vbuffer, sizeof (MMVideoBuffer));
-
+    case GST_VIDEO_FORMAT_ST12:
       ret = TRUE;
-      break;
-    }
+    break;
 #endif
-
       default:
         g_assert_not_reached ();
         break;
@@ -792,7 +742,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
 
   if (caps)
     self->out_port_pool =
-        gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->dec, port);
+        gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->dec, port, GST_OMX_BUFFER_MODE_TBM);
 
 #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
   if (eglimage) {
@@ -955,7 +905,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
       was_enabled = FALSE;
     }
 #ifdef TIZEN_FEATURE_OMX
-    err = gst_omx_port_tbm_allocate_dec_buffers (port, self->bufmgr, port->use_buffer);
+    err = gst_omx_port_tbm_allocate_dec_buffers (port);
 #else
     err = gst_omx_port_allocate_buffers (port);
 #endif
@@ -990,7 +940,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
         }
       }
 #ifdef TIZEN_FEATURE_OMX
-      err = gst_omx_port_tbm_allocate_dec_buffers (port, self->bufmgr, port->use_buffer);
+      err = gst_omx_port_tbm_allocate_dec_buffers (port);
 #else
       err = gst_omx_port_allocate_buffers (port);
 #endif
@@ -1422,7 +1372,6 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
   GstClockTimeDiff deadline;
   OMX_ERRORTYPE err;
 #ifdef TIZEN_FEATURE_OMX
-  GstBuffer *flush_request_buffer = NULL;
   GstMessage *msg = NULL;
 #endif
 
@@ -1458,17 +1407,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
     /* Reallocate all buffers */
     if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE
         && gst_omx_port_is_enabled (port)) {
-#ifdef TIZEN_FEATURE_OMX
-      if (gst_omx_video_dec_acquire_request_flush_buffer (self, &flush_request_buffer)) {
-        flow_ret = gst_pad_push (GST_VIDEO_DECODER_SRC_PAD (self), flush_request_buffer);
 
-        if (flow_ret != GST_FLOW_OK) {
-          gst_buffer_unref (flush_request_buffer);
-          flush_request_buffer = NULL;
-          goto reconfigure_error;
-        }
-      }
-#endif
       err = gst_omx_port_set_enabled (port, FALSE);
       if (err != OMX_ErrorNone)
         goto reconfigure_error;
@@ -1632,38 +1571,6 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
         goto invalid_buffer;
       }
     }
-#ifdef TIZEN_FEATURE_OMX
-    {
-      MMVideoBuffer *mm_vbuffer = NULL;
-      GstMemory *mem = NULL;
-      guint8 *data = NULL;
-      mm_vbuffer = (MMVideoBuffer*)(buf->omx_buf->pBuffer);
-
-      if (gst_buffer_n_memory (outbuf) < 2) {
-        data = g_malloc0 (sizeof (MMVideoBuffer));
-        mem = gst_memory_new_wrapped (0, data, sizeof(MMVideoBuffer), 0, sizeof(MMVideoBuffer), data, g_free);
-        gst_buffer_append_memory (outbuf, mem);
-      } else {
-        GstMapInfo info = GST_MAP_INFO_INIT;
-        mem = gst_buffer_peek_memory (outbuf, 1);
-        gst_memory_map (mem, &info, GST_MAP_WRITE);
-        data = info.data;
-        gst_memory_unmap (mem, &info);
-      }
-      memcpy(data, mm_vbuffer, sizeof(MMVideoBuffer));
-      buf = NULL;
-
-      if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
-        GST_LOG_OBJECT (self, "frame not found: bo[0] :%p, bo[1] : %p, fd[0]:%d  fd[1]:%d fd[2]:%d  w[0]:%d h[0]:%d  buf_share_method:%d",
-            mm_vbuffer->handle.bo[0], mm_vbuffer->handle.bo[1], mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->handle.dmabuf_fd[2],
-            mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->type);
-      } else if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS) {
-        GST_LOG_OBJECT (self, "dec output uses hw addr");
-      } else {
-        GST_WARNING_OBJECT (self, "dec output buf has TBM_BO buf_share_method");
-      }
-    }
-#endif
     flow_ret = gst_pad_push (GST_VIDEO_DECODER_SRC_PAD (self), outbuf);
   } else if (buf->omx_buf->nFilledLen > 0 || buf->eglimage) {
     if (self->out_port_pool) {
@@ -2266,8 +2173,7 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
     if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
 #ifdef TIZEN_FEATURE_OMX
-    if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port,
-        self->bufmgr, self->dec_in_port->use_buffer) != OMX_ErrorNone)
+    if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port) != OMX_ErrorNone)
      return FALSE;
 #else
     if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
@@ -2310,11 +2216,9 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
 
       /* Need to allocate buffers to reach Idle state */
 #ifdef TIZEN_FEATURE_OMX
-      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port,
-          self->bufmgr, self->dec_in_port->use_buffer) != OMX_ErrorNone)
+      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port) != OMX_ErrorNone)
           return FALSE;
-      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_out_port,
-          self->bufmgr, self->dec_out_port->use_buffer) != OMX_ErrorNone)
+      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_out_port) != OMX_ErrorNone)
           return FALSE;
 #else
       if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
@@ -2330,11 +2234,9 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder,
 
       /* Need to allocate buffers to reach Idle state */
 #ifdef TIZEN_FEATURE_OMX
-      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port,
-          self->bufmgr, self->dec_in_port->use_buffer) != OMX_ErrorNone)
+      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_in_port) != OMX_ErrorNone)
           return FALSE;
-      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_out_port,
-          self->bufmgr, self->dec_out_port->use_buffer) != OMX_ErrorNone)
+      if (gst_omx_port_tbm_allocate_dec_buffers (self->dec_out_port) != OMX_ErrorNone)
           return FALSE;
 #else
       if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
@@ -2555,7 +2457,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
         goto reconfigure_error;
       }
 #ifdef TIZEN_FEATURE_OMX
-      err = gst_omx_port_tbm_allocate_dec_buffers (port, self->bufmgr, port->use_buffer);
+      err = gst_omx_port_tbm_allocate_dec_buffers (port);
 #else
       err = gst_omx_port_allocate_buffers (port);
 #endif
@@ -2609,20 +2511,13 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
       buf->omx_buf->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
       buf->omx_buf->nFilledLen = gst_buffer_get_size (codec_data);;
 
-#ifdef TIZEN_FEATURE_OMX
-      if (port->use_buffer) {
-        gst_buffer_extract (codec_data, 0,
-            (OMX_U8 *) buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
-            buf->omx_buf->nFilledLen);
-      } else {
-        gst_buffer_extract (codec_data, 0,
-            buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
-            buf->omx_buf->nFilledLen);
-      }
+      gst_buffer_extract (codec_data, 0,
+          buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
+          buf->omx_buf->nFilledLen);
+
 #ifdef CODEC_DEC_INTPUT_DUMP
       decoder_input_dump (buf, port->use_buffer);
 #endif
-#endif
 
       if (GST_CLOCK_TIME_IS_VALID (timestamp))
         buf->omx_buf->nTimeStamp =
@@ -2649,20 +2544,14 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
         MIN (size - offset, buf->omx_buf->nAllocLen - buf->omx_buf->nOffset);
     GST_DEBUG_OBJECT (self, "nFilledLen %lu, %p", buf->omx_buf->nFilledLen, buf->omx_buf->pBuffer);
 
-#ifdef TIZEN_FEATURE_OMX
-    if (port->use_buffer) {
-      gst_buffer_extract (frame->input_buffer, offset,
-          (OMX_U8 *) buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
-          buf->omx_buf->nFilledLen);
-    } else {
-      gst_buffer_extract (frame->input_buffer, offset,
-          buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
-          buf->omx_buf->nFilledLen);
-    }
+    gst_buffer_extract (frame->input_buffer, offset,
+        buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
+        buf->omx_buf->nFilledLen);
+
 #ifdef CODEC_DEC_INTPUT_DUMP
       decoder_input_dump (buf, port->use_buffer);
 #endif
-#endif
+
     if (timestamp != GST_CLOCK_TIME_NONE) {
       buf->omx_buf->nTimeStamp =
           gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
@@ -2923,43 +2812,6 @@ gst_omx_video_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
 
 #ifdef TIZEN_FEATURE_OMX
 static gboolean
-gst_omx_video_dec_acquire_request_flush_buffer (GstOMXVideoDec * self, GstBuffer ** flush_request_buffer)
-{
-  guint8 *dummy_data = NULL;
-  GstBuffer *buf = NULL;
-  MMVideoBuffer *mm_vbuffer = NULL;
-
-  GST_DEBUG_OBJECT (self, "flush buffer request");
-
-  if (self->out_port_pool) {
-    if (gst_buffer_pool_is_active(self->out_port_pool)) {
-      dummy_data = g_malloc0(128*128);
-      buf = gst_buffer_new_wrapped(dummy_data, 128*128);
-      mm_vbuffer = g_malloc(sizeof(MMVideoBuffer));
-
-      mm_vbuffer->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
-      mm_vbuffer->size[0] = 0;
-      mm_vbuffer->flush_request = TRUE;
-
-      gst_buffer_append_memory(buf,
-        gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, mm_vbuffer, sizeof(MMVideoBuffer), 0,
-          sizeof(MMVideoBuffer), mm_vbuffer, g_free));
-
-      *flush_request_buffer = buf;
-
-      GST_DEBUG_OBJECT (self, "flush buffer requested");
-      return TRUE;
-    } else {
-        GST_DEBUG_OBJECT (self, "the out port pool has not yet been activated");
-        return FALSE;
-    }
-  } else {
-    GST_DEBUG_OBJECT (self, "the output port has not yet been activated");
-    return FALSE;
-  }
-}
-
-static gboolean
 gst_omx_video_dec_handle_event (GstVideoDecoder * decoder,
     GstEvent * event)
 {
index fd08a83..000d02f 100755 (executable)
@@ -77,10 +77,6 @@ struct _GstOMXVideoDec
   gboolean draining;
 
   GstFlowReturn downstream_flow_ret;
-#ifdef TIZEN_FEATURE_OMX
-  gint drm_fd;
-  tbm_bufmgr bufmgr;
-#endif
 #ifdef USE_OMX_TARGET_RPI
   GstOMXComponent *egl_render;
   GstOMXPort *egl_in_port, *egl_out_port;
index 0c84e6f..8e2f179 100755 (executable)
@@ -211,13 +211,10 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self)
 
   g_mutex_init (&self->drain_lock);
   g_cond_init (&self->drain_cond);
-#ifdef TIZEN_FEATURE_OMX
-  self->bufmgr = NULL;
-  self->drm_fd = -1;
-#endif
 }
-
+/*
 #ifdef CODEC_ENC_INPUT_DUMP
+
 static inline void
 gst_omx_video_enc_input_dump (MMVideoBuffer *inbuf)
 {
@@ -246,7 +243,7 @@ gst_omx_video_enc_input_dump (MMVideoBuffer *inbuf)
   fclose(fp);
 }
 #endif
-
+*/
 static gboolean
 gst_omx_video_enc_open (GstVideoEncoder * encoder)
 {
@@ -393,12 +390,6 @@ gst_omx_video_enc_open (GstVideoEncoder * encoder)
     }
   }
 #ifdef TIZEN_FEATURE_OMX
-   self->bufmgr = tbm_bufmgr_init (self->drm_fd);
-   if (self->bufmgr == NULL){
-    GST_ERROR_OBJECT (self, "TBM initialization failed.");
-    return FALSE;
-   }
-
   self->enc_in_port->use_buffer = klass->cdata.in_port_usebuffer;
   self->enc_out_port->use_buffer = klass->cdata.out_port_usebuffer;
 
@@ -795,7 +786,7 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
       if (err != OMX_ErrorNone)
         goto reconfigure_error;
 #ifdef TIZEN_FEATURE_OMX
-    err = gst_omx_port_tbm_allocate_enc_buffers(port, self->bufmgr, port->use_buffer);
+    err = gst_omx_port_tbm_allocate_enc_buffers (port);
 #else
       err = gst_omx_port_allocate_buffers (port);
 #endif
@@ -1168,11 +1159,12 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
 
     case OMX_EXT_COLOR_FormatNV12LPhysicalAddress: /* FALL THROUGH */
     case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
+/*
 #ifdef TIZEN_FEATURE_OMX
         port_def.nBufferSize = sizeof(MMVideoBuffer);
 #endif
         break;
-
+*/
     default:
       g_assert_not_reached ();
   }
@@ -1272,8 +1264,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
     if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone)
       return FALSE;
 #ifdef TIZEN_FEATURE_OMX
-    if (gst_omx_port_tbm_allocate_enc_buffers (self->enc_in_port, self->bufmgr,
-        self->enc_in_port->use_buffer) != OMX_ErrorNone)
+    if (gst_omx_port_tbm_allocate_enc_buffers (self->enc_in_port) != OMX_ErrorNone)
         return FALSE;
 #else
     if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
@@ -1320,8 +1311,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
 
       /* Need to allocate buffers to reach Idle state */
 #ifdef TIZEN_FEATURE_OMX
-    if (gst_omx_port_tbm_allocate_enc_buffers(self->enc_in_port, self->bufmgr,
-        self->enc_in_port->use_buffer) != OMX_ErrorNone)
+    if (gst_omx_port_tbm_allocate_enc_buffers (self->enc_in_port) != OMX_ErrorNone)
         return FALSE;
 #else
       if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
@@ -1329,8 +1319,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
 #endif
 
 #ifdef TIZEN_FEATURE_OMX
-    if (gst_omx_port_tbm_allocate_enc_buffers(self->enc_out_port, self->bufmgr,
-        self->enc_out_port->use_buffer) != OMX_ErrorNone)
+    if (gst_omx_port_tbm_allocate_enc_buffers (self->enc_out_port) != OMX_ErrorNone)
 #else
       if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone)
 #endif
@@ -1563,6 +1552,7 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
       ret = TRUE;
       break;
     }
+/*
     case GST_VIDEO_FORMAT_ST12:
     case GST_VIDEO_FORMAT_SN12:
     {
@@ -1603,6 +1593,7 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
       ret = TRUE;
       break;
     }
+*/
     default:
       GST_ERROR_OBJECT (self, "Unsupported format");
       goto done;
@@ -1684,7 +1675,7 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
         goto reconfigure_error;
       }
 #ifdef TIZEN_FEATURE_OMX
-    err = gst_omx_port_tbm_allocate_enc_buffers (port, self->bufmgr, port->use_buffer);
+    err = gst_omx_port_tbm_allocate_enc_buffers (port);
 #else
       err = gst_omx_port_allocate_buffers (port);
 #endif
index 06748c0..988a3ce 100755 (executable)
@@ -76,10 +76,6 @@ struct _GstOMXVideoEnc
   guint32 quant_b_frames;
 
   GstFlowReturn downstream_flow_ret;
-#ifdef TIZEN_FEATURE_OMX
-  gint drm_fd;
-  tbm_bufmgr bufmgr;
-#endif
 };
 
 struct _GstOMXVideoEncClass
index 2ff2c82..4dbeef2 100755 (executable)
@@ -10,8 +10,8 @@ Source1001:     gst-omx.manifest
 BuildRequires:  which
 BuildRequires:  pkgconfig(gstreamer-1.0)
 BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
-BuildRequires: pkgconfig(libtbm)
-BuildRequires: pkgconfig(mm-common)
+BuildRequires:  pkgconfig(libtbm)
+BuildRequires:  pkgconfig(mm-common)
 ExclusiveArch: %arm aarch64
 
 %description