1. minimize the component's memory allocation in the encoder 45/189645/5 accepted/tizen_5.0_unified tizen_5.0 accepted/tizen/5.0/unified/20181102.024315 accepted/tizen/unified/20180921.143058 submit/tizen/20180920.072713 submit/tizen_5.0/20181101.000006
authorSejun Park <sejun79.park@samsung.com>
Wed, 19 Sep 2018 10:47:34 +0000 (19:47 +0900)
committerSejun Park <sejun79.park@samsung.com>
Thu, 20 Sep 2018 05:18:33 +0000 (14:18 +0900)
2. remove build warning

Change-Id: Ib6cc75c5067fa312cb029b2cb9b12577f3dba148

omx/gstomx.c
omx/gstomx.h
omx/gstomxbufferpool.c
omx/gstomxbufferpool.h
omx/gstomxvideodec.c
omx/gstomxvideoenc.c
omx/gstomxvideoenc.h

index affb656..08db993 100644 (file)
@@ -1803,9 +1803,8 @@ gst_omx_port_allocate_buffers (GstOMXPort * port)
 OMX_ERRORTYPE
 gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port)
 {
-  guint n = 0;
+  gint i = 0;
   gint num = 0;
-  gint i = 0 , j = 0;
   GList *buffers = NULL;
   tbm_surface_h buffer[MAX_INPUT_BUFFER];
   GstOMXComponent *comp;
@@ -1878,21 +1877,24 @@ gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port)
   gint i = 0;
   gint num = 0;
   GList *buffers = NULL;
-  tbm_bo_handle handle_bo;
   tbm_surface_h buffer[MAX_INPUT_BUFFER];
 
   g_return_val_if_fail (port != NULL, OMX_ErrorUndefined);
 
   g_mutex_lock (&port->comp->lock);
 
-  /*deallocate previous allocated buffers...*/
+  /* deallocate previous allocated buffers... */
   if (port->buffers)
     gst_omx_port_deallocate_buffers (port);
 
   if (port->use_buffer) {
     for (i = 0; i < port->port_def.nBufferCountActual; i++) {
-      buffer[i] = tbm_surface_internal_create_with_flags (port->port_def.format.video.nFrameWidth,
-              port->port_def.format.video.nFrameHeight, TBM_FORMAT_NV12, TBM_BO_WC);
+
+      /* Since the input buffer is queued via OMX_EmptyThisBuffer(),
+       * a minimum amount of memory is sufficient.
+       */
+      buffer[i] = tbm_surface_internal_create_with_flags (128, 128, TBM_FORMAT_NV12, TBM_BO_WC);
+
       if (!buffer[i]) {
         g_mutex_unlock (&port->comp->lock);
         goto error;
index e16fbaa..6ceef29 100644 (file)
 #include <OMX_Component.h>
 
 #ifdef TIZEN_FEATURE_OMX
-#include <tbm_type.h>
-#include <tbm_surface.h>
-#include <tbm_bufmgr.h>
 #include <unistd.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+#include <gst/allocators/gstdmabuf.h>
+#include <gst/allocators/gsttizenmemory.h>
 #endif
 
 #ifdef USE_OMX_TARGET_RPI
index 22e7e22..7f3decc 100644 (file)
@@ -25,9 +25,6 @@
 #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
@@ -133,7 +130,6 @@ 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);
@@ -213,6 +209,7 @@ gst_omx_memory_allocator_init (GstOMXMemoryAllocator * allocator)
   GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
 }
 
+#ifndef TIZEN_FEATURE_OMX
 static GstMemory *
 gst_omx_memory_allocator_alloc (GstAllocator * allocator, GstMemoryFlags flags,
     GstOMXBuffer * buf)
@@ -248,6 +245,7 @@ gst_omx_memory_allocator_alloc (GstAllocator * allocator, GstMemoryFlags flags,
 
   return GST_MEMORY_CAST (mem);
 }
+#endif
 
 /* Buffer pool for the buffers of an OpenMAX port.
  *
@@ -484,13 +482,12 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
 
 #ifdef TIZEN_FEATURE_OMX
     tbm_surface_h surface;
-    GstMapInfo map;
     uint32_t _offset = 0;
     uint32_t _stride = 0;
 
     surface = (tbm_surface_h) omx_buf->omx_buf->pBuffer;
 
-    mem = gst_tizen_allocator_alloc_surface (pool->allocator, &pool->video_info, surface, omx_buf, _destroy_tbm_surface);
+    mem = gst_tizen_allocator_alloc_surface (pool->allocator, &pool->video_info, surface, omx_buf, (GDestroyNotify) _destroy_tbm_surface);
 #else
     mem = gst_omx_memory_allocator_alloc (pool->allocator, 0, omx_buf);
 #endif
index 7f14bfe..2705032 100644 (file)
@@ -103,6 +103,11 @@ 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);
+
+gboolean gst_omx_video_memory_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
+    gpointer * data, gint * stride, GstMapFlags flags);
+
+gboolean gst_omx_video_memory_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info);
 #else
 GstBufferPool *gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component, GstOMXPort * port);
 #endif
index 01bd9e3..02d2751 100644 (file)
@@ -127,7 +127,6 @@ 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);
 
@@ -974,10 +973,13 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
     config = gst_buffer_pool_get_config (self->out_port_pool);
 
 #ifndef TIZEN_FEATURE_OMX
-  if (add_videometa)
+    if (add_videometa)
 #endif
+    /* FIXME : it doensn't get a list of options supported by pool */
+    GST_DEBUG_OBJECT (self, "Check if the pool supports option %d", add_videometa);
+
     gst_buffer_pool_config_add_option (config,
-        GST_BUFFER_POOL_OPTION_VIDEO_META);
+      GST_BUFFER_POOL_OPTION_VIDEO_META);
 
     gst_buffer_pool_config_set_params (config, caps,
         self->dec_out_port->port_def.nBufferSize, min, max);
