diff --git a/subprojects/gst-plugins-bad/ext/onnx/gstonnxinference.cpp b/subprojects/gst-plugins-bad/ext/onnx/gstonnxinference.cpp index 00b37e6e45..a271a736b7 100644 --- a/subprojects/gst-plugins-bad/ext/onnx/gstonnxinference.cpp +++ b/subprojects/gst-plugins-bad/ext/onnx/gstonnxinference.cpp @@ -586,7 +586,7 @@ gst_onnx_inference_process (GstBaseTransform * trans, GstBuffer * buf) auto meta = client->copy_tensors_to_meta (outputs, buf); if (!meta) return FALSE; - GST_TRACE_OBJECT (trans, "Num tensors:%d", meta->num_tensors); + GST_TRACE_OBJECT (trans, "Num tensors:%zu", meta->num_tensors); meta->batch_size = 1; } catch (Ort::Exception & ortex) { diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensor.h b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensor.h new file mode 100644 index 0000000000..32b89177be --- /dev/null +++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensor.h @@ -0,0 +1,95 @@ +/* + * GStreamer gstreamer-tensor + * Copyright (C) 2024 Collabora Ltd + * + * gsttensor.h + * + * 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; either + * version 2 of the License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef __GST_TENSOR_H__ +#define __GST_TENSOR_H__ + +#include +#include + +/** + * GstTensorDataType: + * @GST_TENSOR_TYPE_INT4 signed 4 bit integer tensor data + * @GST_TENSOR_TYPE_INT8 signed 8 bit integer tensor data + * @GST_TENSOR_TYPE_INT16 signed 16 bit integer tensor data + * @GST_TENSOR_TYPE_INT32 signed 32 bit integer tensor data + * @GST_TENSOR_TYPE_INT64 signed 64 bit integer tensor data + * @GST_TENSOR_TYPE_UINT4 unsigned 4 bit integer tensor data + * @GST_TENSOR_TYPE_UINT8 unsigned 8 bit integer tensor data + * @GST_TENSOR_TYPE_UINT16 unsigned 16 bit integer tensor data + * @GST_TENSOR_TYPE_UINT32 unsigned 32 bit integer tensor data + * @GST_TENSOR_TYPE_UINT64 unsigned 64 bit integer tensor data + * @GST_TENSOR_TYPE_FLOAT16 16 bit floating point tensor data + * @GST_TENSOR_TYPE_FLOAT32 32 bit floating point tensor data + * @GST_TENSOR_TYPE_FLOAT64 64 bit floating point tensor data + * @GST_TENSOR_TYPE_BFLOAT16 "brain" 16 bit floating point tensor data + * + * Describe the type of data contain in the tensor. + * + * Since: 1.26 + */ +typedef enum _GstTensorDataType +{ + GST_TENSOR_TYPE_INT4, + GST_TENSOR_TYPE_INT8, + GST_TENSOR_TYPE_INT16, + GST_TENSOR_TYPE_INT32, + GST_TENSOR_TYPE_INT64, + GST_TENSOR_TYPE_UINT4, + GST_TENSOR_TYPE_UINT8, + GST_TENSOR_TYPE_UINT16, + GST_TENSOR_TYPE_UINT32, + GST_TENSOR_TYPE_UINT64, + GST_TENSOR_TYPE_FLOAT16, + GST_TENSOR_TYPE_FLOAT32, + GST_TENSOR_TYPE_FLOAT64, + GST_TENSOR_TYPE_BFLOAT16, +} GstTensorDataType; + +/** + * GstTensor: + * @id: semantically identify the contents of the tensor + * @num_dims: number of tensor dimensions + * @dims: tensor dimensions + * @type: #GstTensorDataType of tensor data + * @data: #GstBuffer holding tensor data + * + * Hold tensor data + * + * Since: 1.26 + */ +typedef struct _GstTensor +{ + GQuark id; + gint num_dims; + int64_t *dims; + GstTensorDataType data_type; + GstBuffer *data; +} GstTensor; + +#define GST_TENSOR_MISSING_ID -1 + +#endif /* __GST_TENSOR_H__ */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h index 0630cf5bfe..a458df3aa8 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h @@ -29,87 +29,24 @@ #include #include - -/** - * GstTensorDataType: - * - * @GST_TENSOR_TYPE_INT4 signed 4 bit integer tensor data - * @GST_TENSOR_TYPE_INT8 signed 8 bit integer tensor data - * @GST_TENSOR_TYPE_INT16 signed 16 bit integer tensor data - * @GST_TENSOR_TYPE_INT32 signed 32 bit integer tensor data - * @GST_TENSOR_TYPE_INT64 signed 64 bit integer tensor data - * @GST_TENSOR_TYPE_UINT4 unsigned 4 bit integer tensor data - * @GST_TENSOR_TYPE_UINT8 unsigned 8 bit integer tensor data - * @GST_TENSOR_TYPE_UINT16 unsigned 16 bit integer tensor data - * @GST_TENSOR_TYPE_UINT32 unsigned 32 bit integer tensor data - * @GST_TENSOR_TYPE_UINT64 unsigned 64 bit integer tensor data - * @GST_TENSOR_TYPE_FLOAT16 16 bit floating point tensor data - * @GST_TENSOR_TYPE_FLOAT32 32 bit floating point tensor data - * @GST_TENSOR_TYPE_FLOAT64 64 bit floating point tensor data - * @GST_TENSOR_TYPE_BFLOAT16 "brain" 16 bit floating point tensor data - * - * Describe the type of data contain in the tensor. - * - * Since: 1.24 - */ -typedef enum _GstTensorDataType -{ - GST_TENSOR_TYPE_INT4, - GST_TENSOR_TYPE_INT8, - GST_TENSOR_TYPE_INT16, - GST_TENSOR_TYPE_INT32, - GST_TENSOR_TYPE_INT64, - GST_TENSOR_TYPE_UINT4, - GST_TENSOR_TYPE_UINT8, - GST_TENSOR_TYPE_UINT16, - GST_TENSOR_TYPE_UINT32, - GST_TENSOR_TYPE_UINT64, - GST_TENSOR_TYPE_FLOAT16, - GST_TENSOR_TYPE_FLOAT32, - GST_TENSOR_TYPE_FLOAT64, - GST_TENSOR_TYPE_BFLOAT16, -} GstTensorDataType; - - -/** - * GstTensor: - * - * @id: semantically identify the contents of the tensor - * @num_dims: number of tensor dimensions - * @dims: tensor dimensions - * @type: #GstTensorDataType of tensor data - * @data: #GstBuffer holding tensor data - * - * Since: 1.24 - */ -typedef struct _GstTensor -{ - GQuark id; - gint num_dims; - int64_t *dims; - GstTensorDataType data_type; - GstBuffer *data; -} GstTensor; - -#define GST_TENSOR_MISSING_ID -1 +#include /** * GstTensorMeta: - * * @meta base GstMeta * @num_tensors number of tensors * @tensor @ref GstTensor for each tensor * @batch_size model batch size * - * Since: 1.24 + * Since: 1.26 */ typedef struct _GstTensorMeta { GstMeta meta; - gint num_tensors; + gsize num_tensors; GstTensor *tensor; - int batch_size; + gsize batch_size; } GstTensorMeta; G_BEGIN_DECLS diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build index 81d7c2ce66..af1a777c5a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build +++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build @@ -12,7 +12,8 @@ analytics_headers = files( 'analytics.h', 'gstanalyticsobjectdetectionmtd.h', 'gstanalyticsobjecttrackingmtd.h', 'gstanalyticssegmentationmtd.h', - 'gsttensormeta.h') + 'gsttensormeta.h', + 'gsttensor.h') install_headers(analytics_headers, subdir : 'gstreamer-1.0/gst/analytics') pkg_name = 'gstreamer-analytics-1.0'