[CodeClean] fix indent and codestyle
authorJaeyun Jung <jy1210.jung@samsung.com>
Wed, 3 Jan 2024 05:01:50 +0000 (14:01 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 3 Jan 2024 07:05:19 +0000 (16:05 +0900)
Trivial, fix indent and codestyle for line comment.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
20 files changed:
ext/nnstreamer/tensor_decoder/tensordec-pose.c
ext/nnstreamer/tensor_decoder/tensordec-python3.cc
ext/nnstreamer/tensor_filter/tensor_filter_armnn.cc
ext/nnstreamer/tensor_filter/tensor_filter_deepview_rt.cc
ext/nnstreamer/tensor_filter/tensor_filter_edgetpu.cc
ext/nnstreamer/tensor_filter/tensor_filter_lua.cc
ext/nnstreamer/tensor_filter/tensor_filter_mediapipe.cc
ext/nnstreamer/tensor_filter/tensor_filter_ncnn.cc
ext/nnstreamer/tensor_filter/tensor_filter_snpe.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorrt.cc
ext/nnstreamer/tensor_filter/tensor_filter_tvm.cc
gst/nnstreamer/include/nnstreamer_util.h
gst/nnstreamer/nnstreamer_log.c
meson.build
packaging/nnstreamer.spec
tests/gstreamer_mqtt/unittest_mqtt_w_helper.cc
tests/meson.build
tests/nnstreamer_filter_ncnn/runTest.sh
tests/nnstreamer_filter_onnxruntime/runTest.sh

index 2515eae..59d6c1d 100644 (file)
@@ -798,7 +798,7 @@ pose_decode (void **pdata, const GstTensorsConfig * config,
 
     } else {
       p.x = (maxX * data->width) / data->i_width;
-      p.y = (maxY * data->height) / data->i_height;;
+      p.y = (maxY * data->height) / data->i_height;
     }
     /* Some keypoints can be estimated slightly out of image range */
     p.x = MIN (data->width, (guint) (MAX (0, p.x)));
index 33d3a97..c7fa591 100644 (file)
@@ -287,7 +287,7 @@ static int
 decoder_py_setOption (void **pdata, int opNum, const char *param)
 {
   gchar *path = (gchar *) param;
-  int ret = TRUE;
+  int ret = FALSE;
 
   /* opNum 1 = python script path */
   if (opNum == 0) {
@@ -316,20 +316,18 @@ decoder_py_setOption (void **pdata, int opNum, const char *param)
     } catch (std::bad_alloc &exception) {
       ml_loge ("Failed to allocate memory for decoder subplugin: python3\n");
       ml_loge ("%s", exception.what ());
-      ret = FALSE;
       goto done;
     }
 
     if (core->init () != 0) {
       delete core;
       ml_loge ("failed to initailize the object: Python3\n");
-      ret = FALSE;
       goto done;
     }
-    *pdata = core;
 
+    *pdata = core;
     ret = TRUE;
-    goto done;
+
   done:
     PyGILState_Release (gstate);
     return ret;
index e9c3864..a4ebfad 100644 (file)
 
 #include <armnn/ArmNN.hpp>
 
-#if ENABLE_ARMNN_CAFFE
+#if defined(ENABLE_ARMNN_CAFFE)
 #include <armnnCaffeParser/ICaffeParser.hpp>
 #endif
-#if ENABLE_ARMNN_TFLITE
+#if defined(ENABLE_ARMNN_TFLITE)
 #include <armnnTfLiteParser/ITfLiteParser.hpp>
 #endif
 
@@ -180,7 +180,7 @@ ArmNNCore::getModelPath ()
   return model_path;
 }
 
-#if ENABLE_ARMNN_CAFFE
+#if defined(ENABLE_ARMNN_CAFFE)
 /**
  * @brief make network with caffe parser
  * @param[in] input_map input data map
@@ -233,7 +233,7 @@ ArmNNCore::makeCaffeNetwork (std::map<std::string, armnn::TensorShape> &input_ma
   g_printerr ("ARMNN-CAFFE was not enabled at build-time. tensor-filter::armnn cannot handle caffe networks.");
   return -EPERM;
 }
-#endif
+#endif /* ENABLE_ARMNN_CAFFE */
 
 /**
  * @brief make network with tensorflow parser
@@ -252,7 +252,7 @@ ArmNNCore::makeTfNetwork (std::map<std::string, armnn::TensorShape> &input_map,
   return -EPERM;
 }
 
-#if ENABLE_ARMNN_TFLITE
+#if defined(ENABLE_ARMNN_TFLITE)
 /**
  * @brief make network with tensorflow-lite parser
  * @return 0 on success, -errno on error
@@ -293,7 +293,7 @@ ArmNNCore::makeTfLiteNetwork ()
 {
   return -EPERM;
 }
-#endif
+#endif /* ENABLE_ARMNN_TFLITE */
 
 /**
  * @brief make network based on the model file received
index 8f609ce..b1a58d9 100644 (file)
@@ -584,5 +584,5 @@ _fini_filter_dvrt ()
   dvrt_subplugin::fini_filter_dvrt ();
 }
 
-} // namespace tensorfilter_dvrt
+} /* namespace tensorfilter_dvrt */
 } /* namespace nnstreamer */