index 5ffcabc..e692aee 100644 (file)
@@ -1555,10 +1555,23 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
 #ifdef TIZEN_FEATURE_OMX
     case GST_VIDEO_FORMAT_ST12:
     case GST_VIDEO_FORMAT_SN12: {
+      tbm_surface_h surface;
       GstMemory *mem = gst_buffer_peek_memory (inbuf, 0);
-      outbuf->omx_buf->pBuffer = gst_tizen_memory_get_surface (mem);
-      outbuf->omx_buf->nAllocLen = tbm_surface_internal_get_size (gst_tizen_memory_get_surface (mem));
-      outbuf->omx_buf->nFilledLen = tbm_surface_internal_get_size (gst_tizen_memory_get_surface (mem));
+
+      if (!gst_is_tizen_memory (mem)) {
+        GST_ERROR_OBJECT (self, "Invalid input buffer");
+        ret = FALSE;
+        break;
+      }
+
+      if (!(surface = gst_tizen_memory_get_surface (mem))) {
+        GST_ERROR_OBJECT (self, "Failed to get surface from tizen memory");
+        ret = FALSE;
+        break;
+      }
+      outbuf->omx_buf->pBuffer = (OMX_U8 *) surface;
+      outbuf->omx_buf->nAllocLen = (OMX_U32) tbm_surface_internal_get_size (surface);
+      outbuf->omx_buf->nFilledLen = (OMX_U32) tbm_surface_internal_get_size (surface);
 #ifdef CODEC_ENC_INPUT_DUMP
       gst_omx_video_enc_input_dump (inbuf);
 #endif
index 988a3ce..176ea99 100644 (file)
@@ -24,7 +24,6 @@
 #include <gst/gst.h>
 #include <gst/video/video.h>
 #include <gst/video/gstvideoencoder.h>
-#include <tbm_bufmgr.h>
 
 #include "gstomx.h"