analytics: replace id type from gint to guint

- Replace all id type from gint to guint
- Fix annotation for GstAnalyticsODMtdData

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5758>
This commit is contained in:
Daniel Morin 2023-12-02 22:17:34 -05:00
parent 4ec5de8784
commit aaee569087
9 changed files with 50 additions and 50 deletions

View file

@ -264,7 +264,7 @@ gst_analytics_relation_meta_add_one_cls_mtd (GstAnalyticsRelationMeta *
*/
gboolean
gst_analytics_relation_meta_get_cls_mtd (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsClsMtd * rlt)
guint an_meta_id, GstAnalyticsClsMtd * rlt)
{
return gst_analytics_relation_meta_get_mtd (meta, an_meta_id,
gst_analytics_cls_mtd_get_type_quark (), (GstAnalyticsClsMtd *) rlt);

View file

@ -76,7 +76,7 @@ gst_analytics_relation_meta_add_one_cls_mtd (GstAnalyticsRelationMeta *
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_get_cls_mtd (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsClsMtd * rlt);
guint an_meta_id, GstAnalyticsClsMtd * rlt);
G_END_DECLS
#endif // __GST_ANALYTICS_CLASSIFICATION_H__

View file

@ -29,7 +29,7 @@ GST_DEBUG_CATEGORY_STATIC (an_relation_meta_debug);
static char invalid_type_name[] = "_invalid";
static gint
static guint
gst_analytics_relation_meta_get_next_id (GstAnalyticsRelationMeta * meta);
/**
@ -410,7 +410,7 @@ gst_analytics_relation_meta_get_info (void)
* usage exemple can be found in @gst_analytics_relation_meta_exist.
*/
static void
gst_analytics_relation_meta_bfs (gint start, const guint8 ** adj_mat,
gst_analytics_relation_meta_bfs (guint start, const guint8 ** adj_mat,
gsize adj_mat_order, guint8 edge_mask, gsize max_span, gint * level,
gint * parent)
{
@ -464,7 +464,7 @@ gst_analytics_relation_meta_bfs (gint start, const guint8 ** adj_mat,
* Returns: next id
*
*/
static gint
static guint
gst_analytics_relation_meta_get_next_id (GstAnalyticsRelationMeta * meta)
{
g_return_val_if_fail (meta != NULL, -1);
@ -487,29 +487,29 @@ gst_analytics_relation_meta_get_next_id (GstAnalyticsRelationMeta * meta)
*/
GstAnalyticsRelTypes
gst_analytics_relation_meta_get_relation (GstAnalyticsRelationMeta * meta,
gint an_meta_first, gint an_meta_second)
guint an_meta_first_id, guint an_meta_second_id)
{
GstAnalyticsRelTypes types = GST_ANALYTICS_REL_TYPE_NONE;
g_return_val_if_fail (meta, GST_ANALYTICS_REL_TYPE_NONE);
g_return_val_if_fail (meta->adj_mat != NULL, GST_ANALYTICS_REL_TYPE_NONE);
if (meta->rel_order > an_meta_first && meta->rel_order > an_meta_second) {
types = meta->adj_mat[an_meta_first][an_meta_second];
if (meta->rel_order > an_meta_first_id && meta->rel_order > an_meta_second_id) {
types = meta->adj_mat[an_meta_first_id][an_meta_second_id];
} else {
GST_CAT_DEBUG (GST_CAT_AN_RELATION,
"an_meta_first(%i) and an_meta_second(%i) must be inferior to %"
G_GSIZE_FORMAT, an_meta_first, an_meta_second, meta->rel_order);
"an_meta_first(%u) and an_meta_second(%u) must be inferior to %"
G_GSIZE_FORMAT, an_meta_first_id, an_meta_second_id, meta->rel_order);
if (an_meta_first >= meta->rel_order) {
if (an_meta_first_id >= meta->rel_order) {
GST_CAT_ERROR (GST_CAT_AN_RELATION,
"an_meta_first(%i) must be from a call to "
"gst_analytics_mtd_get_id(...)", an_meta_first);
"an_meta_first(%u) must be from a call to "
"gst_analytics_mtd_get_id(...)", an_meta_first_id);
}
if (an_meta_second >= meta->rel_order) {
if (an_meta_second_id >= meta->rel_order) {
GST_CAT_ERROR (GST_CAT_AN_RELATION,
"an_meta_second(%i) must be from a call to "
"gst_analytics_mtd_get_id(...)", an_meta_second);
"an_meta_second(%u) must be from a call to "
"gst_analytics_mtd_get_id(...)", an_meta_second_id);
}
}
return types;
@ -534,7 +534,7 @@ gst_analytics_relation_meta_get_relation (GstAnalyticsRelationMeta * meta,
*/
gboolean
gst_analytics_relation_meta_set_relation (GstAnalyticsRelationMeta * meta,
GstAnalyticsRelTypes type, gint an_meta_first_id, gint an_meta_second_id)
GstAnalyticsRelTypes type, guint an_meta_first_id, guint an_meta_second_id)
{
g_return_val_if_fail (type < GST_ANALYTICS_REL_TYPE_LAST, FALSE);
g_return_val_if_fail (meta, FALSE);
@ -545,7 +545,7 @@ gst_analytics_relation_meta_set_relation (GstAnalyticsRelationMeta * meta,
}
meta->adj_mat[an_meta_first_id][an_meta_second_id] = type;
GST_CAT_TRACE (GST_CAT_AN_RELATION,
"Relation %x set between %d and %d",
"Relation %x set between %u and %u",
type, an_meta_first_id, an_meta_second_id);
return TRUE;
}
@ -581,8 +581,8 @@ gst_analytics_relation_meta_set_relation (GstAnalyticsRelationMeta * meta,
*/
gboolean
gst_analytics_relation_meta_exist (GstAnalyticsRelationMeta * rmeta,
gint an_meta_first_id,
gint an_meta_second_id,
guint an_meta_first_id,
guint an_meta_second_id,
gint max_relation_span,
GstAnalyticsRelTypes cond_types, GArray ** relations_path)
{
@ -860,7 +860,7 @@ gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
*/
gboolean
gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsMtdType type, GstAnalyticsMtd * rlt)
guint an_meta_id, GstAnalyticsMtdType type, GstAnalyticsMtd * rlt)
{
GstAnalyticsRelatableMtdData *d;
@ -869,7 +869,7 @@ gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta * meta,
rlt->meta = NULL;
if (an_meta_id < 0 || an_meta_id >= meta->length) {
if (an_meta_id >= meta->length) {
GST_CAT_ERROR (GST_CAT_AN_RELATION, "Invalid parameter");
return FALSE;
}
@ -903,11 +903,11 @@ gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta * meta,
*/
GstAnalyticsRelatableMtdData *
gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta *
meta, gint an_meta_id)
meta, guint an_meta_id)
{
GstAnalyticsRelatableMtdData *rv;
g_return_val_if_fail (meta, NULL);
if (an_meta_id < 0 || an_meta_id >= meta->rel_order) {
if (an_meta_id >= meta->rel_order) {
GST_CAT_ERROR (GST_CAT_AN_RELATION, "Invalid parameter");
return NULL;
}
@ -935,7 +935,7 @@ gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta *
*/
gboolean
gst_analytics_relation_meta_get_direct_related (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsRelTypes relation_type,
guint an_meta_id, GstAnalyticsRelTypes relation_type,
GstAnalyticsMtdType type, gpointer * state, GstAnalyticsMtd * rlt_mtd)
{
guint8 **adj_mat;
@ -945,7 +945,7 @@ gst_analytics_relation_meta_get_direct_related (GstAnalyticsRelationMeta * meta,
gsize i;
GST_CAT_TRACE (GST_CAT_AN_RELATION,
"Looking for %s related to %d by %d", g_quark_to_string (type),
"Looking for %s related to %u by %d", g_quark_to_string (type),
an_meta_id, relation_type);
g_return_val_if_fail (rmeta != NULL, FALSE);

View file

@ -167,18 +167,18 @@ gst_analytics_relation_get_length (GstAnalyticsRelationMeta *
GST_ANALYTICS_META_API
GstAnalyticsRelTypes
gst_analytics_relation_meta_get_relation (GstAnalyticsRelationMeta * meta,
gint an_meta_first_id, gint an_meta_second_id);
guint an_meta_first_id, guint an_meta_second_id);
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_set_relation (GstAnalyticsRelationMeta
* meta, GstAnalyticsRelTypes type, gint an_meta_first_id,
gint an_meta_second_id);
* meta, GstAnalyticsRelTypes type, guint an_meta_first_id,
guint an_meta_second_id);
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_exist (GstAnalyticsRelationMeta *
rmeta, gint an_meta_first_id, gint an_meta_second_id,
rmeta, guint an_meta_first_id, guint an_meta_second_id,
gint max_relation_span, GstAnalyticsRelTypes cond_types,
GArray ** relations_path);
@ -203,12 +203,12 @@ gst_analytics_relation_meta_add_mtd (GstAnalyticsRelationMeta * meta,
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_get_mtd (GstAnalyticsRelationMeta *
meta, gint an_meta_id, GstAnalyticsMtdType type, GstAnalyticsMtd * rlt);
meta, guint an_meta_id, GstAnalyticsMtdType type, GstAnalyticsMtd * rlt);
GST_ANALYTICS_META_API
GstAnalyticsRelatableMtdData *
gst_analytics_relation_meta_get_mtd_data (GstAnalyticsRelationMeta * meta,
gint an_meta_id);
guint an_meta_id);
GST_ANALYTICS_META_API
gboolean
@ -219,7 +219,7 @@ gst_analytics_relation_meta_iterate (GstAnalyticsRelationMeta *
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_get_direct_related (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsRelTypes relation_type,
guint an_meta_id, GstAnalyticsRelTypes relation_type,
GstAnalyticsMtdType type, gpointer * state, GstAnalyticsMtd * rlt_mtd);
G_END_DECLS

View file

@ -31,7 +31,7 @@ static char type[] = GST_RELATABLE_MTD_OD_TYPE_NAME;
typedef struct _GstAnalyticsODMtdData GstAnalyticsODMtdData;
/**
* GstAnalyticsODMtd:
* GstAnalyticsODMtdData:
* @parent: parent #GstAnalyticsMtd
* @object_type: Type of object
* @x: x component of upper-left corner
@ -207,7 +207,7 @@ gst_analytics_relation_meta_add_od_mtd (GstAnalyticsRelationMeta *
*/
gboolean
gst_analytics_relation_meta_get_od_mtd (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsODMtd * rlt)
guint an_meta_id, GstAnalyticsODMtd * rlt)
{
return gst_analytics_relation_meta_get_mtd (meta, an_meta_id,
gst_analytics_od_mtd_get_type_quark (), (GstAnalyticsODMtd *) rlt);

View file

@ -65,8 +65,8 @@ gboolean gst_analytics_relation_meta_add_od_mtd (
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_get_od_mtd (GstAnalyticsRelationMeta * xbmeta,
gint an_meta_id, GstAnalyticsODMtd * rlt);
gst_analytics_relation_meta_get_od_mtd (GstAnalyticsRelationMeta * meta,
guint an_meta_id, GstAnalyticsODMtd * rlt);
G_END_DECLS

View file

@ -220,7 +220,7 @@ gst_analytics_relation_meta_add_tracking_mtd (GstAnalyticsRelationMeta *
*/
gboolean
gst_analytics_relation_meta_get_tracking_mtd (GstAnalyticsRelationMeta * meta,
gint an_meta_id, GstAnalyticsTrackingMtd * rlt)
guint an_meta_id, GstAnalyticsTrackingMtd * rlt)
{
return gst_analytics_relation_meta_get_mtd (meta, an_meta_id,
gst_analytics_tracking_mtd_get_type_quark (),

View file

@ -70,8 +70,8 @@ gboolean gst_analytics_relation_meta_add_tracking_mtd (
GST_ANALYTICS_META_API
gboolean
gst_analytics_relation_meta_get_tracking_mtd (GstAnalyticsRelationMeta * xbmeta,
gint an_meta_id, GstAnalyticsTrackingMtd * rlt);
gst_analytics_relation_meta_get_tracking_mtd (GstAnalyticsRelationMeta * meta,
guint an_meta_id, GstAnalyticsTrackingMtd * rlt);
G_END_DECLS

View file

@ -419,10 +419,10 @@ GST_START_TEST (test_path_relation_meta)
if (exist) {
fail_unless (path != NULL);
gint i;
gint path_check_ids[] = { 0, 2 };
guint path_check_ids[] = { 0, 2 };
fail_unless (path->len == 2);
for (i = 0; i < path->len; i++) {
fail_unless (path_check_ids[i] == g_array_index (path, gint, i));
fail_unless (path_check_ids[i] == g_array_index (path, guint, i));
}
g_array_free (g_steal_pointer (&path), TRUE);
fail_unless (i == 2);
@ -433,11 +433,11 @@ GST_START_TEST (test_path_relation_meta)
cls_mtd[2].id, GST_INF_RELATION_SPAN, cond, &path);
if (exist) {
gint i;
gint path_check_ids[] = { 1, 0, 2 };
guint path_check_ids[] = { 1, 0, 2 };
fail_unless (path != NULL);
fail_unless (path->len == 3);
for (i = 0; i < path->len; i++) {
fail_unless (path_check_ids[i] == g_array_index (path, gint, i));
fail_unless (path_check_ids[i] == g_array_index (path, guint, i));
}
g_array_free (g_steal_pointer (&path), TRUE);
fail_unless (i == 3);
@ -501,10 +501,10 @@ GST_START_TEST (test_cyclic_relation_meta)
fail_unless (exist == TRUE);
if (exist) {
gint i;
gint path_ids[] = { 0, 1, 2 };
guint path_ids[] = { 0, 1, 2 };
fail_unless (path->len == 3);
for (i = 0; i < path->len; i++) {
fail_unless (path_ids[i] == g_array_index (path, gint, i));
fail_unless (path_ids[i] == g_array_index (path, guint, i));
}
g_array_free (g_steal_pointer (&path), TRUE);
fail_unless (i == 3);
@ -639,11 +639,11 @@ GST_START_TEST (test_od_cls_relation)
fail_unless (exist == TRUE);
/* Query the relation path and verify it is correct */
gint ids[2];
guint ids[2];
gint i;
fail_unless (path->len == 2);
for (i = 0; i < path->len; i++) {
ids[i] = g_array_index (path, gint, i);
ids[i] = g_array_index (path, guint, i);
GST_LOG ("id=%u", ids[i]);
}
g_array_free (g_steal_pointer (&path), TRUE);
@ -706,7 +706,7 @@ GST_START_TEST (test_multi_od_cls_relation)
GstAnalyticsODMtd od_mtd[2];
GstAnalyticsRelationMetaInitParams init_params = { 5, 150 };
GstAnalyticsRelationMeta *rmeta;
gint cls_id, ids[2], i;
guint cls_id, ids[2], i;
gboolean ret;
const gint dog_cls_index = 0;
const gint cat_cls_index = 1;
@ -798,7 +798,7 @@ GST_START_TEST (test_multi_od_cls_relation)
*/
fail_unless (path->len == 2);
for (i = 0; i < path->len; i++) {
ids[i] = g_array_index (path, gint, i);
ids[i] = g_array_index (path, guint, i);
GST_LOG ("id=%u", ids[i]);
}
g_array_free (g_steal_pointer (&path), TRUE);