Doxygen Book
gsttensor_merge.c File Reference

GStreamer plugin to merge tensors (as a filter for other general neural network filters) More...

#include <string.h>
#include <gst/gst.h>
#include <glib.h>
#include <nnstreamer_util.h>
#include "gsttensor_merge.h"
Include dependency graph for gsttensor_merge.c:

Go to the source code of this file.

Macros

#define GST_CAT_DEFAULT   gst_tensor_merge_debug
 
#define DBG   (!tensor_merge->silent)
 Macro for debug mode. More...
 
#define CAPS_STRING   GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_WITH_NUM ("1")
 Template caps string. More...
 
#define gst_tensor_merge_parent_class   parent_class
 

Enumerations

enum  {
  PROP_0, PROP_MODE, PROP_OPTION, PROP_SYNC_MODE,
  PROP_SYNC_OPTION, PROP_SILENT
}
 

Functions

 GST_DEBUG_CATEGORY_STATIC (gst_tensor_merge_debug)
 
static gboolean gst_tensor_merge_src_event (GstPad *pad, GstObject *parent, GstEvent *event)
 src event vmethod More...
 
static GstPad * gst_tensor_merge_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *req_name, const GstCaps *caps)
 making new request pad (gst element vmethod) More...
 
static GstStateChangeReturn gst_tensor_merge_change_state (GstElement *element, GstStateChange transition)
 change state (gst element vmethod) More...
 
static gboolean gst_tensor_merge_sink_event (GstCollectPads *pads, GstCollectData *data, GstEvent *event, GstTensorMerge *tensor_merge)
 sink event vmethod More...
 
static GstFlowReturn gst_tensor_merge_collected (GstCollectPads *pads, GstTensorMerge *tensor_merge)
 Gst Collect Pads Function which is called once collect pads done. More...
 
static void gst_tensor_merge_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 Get property (gst element vmethod) More...
 
static void gst_tensor_merge_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 Get property (gst element vmethod) More...
 
static void gst_tensor_merge_finalize (GObject *object)
 finalize vmethod More...
 
 G_DEFINE_TYPE (GstTensorMerge, gst_tensor_merge, GST_TYPE_ELEMENT)
 
static void gst_tensor_merge_class_init (GstTensorMergeClass *klass)
 initialize the tensor_merge's class More...
 
static void gst_tensor_merge_init (GstTensorMerge *tensor_merge)
 initialize the new element instantiate pads and add them to element set pad callback functions initialize instance structure More...
 
static tensor_merge_mode gst_tensor_merge_get_mode (const gchar *str)
 Get the corresponding mode from the string value. More...
 
static gboolean gst_tensor_merge_get_merged_config (GstTensorMerge *tensor_merge, const GstTensorsConfig *in_config, GstTensorsConfig *out_config)
 Generate out TensorsConfig with in TensorsConfig. More...
 
static gboolean gst_tensor_merge_collect_buffer (GstTensorMerge *tensor_merge, GstBuffer *tensors_buf, gboolean *is_eos)
 Looping to generete output buffer for srcpad. More...
 
static GstFlowReturn gst_tensor_merge_generate_mem (GstTensorMerge *tensor_merge, GstBuffer *tensors_buf, GstBuffer *tensor_buf)
 Generate Output GstMemory. More...
 
static gboolean gst_tensor_merge_set_src_caps (GstTensorMerge *tensor_merge)
 Set src pad caps if src pad is not negotiated. More...
 
static void gst_tensor_merge_send_segment_event (GstTensorMerge *tensor_merge, GstClockTime pts, GstClockTime dts)
 Send segment event if necessary. More...
 
static void gst_tensor_merge_ready_to_paused (GstTensorMerge *tensor_merge)
 Ready --> Pasuse State Change. More...
 
static gboolean gst_tensor_merge_set_option_data (GstTensorMerge *tensor_merge)
 Setup internal data (data_* in GstTensor_Merge) More...
 

Variables

static const gchar * gst_tensor_merge_mode_string []
 
static const gchar * gst_tensor_merge_linear_string []
 
static GstStaticPadTemplate src_templ
 the capabilities of the inputs and outputs. describe the real formats here. More...
 
static GstStaticPadTemplate sink_templ
 

Detailed Description

GStreamer plugin to merge tensors (as a filter for other general neural network filters)

GStreamer Copyright (C) 2005 Thomas Vander Stichele thoma.nosp@m.s@ap.nosp@m.estaa.nosp@m.rt.o.nosp@m.rg Copyright (C) 2005 Ronald S. Bultje rbult.nosp@m.je@r.nosp@m.onald.nosp@m..bit.nosp@m.freak.nosp@m..net Copyright (C) 2018 Jijoong Moon jijoo.nosp@m.ng.m.nosp@m.oon@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

