Common data for NNStreamer, the GStreamer plugin for neural networks. More...
Go to the source code of this file.
Classes | |
struct | GstTensorExtraInfo |
Data structure to describe a "extra" tensor data. This represents the information of the NNS_TENSOR_SIZE_LIMIT-th memory block for tensor stream. More... | |
struct | gst_tensor_aggregation_data_s |
Internal struct to handle aggregation data in hash table. More... | |
Macros | |
#define | NNS_TENSOR_RANK_LIMIT_PREV (4) |
The old rank of tensor. More... | |
#define | NNS_TENSOR_EXTRA_MAGIC 0xf00dc0de |
#define | AGGREGATION_DEFAULT_KEY 0xC0FFEEU |
Functions | |
static gboolean | gst_memory_map_is_extra_tensor (GstMapInfo *map) |
Check if given memory has extra tensors. More... | |
static void | gst_tensor_extra_info_init (GstTensorExtraInfo *extra, gsize reserved_size) |
Initialize GstTensorExtraInfo structure with given memory. 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... | |
static gboolean | _gst_tensor_time_sync_is_eos (GstCollectPads *collect, tensor_time_sync_data *sync, guint empty) |
Internal function to detect EOS using the number of empty pads. 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... | |
static gboolean | _gst_tensor_time_sync_buffer_update (GstCollectPads *collect, GstCollectData *data, GstClockTime current, GstClockTime base, tensor_time_sync_data *sync) |
Internal function to update buffer in pad data based on the sync mode. 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... | |
static void | gst_tensor_aggregation_free_data (gpointer data) |
Internal function to free aggregation data. More... | |
static gst_tensor_aggregation_data_s * | gst_tensor_aggregation_add_data (GHashTable *table, const guint32 key) |
Internal function to add new aggregation data. More... | |
static gst_tensor_aggregation_data_s * | gst_tensor_aggregation_get_data (GHashTable *table, const guint32 key) |
Internal function to get aggregation data. More... | |
static void | gst_tensor_aggregation_clear_internal (gpointer key, gpointer value, gpointer user_data) |
Internal function to remove all buffers from aggregation data. 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... | |
static gboolean | _append_prev_caps (const GstTensorsConfig *config) |
Internal function to check tensor dimensions to append old caps for backward compatibility (rank 4). More... | |
static GstCaps * | _get_tensor_caps (const GstTensorsConfig *config) |
Internal function to get caps for single tensor from config. More... | |
static GstCaps * | _get_tensors_caps (const GstTensorsConfig *config) |
Internal function to get caps for multi tensors from config. More... | |
static GstCaps * | _get_flexible_caps (const GstTensorsConfig *config) |
Internal function to get caps for flexible tensor from config. More... | |
gboolean | gst_structure_is_tensor_stream (const GstStructure *structure) |
Check given mimetype is tensor stream. More... | |
media_type | gst_structure_get_media_type (const GstStructure *structure) |
Get media type from structure. More... | |
gboolean | gst_tensors_config_from_peer (GstPad *pad, GstTensorsConfig *config, gboolean *is_fixed) |
Parse caps from peer pad and set tensors config. More... | |
static gboolean | _is_structure_dimension_same (GstStructure *st1, GstStructure *st2, const gchar *fieldname) |
Check whether two structures have the same dimension. More... | |
void | gst_tensor_caps_update_dimension (GstCaps *caps, GstCaps *filter) |
Update caps dimensions for negotiation. More... | |
gboolean | gst_tensor_caps_can_intersect (GstCaps *caps1, GstCaps *caps2) |
Try intersecting @caps1 and @caps2 for tensor stream. 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... | |
GstCaps * | gst_tensors_caps_from_config (const GstTensorsConfig *config) |
Get caps from tensors config (for other/tensors) More... | |
GstCaps * | gst_tensor_caps_from_config (const GstTensorsConfig *config) |
Get tensor caps from tensors config. More... | |
gboolean | gst_tensors_config_from_structure (GstTensorsConfig *config, const GstStructure *structure) |
Parse structure and set tensors config (for other/tensors) More... | |
gboolean | gst_tensor_meta_info_parse_memory (GstTensorMetaInfo *meta, GstMemory *mem) |
Parse memory and fill the tensor meta. More... | |
GstMemory * | gst_tensor_meta_info_append_header (GstTensorMetaInfo *meta, GstMemory *mem) |
Append header to memory. More... | |
GstMemory * | gst_tensor_buffer_get_nth_memory (GstBuffer *buffer, const guint index) |
Get the nth GstMemory from given buffer. More... | |
gboolean | gst_tensor_buffer_append_memory (GstBuffer *buffer, GstMemory *memory, const GstTensorInfo *info) |
Append memory to given buffer. More... | |
guint | gst_tensor_buffer_get_count (GstBuffer *buffer) |
Get the number of tensors in the buffer. More... | |
static void | set_property_value (GValue *prop_value, const GParamSpec *param_spec, const gchar *property_value) |
Sets the value of a property based on the specified property value and GParamSpec. More... | |
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... | |
Variables | |
static const gchar * | gst_tensor_time_sync_mode_string [] |
Common data for NNStreamer, the GStreamer plugin for neural networks.
NNStreamer Common Header's Contents (pipeline extension) Copyright (C) 2020 MyungJoo Ham myung joo. ham@s amsu ng.co m
Definition in file nnstreamer_plugin_api_impl.c.
#define AGGREGATION_DEFAULT_KEY 0xC0FFEEU |
Definition at line 662 of file nnstreamer_plugin_api_impl.c.
#define NNS_TENSOR_EXTRA_MAGIC 0xf00dc0de |
Definition at line 33 of file nnstreamer_plugin_api_impl.c.
#define NNS_TENSOR_RANK_LIMIT_PREV (4) |
The old rank of tensor.
Definition at line 31 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to check tensor dimensions to append old caps for backward compatibility (rank 4).
Definition at line 809 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to get caps for flexible tensor from config.
Definition at line 964 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to get caps for single tensor from config.
Definition at line 839 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to get caps for multi tensors from config.
Definition at line 904 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to update buffer in pad data based on the sync mode.
Definition at line 287 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to detect EOS using the number of empty pads.
[in] | collect | Collect pad. |
[in] | sync | Synchronization option. |
[in] | empty | The number of empty pads (pad has no buffer). |
Definition at line 175 of file nnstreamer_plugin_api_impl.c.
|
static |
Check whether two structures have the same dimension.
Definition at line 1072 of file nnstreamer_plugin_api_impl.c.
|
static |
Check if given memory has extra tensors.
[in] | map | GstMapInfo of GstMemory to be checked. |
Definition at line 54 of file nnstreamer_plugin_api_impl.c.
media_type gst_structure_get_media_type | ( | const GstStructure * | structure | ) |
Get media type from structure.
structure | structure to be interpreted |
Definition at line 1001 of file nnstreamer_plugin_api_impl.c.
gboolean gst_structure_is_tensor_stream | ( | const GstStructure * | structure | ) |
Check given mimetype is tensor stream.
structure | structure to be interpreted |
Definition at line 984 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to add new aggregation data.
Definition at line 685 of file nnstreamer_plugin_api_impl.c.
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.
|
static |
Internal function to remove all buffers from aggregation data.
Definition at line 718 of file nnstreamer_plugin_api_impl.c.
|
static |
Internal function to free aggregation data.
Definition at line 668 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.
|
static |
Internal function to get aggregation data.
Definition at line 706 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.
gboolean gst_tensor_buffer_append_memory | ( | GstBuffer * | buffer, |
GstMemory * | memory, | ||
const GstTensorInfo * | info | ||
) |
Append memory to given buffer.
[in/out] | buffer GstBuffer to be appended. | |
[in] | memory | GstMemory to append. This function takes ownership of this, even if it returns failure. |
[in] | info | GstTensorInfo of given memory. |
Free the name string, cause it does not freed by gstreamer.
Definition at line 1666 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.
guint gst_tensor_buffer_get_count | ( | GstBuffer * | buffer | ) |
Get the number of tensors in the buffer.
Definition at line 1813 of file nnstreamer_plugin_api_impl.c.
GstMemory* gst_tensor_buffer_get_nth_memory | ( | GstBuffer * | buffer, |
const guint | index | ||
) |
Get the nth GstMemory from given buffer.
[in] | buffer | GstBuffer to be parsed. |
[in] | index | Index of GstMemory to be returned. |
Definition at line 1586 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensor_caps_can_intersect | ( | GstCaps * | caps1, |
GstCaps * | caps2 | ||
) |
Try intersecting @caps1 and @caps2 for tensor stream.
caps1 | a GstCaps to intersect |
caps2 | a GstCaps to intersect |
Definition at line 1142 of file nnstreamer_plugin_api_impl.c.
GstCaps* gst_tensor_caps_from_config | ( | const GstTensorsConfig * | config | ) |
Get tensor caps from tensors config.
Get tensor caps from tensors config (for other/tensor)
config | tensors config info |
Definition at line 1395 of file nnstreamer_plugin_api_impl.c.
void gst_tensor_caps_update_dimension | ( | GstCaps * | caps, |
GstCaps * | filter | ||
) |
Update caps dimensions for negotiation.
Update caps dimension for negotiation.
caps | caps to compare and update |
filter | caps to compare |
Definition at line 1093 of file nnstreamer_plugin_api_impl.c.
|
static |
Initialize GstTensorExtraInfo structure with given memory.
[in/out] | extra GstTensorExtraInfo to be initialized. | |
[in] | reserved_size | The memory size of extra memory block. |
Definition at line 78 of file nnstreamer_plugin_api_impl.c.
GstMemory* gst_tensor_meta_info_append_header | ( | GstTensorMetaInfo * | meta, |
GstMemory * | mem | ||
) |
Append header to memory.
[in] | meta | tensor meta structure |
[in] | mem | pointer to GstMemory |
Definition at line 1544 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensor_meta_info_parse_memory | ( | GstTensorMetaInfo * | meta, |
GstMemory * | mem | ||
) |
Parse memory and fill the tensor meta.
[out] | meta | tensor meta structure to be filled |
[in] | mem | pointer to GstMemory to be parsed |
Definition at line 1509 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.
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.
GstCaps* gst_tensors_caps_from_config | ( | const GstTensorsConfig * | config | ) |
Get caps from tensors config (for other/tensors)
config | tensors config info |
Definition at line 1372 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensors_config_from_peer | ( | GstPad * | pad, |
GstTensorsConfig * | config, | ||
gboolean * | is_fixed | ||
) |
Parse caps from peer pad and set tensors config.
pad | GstPad to get the capabilities |
config | tensors config structure to be filled |
is_fixed | flag to be updated when peer caps is fixed (not mandatory, do nothing when the param is null) |
Definition at line 1041 of file nnstreamer_plugin_api_impl.c.
gboolean gst_tensors_config_from_structure | ( | GstTensorsConfig * | config, |
const GstStructure * | structure | ||
) |
Parse structure and set tensors config (for other/tensors)
config | tensors config structure to be filled |
structure | structure to be interpreted |
Definition at line 1413 of file nnstreamer_plugin_api_impl.c.
|
static |
Sets the value of a property based on the specified property value and GParamSpec.
prop_value | A pointer to the GValue where the property value will be set. |
param_spec | A pointer to the GParamSpec that describes the property. |
property_value | A string representing the value to be set for the property. |
default is string
Definition at line 1862 of file nnstreamer_plugin_api_impl.c.
|
static |
Definition at line 20 of file nnstreamer_plugin_api_impl.c.