index ffce03a..0222642 100644 (file)
@@ -591,5 +591,5 @@ _fini_filter_edgetpu ()
   edgetpu_subplugin::fini_filter_edgetpu ();
 }
 
-} // namespace tensorfilter_edgetpu
+} /* namespace tensorfilter_edgetpu */
 } /* namespace nnstreamer */
index 01af469..8555a00 100644 (file)
@@ -597,5 +597,5 @@ _fini_filter_lua ()
   lua_subplugin::fini_filter_lua ();
 }
 
-} // namespace tensorfilter_lua
+} /* namespace tensorfilter_lua */
 } /* namespace nnstreamer */
index 89d380b..c104c40 100644 (file)
@@ -260,13 +260,13 @@ mediapipe_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *outp
     throw std::runtime_error ("Fail to start mediapipe graph");
   }
 
-  // Wrap Mat into an ImageFrame.
+  /* Wrap Mat into an ImageFrame. */
   auto input_frame = absl::make_unique<mediapipe::ImageFrame> (
       mediapipe::ImageFormat::SRGB, input_width, input_height, input_widthStep,
       (uint8_t *) input->data, inputPtrDeleter /* do nothing */
   );
 
-  // Send image packet
+  /* Send image packet. */
   status = graph.AddPacketToInputStream (in_info->name,
       mediapipe::Adopt (input_frame.release ()).At (mediapipe::Timestamp (frame_timestamp++)));
   if (!status.ok ()) {
@@ -274,7 +274,7 @@ mediapipe_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *outp
     throw std::runtime_error ("Failed to add input packet");
   }
 
-  // Get the graph result packet, or stop if that fails.
+  /* Get the graph result packet, or stop if that fails. */
   mediapipe::Packet packet;
   if (!poller.Next (&packet)) {
     std::cerr << "Failed to get output packet from mediapipe graph" << std::endl;
@@ -374,5 +374,5 @@ _fini_filter_mediapipe ()
   mediapipe_subplugin::fini_filter_mediapipe ();
 }
 
-} // namespace tensorfilter_mediapipe
+} /* namespace tensorfilter_mediapipe */
 } /* namespace nnstreamer */
