[Converter] Converter Core Function Located
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 27 Mar 2018 07:59:32 +0000 (16:59 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Wed, 28 Mar 2018 06:41:50 +0000 (15:41 +0900)
Fill in gst_convert2tensor_sink_event to convert media data to tensors.
GST Tensor is to be defined with gst_convert2tensor_configure_tensor

Build Tested.

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

index 57082fd..46dcd41 100644 (file)
@@ -101,6 +101,8 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
 /* the capabilities of the outputs
  *
  * In v0.0.1, this is 3-d tensor, [color][height][width]
+ *
+ * @TODO Note: I'm not sure of this.
  */
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
@@ -211,6 +213,12 @@ gst_convert2tensor_get_property (GObject * object, guint prop_id,
 
 /* GstElement vmethod implementations */
 
+/* Configure tensor metadata from sink caps */
+static gboolean
+gst_convert2tensor_configure_tensor(const GstCaps *caps, GstConvert2Tensor *myself) {
+}
+
+
 /* this function handles sink events */
 static gboolean
 gst_convert2tensor_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
@@ -229,7 +237,9 @@ gst_convert2tensor_sink_event (GstPad * pad, GstObject * parent, GstEvent * even
       GstCaps * caps;
 
       gst_event_parse_caps (event, &caps);
-      /* do something with the caps */
+      /* @TODO Construct tensor metadata from sink caps */
+      ret = gst_convert2tensor_configure_tensor(caps, filter);
+
 
       /* and forward */
       ret = gst_pad_event_default (pad, parent, event);
@@ -255,6 +265,10 @@ gst_convert2tensor_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   if (filter->silent == FALSE)
     g_print ("I'm plugged, therefore I'm in.\n");
 
+  /*
+   * @TODO: Convert video/x-raw frame to tensor instance.
+   */
+
   /* just push out the incoming buffer without touching it */
   return gst_pad_push (filter->srcpad, buf);
 }
index bad0092..0e6b682 100644 (file)
@@ -79,6 +79,29 @@ struct _GstConvert2Tensor
   GstPad *sinkpad;     /**< Media stream input */
   GstPad *srcpad;      /**< Tensor stream output */
   gboolean silent;     /**< True if logging is minimized */
+  gboolean tensorConfigured;   /**< True if sinkpad has successfully configured tensor metadata */
+  int rank;            /**< Tensor Rank (# dimensions) */
+  int dimension[4];    /**< Dimensions. We support up to 4th ranks */
+  enum {
+        _C2T_INT32 = 0,
+        _C2T_UINT32,
+        _C2T_INT16,
+        _C2T_UINT16,
+        _C2T_INT8,
+        _C2T_UINT8,
+        _C2T_FLOAT64,
+        _C2T_FLOAT32,
+  } type;              /**< Type of each element in the tensor. User must designate this. Otherwise, this is UINT8 for video/x-raw byte stream */
+};
+unsigned int GstConvert2TensorDataSize[] = {
+        [_C2T_INT32] = 4,
+        [_C2T_UINT32] = 4,
+        [_C2T_INT16] = 2,
+        [_C2T_UINT16] = 2,
+        [_C2T_INT8] = 1,
+        [_C2T_UINT8] = 1,
+        [_C2T_FLOAT64] = 8,
+        [_C2T_FLOAT32] = 4,
 };
 
 struct _GstConvert2TensorClass