Common header file for NNStreamer, the GStreamer plugin for neural networks. More...
#include <glib.h>
#include <stdint.h>
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
#include <gst/base/gstcollectpads.h>
#include "tensor_typedef.h"
#include "nnstreamer_log.h"
#include "nnstreamer_plugin_api.h"
Go to the source code of this file.
Classes | |
struct | _tensor_sync_basepad_data |
Tensor Merge/Mux sync data for baspad mode. More... | |
struct | _tensor_time_sync_data |
Tensor Merge/Mux time sync data. More... | |
struct | GstTensorCollectPadData |
Internal data structure for Collect Pad in mux / merge. More... | |
struct | GstTensorPad |
Internal data structure for pad in demux / split. More... | |
Macros | |
#define | nns_memcpy memcpy |
#define | nns_memset memset |
#define | gst_tensor_pad_caps_is_static(p) (gst_tensor_pad_get_format (p) == _NNS_TENSOR_FORMAT_STATIC) |
Macro to check current pad caps is static tensor. More... | |
#define | gst_tensor_pad_caps_is_flexible(p) (gst_tensor_pad_get_format (p) == _NNS_TENSOR_FORMAT_FLEXIBLE) |
Macro to check current pad caps is flexible tensor. More... | |
#define | gst_tensor_pad_caps_is_sparse(p) (gst_tensor_pad_get_format (p) == _NNS_TENSOR_FORMAT_SPARSE) |
Macro to check current pad caps is sparse tensor. More... | |
#define | silent_debug(self, ...) |
Macro for debug message. More... | |
#define | silent_debug_caps(self, caps, msg) |
Macro for capability debug message. More... | |
Typedefs | |
typedef struct _tensor_sync_basepad_data | tensor_sync_basepad_data |
Tensor Merge/Mux sync data for baspad mode. More... | |
typedef struct _tensor_time_sync_data | tensor_time_sync_data |
Tensor Merge/Mux time sync data. More... | |
Enumerations | |
enum | tensor_time_sync_mode { SYNC_NOSYNC = 0, SYNC_SLOWEST = 1, SYNC_BASEPAD = 2, SYNC_REFRESH = 3, SYNC_END } |
time synchronization options More... | |
Functions | |
void | gst_tensor_parse_config_file (const gchar *config_path, const GObject *object) |
Parses a configuration file and sets the corresponding properties on a GObject. More... | |
tensor_time_sync_mode | gst_tensor_time_sync_get_mode (const gchar *str) |
Get the corresponding mode from the string value. More... | |
const gchar * | gst_tensor_time_sync_get_mode_string (tensor_time_sync_mode mode) |
Get the time-sync mode string. More... | |
gboolean | gst_tensor_time_sync_set_option_data (tensor_time_sync_data *sync) |
Setup time sync option. More... | |
gboolean | gst_tensor_time_sync_get_current_time (GstCollectPads *collect, tensor_time_sync_data *sync, GstClockTime *current_time, GstBuffer *tensors_buf) |
A function call to decide current timestamp among collected pads based on PTS. It will decide current timestamp according to sync option. GstMeta is also copied with same sync mode. More... | |
void | gst_tensor_time_sync_flush (GstCollectPads *collect) |
A function to be called while processing a flushing event. It should clear old buffer and reset pad data. More... | |
gboolean | gst_tensor_time_sync_buffer_from_collectpad (GstCollectPads *collect, tensor_time_sync_data *sync, GstClockTime current_time, GstBuffer *tensors_buf, GstTensorsConfig *configs, gboolean *is_eos) |
A function call to make tensors from collected pads It decide which buffer is going to be used according to sync option. More... | |
GstBuffer * | gst_tensor_buffer_from_config (GstBuffer *in, GstTensorsConfig *config) |
Configure gst-buffer with tensors information. NNStreamer handles single memory chunk as single tensor. If incoming buffer has invalid memories, separate it and generate new gst-buffer using tensors information. Note that this function always takes the ownership of input buffer. More... | |
GstCaps * | gst_tensor_pad_caps_from_config (GstPad *pad, const GstTensorsConfig *config) |
Get pad caps from tensors config and caps of the peer connected to the pad. More... | |
GstCaps * | gst_tensor_pad_possible_caps_from_config (GstPad *pad, const GstTensorsConfig *config) |
Get all possible caps from tensors config. Unlike gst_tensor_pad_caps_from_config(), this function does not check peer caps. More... | |
tensor_format | gst_tensor_pad_get_format (GstPad *pad) |
Get tensor format of current pad caps. More... | |
GHashTable * | gst_tensor_aggregation_init (void) |
Gets new hash table for tensor aggregation. More... | |
void | gst_tensor_aggregation_clear (GHashTable *table, const guint32 key) |
Clears buffers from adapter. More... | |
void | gst_tensor_aggregation_clear_all (GHashTable *table) |
Clears buffers from all adapters in hash table. More... | |
GstAdapter * | gst_tensor_aggregation_get_adapter (GHashTable *table, const guint32 key) |
Gets adapter from hash table. More... | |
Common header file for NNStreamer, the GStreamer plugin for neural networks.
NNStreamer Common Header Copyright (C) 2018 MyungJoo Ham myung joo. ham@s amsu ng.co 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.
Definition in file tensor_common.h.
#define gst_tensor_pad_caps_is_flexible | ( | p | ) | (gst_tensor_pad_get_format (p) == _NNS_TENSOR_FORMAT_FLEXIBLE) |
Macro to check current pad caps is flexible tensor.
Definition at line 231 of file tensor_common.h.
#define gst_tensor_pad_caps_is_sparse | ( | p | ) | (gst_tensor_pad_get_format (p) == _NNS_TENSOR_FORMAT_SPARSE) |
Macro to check current pad caps is sparse tensor.
Definition at line 236 of file tensor_common.h.
#define gst_tensor_pad_caps_is_static | ( | p | ) | (gst_tensor_pad_get_format (p) == _NNS_TENSOR_FORMAT_STATIC) |
Macro to check current pad caps is static tensor.
Definition at line 226 of file tensor_common.h.
#define nns_memcpy memcpy |
Definition at line 52 of file tensor_common.h.
#define nns_memset memset |
Definition at line 53 of file tensor_common.h.
#define silent_debug | ( | self, | |
... | |||
) |
Macro for debug message.
Definition at line 276 of file tensor_common.h.
#define silent_debug_caps | ( | self, | |
caps, | |||
msg | |||
) |
Macro for capability debug message.
Definition at line 285 of file tensor_common.h.
typedef struct _tensor_sync_basepad_data tensor_sync_basepad_data |
Tensor Merge/Mux sync data for baspad mode.
typedef struct _tensor_time_sync_data tensor_time_sync_data |
Tensor Merge/Mux time sync data.
time synchronization options
Enumerator | |
---|---|
SYNC_NOSYNC | |
SYNC_SLOWEST | |
SYNC_BASEPAD | |
SYNC_REFRESH | |
SYNC_END |
Definition at line 62 of file tensor_common.h.
void gst_tensor_aggregation_clear | ( | GHashTable * | table, |
const guint32 | key | ||
) |
Clears buffers from adapter.
table | a hash table instance initialized with gst_tensor_aggregation_init() |
key | the key to look up (set null to get default adapter) |
Definition at line 763 of file nnstreamer_plugin_api_impl.c.
void gst_tensor_aggregation_clear_all | ( | GHashTable * | table | ) |
Clears buffers from all adapters in hash table.
table | a hash table instance initialized with gst_tensor_aggregation_init() |
Definition at line 778 of file nnstreamer_plugin_api_impl.c.
GstAdapter* gst_tensor_aggregation_get_adapter | ( | GHashTable * | table, |
const guint32 | key | ||
) |
Gets adapter from hash table.
table | a hash table instance initialized with gst_tensor_aggregation_init() |
key | the key to look up (set null to get default adapter) |
Definition at line 790 of file nnstreamer_plugin_api_impl.c.
GHashTable* gst_tensor_aggregation_init | ( | void | ) |
Gets new hash table for tensor aggregation.
Add default adapter (for the case if buffer has no specific id). If gst-buffer has tensor-meta which includes client-id, e.g., aggregation frames from multiple clients on query-server pipeline, nnstreamer element should parse meta and request adapter with this id. However, on normal pipeline, gst-buffer does not contain tensor-meta, then the element may request adapter with null key string.
Definition at line 737 of file nnstreamer_plugin_api_impl.c.
GstBuffer* gst_tensor_buffer_from_config | ( | GstBuffer * | in, |
GstTensorsConfig * | config | ||
) |
Configure gst-buffer with tensors information. NNStreamer handles single memory chunk as single tensor. If incoming buffer has invalid memories, separate it and generate new gst-buffer using tensors information. Note that this function always takes the ownership of input buffer.
in | input buffer |
config | tensors config structure |
Definition at line 535 of file nnstreamer_plugin_api_impl.c.
GstCaps* gst_tensor_pad_caps_from_config | ( | GstPad * | pad, |
const GstTensorsConfig * | config | ||
) |
Get pad caps from tensors config and caps of the peer connected to the pad.
pad | GstPad to get possible caps |
config | tensors config structure |
Definition at line 1209 of file nnstreamer_plugin_api_impl.c.
tensor_format gst_tensor_pad_get_format | ( | GstPad * | pad | ) |
Get tensor format of current pad caps.
pad | GstPad to check current caps. |
If pad does not have tensor caps return _NNS_TENSOR_FORMAT_END
Definition at line 1343 of file nnstreamer_plugin_api_impl.c.
GstCaps* gst_tensor_pad_possible_caps_from_config | ( | GstPad * | pad, |
const GstTensorsConfig * | config | ||
) |
Get all possible caps from tensors config. Unlike gst_tensor_pad_caps_from_config(), this function does not check peer caps.
pad | GstPad to get possible caps |
config | tensors config structure |
Definition at line 1286 of file nnstreamer_plugin_api_impl.c.
void gst_tensor_parse_config_file | ( | const gchar * | config_path, |
const GObject * | object | ||
) |
Parses a configuration file and sets the corresponding properties on a GObject.
This function reads the contents of the configuration file located at the given path and sets the properties of the specified GObject based on the configuration data.
config_path | The path to the configuration file. |
object | The GObject on which to set the properties. |
Iterate over each line
Definition at line 1902 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensor_time_sync_buffer_from_collectpad | ( | GstCollectPads * | collect, |
tensor_time_sync_data * | sync, | ||
GstClockTime | current_time, | ||
GstBuffer * | tensors_buf, | ||
GstTensorsConfig * | configs, | ||
gboolean * | is_eos | ||
) |
A function call to make tensors from collected pads It decide which buffer is going to be used according to sync option.
collect | Collect pad. |
sync | Synchronization Option (NOSYNC, SLOWEST, BASEPAD, END) |
current_time | Current Timestamp |
tensors_buf | Generated GstBuffer for Collected Buffer |
configs | Configuration Info for Collected Buffer |
is_eos | True when EOS (end-of-stream) |
A function call to make tensors from collected pads It decide which buffer is going to be used according to sync option.
This would be an internal logic error. in_configs should be already confirmed valid at the negotiation phase and this function should be called in a running pipeline. If new sync mode is enabled (e.g., handle output when a pad gets new buffer), this may cause unexpected exception.
These are internal logic error. If given inputs are incorrect, the negotiation should have been failed before this stage.
Definition at line 332 of file nnstreamer_plugin_api_impl.c.
void gst_tensor_time_sync_flush | ( | GstCollectPads * | collect | ) |
A function to be called while processing a flushing event. It should clear old buffer and reset pad data.
collect | Collect pad. |
Definition at line 263 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensor_time_sync_get_current_time | ( | GstCollectPads * | collect, |
tensor_time_sync_data * | sync, | ||
GstClockTime * | current_time, | ||
GstBuffer * | tensors_buf | ||
) |
A function call to decide current timestamp among collected pads based on PTS. It will decide current timestamp according to sync option. GstMeta is also copied with same sync mode.
collect | Collect pad. |
sync | Synchronization Option (NOSYNC, SLOWEST, BASEPAD, END) |
current_time | Current time |
tensors_buf | Generated GstBuffer for Collected Buffer |
Definition at line 203 of file nnstreamer_plugin_api_impl.c.
tensor_time_sync_mode gst_tensor_time_sync_get_mode | ( | const gchar * | str | ) |
Get the corresponding mode from the string value.
[in] | str | The string value for the mode. |
Definition at line 101 of file nnstreamer_plugin_api_impl.c.
const gchar* gst_tensor_time_sync_get_mode_string | ( | tensor_time_sync_mode | mode | ) |
Get the time-sync mode string.
Definition at line 115 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensor_time_sync_set_option_data | ( | tensor_time_sync_data * | sync | ) |
Setup time sync option.
[in/out] | filter "this" pointer. Sync mode & option MUST BE set already. |
Definition at line 126 of file nnstreamer_plugin_api_impl.c.