index e61120c..1b2fd05 100644 (file)
@@ -157,36 +157,36 @@ ncnn_subplugin::getEmptyInstance ()
 void
 ncnn_subplugin::configure_instance (const GstTensorFilterProperties *prop)
 {
-  // get input / output info from properties
+  /* get input / output info from properties */
   gst_tensors_info_copy (std::addressof (inputInfo), std::addressof (prop->input_meta));
   gst_tensors_info_copy (std::addressof (outputInfo), std::addressof (prop->output_meta));
 
-  // check number of model files
+  /* check number of model files */
   if (prop->num_models > 2 || prop->num_models <= 0) {
     throw std::invalid_argument (std::string ("Number of model files must be 1 or 2;")
                                  + " Multiple model is not supported.");
   }
 
-  // try to parse custom properties of the ncnn_subplugin
+  /* try to parse custom properties of the ncnn_subplugin */
   try {
-    // parse custom properties
+    /* parse custom properties */
     parseCustomProperties (prop);
   } catch (const std::invalid_argument &e) {
     throw std::invalid_argument (
         "Failed to parse custom property : " + std::string (e.what ()));
   }
 
-  // decide use vulkan acceleration
+  /* decide use vulkan acceleration */
   if (std::find (prop->hw_list, prop->hw_list + prop->num_hw, ACCL_GPU)
       != (prop->hw_list + prop->num_hw)) {
     net.opt.use_vulkan_compute = true;
-    g_message ("accl = gpu\n");
+    nns_logi ("accl = gpu\n");
   } else {
     net.opt.use_vulkan_compute = false;
   }
 
-  // load model files
-  // ncnn returns nonzero value when an error occurs
+  /* load model files */
+  /* ncnn returns nonzero value when an error occurs */
   if (prop->num_models == 1) {
     if (net.load_param_bin (prop->model_files[0]))
       throw std::invalid_argument (
@@ -200,7 +200,7 @@ ncnn_subplugin::configure_instance (const GstTensorFilterProperties *prop)
           "Failed to open the bin file " + std::string (prop->model_files[1]));
   }
 
-  // get input layers from the ncnn network
+  /* get input layers from the ncnn network */
   const std::vector<int> &input_indexes = net.input_indexes ();
   input_mats.clear ();
   if (inputInfo.num_tensors != input_indexes.size ())
@@ -209,15 +209,15 @@ ncnn_subplugin::configure_instance (const GstTensorFilterProperties *prop)
         + ": Found in argument = " + std::to_string (inputInfo.num_tensors)
         + ", Found in model file = " + std::to_string (input_indexes.size ()));
 
-  // init input matrices
+  /* init input matrices */
   for (guint i = 0; i < inputInfo.num_tensors; i++) {
-    // get dimensions of the input matrix from inputInfo
+    /* get dimensions of the input matrix from inputInfo */
     const uint32_t *dim = gst_tensors_info_get_nth_info (&inputInfo, i)->dimension;
     std::vector<int> shape;
     while (*dim)
       shape.push_back (*dim++);
 
-    // make ncnn matrix object
+    /* make ncnn matrix object */
     ncnn::Mat in;
     switch (shape.size ()) {
       case 1:
@@ -239,7 +239,7 @@ ncnn_subplugin::configure_instance (const GstTensorFilterProperties *prop)
     input_mats.push_back (in);
   }
 
-  // get output layers from the ncnn network
+  /* get output layers from the ncnn network */
   const std::vector<int> &output_indexes = net.output_indexes ();
   output_mats.clear ();
   if (outputInfo.num_tensors != output_indexes.size ())
@@ -248,7 +248,7 @@ ncnn_subplugin::configure_instance (const GstTensorFilterProperties *prop)
         + ": Found in argument = " + std::to_string (outputInfo.num_tensors)
         + ", Found in model file = " + std::to_string (output_indexes.size ()));
 
-  // init output matrices
+  /* init output matrices */
   output_mats.resize (outputInfo.num_tensors);
 
   empty_model = false;
@@ -267,14 +267,14 @@ ncnn_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *output)
         "nnstreamer or ncnn-subplugin unless if you have directly accessed "
         "ncnn-subplugin.");
 
-  // make extractor instance for each inference
+  /* make extractor instance for each inference */
   ncnn::Extractor ex = net.create_extractor ();
 
-  // get input layer indices
+  /* get input layer indices */
   std::vector<std::thread> input_thrs;
   const std::vector<int> &input_indexes = net.input_indexes ();
 
-  // get input from input tensor and push to the network
+  /* get input from input tensor and push to the network */
   const char *input_data = (const char *) input->data;
   for (guint i = 0; i < inputInfo.num_tensors; i++) {
     ncnn::Mat &in = input_mats.at (i);
@@ -284,30 +284,30 @@ ncnn_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *output)
     input_data += num_bytes;
   }
 
-  // join threads
+  /* join threads */
   for (std::thread &thr : input_thrs)
     thr.join ();
 
