[tensorDec] Implement copy label string to out buffer
authorjinhyuck-park <jinhyuck83.park@samsung.com>
Mon, 1 Oct 2018 05:31:18 +0000 (14:31 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Mon, 1 Oct 2018 07:07:07 +0000 (16:07 +0900)
Implement set out buffer with updated image label text

Signed-off-by: jinhyuck-park <jinhyuck83.park@samsung.com>
gst/tensor_decoder/tensordec.c

index 78df1d0..20b9948 100644 (file)
@@ -727,12 +727,29 @@ gst_get_image_label (GstTensorDec * self, gint label)
  * @brief set output of tensor decoder that will send to src pad  
  * @param self "this" pointer
  * @param outbuf src pad buffer
+ * @param label image label text that will copy to outbuf
  */
 static void
 gst_tensordec_label_set_output (GstTensorDec * self, GstBuffer * outbuf,
     gchar * label)
 {
-/** Not yet implemented TBD*/
+  guint len;
+  GstMemory *out_mem;
+  GstMapInfo out_info;
+
+  g_assert (gst_buffer_get_size (outbuf) == 0);
+
+  len = strlen (label);
+
+  out_mem = gst_allocator_alloc (NULL, (len + 1), NULL);
+  g_assert (out_mem != NULL);
+  g_assert (gst_memory_map (out_mem, &out_info, GST_MAP_WRITE));
+
+  strncpy ((char *) out_info.data, label, len);
+
+  gst_buffer_append_memory (outbuf, out_mem);
+
+  gst_memory_unmap (out_mem, &out_info);
 }
 
 /**