[Build/Filter] code clean
authorJaeyun <jy1210.jung@samsung.com>
Fri, 8 Feb 2019 08:52:09 +0000 (17:52 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 8 Feb 2019 11:18:46 +0000 (20:18 +0900)
fix typo and clean up build script,

1. remove unnecessary variable and dependency.
2. set common path and dependencies, clean up meson script.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
13 files changed:
ext/nnstreamer/tensor_filter/meson.build
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow.c
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h
gst/nnstreamer/meson.build
gst/nnstreamer/tensor_filter/tensor_filter.c
gst/nnstreamer/tensor_filter/tensor_filter_custom.c
gst/nnstreamer/tensor_typedef.h
meson.build
packaging/nnstreamer.spec

index 616251b..adfb810 100644 (file)
@@ -1,51 +1,48 @@
-
 if have_tensorflow
-  tensor_filter_tfcore_lib_shared = shared_library('nnstreamer_filter_tensorflow',
-      [
-        'tensor_filter_tensorflow_core.cc',
-        'tensor_filter_tensorflow.c'
-      ],
+  nnstreamer_filter_tf_sources = [
+    'tensor_filter_tensorflow.c',
+    'tensor_filter_tensorflow_core.cc'
+  ]
+
+  nnstreamer_filter_tf_deps = [tf_dep, protobuf_dep, glib_dep, gst_dep, nnstreamer_dep]
+
+  shared_library('nnstreamer_filter_tensorflow',
+    nnstreamer_filter_tf_sources,
     cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tf_dep, protobuf_dep, nnstreamer_dep],
-    include_directories: nnstreamer_inc,
+    dependencies: nnstreamer_filter_tf_deps,
     install: true,
-    install_dir: join_paths(subplugin_install_prefix, 'filters')
+    install_dir: filter_subplugin_install_dir
   )
 
-  tensor_filter_tfcore_lib_static = static_library('nnstreamer_filter_tensorflow',
-      [
-        'tensor_filter_tensorflow_core.cc',
-        'tensor_filter_tensorflow.c'
-      ],
+  static_library('nnstreamer_filter_tensorflow',
+    nnstreamer_filter_tf_sources,
     cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tf_dep, protobuf_dep, nnstreamer_dep],
-    include_directories: nnstreamer_inc,
+    dependencies: nnstreamer_filter_tf_deps,
     install: true,
     install_dir: nnstreamer_libdir
   )
 endif
 
 if have_tensorflow_lite
-  tensor_filter_tflitecore_lib_shared = shared_library('nnstreamer_filter_tensorflow-lite',
-      [
-        'tensor_filter_tensorflow_lite_core.cc',
-        'tensor_filter_tensorflow_lite.c'
-      ],
+  nnstreamer_filter_tflite_sources = [
+    'tensor_filter_tensorflow_lite.c',
+    'tensor_filter_tensorflow_lite_core.cc'
+  ]
+
+  nnstreamer_filter_tflite_deps = [tflite_dep, thread_dep, libdl_dep, glib_dep, gst_dep, nnstreamer_dep]
+
+  shared_library('nnstreamer_filter_tensorflow-lite',
+    nnstreamer_filter_tflite_sources,
     cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tflite_dep, nnstreamer_dep],
-    include_directories: nnstreamer_inc,
+    dependencies: nnstreamer_filter_tflite_deps,
     install: true,
-    install_dir: join_paths(subplugin_install_prefix, 'filters')
+    install_dir: filter_subplugin_install_dir
   )
 
-  tensor_filter_tflitecore_lib_static = static_library('nnstreamer_filter_tensorflow-lite',
-      [
-        'tensor_filter_tensorflow_lite_core.cc',
-        'tensor_filter_tensorflow_lite.c'
-      ],
+  static_library('nnstreamer_filter_tensorflow-lite',
+    nnstreamer_filter_tflite_sources,
     cpp_args: ['-Wno-sign-compare'],
-    dependencies: [tflite_dep, nnstreamer_dep],
-    include_directories: nnstreamer_inc,
+    dependencies: nnstreamer_filter_tflite_deps,
     install: true,
     install_dir: nnstreamer_libdir
   )
index 296a306..640f124 100644 (file)
@@ -135,8 +135,7 @@ tf_getInputDim (const GstTensorFilterProperties * prop, void **private_data,
   tf_data *tf;
   tf = *private_data;
   g_assert (*private_data);
-  int ret = tf_core_getInputDim (tf->tf_private_data, info);
-  return ret;
+  return tf_core_getInputDim (tf->tf_private_data, info);
 }
 
 /**
@@ -152,8 +151,7 @@ tf_getOutputDim (const GstTensorFilterProperties * prop, void **private_data,
   tf_data *tf;
   tf = *private_data;
   g_assert (*private_data);
-  int ret = tf_core_getOutputDim (tf->tf_private_data, info);
-  return ret;
+  return tf_core_getOutputDim (tf->tf_private_data, info);
 }
 
 /**
index 8af38b0..497b377 100644 (file)
@@ -24,6 +24,7 @@
  * @bug     No known bugs.
  */
 
+#include <nnstreamer_plugin_api.h>
 #include "tensor_filter_tensorflow_core.h"
 
 /**
@@ -45,8 +46,8 @@ TFCore::TFCore (const char * _model_path)
 {
   model_path = _model_path;
 
-  memset (&inputTensorMeta, 0, sizeof (GstTensorsInfo));
-  memset (&outputTensorMeta, 0, sizeof (GstTensorsInfo));
+  gst_tensors_info_init (&inputTensorMeta);
+  gst_tensors_info_init (&outputTensorMeta);
 
   for (int i = 0; i < NNS_TENSOR_SIZE_LIMIT; ++i) {
     inputTensorRank[i] = 0;
index 26bf7db..06a9d81 100644 (file)
@@ -23,8 +23,8 @@
  *
  * @bug     No known bugs.
  */
-#ifndef TENSOR_FILTER_TENSORFLOW_H
-#define TENSOR_FILTER_TENSORFLOW_H
+#ifndef TENSOR_FILTER_TENSORFLOW_CORE_H
+#define TENSOR_FILTER_TENSORFLOW_CORE_H
 
 #include <tensor_typedef.h>
 
@@ -118,4 +118,4 @@ extern "C"
 }
 #endif
 
-#endif
+#endif /* TENSOR_FILTER_TENSORFLOW_CORE_H */
index 7b73a84..88cceba 100644 (file)
@@ -137,8 +137,7 @@ tflite_getInputDim (const GstTensorFilterProperties * prop, void **private_data,
   tflite_data *tf;
   tf = *private_data;
   g_assert (*private_data);
-  int ret = tflite_core_getInputDim (tf->tflite_private_data, info);
-  return ret;
+  return tflite_core_getInputDim (tf->tflite_private_data, info);
 }
 
 /**
@@ -154,8 +153,7 @@ tflite_getOutputDim (const GstTensorFilterProperties * prop,
   tflite_data *tf;
   tf = *private_data;
   g_assert (*private_data);
-  int ret = tflite_core_getOutputDim (tf->tflite_private_data, info);
-  return ret;
+  return tflite_core_getOutputDim (tf->tflite_private_data, info);
 }
 
 GstTensorFilterFramework NNS_support_tensorflow_lite = {
index 69a5f75..39a5305 100644 (file)
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <algorithm>
 
+#include <nnstreamer_plugin_api.h>
 #include "tensor_filter_tensorflow_lite_core.h"
 
 /**
@@ -43,8 +44,8 @@ TFLiteCore::TFLiteCore (const char * _model_path)
 {
   model_path = _model_path;
 
-  memset (&inputTensorMeta, 0, sizeof (GstTensorsInfo));
-  memset (&outputTensorMeta, 0, sizeof (GstTensorsInfo));
+  gst_tensors_info_init (&inputTensorMeta);
+  gst_tensors_info_init (&outputTensorMeta);
 }
 
 /**
index b102f5b..8ce64c6 100644 (file)
  *
  * @bug     No known bugs.
  */
-#ifndef TENSOR_FILTER_TENSORFLOW_LITE_H
-#define TENSOR_FILTER_TENSORFLOW_LITE_H
+#ifndef TENSOR_FILTER_TENSORFLOW_LITE_CORE_H
+#define TENSOR_FILTER_TENSORFLOW_LITE_CORE_H
+
+#include <tensor_typedef.h>
 
 #ifdef __cplusplus
 #include <iostream>
@@ -33,8 +35,6 @@
 #include <tensorflow/contrib/lite/string_util.h>
 #include <tensorflow/contrib/lite/kernels/register.h>
 
-#include <tensor_typedef.h>
-
 /**
  * @brief      ring cache structure
  */
@@ -89,4 +89,4 @@ extern "C"
 }
 #endif
 
