1919
2020#include "vx_internal.h"
2121
22- static VX_INLINE void * ownFormatMemoryPtr (vx_memory_t * memory ,
23- vx_uint32 c ,
24- vx_uint32 x ,
25- vx_uint32 y ,
26- vx_uint32 p )
27- {
28- intmax_t offset = (memory -> strides [p ][VX_DIM_Y ] * y ) +
29- (memory -> strides [p ][VX_DIM_X ] * x ) +
30- (memory -> strides [p ][VX_DIM_C ] * c );
31- void * ptr = (void * )& memory -> ptrs [p ][offset ];
32- //ownPrintMemory(memory);
33- //VX_PRINT(VX_ZONE_INFO, "&(%p[%zu]) = %p\n", memory->ptrs[p], offset, ptr);
34- return ptr ;
35- }
36-
37- static VX_INLINE int isodd (size_t a )
38- {
39- return (int )(a & 1 );
40- }
22+ /*!
23+ * \file
24+ * \brief A set of internal utility functions.
25+ *
26+ * \defgroup group_int_inlines Internal Utility Functions
27+ * \ingroup group_internal
28+ * \brief Static internal utility functions
29+ */
4130
31+ /**
32+ * @brief Is the number odd?
33+ * @ingroup group_int_inlines
34+ * @param a The number to check
35+ * @return vx_true_e if odd, else vx_false_e
36+ */
4237static VX_INLINE vx_bool vxIsOdd (vx_uint32 a )
4338{
4439 if (a & 0x1 )
@@ -47,6 +42,12 @@ static VX_INLINE vx_bool vxIsOdd(vx_uint32 a)
4742 return vx_false_e ;
4843}
4944
45+ /**
46+ * @brief Is the number a power of two?
47+ * @ingroup group_int_inlines
48+ * @param a The number to check
49+ * @return vx_true_e if even, else vx_false_e
50+ */
5051static VX_INLINE vx_bool vxIsPowerOfTwo (vx_uint32 a )
5152{
5253 if (a == 0 )
@@ -57,6 +58,14 @@ static VX_INLINE vx_bool vxIsPowerOfTwo(vx_uint32 a)
5758 return vx_false_e ;
5859}
5960
61+ /**
62+ * @brief Count the number of occurrences of a character in a string.
63+ * @ingroup group_int_inlines
64+ * @param string The string to search
65+ * @param size The size of the string
66+ * @param c The character to count
67+ * @return The number of occurrences of the character in the string.
68+ */
6069static VX_INLINE vx_size strncount (const vx_char string [], vx_size size , vx_char c )
6170{
6271 vx_size i = 0ul , count = 0ul ;
@@ -66,6 +75,14 @@ static VX_INLINE vx_size strncount(const vx_char string[], vx_size size, vx_char
6675 return count ;
6776}
6877
78+ /**
79+ * @brief Find the index of a character in a string.
80+ * @ingroup group_int_inlines
81+ * @param str The string to search
82+ * @param c The character to find
83+ * @param limit The maximum number of characters to search
84+ * @return The index of the character in the string.
85+ */
6986static VX_INLINE vx_size strnindex (const vx_char * str , vx_char c , vx_size limit )
7087{
7188 vx_size index = 0 ;
@@ -82,6 +99,13 @@ static VX_INLINE vx_size strnindex(const vx_char *str, vx_char c, vx_size limit)
8299 return index ;
83100}
84101
102+ /**
103+ * @brief Is valid format?
104+ * @ingroup group_int_inlines
105+ * @param data_type data type
106+ * @param fixed_point_pos fixed point position
107+ * @return vx_true_e if valid, else vx_false_e
108+ */
85109static VX_INLINE int validFormat (vx_enum data_type , vx_uint8 fixed_point_pos )
86110{
87111 return
@@ -96,4 +120,62 @@ static VX_INLINE int validFormat(vx_enum data_type, vx_uint8 fixed_point_pos)
96120 (data_type == VX_TYPE_UINT8 && fixed_point_pos == 0 );
97121}
98122
123+ /*! \brief Prints the name of an object type.
124+ * \ingroup group_int_inlines
125+ */
126+ static VX_INLINE const char * vxGetObjectTypeName (vx_enum type )
127+ {
128+ const char * name = "" ;
129+
130+ switch (type )
131+ {
132+ case VX_TYPE_CONTEXT :
133+ name = "CONTEXT" ; break ;
134+ case VX_TYPE_GRAPH :
135+ name = "GRAPH" ; break ;
136+ case VX_TYPE_NODE :
137+ name = "NODE" ; break ;
138+ case VX_TYPE_KERNEL :
139+ name = "KERNEL" ; break ;
140+ case VX_TYPE_TARGET :
141+ name = "TARGET" ; break ;
142+ case VX_TYPE_PARAMETER :
143+ name = "PARAMETER" ; break ;
144+ case VX_TYPE_DELAY :
145+ name = "DELAY" ; break ;
146+ case VX_TYPE_LUT :
147+ name = "LUT" ; break ;
148+ case VX_TYPE_DISTRIBUTION :
149+ name = "DISTRIBUTION" ; break ;
150+ case VX_TYPE_PYRAMID :
151+ name = "PYRAMID" ; break ;
152+ case VX_TYPE_THRESHOLD :
153+ name = "THRESHOLD" ; break ;
154+ case VX_TYPE_MATRIX :
155+ name = "MATRIX" ; break ;
156+ case VX_TYPE_CONVOLUTION :
157+ name = "CONVOLUTION" ; break ;
158+ case VX_TYPE_SCALAR :
159+ name = "SCALAR" ; break ;
160+ case VX_TYPE_ARRAY :
161+ name = "ARRAY" ; break ;
162+ case VX_TYPE_IMAGE :
163+ name = "IMAGE" ; break ;
164+ case VX_TYPE_REMAP :
165+ name = "REMAP" ; break ;
166+ case VX_TYPE_ERROR :
167+ name = "<ERROR OBJECT>" ; break ;
168+ case VX_TYPE_META_FORMAT :
169+ name = "META_FORMAT" ; break ;
170+ case VX_TYPE_OBJECT_ARRAY :
171+ name = "OBJECT_ARRAY" ; break ;
172+ case VX_TYPE_TENSOR :
173+ name = "TENSOR" ; break ;
174+ default :
175+ name = "<UNKNOWN TYPE>" ;
176+ }
177+
178+ return name ;
179+ }
180+
99181#endif /* VX_INLINES_H */
0 commit comments