[converter, filter] Reduce log messages
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 12 Jun 2018 01:37:22 +0000 (10:37 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Thu, 14 Jun 2018 04:26:10 +0000 (13:26 +0900)
Emit debug/log messages when proper options are given only.
Do not write such messages when no options are specified.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
tensor_converter/tensor_converter.c
tensor_filter/tensor_filter.c

index 2663c2b..e6dcf58 100644 (file)
@@ -579,6 +579,7 @@ static GstCaps* gst_tensor_converter_transform_caps(GstBaseTransform *trans,
   gboolean ret;
   GstTensor_Converter bogusFilter = {0};
   bogusFilter.tensorConfigured = FALSE;
+  GstTensor_Converter *obj = GST_TENSOR_CONVERTER_CAST(trans);
 
   /* @TODO: Verify if direction == GST_PAD_SINK means caps is sink pad */
   if (direction == GST_PAD_SINK) {
@@ -623,7 +624,8 @@ static GstCaps* gst_tensor_converter_transform_caps(GstBaseTransform *trans,
       else
         g_sprintf(colors, "{3, 4}");
 
-      g_printerr("Structure from caps = %s\n", str);
+      if (obj->silent == FALSE)
+        g_printerr("Structure from caps = %s\n", str);
 
       g_sprintf(str2,
           "other/tensor, "
@@ -636,7 +638,8 @@ static GstCaps* gst_tensor_converter_transform_caps(GstBaseTransform *trans,
           "dim4 = (int) 1"
           , framerate, colors, width, height);
       tmp = gst_caps_from_string(str2);
-      g_printerr("Structure from caps to = %s\n", str2);
+      if (obj->silent == FALSE)
+        g_printerr("Structure from caps to = %s\n", str2);
 
       /* If given caps are in range for width/height,
          we cannot configure tensor, however, we may return proper srcpad caps */
@@ -647,7 +650,6 @@ static GstCaps* gst_tensor_converter_transform_caps(GstBaseTransform *trans,
       tmp = gst_caps_new_empty();
       return tmp; /* Empty Cap */
     }
-    g_printerr("transform_caps SINK specific\n");
 
     g_assert(bogusFilter.tensorConfigured == TRUE);
 
@@ -667,12 +669,16 @@ static GstCaps* gst_tensor_converter_transform_caps(GstBaseTransform *trans,
       gst_caps_unref(tmp);
       tmp = tmp2;
     }
+    if (obj->silent == FALSE) {
       structure = gst_caps_get_structure(caps, 0);
       str = gst_structure_to_string(structure);
       g_printerr("From = %s\n", str);
+      g_free(str);
       structure = gst_caps_get_structure(tmp, 0);
       str = gst_structure_to_string(structure);
       g_printerr("To = %s\n", str);
+      g_free(str);
+    }
 
     GST_DEBUG_OBJECT(trans, "SINK transformed %" GST_PTR_FORMAT " into %"
         GST_PTR_FORMAT, caps, tmp);
@@ -692,20 +698,29 @@ static GstCaps* gst_tensor_converter_transform_caps(GstBaseTransform *trans,
        "height = (int)[1, 65535]");
     tmp = gst_static_caps_get(&staticcap);
 
-    structure = gst_caps_get_structure(caps, 0);
-    str = gst_structure_to_string(structure);
-    g_printerr("Structure from src = %s\n", str);
+    if (obj->silent == FALSE) {
+      structure = gst_caps_get_structure(caps, 0);
+      str = gst_structure_to_string(structure);
+      g_printerr("Structure from src = %s\n", str);
+      g_free(str);
+    }
     if (filter) {
       GstCaps *tmp2;
-      structure = gst_caps_get_structure(filter, 0);
-      str = gst_structure_to_string(structure);
-      g_printerr("Structure from filter = %s\n", str);
+      if (obj->silent == FALSE) {
+        structure = gst_caps_get_structure(filter, 0);
+        str = gst_structure_to_string(structure);
+        g_printerr("Structure from filter = %s\n", str);
+        g_free(str);
+      }
 
       tmp2 = gst_caps_intersect_full(filter, tmp, GST_CAPS_INTERSECT_FIRST);
 
-      structure = gst_caps_get_structure(tmp2, 0);
-      str = gst_structure_to_string(structure);
-      g_printerr("Structure from intersection = %s\n", str);
+      if (obj->silent == FALSE) {
+        structure = gst_caps_get_structure(tmp2, 0);
+        str = gst_structure_to_string(structure);
+        g_printerr("Structure from intersection = %s\n", str);
+        g_free(str);
+      }
 
       gst_caps_unref(tmp);
       tmp = tmp2;
index ee90f16..cea271b 100644 (file)
@@ -124,6 +124,7 @@ enum
   PROP_OUTPUT,
   PROP_OUTPUTTYPE,
   PROP_DEBUG,
+  PROP_CUSTOM,
 };
 
 /**
@@ -339,19 +340,26 @@ gst_tensor_filter_fix_caps (GstTensor_Filter *filter, gboolean isInput, GstCaps
   }
 
   if (targetCaps) {
-    gchar *str = gst_caps_to_string(targetCaps);
-    g_printerr("targetCaps: %s\n", str);
-    g_free(str);
+    gchar *str;
+    if (filter->debug == TRUE) {
+      str = gst_caps_to_string(targetCaps);
+      g_printerr("targetCaps: %s\n", str);
+      g_free(str);
+    }
     tmp2 = gst_caps_intersect_full(targetCaps, tmp, GST_CAPS_INTERSECT_FIRST);
     gst_caps_unref(tmp);
     tmp = tmp2;
-    str = gst_caps_to_string(tmp);
-    g_printerr("resultCaps: %s\n", str);
-    g_free(str);
+    if (filter->debug == TRUE) {
+      str = gst_caps_to_string(tmp);
+      g_printerr("resultCaps: %s\n", str);
+      g_free(str);
+    }
   } else {
-    gchar *str = gst_caps_to_string(tmp);
-    g_printerr("resultCaps w/o targetCaps: %s\n", str);
-    g_free(str);
+    if (filter->debug == TRUE) {
+      gchar *str = gst_caps_to_string(tmp);
+      g_printerr("resultCaps w/o targetCaps: %s\n", str);
+      g_free(str);
+    }
   }
 
   /* @TODO 3. Check if tmp ( = targetCap \cap tmp(from dim)) is not \null-set. */
@@ -438,6 +446,8 @@ gst_tensor_filter_set_property (GObject * object, guint prop_id,
         int rank = get_tensor_dimension(g_value_get_string(value), filter->outputDimension);
        g_assert(rank > 0 && rank <= NNS_TENSOR_RANK_LIMIT);
        filter->outputConfigured = TRUE;
+        if (filter->debug == TRUE)
+          g_printerr("Output Prop: %d:%d:%d:%d Rank %d\n", filter->outputDimension[0], filter->outputDimension[1], filter->outputDimension[2], filter->outputDimension[3], rank);
       }
 
       if (filter->outputType != _NNS_END && filter->debug == TRUE)
@@ -447,6 +457,8 @@ gst_tensor_filter_set_property (GObject * object, guint prop_id,
       g_assert(filter->inputType == _NNS_END && value);
       /* Once configures, it cannot be changed in runtime */
       filter->inputType = get_tensor_type(g_value_get_string(value));
+      if (filter->debug == TRUE)
+        g_printerr("Output Type: %s -> %d\n", g_value_get_string(value), filter->inputType);
       g_assert(filter->inputType != _NNS_END);
       if (filter->inputConfigured == TRUE && filter->debug == TRUE)
         gst_tensor_filter_fix_caps(filter, TRUE, NULL, TRUE);