-#endif
+#endif /* TENSOR_FILTER_TENSORFLOW_LITE_CORE_H */
index 03dad9f..67281b0 100644 (file)
@@ -19,10 +19,6 @@ if have_orcc
   nnstreamer_base_deps += [orc_dep]
 endif
 
-# For extra dependencies (subplugins, filters)
-# Remove this after ext subplugins migration
-nnstreamer_extra_deps = []
-
 # Internal dependencies
 nnstreamer_internal_deps = []
 
@@ -31,6 +27,7 @@ nnst_common_sources = [
   'nnstreamer.c',
   'nnstreamer_conf.c',
   'nnstreamer_subplugin.c',
+  'nnstreamer_plugin_api.c',
   'tensor_common.c',
   'tensor_repo.c'
 ]
@@ -39,15 +36,6 @@ foreach s : nnst_common_sources
   nnstreamer_sources += join_paths(meson.current_source_dir(), s)
 endforeach
 
-# Add nnstreamer API plugin sources
-nnst_plugin_api_sources = [
-  'nnstreamer_plugin_api.c'
-]
-
-foreach s : nnst_plugin_api_sources
-  nnstreamer_sources += join_paths(meson.current_source_dir(), s)
-endforeach
-
 # Common headers to be installed
 nnst_common_headers = [
   'tensor_typedef.h',
@@ -83,7 +71,7 @@ endforeach
 # Build libraries ("both_libraries" are supported from 0.46.)
 nnstreamer_shared = shared_library('nnstreamer',
   nnstreamer_sources,
-  dependencies: [nnstreamer_base_deps, nnstreamer_extra_deps],
+  dependencies: nnstreamer_base_deps,
   include_directories: nnstreamer_inc,
   install: true,
   install_dir: plugins_install_dir
@@ -91,7 +79,7 @@ nnstreamer_shared = shared_library('nnstreamer',
 
 nnstreamer_static = static_library('nnstreamer',
   nnstreamer_sources,
-  dependencies: [nnstreamer_base_deps, nnstreamer_extra_deps],
+  dependencies: nnstreamer_base_deps,
   include_directories: nnstreamer_inc,
   install: true,
   install_dir: nnstreamer_libdir
index 4bfd717..ddb9d4a 100644 (file)
@@ -317,6 +317,7 @@ static gboolean gst_tensor_filter_stop (GstBaseTransform * trans);
         g_free_const (filter->prop.fwname); \
         filter->prop.fwname = NULL; \
         filter->fw = NULL; \
+        filter->privateData = NULL; \
       } \
     } while (0)
 
index 5a1be82..7a503ba 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * GStreamer Tensor_Filter, Tensorflow-Lite Module
+ * GStreamer Tensor_Filter Module
  * Copyright (C) 2018 MyungJoo Ham <myungjoo.ham@samsung.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -38,8 +38,6 @@ static GstTensorFilterFramework NNS_support_custom;
  */
 struct _internal_data
 {
-  GstTensorFilter *parent;
-
   void *handle;
   NNStreamer_custom_class *methods;
 
@@ -69,7 +67,6 @@ custom_loadlib (const GstTensorFilterProperties * prop, void **private_data)
 
   ptr = g_new0 (internal_data, 1);      /* Fill Zero! */
   *private_data = ptr;
-  ptr->parent = GstTensorFilter_of_privateData (private_data);
 
   /* Load .so if this is the first time for this instance. */
   ptr->handle = dlopen (prop->model_file, RTLD_NOW);
@@ -139,7 +136,7 @@ custom_invoke (const GstTensorFilterProperties * prop, void **private_data,
   int retval = custom_loadlib (prop, private_data);
   internal_data *ptr;
 
-  /* Actually, tensor_filter must have called getInput/OotputDim first. */
+  /* Actually, tensor_filter must have called getInput/OutputDim first. */
   g_assert (retval == 1);
   g_assert (*private_data);
   ptr = *private_data;
index 1d9b25a..8a6b791 100644 (file)
@@ -225,8 +225,8 @@ typedef struct _GstTensorFilterProperties
  * @brief Tensor_Filter Subplugin definition
  *
  * Common callback parameters:
- * filter Filter properties. Read Only
- * private_data Subplugin's private data. Set this (*private_data = XXX) if you want to change filter->private_data
+ * prop Filter properties. Read Only.
+ * private_data Subplugin's private data. Set this (*private_data = XXX) if you want to change filter->private_data.
  */
 typedef struct _GstTensorFilterFramework
 {
@@ -272,7 +272,7 @@ typedef struct _GstTensorFilterFramework
   int (*setInputDimension) (const GstTensorFilterProperties * prop,
       void **private_data, const GstTensorsInfo * in_info,
       GstTensorsInfo * out_info);
-      /**< Optional. Set Null if not supported. Tensor_filter::main will
+      /**< Optional. Set Null if not supported. Tensor_Filter::main will
        * configure input dimension from pad-cap in run-time for the sub-plugin.
        * Then, the sub-plugin is required to return corresponding output dimension
        * If this is NULL, both getInput/OutputDimension must be non-NULL.
index 1123e8a..77d9a0a 100644 (file)
@@ -30,18 +30,18 @@ nnstreamer_bindir = join_paths(nnstreamer_prefix, get_option('bindir'))
 nnstreamer_includedir = join_paths(nnstreamer_prefix, get_option('includedir'))
 nnstreamer_inidir = get_option('sysconfdir')
 
-libs_install_dir = nnstreamer_libdir
+# nnstreamer plugins path
 plugins_install_dir = join_paths(nnstreamer_libdir, 'gstreamer-' + gst_api_verision)
-subplugins_install_dir = nnstreamer_libdir
-examples_install_dir = nnstreamer_bindir
 
 # nnstreamer sub-plugins path
 subplugin_install_prefix = join_paths(nnstreamer_prefix, 'lib', 'nnstreamer')
+filter_subplugin_install_dir = join_paths(subplugin_install_prefix, 'filters')
+decoder_subplugin_install_dir = join_paths(subplugin_install_prefix, 'decoders')
 customfilter_install_dir = join_paths(subplugin_install_prefix, 'customfilters')
 
 nnstreamer_conf.set('PREFIX', nnstreamer_prefix)
 nnstreamer_conf.set('EXEC_PREFIX', nnstreamer_bindir)
-nnstreamer_conf.set('LIB_INSTALL_DIR', libs_install_dir)
+nnstreamer_conf.set('LIB_INSTALL_DIR', nnstreamer_libdir)
 nnstreamer_conf.set('GST_INSTALL_DIR', plugins_install_dir)
 nnstreamer_conf.set('INCLUDE_INSTALL_DIR', nnstreamer_includedir)
 nnstreamer_conf.set('SUBPLUGIN_INSTALL_PREFIX', subplugin_install_prefix)
@@ -129,6 +129,6 @@ configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer.ini',
 # Install .pc
 configure_file(input: 'nnstreamer.pc.in', output: 'nnstreamer.pc',
   install: true,
-  install_dir: join_paths(libs_install_dir, 'pkgconfig'),
+  install_dir: join_paths(nnstreamer_libdir, 'pkgconfig'),
   configuration: nnstreamer_conf
 )
index a8e5363..320181f 100644 (file)
@@ -93,11 +93,13 @@ CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
 mkdir -p build
 
 %ifarch x86_64 aarch64
-    meson --buildtype=plain --werror --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} --bindir=%{nnstexampledir} --includedir=%{_includedir} -Dinstall-example=true build
+enable_tf=true
 %else
-    meson --buildtype=plain --werror --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} --bindir=%{nnstexampledir} --includedir=%{_includedir} -Dinstall-example=true -Denable-tensorflow=false build
+enable_tf=false
 %endif
 
+meson --buildtype=plain --werror --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} --bindir=%{nnstexampledir} --includedir=%{_includedir} -Dinstall-example=true -Denable-tensorflow=${enable_tf} build
+
 ninja -C build %{?_smp_mflags}
 
 %if 0%{?unit_test}