Adding conditional compilation for SN12 conversion and tbm buffers.
authorBarun Kumar Singh <barun.singh@samsung.com>
Tue, 4 Aug 2015 10:32:27 +0000 (16:02 +0530)
committerBarun Kumar Singh <barun.singh@samsung.com>
Thu, 20 Aug 2015 06:06:07 +0000 (11:36 +0530)
Signed-off-by: Barun Kumar Singh <barun.singh@samsung.com>
Change-Id: I45ed1ccb347162eed8a894ab000bb86bc5e3742d

configure.ac
gst/videoconvert/Makefile.am
gst/videoconvert/gsttbmbufferpool.c
gst/videoconvert/gsttbmbufferpool.h
gst/videoconvert/gstvideoconvert.c
gst/videoconvert/videoconvert.c
packaging/gst-plugins-base.spec

index 7b498c5..adc6086 100644 (file)
@@ -153,6 +153,19 @@ AM_CONDITIONAL(HAVE_CXX, test "x$working_cxx" = "xyes")
 AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
 AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
 
+dnl check for tbm buffer
+
+AC_ARG_ENABLE(tbmbuf, AC_HELP_STRING([--enable-use-tbmbuf], [use tbm buf]),
+        [
+          case "${enableval}" in
+           yes) BOARD_USE_TBM_BUF=yes ;;
+           no)  BOARD_USE_TBM_BUF=no ;;
+           *)   AC_MSG_ERROR(bad value ${enableval} for --enable-use-tbmbuf) ;;
+          esac
+        ],
+        [BOARD_USE_TBM_BUF=yes])
+AM_CONDITIONAL([BOARD_USE_TBM_BUF], [test "x$BOARD_USE_TBM_BUF" = "xyes"])
+
 dnl check for gobject-introspection
 GOBJECT_INTROSPECTION_CHECK([1.31.1])
 
index 50ce71c..70eeada 100644 (file)
@@ -3,29 +3,30 @@ plugin_LTLIBRARIES = libgstvideoconvert.la
 ORC_SOURCE=gstvideoconvertorc
 include $(top_srcdir)/common/orc.mak
 
-libgstvideoconvert_la_SOURCES = gsttbmbufferpool.c gstvideoconvert.c videoconvert.c gstcms.c
+libgstvideoconvert_la_SOURCES = gstvideoconvert.c videoconvert.c gstcms.c
 nodist_libgstvideoconvert_la_SOURCES = $(ORC_NODIST_SOURCES)
 libgstvideoconvert_la_CFLAGS = \
        $(GST_PLUGINS_BASE_CFLAGS) \
        $(GST_CFLAGS) \
-       $(ORC_CFLAGS) \
-       $(MMCOMMON_CFLAGS) \
-       $(TBM_CFLAGS)
-
-libgstvideoconvert_la_CFLAGS += -DUSE_TBM_BUFFER
+       $(ORC_CFLAGS)
 
 libgstvideoconvert_la_LIBADD = \
        $(top_builddir)/gst-libs/gst/video/libgstvideo-$(GST_API_VERSION).la \
        $(GST_BASE_LIBS) \
        $(GST_LIBS) \
-       $(ORC_LIBS) \
-       $(LIBM) \
-       $(TBM_LIBS)
-libgstvideoconvert_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(TBM_LDFLAGS)
+       $(ORC_LIBS)
+libgstvideoconvert_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstvideoconvert_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
 
 noinst_HEADERS = gstvideoconvert.h videoconvert.h gstcms.h
 
+if BOARD_USE_TBM_BUF
+libgstvideoconvert_la_SOURCES += gsttbmbufferpool.c
+libgstvideoconvert_la_CFLAGS += -DUSE_TBM_BUFFER $(MMCOMMON_CFLAGS) $(TBM_CFLAGS)
+libgstvideoconvert_la_LIBADD += $(TBM_LIBS) $(MM_COMMON_LIBS)
+libgstvideoconvert_la_LDFLAGS += $(TBM_LDFLAGS) $(MM_COMMON_LDFLAGS)
+endif
+
 Android.mk: Makefile.am $(BUILT_SOURCES)
        androgenizer \
        -:PROJECT libgstvideoconvert -:SHARED libgstvideoconvert \
