GstMemory *mem[ML_TENSOR_SIZE_LIMIT];
GstMapInfo map[ML_TENSOR_SIZE_LIMIT];
guint i;
- guint num_mems;
+ guint num_mems, num_tensors;
GList *l;
ml_tensors_data_s *_data = NULL;
ml_tensors_info_s *_info;
_info = &elem->tensors_info;
num_mems = gst_buffer_n_memory (b);
+ num_tensors = gst_tensor_buffer_get_count (b);
- if (num_mems > ML_TENSOR_SIZE_LIMIT) {
+ if (num_mems > ML_TENSOR_SIZE_LIMIT_STATIC) {
_ml_loge (_ml_detail
("Number of memory chunks in a GstBuffer exceed the limit: %u > %u. Please check the version or variants of GStreamer you use. If you have modified the maximum number of memory chunks of a GST-Buffer, this might happen. Please update nnstreamer and ml-api code to make them consistent with your modification of GStreamer.",
- num_mems, ML_TENSOR_SIZE_LIMIT));
+ num_mems, ML_TENSOR_SIZE_LIMIT_STATIC));
return;
}
g_mutex_lock (&elem->lock);
- _data->num_tensors = num_mems;
- for (i = 0; i < num_mems; i++) {
- mem[i] = gst_buffer_peek_memory (b, i);
+ _data->num_tensors = num_tensors;
+ for (i = 0; i < num_tensors; i++) {
+ mem[i] = gst_tensor_buffer_get_nth_memory (b, i);
if (!gst_memory_map (mem[i], &map[i], GST_MAP_READ)) {
_ml_loge (_ml_detail
("Failed to map the output in sink '%s' callback, which is registered by ml_pipeline_sink_register ()",
goto send_cb;
}
- if (_info->num_tensors != num_mems) {
+ if (_info->num_tensors != num_tensors) {
_ml_loge (_ml_detail
("The sink event of [%s] cannot be handled because the number of tensors mismatches.",
elem->name));
}
}
- /* Get the data! */
- if (gst_buffer_get_size (b) != total_size ||
- (elem->size > 0 && total_size != elem->size)) {
- _ml_loge (_ml_detail
- ("The buffersize mismatches. All the three values must be the same: %zu, %zu, %zu",
- total_size, elem->size, gst_buffer_get_size (b)));
- goto error;
- }
-
send_cb:
/* set info for flexible stream */
if (elem->is_flexible_tensor) {
error:
g_mutex_unlock (&elem->lock);
- for (i = 0; i < num_mems; i++) {
+ for (i = 0; i < num_tensors; i++) {
gst_memory_unmap (mem[i], &map[i]);
+ gst_memory_unref (mem[i]);
}
_ml_tensors_data_destroy_internal (_data, FALSE);
gst_memory_unref (tmp);
}
- gst_buffer_append_memory (buffer, mem);
+ gst_tensor_buffer_append_memory (buffer, mem, _gst_tensor_info);
/** @todo Verify that gst_buffer_append lists tensors/gstmem in the correct order */
}