GStreamer plugin to aggregate tensor stream. More...
#include <string.h>
#include "gsttensor_aggregator.h"
#include "tensor_meta.h"
#include <nnstreamer_util.h>
Go to the source code of this file.
Macros | |
#define | DBG (!self->silent) |
Macro for debug mode. More... | |
#define | silent_debug_config(self, c, msg) |
#define | GST_CAT_DEFAULT gst_tensor_aggregator_debug |
#define | DEFAULT_SILENT TRUE |
Flag to print minimized log. More... | |
#define | DEFAULT_FRAMES_IN 1 |
The number of frames in input buffer. More... | |
#define | DEFAULT_FRAMES_OUT 1 |
The number of frames in output buffer. More... | |
#define | DEFAULT_FRAMES_FLUSH 0 |
The number of frames to flush. More... | |
#define | DEFAULT_FRAMES_DIMENSION (NNS_TENSOR_RANK_LIMIT - 1) |
The dimension index of frames in configured tensor. More... | |
#define | DEFAULT_CONCAT TRUE |
Flag to concatenate output buffer. More... | |
#define | CAPS_STRING GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_WITH_NUM ("1") |
Template caps string for pads. More... | |
#define | gst_tensor_aggregator_parent_class parent_class |
Enumerations | |
enum | { PROP_0, PROP_FRAMES_IN, PROP_FRAMES_OUT, PROP_FRAMES_FLUSH, PROP_FRAMES_DIMENSION, PROP_CONCAT, PROP_SILENT } |
tensor_aggregator properties More... | |
Functions | |
GST_DEBUG_CATEGORY_STATIC (gst_tensor_aggregator_debug) | |
G_DEFINE_TYPE (GstTensorAggregator, gst_tensor_aggregator, GST_TYPE_ELEMENT) | |
static void | gst_tensor_aggregator_finalize (GObject *object) |
Function to finalize instance. More... | |
static void | gst_tensor_aggregator_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
Setter for tensor_aggregator properties. More... | |
static void | gst_tensor_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
Getter for tensor_aggregator properties. More... | |
static gboolean | gst_tensor_aggregator_sink_event (GstPad *pad, GstObject *parent, GstEvent *event) |
This function handles sink events. More... | |
static gboolean | gst_tensor_aggregator_sink_query (GstPad *pad, GstObject *parent, GstQuery *query) |
This function handles sink pad query. More... | |
static gboolean | gst_tensor_aggregator_src_query (GstPad *pad, GstObject *parent, GstQuery *query) |
This function handles src pad query. More... | |
static GstFlowReturn | gst_tensor_aggregator_chain (GstPad *pad, GstObject *parent, GstBuffer *buf) |
Chain function, this function does the actual processing. More... | |
static GstStateChangeReturn | gst_tensor_aggregator_change_state (GstElement *element, GstStateChange transition) |
Called to perform state change. More... | |
static void | gst_tensor_aggregator_reset (GstTensorAggregator *self) |
Clear and reset data. More... | |
static GstCaps * | gst_tensor_aggregator_query_caps (GstTensorAggregator *self, GstPad *pad, GstCaps *filter) |
Get pad caps for caps negotiation. More... | |
static gboolean | gst_tensor_aggregator_parse_caps (GstTensorAggregator *self, const GstCaps *caps) |
Parse caps and set tensor info. More... | |
static void | gst_tensor_aggregator_class_init (GstTensorAggregatorClass *klass) |
Initialize the tensor_aggregator's class. More... | |
static void | gst_tensor_aggregator_init (GstTensorAggregator *self) |
Initialize tensor_aggregator element. More... | |
static GstAdapter * | gst_tensor_aggregator_get_adapter (GstTensorAggregator *self, GstBuffer *buf) |
Internal function to get adapter. More... | |
static gboolean | gst_tensor_aggregator_check_concat_axis (GstTensorAggregator *self, const GstTensorInfo *info) |
Check tensor dimension and axis to concatenate data. More... | |
static gboolean | gst_tensor_aggregator_concat (GstTensorAggregator *self, GstBuffer *outbuf, const GstTensorInfo *info) |
Change the data in buffer with given axis. More... | |
static GstFlowReturn | gst_tensor_aggregator_push (GstTensorAggregator *self, GstBuffer *outbuf, gsize frame_size) |
Push the buffer to source pad. (Concatenate the buffer if needed) More... | |
Variables | |
static GstStaticPadTemplate | sink_template |
Template for sink pad. More... | |
static GstStaticPadTemplate | src_template |
Template for src pad. More... | |
GStreamer plugin to aggregate tensor stream.
GStreamer Copyright (C) 2005 Thomas Vander Stichele thoma Copyright (C) 2005 Ronald S. Bultje s@ap estaa rt.o rgrbult Copyright (C) 2018 Samsung Electronics Co., Ltd. je@r onald .bit freak .net
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. SECTION:element-tensor_aggregator
Definition in file gsttensor_aggregator.c.
#define CAPS_STRING GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_WITH_NUM ("1") |
Template caps string for pads.
Definition at line 106 of file gsttensor_aggregator.c.
#define DBG (!self->silent) |
Macro for debug mode.
Definition at line 42 of file gsttensor_aggregator.c.
#define DEFAULT_CONCAT TRUE |
Flag to concatenate output buffer.
Definition at line 101 of file gsttensor_aggregator.c.
#define DEFAULT_FRAMES_DIMENSION (NNS_TENSOR_RANK_LIMIT - 1) |
The dimension index of frames in configured tensor.
Definition at line 96 of file gsttensor_aggregator.c.
#define DEFAULT_FRAMES_FLUSH 0 |
The number of frames to flush.
Definition at line 91 of file gsttensor_aggregator.c.
#define DEFAULT_FRAMES_IN 1 |
The number of frames in input buffer.
Definition at line 81 of file gsttensor_aggregator.c.
#define DEFAULT_FRAMES_OUT 1 |
The number of frames in output buffer.
Definition at line 86 of file gsttensor_aggregator.c.
#define DEFAULT_SILENT TRUE |
Flag to print minimized log.
Definition at line 76 of file gsttensor_aggregator.c.
#define GST_CAT_DEFAULT gst_tensor_aggregator_debug |
Definition at line 57 of file gsttensor_aggregator.c.
#define gst_tensor_aggregator_parent_class parent_class |
Definition at line 124 of file gsttensor_aggregator.c.
#define silent_debug_config | ( | self, | |
c, | |||
msg | |||
) |
Definition at line 45 of file gsttensor_aggregator.c.
anonymous enum |
tensor_aggregator properties
Enumerator | |
---|---|
PROP_0 | |
PROP_FRAMES_IN | |
PROP_FRAMES_OUT | |
PROP_FRAMES_FLUSH | |
PROP_FRAMES_DIMENSION | |
PROP_CONCAT | |
PROP_SILENT |
Definition at line 62 of file gsttensor_aggregator.c.
G_DEFINE_TYPE | ( | GstTensorAggregator | , |
gst_tensor_aggregator | , | ||
GST_TYPE_ELEMENT | |||
) |
GST_DEBUG_CATEGORY_STATIC | ( | gst_tensor_aggregator_debug | ) |
|
static |
Chain function, this function does the actual processing.
push the incoming buffer (do concat if needed)
supposed same duration for incoming buffer
Update timestamp. If frames-in is larger then frames-out, the same timestamp (pts and dts) would be returned.
set timestamp
flush data
Definition at line 835 of file gsttensor_aggregator.c.
|
static |
Called to perform state change.
Definition at line 947 of file gsttensor_aggregator.c.
|
static |
Check tensor dimension and axis to concatenate data.
self | this pointer to GstTensorAggregator |
info | tensor info for one frame |
Internal error. Caller should've checked it
Check condition to concatenate data.
concatenate data
Definition at line 540 of file gsttensor_aggregator.c.
|
static |
Initialize the tensor_aggregator's class.
GstTensorAggregator::frames-in:
The number of frames in incoming buffer. GstTensorAggregator itself cannot get the frames in buffer. (buffer is a sinle tensor instance) GstTensorAggregator calculates the size of single frame with this property.
GstTensorAggregator::frames-out:
The number of frames in outgoing buffer. (buffer is a sinle tensor instance) GstTensorAggregator calculates the size of outgoing frames and pushes a buffer to source pad.
GstTensorAggregator::frames-flush:
The number of frames to flush. GstTensorAggregator flushes the bytes (N frames) in GstAdapter after pushing a buffer. If set 0 (default value), all outgoing frames will be flushed.
GstTensorAggregator::frames-dim:
The dimension index of frames in tensor. If frames-in and frames-out are different, GstTensorAggregator has to change the dimension of tensor. With this property, GstTensorAggregator changes the out-caps.
The flag to concatenate output buffer. If concat is true and frames-out is larger than 1, GstTensorAggregator will concatenate the output buffer with the axis frames-dim.
The flag to enable/disable debugging messages.
Definition at line 155 of file gsttensor_aggregator.c.
|
static |
Change the data in buffer with given axis.
self | this pointer to GstTensorAggregator |
outbuf | buffer to be concatenated |
info | tensor info for one frame |
Internal error
Concatenate output buffer with given axis (frames-dim) If frames-dim is equal to (NNS_TENSOR_RANK_LIMIT - 1), nothing to do. (In this case, this function will not be called. See gst_tensor_aggregator_check_concat_axis ())
Ex1) concatenate 2 frames with dimension 3:4:2:1
frame 1 [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] ] ]
frame 2 [ [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ]
1-1. result with frames-dim 3 (3:4:2:2) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] ] ] [ [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ]
1-2. result with frames-dim 2 (3:4:4:1) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] ] [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ]
1-3. result with frames-dim 1 (3:8:2:1) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ]
1-4. result with frames-dim 0 (6:4:2:1) [ [ [1101 1102 1103 2101 2102 2103] [1104 1105 1106 2104 2105 2106] [1107 1108 1109 2107 2108 2109] [1110 1111 1112 2110 2111 2112] ] [ [1113 1114 1115 2113 2114 2115] [1116 1117 1118 2116 2117 2118] [1119 1120 1121 2119 2120 2121] [1122 1123 1124 2122 2123 2124] ] ]
Ex2) concatenate 2 frames with dimension 3:4:2:2
frame 1 [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] ] ] [ [ [1201 1202 1203] [1204 1205 1206] [1207 1208 1209] [1210 1211 1212] ] [ [1213 1214 1215] [1216 1217 1218] [1219 1220 1221] [1222 1223 1224] ] ]
frame 2 [ [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ] [ [ [2201 2202 2203] [2204 2205 2206] [2207 2208 2209] [2210 2211 2212] ] [ [2213 2214 2215] [2216 2217 2218] [2219 2220 2221] [2222 2223 2224] ] ]
2-1. result with frames-dim 3 (3:4:2:4) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] ] ] [ [ [1201 1202 1203] [1204 1205 1206] [1207 1208 1209] [1210 1211 1212] ] [ [1213 1214 1215] [1216 1217 1218] [1219 1220 1221] [1222 1223 1224] ] ] [ [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ] [ [ [2201 2202 2203] [2204 2205 2206] [2207 2208 2209] [2210 2211 2212] ] [ [2213 2214 2215] [2216 2217 2218] [2219 2220 2221] [2222 2223 2224] ] ]
2-2. result with frames-dim 2 (3:4:4:2) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] ] [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ] [ [ [1201 1202 1203] [1204 1205 1206] [1207 1208 1209] [1210 1211 1212] ] [ [1213 1214 1215] [1216 1217 1218] [1219 1220 1221] [1222 1223 1224] ] [ [2201 2202 2203] [2204 2205 2206] [2207 2208 2209] [2210 2211 2212] ] [ [2213 2214 2215] [2216 2217 2218] [2219 2220 2221] [2222 2223 2224] ] ]
2-3. result with frames-dim 1 (3:8:2:2) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] [ [1113 1114 1115] [1116 1117 1118] [1119 1120 1121] [1122 1123 1124] [2113 2114 2115] [2116 2117 2118] [2119 2120 2121] [2122 2123 2124] ] ] [ [ [1201 1202 1203] [1204 1205 1206] [1207 1208 1209] [1210 1211 1212] [2201 2202 2203] [2204 2205 2206] [2207 2208 2209] [2210 2211 2212] ] [ [1213 1214 1215] [1216 1217 1218] [1219 1220 1221] [1222 1223 1224] [2213 2214 2215] [2216 2217 2218] [2219 2220 2221] [2222 2223 2224] ] ]
2-4. result with frames-dim 0 (6:4:2:2) [ [ [1101 1102 1103 2101 2102 2103] [1104 1105 1106 2104 2105 2106] [1107 1108 1109 2107 2108 2109] [1110 1111 1112 2110 2111 2112] ] [ [1113 1114 1115 2113 2114 2115] [1116 1117 1118 2116 2117 2118] [1119 1120 1121 2119 2120 2121] [1122 1123 1124 2122 2123 2124] ] ] [ [ [1201 1202 1203 2201 2202 2203] [1204 1205 1206 2204 2205 2206] [1207 1208 1209 2207 2208 2209] [1210 1211 1212 2210 2211 2212] ] [ [1213 1214 1215 2213 2214 2215] [1216 1217 1218 2216 2217 2218] [1219 1220 1221 2219 2220 2221] [1222 1223 1224 2222 2223 2224] ] ]
Ex3) concatenate 2 frames with dimension 3:4:1:1
frame 1 [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] ]
frame 2 [ [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] ]
3-1. result with frames-dim 3 (3:4:1:2) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] ] [ [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] ]
3-2. result with frames-dim 2 (3:4:2:1) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] ] [ [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] ]
3-3. result with frames-dim 1 (3:8:1:1) [ [ [1101 1102 1103] [1104 1105 1106] [1107 1108 1109] [1110 1111 1112] [2101 2102 2103] [2104 2105 2106] [2107 2108 2109] [2110 2111 2112] ] ]
3-4. result with frames-dim 0 (6:4:1:1) [ [ [1101 1102 1103 2101 2102 2103] [1104 1105 1106 2104 2105 2106] [1107 1108 1109 2107 2108 2109] [1110 1111 1112 2110 2111 2112] ] ]
get block size
Definition at line 569 of file gsttensor_aggregator.c.
|
static |
Function to finalize instance.
Definition at line 294 of file gsttensor_aggregator.c.
|
static |
Internal function to get adapter.
Definition at line 521 of file gsttensor_aggregator.c.
|
static |
Getter for tensor_aggregator properties.
Definition at line 349 of file gsttensor_aggregator.c.
|
static |
Initialize tensor_aggregator element.
setup sink pad
setup src pad
init properties
Definition at line 254 of file gsttensor_aggregator.c.
|
static |
Parse caps and set tensor info.
update dimension in output tensor. e.g, in-dimension 2:200:200:1 if frames_out=10 and frames_dim=3, then out-dimension is 2:200:200:10. if frames_out=10 and frames_dim=2, then out-dimension is 2:200:2000:1.
Definition at line 1026 of file gsttensor_aggregator.c.
|
static |
Push the buffer to source pad. (Concatenate the buffer if needed)
tensor info for one frame
change data in buffer with given axis
Definition at line 805 of file gsttensor_aggregator.c.
|
static |
Get pad caps for caps negotiation.
Definition at line 990 of file gsttensor_aggregator.c.
|
static |
Clear and reset data.
Definition at line 980 of file gsttensor_aggregator.c.
|
static |
Setter for tensor_aggregator properties.
Definition at line 313 of file gsttensor_aggregator.c.
|
static |
This function handles sink events.
Definition at line 385 of file gsttensor_aggregator.c.
|
static |
This function handles sink pad query.
Definition at line 434 of file gsttensor_aggregator.c.
|
static |
This function handles src pad query.
Definition at line 487 of file gsttensor_aggregator.c.
|
static |
Template for sink pad.
Definition at line 111 of file gsttensor_aggregator.c.
|
static |
Template for src pad.
Definition at line 119 of file gsttensor_aggregator.c.