analytics: add more convenient API to retrieve tensor
`gst_tensor_meta_get_by_id (meta,id)' is more convenient then retrieving the tensor index using `gst_tensor_meta_get_index_from_id()` followed by `gst_tensor_meta_get ()`. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8848>
This commit is contained in:
parent
37629385d0
commit
93af941ce7
@ -1481,6 +1481,25 @@ smaller than #GstTensorMeta.num_tensors</doc>
|
|||||||
</parameter>
|
</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_by_id" c:identifier="gst_tensor_meta_get_by_id" version="1.28">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.c">Get the first tensor from the #GstTensorMeta identified by @id.</doc>
|
||||||
|
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h"/>
|
||||||
|
<return-value transfer-ownership="none" nullable="1">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.c">a GstTensor with id matching @id.
|
||||||
|
Otherwise NULL will be returned.</doc>
|
||||||
|
<type name="Tensor" c:type="const GstTensor*"/>
|
||||||
|
</return-value>
|
||||||
|
<parameters>
|
||||||
|
<instance-parameter name="tmeta" transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.c">A #GstTensorMeta</doc>
|
||||||
|
<type name="TensorMeta" c:type="GstTensorMeta*"/>
|
||||||
|
</instance-parameter>
|
||||||
|
<parameter name="id" transfer-ownership="none">
|
||||||
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.c">A #GQuark identifying tensor-encoding</doc>
|
||||||
|
<type name="GLib.Quark" c:type="GQuark"/>
|
||||||
|
</parameter>
|
||||||
|
</parameters>
|
||||||
|
</method>
|
||||||
<method name="get_index_from_id" c:identifier="gst_tensor_meta_get_index_from_id" version="1.26">
|
<method name="get_index_from_id" c:identifier="gst_tensor_meta_get_index_from_id" version="1.26">
|
||||||
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.c">Finds the first tensor with the requsted ID in the meta</doc>
|
<doc xml:space="preserve" filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.c">Finds the first tensor with the requsted ID in the meta</doc>
|
||||||
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h"/>
|
<source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/analytics/gsttensormeta.h"/>
|
||||||
|
@ -153,6 +153,32 @@ gst_tensor_meta_set (GstTensorMeta * tmeta, guint num_tensors,
|
|||||||
tmeta->tensors = tensors;
|
tmeta->tensors = tensors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_tensor_meta_get_by_id:
|
||||||
|
* @tmeta: A #GstTensorMeta
|
||||||
|
* @id: A #GQuark identifying tensor-encoding
|
||||||
|
*
|
||||||
|
* Get the first tensor from the #GstTensorMeta identified by @id.
|
||||||
|
*
|
||||||
|
* Return: (nullable)(transfer none): a GstTensor with id matching @id.
|
||||||
|
* Otherwise NULL will be returned.
|
||||||
|
*
|
||||||
|
* Since: 1.28
|
||||||
|
*/
|
||||||
|
const GstTensor *
|
||||||
|
gst_tensor_meta_get_by_id (GstTensorMeta * tmeta, GQuark id)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (tmeta != NULL, NULL);
|
||||||
|
g_return_val_if_fail (tmeta->tensors, NULL);
|
||||||
|
|
||||||
|
for (int i = 0; i < tmeta->num_tensors; ++i) {
|
||||||
|
if (tmeta->tensors[i]->id == id)
|
||||||
|
return tmeta->tensors[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_tensor_meta_get:
|
* gst_tensor_meta_get:
|
||||||
* @tmeta: A #GstTensorMeta
|
* @tmeta: A #GstTensorMeta
|
||||||
|
@ -79,6 +79,9 @@ GST_ANALYTICS_META_API
|
|||||||
void gst_tensor_meta_set (GstTensorMeta *tmeta, guint num_tensors,
|
void gst_tensor_meta_set (GstTensorMeta *tmeta, guint num_tensors,
|
||||||
GstTensor **tensors);
|
GstTensor **tensors);
|
||||||
|
|
||||||
|
GST_ANALYTICS_META_API
|
||||||
|
const GstTensor *gst_tensor_meta_get_by_id (GstTensorMeta *tmeta, GQuark id);
|
||||||
|
|
||||||
GST_ANALYTICS_META_API
|
GST_ANALYTICS_META_API
|
||||||
const GstTensor *gst_tensor_meta_get (GstTensorMeta *tmeta, gsize index);
|
const GstTensor *gst_tensor_meta_get (GstTensorMeta *tmeta, gsize index);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user