Code clean, prepare caps string with tensor format.
- clean source code and update description
Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
#include <nnstreamer_plugin_api.h>
/**
- * @brief Default static capability for Protocol Buffers
- * protobuf converter will convert this capability to other/tensor(s)
- */
-#define GST_PROTOBUF_TENSOR_CAP_DEFAULT \
- "other/protobuf-tensor, " \
- "framerate = " GST_TENSOR_RATE_RANGE
-
-/**
* @brief tensordec-plugin's GstTensorDecoderDef callback
* @param[in] config The structure of input tensor info.
* @param[in] input The array of input tensor data. The maximum array size of input data is NNS_TENSOR_SIZE_LIMIT.
/**
* type should be one of types in GST_TENSOR_TYPE_ALL
* "type = (string) uint8"
- * dimension shoule be a formatted string with rank NNS_TENSOR_RANK_LIMIT
+ * dimension should be a formatted string with rank NNS_TENSOR_RANK_LIMIT
* "dimension = (string) dim1:dim2:dim3:dim4"
*/
/**
- * @brief Caps string for the caps template (other/tensors).
+ * @brief Caps string for the caps template (other/tensors, static tensor stream with fixed number of tensors).
* num should be a string format that describes the number of tensors, or the range of incoming tensors.
+ * The types and dimensions of tensors should be described for caps negotiation.
*/
#define GST_TENSORS_CAP_WITH_NUM(num) \
NNS_MIMETYPE_TENSORS ", " \
"num_tensors = " num ", " \
"framerate = " GST_TENSOR_RATE_RANGE
- /**
- * type should be one of types in GST_TENSOR_TYPE_ALL
- * "types = (string) uint8, uint8, uint8"
- * Dimensions of Tensors for negotiation. It's comment out here,
- * but when we call gst_structure_get_string, it actually is working well.
- * "dimensions = (string) dim1:dim2:dim3:dim4, dim1:dim2:dim3:dim4"
- */
/**
- * @brief Default static capability for other/tensors
+ * @brief Caps string for the caps template of static tensor stream.
*/
#define GST_TENSORS_CAP_DEFAULT \
GST_TENSORS_CAP_WITH_NUM(GST_TENSOR_NUM_TENSORS_RANGE)
NNS_MIMETYPE_TENSORS_FLEXIBLE
/**
+ * @brief Default static capability for Protocol Buffers
+ * protobuf converter will convert this capability to other/tensor(s)
+ */
+#define GST_PROTOBUF_TENSOR_CAP_DEFAULT \
+ "other/protobuf-tensor, " \
+ "framerate = " GST_TENSOR_RATE_RANGE
+
+/**
* @brief Default static capability for flatbuffers
* Flatbuf converter will convert this capability to other/tensor(s)
* @todo Move this definition to proper header file
{
GstStructure *structure;
GstTensorsConfig config;
+ GstTensorInfo *_info;
uint32_t per_frame;
guint count;
}
self->in_config = config;
+ /* tensor-aggregator now handles single tensor. */
+ _info = &config.info.info[0];
/**
* update dimension in output tensor.
* if frames_out=10 and frames_dim=2, then out-dimension is 2:200:2000:1.
*/
if (self->frames_dim >= NNS_TENSOR_RANK_LIMIT ||
- (config.info.info[0].dimension[self->frames_dim] % self->frames_in) !=
- 0) {
+ (_info->dimension[self->frames_dim] % self->frames_in) != 0) {
GST_ERROR_OBJECT (self, "Cannot update dimension in output tensor");
return FALSE;
}
- per_frame = config.info.info[0].dimension[self->frames_dim] / self->frames_in;
+ per_frame = _info->dimension[self->frames_dim] / self->frames_in;
- config.info.info[0].dimension[self->frames_dim] =
- per_frame * self->frames_out;
+ _info->dimension[self->frames_dim] = per_frame * self->frames_out;
self->out_config = config;
self->tensor_configured = TRUE;
_peer_is_flexible_tensor_caps (GstPad * pad)
{
GstTensorsConfig config;
- gboolean fixed, flexible;
+ gboolean flexible = FALSE;
- fixed = flexible = FALSE;
-
- if (gst_tensors_config_from_peer (pad, &config, &fixed))
- flexible = (fixed && gst_tensors_info_is_flexible (&config.info));
+ if (gst_tensors_config_from_peer (pad, &config, NULL))
+ flexible = gst_tensors_info_is_flexible (&config.info);
+ gst_tensors_config_free (&config);
return flexible;
}
templ = gst_pad_get_pad_template_caps (pad);
- /* other/tensors-flexible */
+ /* other/tensors (flexible) */
is_flexible = gst_tensors_info_is_flexible (&config->info);
/* check peer element is flexible */
gst_caps_unref (caps);
}
- /* other/tensors */
+ /* other/tensors (static) */
caps = gst_tensors_caps_from_config (config);
intersectable:
caps = gst_pad_get_current_caps (pad);
if (caps) {
- GstStructure *structure = gst_caps_get_structure (caps, 0);
+ GstStructure *structure;
+ GstTensorsConfig config;
+
+ structure = gst_caps_get_structure (caps, 0);
+ if (gst_tensors_config_from_structure (&config, structure))
+ ret = gst_tensors_info_is_flexible (&config.info);
- ret = gst_structure_has_name (structure, NNS_MIMETYPE_TENSORS_FLEXIBLE);
gst_caps_unref (caps);
+ gst_tensors_config_free (&config);
}
return ret;
case _NNS_MEDIA_ANY:
{
GstTensorsConfig new_config;
+
+ gst_tensors_config_init (&new_config);
+
if (self->mode == _CONVERTER_MODE_CUSTOM_CODE) {
if (self->custom.func == NULL) {
nns_loge
} else if (0 == strncmp (parsed, "delay-", 6)) {
parsed = parsed + 6;
if (*parsed)
- data->delay = (uint32_t) g_ascii_strtoll (parsed, NULL, 10);;
+ data->delay = (uint32_t) g_ascii_strtoll (parsed, NULL, 10);
}
counter++;