index aa63852..5743177 100644 (file)
@@ -2,6 +2,28 @@
 #include "gsttbmbufferpool.h"
 #include <gst/video/gstvideofilter.h>
 
+
+int calc_yplane(int width, int height)
+{
+    int mbX, mbY;
+
+    mbX = DIV_ROUND_UP(width, 16);
+    mbY = DIV_ROUND_UP(height, 16);
+
+    return (ALIGN((mbX * mbY) * 256, 256) + 256);
+}
+
+int calc_uvplane(int width, int height)
+{
+    int mbX, mbY;
+
+    mbX = DIV_ROUND_UP(width, 16);
+    mbY = DIV_ROUND_UP(height, 16);
+
+    return (ALIGN((mbX * mbY) * 128, 256) + 128);
+}
+
+
 static GstMemory *
 gst_mm_memory_allocator_alloc_dummy (GstAllocator * allocator, gsize size,
     GstAllocationParams * params)
@@ -236,12 +258,15 @@ gst_mm_buffer_pool_alloc_buffer (GstBufferPool * bpool,
     mm_video_buf->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
     mm_video_buf->plane_num = 2;
     /* Setting Y plane size */
-    mm_video_buf->size[0] = width * height;
+    mm_video_buf->size[0] = calc_yplane(width, height);
     /* Setting UV plane size */
-    mm_video_buf->size[1] = (width * height) >> 1;
+    mm_video_buf->size[1] = calc_uvplane(width, height);
     mm_video_buf->handle.bo[0] = tbm_bo_alloc(pool->hTBMBufMgr, mm_video_buf->size[0], TBM_BO_WC);
     mm_video_buf->handle.bo[1] = tbm_bo_alloc(pool->hTBMBufMgr, mm_video_buf->size[1], TBM_BO_WC);
 
+    mm_video_buf->handle.dmabuf_fd[0] = (tbm_bo_get_handle(mm_video_buf->handle.bo[0], TBM_DEVICE_MM)).u32;
+    mm_video_buf->handle.dmabuf_fd[1] = (tbm_bo_get_handle(mm_video_buf->handle.bo[1], TBM_DEVICE_MM)).u32;
+
     mm_video_buf->handle.paddr[0] = (tbm_bo_map(mm_video_buf->handle.bo[0], TBM_DEVICE_CPU,TBM_OPTION_WRITE)).ptr;
     mm_video_buf->handle.paddr[1] = (tbm_bo_map(mm_video_buf->handle.bo[1], TBM_DEVICE_CPU,TBM_OPTION_WRITE)).ptr;
     /* Setting stride height & width for Y plane */
index ec2de2e..8b1ef6c 100644 (file)
@@ -15,6 +15,8 @@
 #include <tbm_bufmgr.h>
 #endif
 
+#define ALIGN(x, a)       (((x) + (a) - 1) & ~((a) - 1))
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 
 typedef struct _GstMMVideoMemory                GstMMVideoMemory;
 typedef struct _GstMMVideoMemoryAllocator       GstMMVideoMemoryAllocator;
index 6a5c6b6..3c42bcf 100644 (file)
@@ -50,8 +50,6 @@
 #ifdef USE_TBM_BUFFER
 #include <mm_types.h>
 #include "gsttbmbufferpool.h"
-#else
-#error "Not including MM_TYPES"
 #endif
 
 #include <string.h>
@@ -491,7 +489,13 @@ gst_video_convert_finalize (GObject * obj)
   if (space->convert) {
     videoconvert_convert_free (space->convert);
   }
-
+#ifdef USE_TBM_BUFFER
+  if(space->tbm_buffer_pool) {
+     gst_buffer_pool_set_active (space->tbm_buffer_pool, FALSE);
+     gst_object_unref (space->tbm_buffer_pool);
+     space->tbm_buffer_pool = NULL;
+  }
+#endif
   G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
 
@@ -548,6 +552,9 @@ gst_video_convert_class_init (GstVideoConvertClass * klass)
 static void
 gst_video_convert_init (GstVideoConvert * space)
 {
+#ifdef USE_TBM_BUFFER
+  space->tbm_buffer_pool = NULL;
+#endif
 }
 
 void
@@ -638,7 +645,7 @@ gst_video_convert_decide_allocation (GstBaseTransform * trans,
           if(vc->tbm_buffer_pool == NULL) {
               min = 8;
               max = 11;
-              GST_ERROR("[%s]CREATING VIDEO_BUFFER_POOL",__FUNCTION__);
+              GST_DEBUG("[%s]CREATING VIDEO_BUFFER_POOL",__FUNCTION__);
               vc->tbm_buffer_pool = gst_mm_buffer_pool_new(trans);
           }
           config = gst_buffer_pool_get_config (vc->tbm_buffer_pool);
@@ -658,7 +665,7 @@ gst_video_convert_decide_allocation (GstBaseTransform * trans,
 
           gst_buffer_pool_set_active(vc->tbm_buffer_pool,TRUE);
 
-          GST_ERROR("[%s]BUFFER_POOL max:[%d], min:[%d]",__FUNCTION__, max, min);
+          GST_DEBUG("[%s]BUFFER_POOL max:[%d], min:[%d]",__FUNCTION__, max, min);
   }
   return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans, query);
 
@@ -676,7 +683,7 @@ gst_video_convert_prepare_output_buffer (GstBaseTransform * trans,
 
   if(filter->out_info.finfo->format == GST_VIDEO_FORMAT_SN12 ) {
       if(gst_buffer_pool_acquire_buffer(vc->tbm_buffer_pool,outbuf,0) != GST_FLOW_OK) {
-        GST_ERROR("[%s] memory prepared failed.",__FUNCTION__);
+        GST_ERROR("[%s] memory prepare failed.",__FUNCTION__);
         return GST_FLOW_ERROR;
       }
       return GST_FLOW_OK;
index a61a008..120bf66 100644 (file)
@@ -810,7 +810,6 @@ convert_I420_SN12 (VideoConvert * convert, GstVideoFrame * dest,
   gint height = convert->height;
 
   if(gst_buffer_n_memory(dest->buffer) >= 2) {
-      GST_DEBUG("[%s] Retrieving GstMemory at position 1.",__FUNCTION__);
       GstMapInfo map_info = GST_MAP_INFO_INIT;
       mem = gst_buffer_peek_memory (dest->buffer, 1);
       if (mem != NULL) {
@@ -829,7 +828,6 @@ convert_I420_SN12 (VideoConvert * convert, GstVideoFrame * dest,
   mY = mm_video_buf->handle.paddr[0];
   mUV = mm_video_buf->handle.paddr[1];
 
-  GST_DEBUG(" Addr Y:[%p] UV:[%p]",mY,mUV);
   for (int i = 0; i < GST_ROUND_DOWN_2 (height); i += 2) {
     GET_LINE_OFFSETS (interlaced, i, l1, l2);
 
@@ -848,7 +846,6 @@ convert_I420_SN12 (VideoConvert * convert, GstVideoFrame * dest,
     }
   }
 
-  GST_ERROR("RETURNING [%s]",__FUNCTION__);
 }
 
 static void
index d5264b8..3f0eb7f 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:           gst-plugins-base
 Version:        1.4.1
-Release:        6
+Release:        7
 License:        LGPL-2.1+ and GPL-2.0+
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 Url:            http://gstreamer.freedesktop.org/