[Demux/Split] copy meta from incoming buffer
authorJaeyun <jy1210.jung@samsung.com>
Wed, 17 Oct 2018 09:54:16 +0000 (18:54 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Fri, 19 Oct 2018 02:22:14 +0000 (11:22 +0900)
1. add code to copy metadata from incoming buffer
2. remove code about discontinuity flag

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/tensor_demux/gsttensordemux.c
gst/tensor_demux/gsttensordemux.h
gst/tensor_split/gsttensorsplit.c
gst/tensor_split/gsttensorsplit.h

index f183d60..57b0ef4 100644 (file)
@@ -335,7 +335,6 @@ gst_tensor_demux_get_tensor_pad (GstTensorDemux * tensor_demux,
   tensorpad->nth = nth;
   tensorpad->last_ret = GST_FLOW_OK;
   tensorpad->last_ts = GST_CLOCK_TIME_NONE;
-  tensorpad->discont = TRUE;
 
   tensor_demux->srcpads = g_slist_append (tensor_demux->srcpads, tensorpad);
   gst_tensor_demux_get_tensor_config (tensor_demux, &config,
@@ -431,16 +430,8 @@ gst_tensor_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   GstTensorDemux *tensor_demux;
   tensor_demux = GST_TENSOR_DEMUX (parent);
 
-  if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
-    GSList *l;
-    for (l = tensor_demux->srcpads; l != NULL; l = l->next) {
-      GstTensorPad *srcpad = l->data;
-      srcpad->discont = TRUE;
-    }
-  }
-
   num_tensors = tensor_demux->tensors_config.info.num_tensors;
-  GST_DEBUG_OBJECT (tensor_demux, " Number or Tensors: %d", num_tensors);
+  GST_DEBUG_OBJECT (tensor_demux, " Number of Tensors: %d", num_tensors);
 
   /* supposed n memory blocks in buffer */
   g_assert (gst_buffer_n_memory (buf) == num_tensors);
@@ -469,7 +460,7 @@ gst_tensor_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
     outbuf = gst_buffer_new ();
     mem = gst_buffer_peek_memory (buf, i);
     gst_buffer_append_memory (outbuf, mem);
-    ts = GST_BUFFER_PTS (buf);
+    ts = GST_BUFFER_TIMESTAMP (buf);
 
     if (created) {
       GstSegment segment;
@@ -478,18 +469,15 @@ gst_tensor_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
     }
 
     outbuf = gst_buffer_make_writable (outbuf);
+
+    /* metadata from incoming buffer */
+    gst_buffer_copy_into (outbuf, buf, GST_BUFFER_COPY_METADATA, 0, -1);
+
     if (srcpad->last_ts == GST_CLOCK_TIME_NONE || srcpad->last_ts != ts) {
-      GST_BUFFER_TIMESTAMP (outbuf) = ts;
       srcpad->last_ts = ts;
     } else {
-      GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
-    }
-
-    if (srcpad->discont) {
-      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-      srcpad->discont = FALSE;
-    } else {
-      GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DISCONT);
+      GST_DEBUG_OBJECT (tensor_demux, "invalid timestamp %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (ts));
     }
 
     GST_DEBUG_OBJECT (tensor_demux,
index 315e778..faa3119 100644 (file)
@@ -47,7 +47,6 @@ typedef struct
   GstPad *pad;
   GstClockTime last_ts;
   GstFlowReturn last_ret;
-  gboolean discont;
   gint nth;
 } GstTensorPad;
 
index 6ecf312..8c76e28 100644 (file)
@@ -306,7 +306,6 @@ gst_get_tensor_pad (GstTensorSplit * tensor_split, GstBuffer * inbuf,
   tensorpad->nth = nth;
   tensorpad->last_ret = GST_FLOW_OK;
   tensorpad->last_ts = GST_CLOCK_TIME_NONE;
-  tensorpad->discont = TRUE;
 
   tensor_split->srcpads = g_slist_append (tensor_split->srcpads, tensorpad);
   dim =
@@ -459,16 +458,10 @@ gst_tensor_split_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   GstFlowReturn res = GST_FLOW_OK;
   GstTensorSplit *tensor_split;
   tensor_split = GST_TENSOR_SPLIT (parent);
-  if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) {
-    GSList *l;
-    for (l = tensor_split->srcpads; l != NULL; l = l->next) {
-      GstTensorPad *srcpad = l->data;
-      srcpad->discont = TRUE;
-    }
-  }
 
   num_tensors = tensor_split->num_tensors;
-  GST_DEBUG_OBJECT (tensor_split, " Number or Tensors: %d", num_tensors);
+  GST_DEBUG_OBJECT (tensor_split, " Number of Tensors: %d", num_tensors);
+
   for (i = 0; i < num_tensors; i++) {
     if (tensor_split->tensorpick != NULL) {
       gboolean found = FALSE;
@@ -493,25 +486,26 @@ gst_tensor_split_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
     outbuf = gst_buffer_new ();
     mem = gst_get_splited_tensor (tensor_split, buf, i);
     gst_buffer_append_memory (outbuf, mem);
-    ts = GST_BUFFER_PTS (buf);
+    ts = GST_BUFFER_TIMESTAMP (buf);
+
     if (created) {
       GstSegment segment;
       gst_segment_init (&segment, GST_FORMAT_TIME);
       gst_pad_push_event (srcpad->pad, gst_event_new_segment (&segment));
     }
+
     outbuf = gst_buffer_make_writable (outbuf);
+
+    /* metadata from incoming buffer */
+    gst_buffer_copy_into (outbuf, buf, GST_BUFFER_COPY_METADATA, 0, -1);
+
     if (srcpad->last_ts == GST_CLOCK_TIME_NONE || srcpad->last_ts != ts) {
-      GST_BUFFER_TIMESTAMP (outbuf) = ts;
       srcpad->last_ts = ts;
     } else {
-      GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
-    }
-    if (srcpad->discont) {
-      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-      srcpad->discont = FALSE;
-    } else {
-      GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DISCONT);
+      GST_DEBUG_OBJECT (tensor_split, "invalid timestamp %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (ts));
     }
+
     GST_DEBUG_OBJECT (tensor_split,
         "pushing buffer with timestamp %" GST_TIME_FORMAT,
         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
index 547ab4a..734e645 100644 (file)
@@ -47,7 +47,6 @@ typedef struct
   GstPad *pad;
   GstClockTime last_ts;
   GstFlowReturn last_ret;
-  gboolean discont;
   gint nth;
 } GstTensorPad;