[Common] function to get element type str
authorJaeyun <jy1210.jung@samsung.com>
Thu, 25 Apr 2019 07:31:38 +0000 (16:31 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 15 May 2019 13:03:23 +0000 (22:03 +0900)
define function to get tensor type string

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/nnstreamer/nnstreamer_plugin_api.h
gst/nnstreamer/tensor_common.c
gst/nnstreamer/tensor_converter/tensor_converter.c
gst/nnstreamer/tensor_filter/tensor_filter.c
tests/nnstreamer_sink/unittest_sink.cpp

index 2d20827..bb8337b 100644 (file)
 G_BEGIN_DECLS
 
 /**
- * @brief String representations for each tensor element type.
- */
-extern const gchar *tensor_element_typename[];
-
-/**
  * @brief Initialize the tensor info structure
  * @param info tensor info structure to be initialized
  */
@@ -308,7 +303,7 @@ extern gsize
 gst_tensor_get_element_count (const tensor_dim dim);
 
 /**
- * @brief Get tensor_type from string tensor_type input
+ * @brief Get tensor type from string input.
  * @return Corresponding tensor_type. _NNS_END if unrecognized value is there.
  * @param typestr The string type name, supposed to be one of tensor_element_typename[]
  */
@@ -316,6 +311,12 @@ extern tensor_type
 gst_tensor_get_type (const gchar * typestr);
 
 /**
+ * @brief Get type string of tensor type.
+ */
+extern const gchar *
+gst_tensor_get_type_string (tensor_type type);
+
+/**
  * @brief Find the index value of the given key string array
  * @return Corresponding index
  * @param strv Null terminated array of gchar *
index a0deea4..56e2305 100644 (file)
@@ -29,7 +29,7 @@
 /**
  * @brief String representations for each tensor element type.
  */
-const gchar *tensor_element_typename[] = {
+static const gchar *tensor_element_typename[] = {
   [_NNS_INT32] = "int32",
   [_NNS_UINT32] = "uint32",
   [_NNS_INT16] = "int16",
@@ -480,7 +480,7 @@ gst_tensors_info_get_types_string (const GstTensorsInfo * info)
     GString *types = g_string_new (NULL);
 
     for (i = 0; i < info->num_tensors; i++) {
-      g_string_append (types, tensor_element_typename[info->info[i].type]);
+      g_string_append (types, gst_tensor_get_type_string (info->info[i].type));
 
       if (i < info->num_tensors - 1) {
         g_string_append (types, ",");
@@ -639,7 +639,7 @@ gst_tensor_caps_from_config (const GstTensorConfig * config)
 
   if (config->info.type != _NNS_END) {
     gst_caps_set_simple (caps, "type", G_TYPE_STRING,
-        tensor_element_typename[config->info.type], NULL);
+        gst_tensor_get_type_string (config->info.type), NULL);
   }
 
   if (config->rate_n >= 0 && config->rate_d > 0) {
@@ -920,7 +920,7 @@ gst_tensor_get_element_count (const tensor_dim dim)
 }
 
 /**
- * @brief Get tensor_type from string tensor_type input
+ * @brief Get tensor type from string input.
  * @return Corresponding tensor_type. _NNS_END if unrecognized value is there.
  * @param typestr The string type name, supposed to be one of tensor_element_typename[]
  */
@@ -987,6 +987,15 @@ gst_tensor_get_type (const gchar * typestr)
 }
 
 /**
+ * @brief Get type string of tensor type.
+ */
+const gchar *
+gst_tensor_get_type_string (tensor_type type)
+{
+  return tensor_element_typename[type];
+}
+
+/**
  * @brief Find the index value of the given key string array
  * @return Corresponding index. Returns -1 if not found.
  * @param strv Null terminated array of gchar *
index fdaf874..b79eed8 100644 (file)
@@ -382,7 +382,7 @@ gst_tensor_converter_get_property (GObject * object, guint prop_id,
     case PROP_INPUT_TYPE:
       if (self->tensor_info.type != _NNS_END) {
         g_value_set_string (value,
-            tensor_element_typename[self->tensor_info.type]);
+            gst_tensor_get_type_string (self->tensor_info.type));
       } else {
         g_value_set_string (value, "");
       }
index 462ec9d..dc67cc5 100644 (file)
@@ -1004,7 +1004,7 @@ gst_tensor_filter_compare_tensors (GstTensorsInfo * info1,
     if (info1->num_tensors > i) {
       dimstr = gst_tensor_get_dimension_string (info1->info[i].dimension);
       left = g_strdup_printf ("%s [%s]",
-          tensor_element_typename[info1->info[i].type], dimstr);
+          gst_tensor_get_type_string (info1->info[i].type), dimstr);
       g_free (dimstr);
     } else {
       left = null;
@@ -1013,7 +1013,7 @@ gst_tensor_filter_compare_tensors (GstTensorsInfo * info1,
     if (info2->num_tensors > i) {
       dimstr = gst_tensor_get_dimension_string (info2->info[i].dimension);
       right = g_strdup_printf ("%s [%s]",
-          tensor_element_typename[info2->info[i].type], dimstr);
+          gst_tensor_get_type_string (info2->info[i].type), dimstr);
       g_free (dimstr);
     } else {
       right = null;
index 1b2db00..fcb5615 100644 (file)
@@ -803,7 +803,7 @@ _setup_pipeline (TestOption & option)
           g_strdup_printf
           ("appsrc name=appsrc caps=text/x-raw,format=utf8 ! "
           "tensor_converter input-dim=10 ! tensor_transform mode=typecast option=%s ! tensor_sink name=test_sink",
-          tensor_element_typename[option.t_type]);
+          gst_tensor_get_type_string (option.t_type));
       break;
     case TEST_TYPE_ISSUE739_MUX_PARALLEL_1:
       /** 4x4 tensor stream, different FPS, tensor_mux them @ slowest */