Date
03 July 2018
See also
https://github.com/nnstreamer/nnstreamer
Author
Jijoong Moon jijoo.nosp@m.ng.m.nosp@m.oon@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m
Bug:
No known bugs except for NYI items

Definition in file gsttensor_merge.c.

Macro Definition Documentation

◆ CAPS_STRING

#define CAPS_STRING   GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_WITH_NUM ("1")

Template caps string.

Definition at line 102 of file gsttensor_merge.c.

◆ DBG

#define DBG   (!tensor_merge->silent)

Macro for debug mode.

Definition at line 73 of file gsttensor_merge.c.

◆ GST_CAT_DEFAULT

#define GST_CAT_DEFAULT   gst_tensor_merge_debug

Definition at line 67 of file gsttensor_merge.c.

◆ gst_tensor_merge_parent_class

#define gst_tensor_merge_parent_class   parent_class

Definition at line 135 of file gsttensor_merge.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_0 
PROP_MODE 
PROP_OPTION 
PROP_SYNC_MODE 
PROP_SYNC_OPTION 
PROP_SILENT 

Definition at line 76 of file gsttensor_merge.c.

Function Documentation

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( GstTensorMerge  ,
gst_tensor_merge  ,
GST_TYPE_ELEMENT   
)

◆ GST_DEBUG_CATEGORY_STATIC()

GST_DEBUG_CATEGORY_STATIC ( gst_tensor_merge_debug  )

SECTION:element-tensormerge

A Merger that merge tensor stream to tensor stream for NN frameworks. The output is always in the format of other/tensor

<refsect2> <title>Example launch line</title> |[ gst-launch -v -m tensor_merge name=merge ! fakesink filesrc location=b.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! merge.sink_0 filesrc location=b.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! merge.sink_1 filesrc location=b.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,width=100,height=100,framerate=0/1 ! tensor_converter ! merge.sink_2 ]|

