[Filter] Handle othercap only when it's valid.
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 5 Nov 2018 08:00:48 +0000 (17:00 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 7 Nov 2018 03:45:37 +0000 (12:45 +0900)
Assume othercap is "ANY" if cap-size is ZERO.

Fixes #549

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

index 5be6ec2..5d84de7 100644 (file)
@@ -1032,9 +1032,15 @@ gst_tensor_filter_transform_caps (GstBaseTransform * trans,
     }
   }
 
-  if (filter) {
+  if (filter && gst_caps_get_size (filter) > 0) {
     GstCaps *intersection;
 
+    /**
+     * @todo We do not have a testcase hitting here. Thus, we do not ensure the validity here.
+     * However, according to gstreamer doxygen entry, if filter is given, that's not to be ignored.
+     * For now, we assume that if caps-size is 0, filter is "ANY".
+     */
+
     intersection =
         gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
 
@@ -1065,9 +1071,9 @@ gst_tensor_filter_fixate_caps (GstBaseTransform * trans,
   /**
    * To get the out-caps, GstTensorFilter has to parse tensor info from NN model.
    */
-  gst_caps_unref (othercaps);
 
-  result = gst_tensor_filter_transform_caps (trans, direction, caps, NULL);
+  result = gst_tensor_filter_transform_caps (trans, direction, caps, othercaps);
+  gst_caps_unref (othercaps);
   result = gst_caps_make_writable (result);
   result = gst_caps_fixate (result);