-  // get output layer indices
+  /* get output layer indices */
   std::vector<std::thread> output_thrs;
   const std::vector<int> &output_indexes = net.output_indexes ();
 
   if (use_yolo_decoder) {
-    // get output and store to ncnn matrix
+    /* get output and store to ncnn matrix */
     for (guint i = 0; i < outputInfo.num_tensors; i++) {
       ncnn::Mat &out = output_mats.at (i);
       output_thrs.emplace_back (extract_thread, std::ref (ex),
           output_indexes.at (i), std::ref (out), nullptr, 0);
     }
 
-    // memset output to zero and hide latency by multithreading
+    /* memset output to zero and hide latency by multithreading */
     memset (output->data, 0, output->size);
 
-    // join threads
+    /* join threads */
     for (std::thread &thr : output_thrs)
       thr.join ();
 
-    // write detection-box infos to the output tensor
+    /* write detection-box infos to the output tensor */
     for (guint i = 0; i < outputInfo.num_tensors; i++) {
       ncnn::Mat &out = output_mats.at (i);
       const int label_count
@@ -330,7 +330,7 @@ ncnn_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *output)
       }
     }
   } else {
-    // get output and store to the output tensor
+    /* get output and store to the output tensor */
     char *output_data = (char *) output->data;
     for (guint i = 0; i < outputInfo.num_tensors; i++) {
       ncnn::Mat &out = output_mats.at (i);
@@ -340,7 +340,7 @@ ncnn_subplugin::invoke (const GstTensorMemory *input, GstTensorMemory *output)
       output_data += num_bytes;
     }
 
-    // join threads
+    /* join threads */
     for (std::thread &thr : output_thrs)
       thr.join ();
   }
@@ -394,25 +394,25 @@ ncnn_subplugin::parseCustomProperties (const GstTensorFilterProperties *prop)
   using uniq_g_strv = std::unique_ptr<gchar *, std::function<void (gchar **)>>;
   const char *custom_props = prop->custom_properties;
 
-  // set default values
+  /* set default values */
   use_yolo_decoder = false;
 
   if (custom_props) {
-    // split with , to parse options
+    /* split with , to parse options */
     uniq_g_strv options (g_strsplit (custom_props, ",", -1), g_strfreev);
     guint len = g_strv_length (options.get ());
 
     for (guint i = 0; i < len; i++) {
-      // split with = to parse single option
+      /* split with = to parse single option */
       uniq_g_strv option (g_strsplit (options.get ()[i], ":", -1), g_strfreev);
 
-      // we only have key=value form option
+      /* we only have key=value form option */
       if (g_strv_length (option.get ()) == 2) {
         g_strstrip (option.get ()[0]);
         g_strstrip (option.get ()[1]);
 
         if (g_ascii_strcasecmp (option.get ()[0], "use_yolo_decoder") == 0) {
-          // true or false (default) only
+          /* true or false (default) only */
           if (g_ascii_strcasecmp (option.get ()[1], "true") == 0) {
             use_yolo_decoder = true;
           } else if (g_ascii_strcasecmp (option.get ()[1], "false") == 0) {
@@ -440,10 +440,10 @@ void
 ncnn_subplugin::input_thread (ncnn::Extractor &ex, const int idx,
     const ncnn::Mat &in, const void *input_data, const uint32_t num_bytes)
 {
-  // copy from the input matrix
+  /* copy from the input matrix */
   memcpy (in.data, input_data, num_bytes);
 
-  // input to the network
+  /* input to the network */
   ex.input (idx, in);
 }
 
@@ -454,10 +454,10 @@ void
 ncnn_subplugin::extract_thread (ncnn::Extractor &ex, const int idx,
     ncnn::Mat &out, void *output_data, const uint32_t num_bytes)
 {
-  // output from the network
+  /* output from the network */
   ex.extract (idx, out);
 
-  // copy to the output matrix
+  /* copy to the output matrix */
   if (output_data)
     memcpy (output_data, out.data, num_bytes);
 }
@@ -480,7 +480,7 @@ ncnn_subplugin::init_filter_ncnn (void)
 void
 ncnn_subplugin::fini_filter_ncnn (void)
 {
-  assert (registeredRepresentation != nullptr);
+  g_assert (registeredRepresentation != nullptr);
   tensor_filter_subplugin::unregister_subplugin (registeredRepresentation);
 }
 
@@ -502,5 +502,5 @@ fini_filter_ncnn ()
   ncnn_subplugin::fini_filter_ncnn ();
 }
 
-} // namespace tensorfilter_ncnn
+} /* namespace tensorfilter_ncnn */
 } /* namespace nnstreamer */
index 48d6d5f..a6b4b28 100644 (file)
@@ -785,7 +785,7 @@ _snpe_set_env (JNIEnv *env, jobject context)
       ";/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp;/dsp", NULL);
 
   /**
-   *  See https://developer.qualcomm.com/docs/snpe/dsp_runtime.html for details
+   * See https://developer.qualcomm.com/docs/snpe/dsp_runtime.html for details
    */
   nns_logi ("Set env ADSP_LIBRARY_PATH for snpe DSP/AIP runtime: %s", new_path);
   g_setenv ("ADSP_LIBRARY_PATH", new_path, TRUE);