|[ gst-launch -v -m tensor_merge name=merge ! filesink location=merge.log multifilesrc location="testsequence_%1d.png" index=0 caps="image/png, framerate=(fraction)30/1" ! pngdec ! tensor_converter ! merge.sink_0 multifilesrc location="testsequence_%1d.png" index=0 caps="image/png, framerate=(fraction)30/1" ! pngdec ! tensor_converter ! merge.sink_1 multifilesrc location="testsequence_%1d.png" index=0 caps="image/png, framerate=(fraction)30/1" ! pngdec ! tensor_converter ! merge.sink_2

</refsect2>

◆ gst_tensor_merge_change_state()

static GstStateChangeReturn gst_tensor_merge_change_state ( GstElement *  element,
GstStateChange  transition 
)
static

change state (gst element vmethod)

Definition at line 776 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_class_init()

static void gst_tensor_merge_class_init ( GstTensorMergeClass klass)
static

initialize the tensor_merge's class

Definition at line 142 of file gsttensor_merge.c.

Here is the call graph for this function:

◆ gst_tensor_merge_collect_buffer()

static gboolean gst_tensor_merge_collect_buffer ( GstTensorMerge tensor_merge,
GstBuffer *  tensors_buf,
gboolean *  is_eos 
)
static

Looping to generete output buffer for srcpad.

Parameters
tensor_mergetensor merger
tensor_bufoutput buffer for srcpad
is_eosboolean EOS ( End of Stream )
Returns
TRUE to push buffer to src pad

Definition at line 448 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_collected()

static GstFlowReturn gst_tensor_merge_collected ( GstCollectPads *  pads,
GstTensorMerge tensor_merge 
)
static

Gst Collect Pads Function which is called once collect pads done.

Parameters
padsGstCollectPads
tensor_mergeMerger
Returns
GstFlowReturn

Cannot use gst-pad util to get stream ID (multiple sink pads). Create stream ID using first sink pad.

Definition at line 693 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_finalize()

static void gst_tensor_merge_finalize ( GObject *  object)
static

finalize vmethod

Definition at line 258 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_generate_mem()

static GstFlowReturn gst_tensor_merge_generate_mem ( GstTensorMerge tensor_merge,
GstBuffer *  tensors_buf,
GstBuffer *  tensor_buf 
)
static

Generate Output GstMemory.

Parameters
tensor_mergetensor merger
tensors_bufcollected tensors buffer
tensor_bufoutput tensor buffer
Returns
boolean

Definition at line 475 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_get_merged_config()

static gboolean gst_tensor_merge_get_merged_config ( GstTensorMerge tensor_merge,
const GstTensorsConfig in_config,
GstTensorsConfig out_config 
)
static

Generate out TensorsConfig with in TensorsConfig.

Parameters
tensor_mergetensor merger
in_configin tensors config data (multi tensors)
out_configout tensors config data (single tensor)
Returns
true / false

Definition at line 379 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_get_mode()

static tensor_merge_mode gst_tensor_merge_get_mode ( const gchar *  str)
static

Get the corresponding mode from the string value.

Parameters
[in]strThe string value for the mode
Returns
corresponding mode for the string. GTT_END for errors

Definition at line 244 of file gsttensor_merge.c.

Here is the caller graph for this function:

◆ gst_tensor_merge_get_property()

static void gst_tensor_merge_get_property ( GObject *  object,
guint  prop_id,
GValue *  value,
GParamSpec *  pspec 
)
static

Get property (gst element vmethod)

Definition at line 894 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_init()

static void gst_tensor_merge_init ( GstTensorMerge tensor_merge)
static

initialize the new element instantiate pads and add them to element set pad callback functions initialize instance structure

Definition at line 209 of file gsttensor_merge.c.

Here is the call graph for this function:

◆ gst_tensor_merge_ready_to_paused()

static void gst_tensor_merge_ready_to_paused ( GstTensorMerge tensor_merge)
static

Ready --> Pasuse State Change.

Definition at line 764 of file gsttensor_merge.c.

Here is the caller graph for this function:

◆ gst_tensor_merge_request_new_pad()

static GstPad * gst_tensor_merge_request_new_pad ( GstElement *  element,
GstPadTemplate *  templ,
const gchar *  name,
const GstCaps *  caps 
)
static

making new request pad (gst element vmethod)

Definition at line 287 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_send_segment_event()

static void gst_tensor_merge_send_segment_event ( GstTensorMerge tensor_merge,
GstClockTime  pts,
GstClockTime  dts 
)
static

Send segment event if necessary.

Definition at line 666 of file gsttensor_merge.c.

Here is the caller graph for this function:

◆ gst_tensor_merge_set_option_data()

static gboolean gst_tensor_merge_set_option_data ( GstTensorMerge tensor_merge)
static

Setup internal data (data_* in GstTensor_Merge)

Parameters
[in/out]filter "this" pointer. mode & option MUST BE set already.
Return values
TRUEif ok or not configured, yet.
FALSEif given input is configured invalid.

Definition at line 812 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_set_property()

static void gst_tensor_merge_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Get property (gst element vmethod)

Definition at line 841 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_set_src_caps()

static gboolean gst_tensor_merge_set_src_caps ( GstTensorMerge tensor_merge)
static

Set src pad caps if src pad is not negotiated.

Internal Logic Error?

Definition at line 632 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_sink_event()

static gboolean gst_tensor_merge_sink_event ( GstCollectPads *  pads,
GstCollectData *  data,
GstEvent *  event,
GstTensorMerge tensor_merge 
)
static

sink event vmethod

Definition at line 353 of file gsttensor_merge.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_merge_src_event()

static gboolean gst_tensor_merge_src_event ( GstPad *  pad,
GstObject *  parent,
GstEvent *  event 
)
static

src event vmethod

Definition at line 334 of file gsttensor_merge.c.

Here is the caller graph for this function:

Variable Documentation

◆ gst_tensor_merge_linear_string

const gchar* gst_tensor_merge_linear_string[]
static
Initial value:
= {
[LINEAR_FIRST] = "0",
[LINEAR_SECOND] = "1",
[LINEAR_THIRD] = "2",
[LINEAR_FOURTH] = "3",
[LINEAR_END] = NULL,
}

Definition at line 91 of file gsttensor_merge.c.

◆ gst_tensor_merge_mode_string

const gchar* gst_tensor_merge_mode_string[]
static
Initial value:
= {
[GTT_LINEAR] = "linear",
[GTT_END] = "error",
}

Definition at line 86 of file gsttensor_merge.c.

◆ sink_templ

GstStaticPadTemplate sink_templ
static
Initial value:
= GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS (CAPS_STRING))

Definition at line 113 of file gsttensor_merge.c.

◆ src_templ

GstStaticPadTemplate src_templ
static
Initial value:
= GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CAPS_STRING))

the capabilities of the inputs and outputs. describe the real formats here.

Definition at line 108 of file gsttensor_merge.c.

LINEAR_FOURTH
@ LINEAR_FOURTH
Definition: gsttensor_merge.h:56
LINEAR_FIRST
@ LINEAR_FIRST
Definition: gsttensor_merge.h:53
LINEAR_END
@ LINEAR_END
Definition: gsttensor_merge.h:57
CAPS_STRING
#define CAPS_STRING
Template caps string.
Definition: gsttensor_merge.c:102
GTT_LINEAR
@ GTT_LINEAR
Definition: gsttensor_merge.h:47
GTT_END
@ GTT_END
Definition: gsttensor_merge.h:48
LINEAR_SECOND
@ LINEAR_SECOND
Definition: gsttensor_merge.h:54
LINEAR_THIRD
@ LINEAR_THIRD
Definition: gsttensor_merge.h:55