[Mux/Merge] Fix time synchronization buf for cornner cases
authorjijoong.moon <jijoong.moon@samsung.com>
Fri, 9 Nov 2018 07:01:10 +0000 (16:01 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 14 Nov 2018 10:54:10 +0000 (19:54 +0900)
For the basepad options with 0 and maximum duration, current
implementation is not work properly. In order to support this
situation, base time is decided min(duration, pts(nth)-pts(n-1 th)-1).

**Self evaluation:**
1. Build test:  [X]Passed [ ]Failed [ ]Skipped
2. Run test:  [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
gst/nnstreamer/tensor_common.c

index fe3ded7..fb74432 100644 (file)
@@ -1168,8 +1168,28 @@ gst_gen_tensors_from_collectpad (GstCollectPads * collect,
   gint old_denominator = G_MAXINT;
   gint counting = 0;
   GstTensorConfig config;
+  GstClockTime base = 0;
 
   walk = collect->data;
+
+  if (sync.mode == SYNC_BASEPAD) {
+    walk = g_slist_nth (walk, sync.data_basepad.sink_id);
+    GstCollectData *data = (GstCollectData *) walk->data;
+    GstTensorCollectPadData *pad = (GstTensorCollectPadData *) data;
+    GstBuffer *buf = NULL;
+    buf = gst_collect_pads_peek (collect, data);
+    if (buf != NULL) {
+      if (pad->buffer != NULL)
+        base =
+            MIN (sync.data_basepad.duration,
+            ABS (GST_CLOCK_DIFF (GST_BUFFER_PTS (buf),
+                    GST_BUFFER_PTS (pad->buffer))) - 1);
+      gst_buffer_unref (buf);
+    }
+  }
+
+  walk = collect->data;
+
   while (walk) {
     GstCollectData *data = (GstCollectData *) walk->data;
     GstTensorCollectPadData *pad = (GstTensorCollectPadData *) data;
@@ -1238,10 +1258,9 @@ gst_gen_tensors_from_collectpad (GstCollectPads * collect,
             return FALSE;
           }
 
-          if (pad->buffer != NULL &&
-              (ABS (GST_CLOCK_DIFF (current_time,
-                          GST_BUFFER_PTS (buf))) >
-                  sync.data_basepad.duration)) {
+          if ((pad->buffer != NULL &&
+                  (ABS (GST_CLOCK_DIFF (current_time,
+                              GST_BUFFER_PTS (buf))) > base))) {
             gst_buffer_unref (buf);
             buf = pad->buffer;
           } else {