@@ -854,5 +854,5 @@ fini_filter_snpe ()
   snpe_subplugin::fini_filter_snpe ();
 }
 
-} // namespace tensor_filter_snpe
+} /* namespace tensor_filter_snpe */
 } /* namespace nnstreamer */
index eb850d2..e6add13 100644 (file)
@@ -786,7 +786,7 @@ static GstTensorFilterFramework NNS_support_tensorflow = { .version = GST_TENSOR
         .reloadModel = nullptr,
         .handleEvent = nullptr,
         .checkAvailability = tf_checkAvailability,
-        .allocateInInvoke = nullptr, // TODO: what, it's allocate_in_invoke
+        .allocateInInvoke = nullptr, /** @todo what, it's allocate_in_invoke */
     } } };
 
 /** @brief Initialize this object for tensor_filter subplugin runtime register */
index 75cf0fc..6ef1c42 100644 (file)
@@ -269,7 +269,6 @@ tensorrt_subplugin::getModelInfo (
   }
 
   gst_tensors_info_copy (std::addressof (in_info), std::addressof (_inputTensorMeta));
-
   gst_tensors_info_copy (std::addressof (out_info), std::addressof (_outputTensorMeta));
 
   return 0;
@@ -508,5 +507,5 @@ _fini_filter_tensorrt (void)
   tensorrt_subplugin::fini_filter_tensorrt ();
 }
 
-} // namespace tensorfilter_tensorrt
+} /* namespace tensorfilter_tensorrt */
 } /* namespace nnstreamer */
index ab84f6c..0f3526f 100644 (file)
@@ -492,5 +492,5 @@ fini_filter_tvm ()
   tvm_subplugin::fini_filter_tvm ();
 }
 
-} // namespace tensorfilter_tvm
+} /* namespace tensorfilter_tvm */
 } /* namespace nnstreamer */
index 4a2c4ad..98750c3 100644 (file)
@@ -25,7 +25,7 @@
 /**
  * @brief g_memdup() function replaced by g_memdup2() in glib version >= 2.68
  */
-#if GLIB_USE_G_MEMDUP2
+#if defined(GLIB_USE_G_MEMDUP2)
 #define _g_memdup(data, size) g_memdup2 (data, size)
 #else
 #define _g_memdup(data, size) g_memdup (data, size)
