Code clean, remove unnecessary copy of tensors-info and use util to get nth info.
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
GstMemory *in_mem, *out_mem;
GstMapInfo in_info;
guint mem_size;
+ GstTensorInfo *_info;
+
UNUSED (priv_data);
if (!in_buf || !config) {
std::string _name = tensor->Get (i)->name ()->str ();
const gchar *name = _name.c_str ();
- config->info.info[i].name = (name && strlen (name) > 0) ? g_strdup (name) : NULL;
- config->info.info[i].type = (tensor_type) tensor->Get (i)->type ();
+ _info = gst_tensors_info_get_nth_info (&config->info, i);
+
+ g_free (_info->name);
+ _info->name = (name && strlen (name) > 0) ? g_strdup (name) : NULL;
+ _info->type = (tensor_type) tensor->Get (i)->type ();
tensor_data = tensor->Get (i)->data ();
for (guint j = 0; j < NNS_TENSOR_RANK_LIMIT; j++) {
- config->info.info[i].dimension[j] = tensor->Get (i)->dimension ()->Get (j);
+ _info->dimension[j] = tensor->Get (i)->dimension ()->Get (j);
}
mem_size = VectorLength (tensor_data);
GstMemory *in_mem, *out_mem;
GstMapInfo in_info;
gsize mem_size;
+ GstTensorInfo *_info;
+
UNUSED (priv_data);
if (!in_buf || !config) {
flexbuffers::String _name = tensor[0].AsString ();
const gchar *name = _name.c_str ();
- config->info.info[i].name = (name && strlen (name) > 0) ? g_strdup (name) : NULL;
- config->info.info[i].type = (tensor_type) tensor[1].AsInt32 ();
+ _info = gst_tensors_info_get_nth_info (&config->info, i);
+
+ g_free (_info->name);
+ _info->name = (name && strlen (name) > 0) ? g_strdup (name) : NULL;
+ _info->type = (tensor_type) tensor[1].AsInt32 ();
flexbuffers::TypedVector dim = tensor[2].AsTypedVector ();
for (guint j = 0; j < NNS_TENSOR_RANK_LIMIT; j++) {
- config->info.info[i].dimension[j] = dim[j].AsInt32 ();
+ _info->dimension[j] = dim[j].AsInt32 ();
}
flexbuffers::Blob tensor_data = tensor[3].AsBlob ();
mem_size = gst_tensor_info_get_size (&config->info.info[i]);
fbd_decode (void **pdata, const GstTensorsConfig *config,
const GstTensorMemory *input, GstBuffer *outbuf)
{
- char *name;
Tensor_type type;
Tensor_format format;
GstMapInfo out_info;
frame_rate fr;
gboolean is_flexible;
GstTensorMetaInfo meta;
- GstTensorsConfig fbd_config;
+ GstTensorInfo *_info;
UNUSED (pdata);
ml_loge ("NULL parameter is passed to tensor_decoder::flatbuf");
return GST_FLOW_ERROR;
}
- gst_tensors_config_copy (&fbd_config, config);
- is_flexible = gst_tensors_config_is_flexible (&fbd_config);
+ is_flexible = gst_tensors_config_is_flexible (config);
- num_tensors = fbd_config.info.num_tensors;
- fr = frame_rate (fbd_config.rate_n, fbd_config.rate_d);
- format = (Tensor_format) fbd_config.info.format;
+ num_tensors = config->info.num_tensors;
+ fr = frame_rate (config->rate_n, config->rate_d);
+ format = (Tensor_format) config->info.format;
/* Fill the info in tensor and puth to tensor vector */
for (i = 0; i < num_tensors; i++) {
unsigned char *tmp_buf;
+ _info = gst_tensors_info_get_nth_info ((GstTensorsInfo *) &config->info, i);
+
if (is_flexible) {
gst_tensor_meta_info_parse_header (&meta, input[i].data);
- gst_tensor_meta_info_convert (&meta, &fbd_config.info.info[i]);
+ gst_tensor_meta_info_convert (&meta, _info);
}
- dim = builder.CreateVector (fbd_config.info.info[i].dimension, NNS_TENSOR_RANK_LIMIT);
- name = fbd_config.info.info[i].name;
- if (name == NULL)
+ dim = builder.CreateVector (_info->dimension, NNS_TENSOR_RANK_LIMIT);
+
+ if (_info->name == NULL)
tensor_name = builder.CreateString ("");
else
- tensor_name = builder.CreateString (name);
+ tensor_name = builder.CreateString (_info->name);
- type = (Tensor_type) fbd_config.info.info[i].type;
+ type = (Tensor_type) _info->type;
/* Create the vector first, and fill in data later */
/** @todo Consider to remove memcpy */
flexbuffers::Builder fbb;
gboolean is_flexible;
GstTensorMetaInfo meta;
- GstTensorsConfig flxd_config;
+ GstTensorInfo *_info;
+
UNUSED (pdata);
if (!config || !input || !outbuf) {
ml_loge ("NULL parameter is passed to tensor_decoder::flexbuf");
return GST_FLOW_ERROR;
}
- gst_tensors_config_copy (&flxd_config, config);
- is_flexible = gst_tensors_config_is_flexible (&flxd_config);
- num_tensors = flxd_config.info.num_tensors;
+ is_flexible = gst_tensors_config_is_flexible (config);
+
+ num_tensors = config->info.num_tensors;
fbb.Map ([&] () {
fbb.UInt ("num_tensors", num_tensors);
- fbb.Int ("rate_n", flxd_config.rate_n);
- fbb.Int ("rate_d", flxd_config.rate_d);
- fbb.Int ("format", flxd_config.info.format);
+ fbb.Int ("rate_n", config->rate_n);
+ fbb.Int ("rate_d", config->rate_d);
+ fbb.Int ("format", config->info.format);
for (i = 0; i < num_tensors; i++) {
gchar *tensor_key = g_strdup_printf ("tensor_%d", i);
gchar *tensor_name = NULL;
+
+ _info = gst_tensors_info_get_nth_info ((GstTensorsInfo *) &config->info, i);
+
if (is_flexible) {
gst_tensor_meta_info_parse_header (&meta, input[i].data);
- gst_tensor_meta_info_convert (&meta, &flxd_config.info.info[i]);
+ gst_tensor_meta_info_convert (&meta, _info);
}
- tensor_name = flxd_config.info.info[i].name;
- if (flxd_config.info.info[i].name == NULL) {
+
+ if (_info->name == NULL) {
tensor_name = g_strdup ("");
} else {
- tensor_name = g_strdup (flxd_config.info.info[i].name);
+ tensor_name = g_strdup (_info->name);
}
- tensor_type type = flxd_config.info.info[i].type;
+ tensor_type type = _info->type;
fbb.Vector (tensor_key, [&] () {
fbb += tensor_name;
fbb += type;
- fbb.Vector (flxd_config.info.info[i].dimension, NNS_TENSOR_RANK_LIMIT);
+ fbb.Vector (_info->dimension, NNS_TENSOR_RANK_LIMIT);
fbb.Blob (input[i].data, input[i].size);
});
g_free (tensor_key);