index d7023f5..04cb5d7 100644 (file)
@@ -36,7 +36,6 @@ _backtrace_to_string (void)
 {
   char *retstr = NULL;
 #ifndef _NO_EXECINFO_
-/* Android does not have execinfo.h. It has unwind.h instead. */
   void *array[20];
   char **strings;
   int size, i, len;
@@ -98,8 +97,9 @@ _nnstreamer_error (void)
 __attribute__((__format__ (__printf__, 1, 2)))
      void _nnstreamer_error_write (const char *fmt, ...)
 {
-  /** The attribute is for clang workaround in macos:
-      https://stackoverflow.com/questions/20167124/vsprintf-and-vsnprintf-wformat-nonliteral-warning-on-clang-5-0
+  /**
+   * The attribute is for clang workaround in macos:
+   * https://stackoverflow.com/questions/20167124/vsprintf-and-vsnprintf-wformat-nonliteral-warning-on-clang-5-0
    */
   va_list arg_ptr;
   G_LOCK (errlock);
index 2381f08..c38f344 100644 (file)
@@ -361,6 +361,7 @@ endif
 if not get_option('datarepo-support').disabled() and not json_glib_dep.found()
   message('datarepo-support is off because json-glib-1.0 is not available.')
 endif
+
 # ml-agent
 ml_agent_dep = dependency('', required: false)
 if not get_option('ml-agent-support').disabled()
index f46adae..d11724b 100644 (file)
@@ -36,7 +36,7 @@
 %define                tvm_support 1
 %define                snpe_support 1
 %define                trix_engine_support 1
-%define     onnxruntime_support 0
+%define                onnxruntime_support 0
 # Support AI offloading (tensor_query) using nnstreamer-edge interface
 %define                nnstreamer_edge_support 1
 %define                datarepo_support 1
 %define                tvm_support 0
 %define                snpe_support 0
 %define                trix_engine_support 0
-%define     onnxruntime_support 0
+%define                onnxruntime_support 0
 %define                nnstreamer_edge_support 0
 %endif
 
 %define                mqtt_support 0
 %define                tvm_support 0
 %define                trix_engine_support 0
-%define     onnxruntime_support 0
+%define                onnxruntime_support 0
 %endif
 
 # Release unit test suite as a subpackage only if check_test is enabled.
@@ -667,7 +667,6 @@ Summary:    NNStreamer extra packages
 %if 0%{?mqtt_support}
 BuildRequires: pkgconfig(paho-mqtt-c)
 %endif
-
 %description misc
 Provides additional gstreamer plugins for nnstreamer pipelines
 
@@ -902,7 +901,8 @@ meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir
        %{enable_tf_lite} %{enable_tf2_lite} %{enable_tf} %{enable_pytorch} %{enable_caffe2} %{enable_python3} \
        %{enable_nnfw_runtime} %{enable_mvncsdk2} %{enable_openvino} %{enable_armnn} %{enable_edgetpu}  %{enable_vivante} \
        %{enable_flatbuf} %{enable_trix_engine} %{enable_datarepo} \
-       %{enable_tizen_sensor} %{enable_mqtt} %{enable_lua} %{enable_tvm} %{enable_onnxruntime} %{enable_test} %{enable_test_coverage} %{install_test} \
+       %{enable_tizen_sensor} %{enable_mqtt} %{enable_lua} %{enable_tvm} %{enable_onnxruntime} \
+        %{enable_test} %{enable_test_coverage} %{install_test} \
        %{fp16_support} %{nnsedge} %{enable_ml_agent} \
        %{builddir}
 
index c0db081..8873b21 100644 (file)
@@ -186,7 +186,7 @@ MQTTAsync_unsubscribe (MQTTAsync handle, const char *topic, MQTTAsync_responseOp
 /**
  * @brief A helper function to fill the timestamp information into the header
  */
-void
+static void
 _set_ts_gst_mqtt_message_hdr (GstElement *elm, GstMQTTMessageHdr *hdr,
     const GstClockTimeDiff diff_sent, const GstClockTime duration)
 {
index f2d5aa4..4d6e904 100644 (file)
@@ -375,7 +375,7 @@ if gtest_dep.found()
     )
   endif
 
-    # ONNXRUNTIME unittest
+  # ONNXRUNTIME unittest
   if onnxruntime_support_is_available
     unittest_filter_onnxruntime = executable('unittest_filter_onnxruntime',
       join_paths('nnstreamer_filter_onnxruntime', 'unittest_filter_onnxruntime.cc'),
index 2a8fa4a..64050a8 100755 (executable)
@@ -58,7 +58,7 @@ else
             report
             exit
         fi
-else
+    else
         echo "Cannot identify nnstreamer.ini"
         report
         exit
index 12a420a..1dd5b29 100644 (file)
@@ -59,7 +59,7 @@ else
             report
             exit
         fi
-else
+    else
         echo "Cannot identify nnstreamer.ini"
         report
         exit