libxcoder 5.8.0
Loading...
Searching...
No Matches
ni_util.h File Reference

Utility definitions. More...

#include "ni_device_api.h"
#include "ni_log.h"
#include "ni_defs.h"

Go to the source code of this file.

Macros

#define NI_INVALID_POWER   0xFFFFFFFF
 
#define TPS25940_IMON_OS   0.8f
 
#define TPS25940_GAIN_IMON   52.0f
 
#define TPS25940_R_IMON   5.6f
 
#define TPS25946_GAIN_IMON   182.0f
 
#define TPS25974_GAIN_IMON   105.5f
 
#define TPS25946_R_IMON_T2A   1000.0f
 
#define TPS25946_R_IMON_T1U_UA   1130.0f
 
#define TPS25946_R_IMON_T1S   562.0f
 
#define TPS25974_R_IMON_T1M   750.0f
 
#define MAX15162AAWE_C_IRATIO   4000.0f
 
#define MAX15162AAWE_R_IMON   1500.0f
 
#define MAX17613B_R_ISET_TOTAL   1510.0f /* Voltage Divider at ADC */
 
#define MAX17613B_R_ISET_R2   1000.0f
 
#define MAX17613B_C_IRATIO   3000.0f
 
#define MCU_FSR_ADC   4096.0f
 
#define MCU_REF_VOLTAGE   2500.0f
 
#define NIALIGN(x, a)   (((x) + (a)-1) & ~((a)-1))
 
#define COMPILE_ASSERT(condition)   ((void)sizeof(char[1 - 2 * !(condition)]))
 
#define XCODER_MAX_NUM_TS_TABLE   32
 
#define XCODER_FRAME_OFFSET_DIFF_THRES   100
 
#define XCODER_MAX_ENC_PACKETS_PER_READ   16
 
#define XCODER_MAX_NUM_QUEUE_ENTRIES   6000
 
#define XCODER_MAX_NUM_TEMPORAL_LAYER   7
 
#define BUFFER_POOL_SZ_PER_CONTEXT   300
 
#define XCODER_MIN_ENC_PIC_WIDTH   144
 
#define XCODER_MIN_ENC_PIC_HEIGHT   128
 
#define XCODER_MAX_ENC_PIC_WIDTH   8192
 
#define XCODER_MAX_ENC_PIC_HEIGHT   8192
 
#define NI_DEC_FRAME_BUF_POOL_SIZE_INIT   20
 
#define NI_DEC_FRAME_BUF_POOL_SIZE_EXPAND   20
 
#define ni_aligned_free(p_memptr)
 
#define ni_memfree(p_memptr)
 

Functions

ni_buf_tni_buf_pool_get_buffer (ni_buf_pool_t *p_buffer_pool)
 
void ni_buf_pool_return_buffer (ni_buf_t *buf, ni_buf_pool_t *p_buffer_pool)
 
ni_buf_tni_buf_pool_allocate_buffer (ni_buf_pool_t *p_buffer_pool, int buffer_size)
 
int32_t ni_dec_fme_buffer_pool_initialize (ni_session_context_t *p_ctx, int32_t number_of_buffers, int width, int height, int height_align, int factor)
 
void ni_dec_fme_buffer_pool_free (ni_buf_pool_t *p_buffer_pool)
 
void ni_buffer_pool_free (ni_queue_buffer_pool_t *p_buffer_pool)
 
ni_retcode_t ni_find_blk_name (const char *p_dev, char *p_out_buf, int out_buf_len)
 Find NVMe name space block from device name If none is found, assume nvme multi-pathing is disabled and return /dev/nvmeXn1.
 
ni_retcode_t ni_check_dev_name (const char *p_dev)
 check dev name
 
ni_retcode_t ni_timestamp_init (ni_session_context_t *p_ctx, ni_timestamp_table_t **pp_table, const char *name)
 Initialize timestamp handling.
 
ni_retcode_t ni_timestamp_done (ni_timestamp_table_t *p_table, ni_queue_buffer_pool_t *p_buffer_pool)
 Clean up timestamp handling.
 
ni_retcode_t ni_timestamp_register (ni_queue_buffer_pool_t *p_buffer_pool, ni_timestamp_table_t *p_table, int64_t timestamp, uint64_t data_info)
 Register timestamp in timestamp/frameoffset table.
 
ni_retcode_t ni_timestamp_get (ni_timestamp_table_t *p_table, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_queue_buffer_pool_t *p_buffer_pool)
 Retrieve timestamp from table based on frameoffset info.
 
ni_retcode_t ni_timestamp_get_v2 (ni_timestamp_table_t *p_table, uint64_t frame_offset, int64_t *p_timestamp, int32_t threshold, ni_queue_buffer_pool_t *p_buffer_pool)
 Retrieve timestamp from table based on frameoffset info.
 
ni_retcode_t ni_timestamp_get_with_threshold (ni_timestamp_table_t *p_table, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_queue_buffer_pool_t *p_buffer_pool)
 
void ni_timestamp_scan_cleanup (ni_timestamp_table_t *pts_list, ni_timestamp_table_t *dts_list, ni_queue_buffer_pool_t *p_buffer_pool)
 
ni_retcode_t ni_queue_init (ni_session_context_t *p_ctx, ni_queue_t *p_queue, const char *name)
 Initialize xcoder queue.
 
ni_retcode_t ni_queue_push (ni_queue_buffer_pool_t *p_buffer_pool, ni_queue_t *p_queue, uint64_t frame_offset, int64_t timestamp)
 Push into xcoder queue.
 
ni_retcode_t ni_queue_pop (ni_queue_t *p_queue, uint64_t frame_offset, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_queue_buffer_pool_t *p_buffer_pool)
 Pop from the xcoder queue.
 
ni_retcode_t ni_queue_pop_threshold (ni_queue_t *p_queue, uint64_t frame_offset, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_queue_buffer_pool_t *p_buffer_pool)
 
ni_retcode_t ni_queue_free (ni_queue_t *p_queue, ni_queue_buffer_pool_t *p_buffer_pool)
 Free xcoder queue.
 
ni_retcode_t ni_queue_print (ni_queue_t *p_queue)
 Print xcoder queue info.
 
int32_t ni_atobool (const char *p_str, bool *b_error)
 Convert string to boolean.
 
int32_t ni_atoi (const char *p_str, bool *b_error)
 
double ni_atof (const char *p_str, bool *b_error)
 Convert string to floating.
 
LIB_API ni_retcode_t ni_strtoi (const char *str, int32_t *out_val)
 Safely convert a decimal string to a 32-bit integer with full validation. Trailing whitespace is tolerated.
 
LIB_API ni_retcode_t ni_strtod_val (const char *str, double *out_val)
 Safely convert a decimal string to a double with full validation. Trailing whitespace is tolerated.
 
int32_t ni_parse_name (const char *arg, const char *const *names, bool *b_error)
 Parse name.
 
uint32_t ni_decode_power_measurement (uint32_t power_value, const uint8_t *serial_number)
 decode the raw current obtained and determine power
 
ni_retcode_t ni_quadra_card_identify_precheck (const char *p_dev)
 precheck a device can be read by ni_device_capability_query() INFO OR ERROR logs will not be printed in this function
 
LIB_API void ni_get_hw_yuv420p_dim (int width, int height, int bit_depth_factor, int is_semiplanar, int plane_stride[NI_MAX_NUM_DATA_POINTERS], int plane_height[NI_MAX_NUM_DATA_POINTERS])
 Get dimension information of Netint HW YUV420p frame to be sent to encoder for encoding. Caller usually retrieves this info and uses it in the call to ni_encoder_frame_buffer_alloc for buffer allocation.
 
LIB_API void ni_get_frame_dim (int width, int height, ni_pix_fmt_t pix_fmt, int plane_stride[NI_MAX_NUM_DATA_POINTERS], int plane_height[NI_MAX_NUM_DATA_POINTERS])
 Get dimension information of frame to be sent to encoder for encoding. Caller usually retrieves this info and uses it in the call to ni_encoder_frame_buffer_alloc for buffer allocation. The returned stride and height info will take alignment requirements into account.
 
LIB_API void ni_get_min_frame_dim (int width, int height, ni_pix_fmt_t pix_fmt, int plane_stride[NI_MAX_NUM_DATA_POINTERS], int plane_height[NI_MAX_NUM_DATA_POINTERS])
 Get dimension information of frame to be sent to encoder for encoding. Caller usually retrieves this info and uses it in the call to ni_encoder_frame_buffer_alloc for buffer allocation. The returned stride and height info will take into account both min resolution and alignment requirements.
 
LIB_API void ni_copy_hw_yuv420p (uint8_t *p_dst[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_MAX_NUM_DATA_POINTERS], int width, int height, int bit_depth_factor, int is_semiplanar, int conf_win_right, int dst_stride[NI_MAX_NUM_DATA_POINTERS], int dst_height[NI_MAX_NUM_DATA_POINTERS], int src_stride[NI_MAX_NUM_DATA_POINTERS], int src_height[NI_MAX_NUM_DATA_POINTERS])
 Copy YUV data to Netint HW YUV420p frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc.
 
LIB_API void ni_copy_frame_data (uint8_t *p_dst[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_MAX_NUM_DATA_POINTERS], int frame_width, int frame_height, int factor, ni_pix_fmt_t pix_fmt, int conf_win_right, int dst_stride[NI_MAX_NUM_DATA_POINTERS], int dst_height[NI_MAX_NUM_DATA_POINTERS], int src_stride[NI_MAX_NUM_DATA_POINTERS], int src_height[NI_MAX_NUM_DATA_POINTERS])
 Copy RGBA or YUV data to Netint HW frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc.
 
LIB_API void ni_copy_yuv_444p_to_420p (uint8_t *p_dst0[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_dst1[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_MAX_NUM_DATA_POINTERS], int width, int height, int factor, int mode)
 Copy yuv444p data to yuv420p frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc.
 
LIB_API int ni_insert_emulation_prevent_bytes (uint8_t *buf, int size)
 Insert emulation prevention byte(s) as needed into the data buffer.
 
LIB_API int ni_remove_emulation_prevent_bytes (uint8_t *buf, int size)
 Remove emulation prevention byte(s) as needed from the data buffer.
 
LIB_API int32_t ni_gettimeofday (struct timeval *p_tp, void *p_tzp)
 Get time for logs with microsecond timestamps.
 
LIB_API int ni_posix_memalign (void **memptr, size_t alignment, size_t size)
 Allocate aligned memory.
 
uint32_t ni_round_up (uint32_t number_to_round, uint32_t multiple)
 
LIB_API uint64_t ni_gettime_ns (void)
 
LIB_API void ni_usleep (int64_t usec)
 
LIB_API char * ni_strtok (char *s, const char *delim, char **saveptr)
 
LIB_API ni_retcode_t ni_strncpy (char *dest, size_t dmax, const char *src, size_t slen)
 
LIB_API ni_retcode_t ni_strcpy (char *dest, size_t dmax, const char *src)
 
LIB_API ni_retcode_t ni_strerror (char *dest, size_t dmax, int errnum)
 
LIB_API ni_retcode_t ni_strcat (char *dest, size_t dmax, const char *src)
 
LIB_API ni_retcode_t ni_strncat (char *dest, size_t dmax, const char *src, size_t slen)
 
LIB_API ni_retcode_t ni_fopen (FILE **fp, const char *filename, const char *mode)
 
LIB_API struct tm * ni_localtime (struct tm *dest, const time_t *src)
 
LIB_API int ni_fscanf (FILE *stream, const char *fmt,...)
 
LIB_API int ni_vsprintf (char *dest, const size_t dmax, const char *fmt, va_list args)
 
LIB_API int ni_sprintf (char *dest, size_t dmax, const char *fmt,...)
 
LIB_API ni_retcode_t ni_network_layer_convert_output (float *dst, uint32_t num, ni_packet_t *p_packet, ni_network_data_t *p_network, uint32_t layer)
 
LIB_API uint32_t ni_ai_network_layer_size (ni_network_layer_params_t *p_param)
 
LIB_API uint32_t ni_ai_network_layer_dims (ni_network_layer_params_t *p_param)
 
LIB_API ni_retcode_t ni_network_layer_convert_tensor (uint8_t *dst, uint32_t dst_len, const char *tensor_file, ni_network_layer_params_t *p_param)
 
LIB_API ni_retcode_t ni_network_convert_tensor_to_data (uint8_t *dst, uint32_t dst_len, float *src, uint32_t src_len, ni_network_layer_params_t *p_param)
 
LIB_API ni_retcode_t ni_network_convert_data_to_tensor (float *dst, uint32_t dst_len, uint8_t *src, uint32_t src_len, ni_network_layer_params_t *p_param)
 
LIB_API void ni_calculate_sha256 (const uint8_t aui8Data[], size_t ui32DataLength, uint8_t aui8Hash[])
 
LIB_API void ni_copy_hw_descriptors (uint8_t *p_dst[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_MAX_NUM_DATA_POINTERS])
 Copy Descriptor data to Netint HW descriptor frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc. Only necessary when metadata size in source is insufficient.
 
LIB_API char * ni_get_libxcoder_api_ver (void)
 Get libxcoder API version.
 
LIB_API NI_DEPRECATED char * ni_get_compat_fw_api_ver (void)
 Get FW API version libxcoder is compatible with.
 
LIB_API void ni_fmt_fw_api_ver_str (const char ver_str[], char fmt_str[])
 Get formatted FW API version string from unformatted FW API version string.
 
LIB_API int ni_cmp_fw_api_ver (const char ver1[], const char ver2[])
 Compare two 3 character strings containing a FW API version. Handle comparision when FW API version format length changed from 2 to 3.
 
LIB_API char * ni_get_libxcoder_release_ver (void)
 Get libxcoder SW release version.
 
LIB_API int ni_pthread_mutex_init (ni_pthread_mutex_t *mutex)
 initialize a mutex
 
LIB_API int ni_pthread_mutex_destroy (ni_pthread_mutex_t *mutex)
 destory a mutex
 
LIB_API int ni_pthread_mutex_lock (ni_pthread_mutex_t *mutex)
 thread mutex lock
 
LIB_API int ni_pthread_mutex_unlock (ni_pthread_mutex_t *mutex)
 thread mutex unlock
 
LIB_API int ni_pthread_create (ni_pthread_t *thread, const ni_pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
 create a new thread
 
LIB_API int ni_pthread_join (ni_pthread_t thread, void **value_ptr)
 join with a terminated thread
 
LIB_API int ni_pthread_cond_init (ni_pthread_cond_t *cond, const ni_pthread_condattr_t *attr)
 initialize condition variables
 
LIB_API int ni_pthread_cond_destroy (ni_pthread_cond_t *cond)
 destroy condition variables
 
LIB_API int ni_pthread_cond_broadcast (ni_pthread_cond_t *cond)
 broadcast a condition
 
LIB_API int ni_pthread_cond_wait (ni_pthread_cond_t *cond, ni_pthread_mutex_t *mutex)
 wait on a condition
 
LIB_API int ni_pthread_cond_signal (ni_pthread_cond_t *cond)
 signal a condition
 
LIB_API int ni_pthread_cond_timedwait (ni_pthread_cond_t *cond, ni_pthread_mutex_t *mutex, const struct timespec *abstime)
 wait on a condition
 
LIB_API int ni_pthread_sigmask (int how, const ni_sigset_t *set, ni_sigset_t *oldset)
 examine and change mask of blocked signals
 
LIB_API const char * ni_get_rc_txt (ni_retcode_t rc)
 Get text string for the provided error.
 
LIB_API int ni_param_get_key_value (char *p_str, char *key, char *value)
 Retrieve key and value from 'key=value' pair.
 
LIB_API int ni_retrieve_xcoder_params (char xcoderParams[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
 Retrieve encoder config parameter values from –xcoder-params.
 
LIB_API int ni_retrieve_xcoder_gop (char xcoderGop[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
 Retrieve custom gop config values from –xcoder-gop.
 
LIB_API int ni_retrieve_decoder_params (char xcoderParams[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
 Retrieve decoder config parameter values from –decoder-params.
 
LIB_API const char * ni_ai_errno_to_str (int rc)
 return error string according to error code from firmware
 

Detailed Description

Utility definitions.


Definition in file ni_util.h.

Macro Definition Documentation

◆ BUFFER_POOL_SZ_PER_CONTEXT

#define BUFFER_POOL_SZ_PER_CONTEXT   300

Definition at line 109 of file ni_util.h.

◆ COMPILE_ASSERT

#define COMPILE_ASSERT (   condition)    ((void)sizeof(char[1 - 2 * !(condition)]))

Definition at line 102 of file ni_util.h.

◆ MAX15162AAWE_C_IRATIO

#define MAX15162AAWE_C_IRATIO   4000.0f

Definition at line 59 of file ni_util.h.

◆ MAX15162AAWE_R_IMON

#define MAX15162AAWE_R_IMON   1500.0f

Definition at line 60 of file ni_util.h.

◆ MAX17613B_C_IRATIO

#define MAX17613B_C_IRATIO   3000.0f

Definition at line 65 of file ni_util.h.

◆ MAX17613B_R_ISET_R2

#define MAX17613B_R_ISET_R2   1000.0f

Definition at line 64 of file ni_util.h.

◆ MAX17613B_R_ISET_TOTAL

#define MAX17613B_R_ISET_TOTAL   1510.0f /* Voltage Divider at ADC */

Definition at line 63 of file ni_util.h.

◆ MCU_FSR_ADC

#define MCU_FSR_ADC   4096.0f

Definition at line 67 of file ni_util.h.

◆ MCU_REF_VOLTAGE

#define MCU_REF_VOLTAGE   2500.0f

Definition at line 68 of file ni_util.h.

◆ ni_aligned_free

#define ni_aligned_free (   p_memptr)
Value:
do { \
if ((p_memptr) != NULL) { \
free(p_memptr); \
p_memptr = NULL; \
} \
}while(0)

Definition at line 402 of file ni_util.h.

◆ NI_DEC_FRAME_BUF_POOL_SIZE_EXPAND

#define NI_DEC_FRAME_BUF_POOL_SIZE_EXPAND   20

Definition at line 118 of file ni_util.h.

◆ NI_DEC_FRAME_BUF_POOL_SIZE_INIT

#define NI_DEC_FRAME_BUF_POOL_SIZE_INIT   20

Definition at line 117 of file ni_util.h.

◆ NI_INVALID_POWER

#define NI_INVALID_POWER   0xFFFFFFFF

Definition at line 44 of file ni_util.h.

◆ ni_memfree

#define ni_memfree (   p_memptr)
Value:
do { \
if ((p_memptr) != NULL) { \
free(p_memptr); \
p_memptr = NULL; \
} \
}while(0)

Definition at line 412 of file ni_util.h.

◆ NIALIGN

#define NIALIGN (   x,
 
)    (((x) + (a)-1) & ~((a)-1))

Definition at line 100 of file ni_util.h.

◆ TPS25940_GAIN_IMON

#define TPS25940_GAIN_IMON   52.0f

Definition at line 47 of file ni_util.h.

◆ TPS25940_IMON_OS

#define TPS25940_IMON_OS   0.8f

Definition at line 46 of file ni_util.h.

◆ TPS25940_R_IMON

#define TPS25940_R_IMON   5.6f

Definition at line 48 of file ni_util.h.

◆ TPS25946_GAIN_IMON

#define TPS25946_GAIN_IMON   182.0f

Definition at line 51 of file ni_util.h.

◆ TPS25946_R_IMON_T1S

#define TPS25946_R_IMON_T1S   562.0f

Definition at line 55 of file ni_util.h.

◆ TPS25946_R_IMON_T1U_UA

#define TPS25946_R_IMON_T1U_UA   1130.0f

Definition at line 54 of file ni_util.h.

◆ TPS25946_R_IMON_T2A

#define TPS25946_R_IMON_T2A   1000.0f

Definition at line 53 of file ni_util.h.

◆ TPS25974_GAIN_IMON

#define TPS25974_GAIN_IMON   105.5f

Definition at line 52 of file ni_util.h.

◆ TPS25974_R_IMON_T1M

#define TPS25974_R_IMON_T1M   750.0f

Definition at line 56 of file ni_util.h.

◆ XCODER_FRAME_OFFSET_DIFF_THRES

#define XCODER_FRAME_OFFSET_DIFF_THRES   100

Definition at line 105 of file ni_util.h.

◆ XCODER_MAX_ENC_PACKETS_PER_READ

#define XCODER_MAX_ENC_PACKETS_PER_READ   16

Definition at line 106 of file ni_util.h.

◆ XCODER_MAX_ENC_PIC_HEIGHT

#define XCODER_MAX_ENC_PIC_HEIGHT   8192

Definition at line 115 of file ni_util.h.

◆ XCODER_MAX_ENC_PIC_WIDTH

#define XCODER_MAX_ENC_PIC_WIDTH   8192

Definition at line 114 of file ni_util.h.

◆ XCODER_MAX_NUM_QUEUE_ENTRIES

#define XCODER_MAX_NUM_QUEUE_ENTRIES   6000

Definition at line 107 of file ni_util.h.

◆ XCODER_MAX_NUM_TEMPORAL_LAYER

#define XCODER_MAX_NUM_TEMPORAL_LAYER   7

Definition at line 108 of file ni_util.h.

◆ XCODER_MAX_NUM_TS_TABLE

#define XCODER_MAX_NUM_TS_TABLE   32

Definition at line 104 of file ni_util.h.

◆ XCODER_MIN_ENC_PIC_HEIGHT

#define XCODER_MIN_ENC_PIC_HEIGHT   128

Definition at line 113 of file ni_util.h.

◆ XCODER_MIN_ENC_PIC_WIDTH

#define XCODER_MIN_ENC_PIC_WIDTH   144

Definition at line 112 of file ni_util.h.

Function Documentation

◆ ni_ai_errno_to_str()

LIB_API const char * ni_ai_errno_to_str ( int  rc)

return error string according to error code from firmware


Parameters
[in]rcerror code return from firmware
Returns
error string

Parameters
[in]rcerror code return from firmware
Returns
error string

Definition at line 5032 of file ni_util.c.

◆ ni_ai_network_layer_dims()

LIB_API uint32_t ni_ai_network_layer_dims ( ni_network_layer_params_t p_param)

Definition at line 4076 of file ni_util.c.

◆ ni_ai_network_layer_size()

LIB_API uint32_t ni_ai_network_layer_size ( ni_network_layer_params_t p_param)

Definition at line 4070 of file ni_util.c.

◆ ni_atobool()

int32_t ni_atobool ( const char *  p_str,
bool *  b_error 
)

Convert string to boolean.


Parameters

return

Definition at line 2550 of file ni_util.c.

◆ ni_atof()

double ni_atof ( const char *  p_str,
bool *  b_error 
)

Convert string to floating.


Parameters

return

Definition at line 2653 of file ni_util.c.

◆ ni_atoi()

int32_t ni_atoi ( const char *  p_str,
bool *  b_error 
)

Definition at line 2633 of file ni_util.c.

◆ ni_buf_pool_allocate_buffer()

ni_buf_t * ni_buf_pool_allocate_buffer ( ni_buf_pool_t p_buffer_pool,
int  buffer_size 
)

Definition at line 1222 of file ni_util.c.

◆ ni_buf_pool_get_buffer()

ni_buf_t * ni_buf_pool_get_buffer ( ni_buf_pool_t p_buffer_pool)

Definition at line 1105 of file ni_util.c.

◆ ni_buf_pool_return_buffer()

void ni_buf_pool_return_buffer ( ni_buf_t buf,
ni_buf_pool_t p_buffer_pool 
)

Definition at line 1166 of file ni_util.c.

◆ ni_buffer_pool_free()

void ni_buffer_pool_free ( ni_queue_buffer_pool_t p_buffer_pool)

Definition at line 1427 of file ni_util.c.

◆ ni_calculate_sha256()

LIB_API void ni_calculate_sha256 ( const uint8_t  aui8Data[],
size_t  ui32DataLength,
uint8_t  aui8Hash[] 
)

Definition at line 4257 of file ni_util.c.

◆ ni_check_dev_name()

ni_retcode_t ni_check_dev_name ( const char *  p_dev)

check dev name


Parameters
[in]p_devDevice name represented as c string. ex: "/dev/nvmeXnY"
Returns
On success returns NI_RETCODE_SUCCESS On failure returns NI_RETCODE_FAILURE or NI_RETCODE_INVALID_PARAM

Definition at line 1892 of file ni_util.c.

◆ ni_cmp_fw_api_ver()

LIB_API int ni_cmp_fw_api_ver ( const char  ver1[],
const char  ver2[] 
)

Compare two 3 character strings containing a FW API version. Handle comparision when FW API version format length changed from 2 to 3.


Parameters
[in]ver1pointer to string containing FW API. Only up to 3 characters will be read
[in]ver2pointer to string containing FW API. Only up to 3 characters will be read
Returns
0 if ver1 == ver2, 1 if ver1 > ver2, -1 if ver1 < ver2

Parameters
[in]ver1pointer to string containing FW API. Only up to 3 characters will be read
[in]ver2pointer to string containing FW API. Only up to 3 characters will be read
Returns
0 if ver1 == ver2, 1 if ver1 > ver2, -1 if ver1 < ver2

Definition at line 4383 of file ni_util.c.

◆ ni_copy_frame_data()

LIB_API void ni_copy_frame_data ( uint8_t *  p_dst[NI_MAX_NUM_DATA_POINTERS],
uint8_t *  p_src[NI_MAX_NUM_DATA_POINTERS],
int  frame_width,
int  frame_height,
int  factor,
ni_pix_fmt_t  pix_fmt,
int  conf_win_right,
int  dst_stride[NI_MAX_NUM_DATA_POINTERS],
int  dst_height[NI_MAX_NUM_DATA_POINTERS],
int  src_stride[NI_MAX_NUM_DATA_POINTERS],
int  src_height[NI_MAX_NUM_DATA_POINTERS] 
)

Copy RGBA or YUV data to Netint HW frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc.


Parameters
[out]p_dstpointers to which data is copied
[in]p_srcpointers from which data is copied
[in]widthsource frame width
[in]heightsource frame height
[in]factor1 for 8 bit, 2 for 10 bit
[in]pix_fmtpixel format to distinguish between planar types and/or components
[in]conf_win_rightright offset of conformance window
[in]dst_stridesize (in bytes) of each plane width in destination
[in]dst_heightsize of each plane height in destination
[in]src_stridesize (in bytes) of each plane width in source
[in]src_heightsize of each plane height in source
Returns
copied data

Parameters
[out]p_dstpointers to which data is copied
[in]p_srcpointers from which data is copied
[in]widthsource frame width
[in]heightsource frame height
[in]factor1 for 8 bit, 2 for 10 bit
[in]pix_fmtpixel format to distinguish between planar types and/or components
[in]conf_win_rightright offset of conformance window
[in]dst_stridesize (in bytes) of each plane width in destination
[in]dst_heightsize of each plane height in destination
[in]src_stridesize (in bytes) of each plane width in source
[in]src_heightsize of each plane height in source
Returns
copied data

Definition at line 3102 of file ni_util.c.

◆ ni_copy_hw_descriptors()

LIB_API void ni_copy_hw_descriptors ( uint8_t *  p_dst[NI_MAX_NUM_DATA_POINTERS],
uint8_t *  p_src[NI_MAX_NUM_DATA_POINTERS] 
)

Copy Descriptor data to Netint HW descriptor frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc. Only necessary when metadata size in source is insufficient.


Parameters
[out]p_dstpointers of Y/Cb/Cr to which data is copied
[in]p_srcpointers of Y/Cb/Cr from which data is copied
Returns
descriptor data

Parameters
[out]p_dstpointers of Y/Cb/Cr to which data is copied
[in]p_srcpointers of Y/Cb/Cr from which data is copied
Returns
descriptor data

Definition at line 4283 of file ni_util.c.

◆ ni_copy_hw_yuv420p()

LIB_API void ni_copy_hw_yuv420p ( uint8_t *  p_dst[NI_MAX_NUM_DATA_POINTERS],
uint8_t *  p_src[NI_MAX_NUM_DATA_POINTERS],
int  frame_width,
int  frame_height,
int  factor,
int  is_semiplanar,
int  conf_win_right,
int  dst_stride[NI_MAX_NUM_DATA_POINTERS],
int  dst_height[NI_MAX_NUM_DATA_POINTERS],
int  src_stride[NI_MAX_NUM_DATA_POINTERS],
int  src_height[NI_MAX_NUM_DATA_POINTERS] 
)

Copy YUV data to Netint HW YUV420p frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc.


Parameters
[out]p_dstpointers of Y/Cb/Cr to which data is copied
[in]p_srcpointers of Y/Cb/Cr from which data is copied
[in]widthsource YUV frame width
[in]heightsource YUV frame height
[in]bit_depth_factor1 for 8 bit, 2 for 10 bit
[in]is_semiplanarnon-0 for semiplanar frame, 0 otherwise
[in]conf_win_rightright offset of conformance window
[in]dst_stridesize (in bytes) of each plane width in destination
[in]dst_heightsize of each plane height in destination
[in]src_stridesize (in bytes) of each plane width in source
[in]src_heightsize of each plane height in source
Returns
Y/Cb/Cr data

Parameters
[out]p_dstpointers of Y/Cb/Cr to which data is copied
[in]p_srcpointers of Y/Cb/Cr from which data is copied
[in]widthsource YUV frame width
[in]heightsource YUV frame height
[in]factor1 for 8 bit, 2 for 10 bit
[in]is_semiplanarnon-0 for semiplanar frame, 0 otherwise
[in]conf_win_rightright offset of conformance window
[in]dst_stridesize (in bytes) of each plane width in destination
[in]dst_heightsize of each plane height in destination
[in]src_stridesize (in bytes) of each plane width in source
[in]src_heightsize of each plane height in source
Returns
Y/Cb/Cr data

Definition at line 3056 of file ni_util.c.

◆ ni_copy_yuv_444p_to_420p()

LIB_API void ni_copy_yuv_444p_to_420p ( uint8_t *  p_dst0[NI_MAX_NUM_DATA_POINTERS],
uint8_t *  p_dst1[NI_MAX_NUM_DATA_POINTERS],
uint8_t *  p_src[NI_MAX_NUM_DATA_POINTERS],
int  frame_width,
int  frame_height,
int  factor,
int  mode 
)

Copy yuv444p data to yuv420p frame layout to be sent to encoder for encoding. Data buffer (dst) is usually allocated by ni_encoder_frame_buffer_alloc.


Parameters
[out]p_dst0pointers of Y/Cb/Cr as yuv420p output0
[out]p_dst1pointers of Y/Cb/Cr as yuv420p output1
[in]p_srcpointers of Y/Cb/Cr as yuv444p intput
[in]widthsource YUV frame width
[in]heightsource YUV frame height
[in]factor1 for 8 bit, 2 for 10 bit
[in]mode0 for out0 is Y+1/2V, with the original input as the out0, 1/4V copy to data[1] 1/4V copy to data[2] out1 is U+1/2V, U copy to data[0], 1/4V copy to data[1], 1/4V copy to data[2] mode 1 for out0 is Y+1/2u+1/2v, with the original input as the output0, 1/4U copy to data[1] 1/4V copy to data[2] out1 is (1/2U+1/2V)+1/4U+1/4V, 1/2U & 1/2V copy to data[0], 1/4U copy to data[1], 1/4V copy to data[2]
Returns
Y/Cb/Cr data

Parameters
[out]p_dst0pointers of Y/Cb/Cr as yuv420p output0
[out]p_dst1pointers of Y/Cb/Cr as yuv420p output1
[in]p_srcpointers of Y/Cb/Cr as yuv444p intput
[in]widthsource YUV frame width
[in]heightsource YUV frame height
[in]factor1 for 8 bit, 2 for 10 bit
[in]mode0 for out0 is Y+1/2V, with the original input as the out0, 1/4V copy to data[1] 1/4V copy to data[2] out1 is U+1/2V, U copy to data[0], 1/4V copy to data[1], 1/4V copy to data[2] mode 1 for out0 is Y+1/2u+1/2v, with the original input as the output0, 1/4U copy to data[1] 1/4V copy to data[2] out1 is (1/2U+1/2V)+1/4U+1/4V, 1/2U & 1/2V copy to data[0], 1/4U copy to data[1], 1/4V copy to data[2]
Returns
Y/Cb/Cr data

Definition at line 3182 of file ni_util.c.

◆ ni_dec_fme_buffer_pool_free()

void ni_dec_fme_buffer_pool_free ( ni_buf_pool_t p_buffer_pool)

Definition at line 1373 of file ni_util.c.

◆ ni_dec_fme_buffer_pool_initialize()

int32_t ni_dec_fme_buffer_pool_initialize ( ni_session_context_t p_ctx,
int32_t  number_of_buffers,
int  width,
int  height,
int  height_align,
int  factor 
)

Definition at line 1264 of file ni_util.c.

◆ ni_decode_power_measurement()

uint32_t ni_decode_power_measurement ( uint32_t  current_data,
const uint8_t *  serial_number 
)

decode the raw current obtained and determine power


Parameters
[in]current_valuecurrent value
[in]serial_numberboard SN
Returns
On success returns power On failure returns -1

Definition at line 5095 of file ni_util.c.

◆ ni_find_blk_name()

ni_retcode_t ni_find_blk_name ( const char *  p_dev,
char *  p_out_buf,
int  out_buf_len 
)

Find NVMe name space block from device name If none is found, assume nvme multi-pathing is disabled and return /dev/nvmeXn1.


Parameters
[in]p_devDevice name represented as c string. ex: "/dev/nvme0"
[in]out_bufOutput buffer to put NVMe name space block. Must be at least length 21
Returns
On success returns NI_RETCODE_SUCCESS On failure returns NI_RETCODE_FAILURE

Definition at line 1821 of file ni_util.c.

◆ ni_fmt_fw_api_ver_str()

LIB_API void ni_fmt_fw_api_ver_str ( const char  ver_str[],
char  fmt_str[] 
)

Get formatted FW API version string from unformatted FW API version string.


Parameters
[in]ver_strpointer to string containing FW API. Only up to 3 characters will be read
[out]fmt_strpointer to string buffer of at least size 5 to output formated version string to
Returns
none

Parameters
[in]ver_strpointer to string containing FW API. Only up to 3 characters will be read
[out]fmt_strpointer to string buffer of at least size 5 to output formated version string to
Returns
none

Definition at line 4353 of file ni_util.c.

◆ ni_fopen()

LIB_API ni_retcode_t ni_fopen ( FILE **  fp,
const char *  filename,
const char *  mode 
)

Definition at line 998 of file ni_util.c.

◆ ni_fscanf()

LIB_API int ni_fscanf ( FILE *  stream,
const char *  fmt,
  ... 
)

Definition at line 1035 of file ni_util.c.

◆ ni_get_compat_fw_api_ver()

LIB_API NI_DEPRECATED char * ni_get_compat_fw_api_ver ( void  )

Get FW API version libxcoder is compatible with.


Returns
char pointer to FW API version libxcoder is compatible with

Get FW API version libxcoder is compatible with.


Returns
char pointer to FW API version libxcoder is compatible with

Definition at line 4320 of file ni_util.c.

◆ ni_get_frame_dim()

LIB_API void ni_get_frame_dim ( int  width,
int  height,
ni_pix_fmt_t  pix_fmt,
int  plane_stride[NI_MAX_NUM_DATA_POINTERS],
int  plane_height[NI_MAX_NUM_DATA_POINTERS] 
)

Get dimension information of frame to be sent to encoder for encoding. Caller usually retrieves this info and uses it in the call to ni_encoder_frame_buffer_alloc for buffer allocation. The returned stride and height info will take alignment requirements into account.


Parameters
[in]widthsource frame width
[in]heightsource frame height
[in]pix_fmtni pixel format
[out]plane_stridesize (in bytes) of each plane width
[out]plane_heightsize of each plane height
Returns
stride and height info

Parameters
[in]widthsource frame width
[in]heightsource frame height
[in]pix_fmtni pixel format
[out]plane_stridesize (in bytes) of each plane width
[out]plane_heightsize of each plane height
Returns
stride and height info

Definition at line 2795 of file ni_util.c.

◆ ni_get_hw_yuv420p_dim()

LIB_API void ni_get_hw_yuv420p_dim ( int  width,
int  height,
int  factor,
int  is_semiplanar,
int  plane_stride[NI_MAX_NUM_DATA_POINTERS],
int  plane_height[NI_MAX_NUM_DATA_POINTERS] 
)

Get dimension information of Netint HW YUV420p frame to be sent to encoder for encoding. Caller usually retrieves this info and uses it in the call to ni_encoder_frame_buffer_alloc for buffer allocation.


Parameters
[in]widthsource YUV frame width
[in]heightsource YUV frame height
[in]bit_depth_factor1 for 8 bit, 2 for 10 bit
[in]is_semiplanarnon-0 for semiplnar frame, 0 otherwise
[out]plane_stridesize (in bytes) of each plane width
[out]plane_heightsize of each plane height
Returns
Y/Cb/Cr stride and height info

Parameters
[in]widthsource YUV frame width
[in]heightsource YUV frame height
[in]factor1 for 8 bit, 2 for 10 bit
[in]is_semiplanar1 for semiplanar frame, 0 otherwise
[out]plane_stridesize (in bytes) of each plane width
[out]plane_heightsize of each plane height
Returns
Y/Cb/Cr stride and height info

Definition at line 2743 of file ni_util.c.

◆ ni_get_libxcoder_api_ver()

LIB_API char * ni_get_libxcoder_api_ver ( void  )

Get libxcoder API version.


Returns
char pointer to libxcoder API version

Returns
char pointer to libxcoder API version

Definition at line 4307 of file ni_util.c.

◆ ni_get_libxcoder_release_ver()

LIB_API char * ni_get_libxcoder_release_ver ( void  )

Get libxcoder SW release version.


Returns
char pointer to libxcoder SW release version

Returns
char pointer to libxcoder SW release version

Definition at line 4419 of file ni_util.c.

◆ ni_get_min_frame_dim()

LIB_API void ni_get_min_frame_dim ( int  width,
int  height,
ni_pix_fmt_t  pix_fmt,
int  plane_stride[NI_MAX_NUM_DATA_POINTERS],
int  plane_height[NI_MAX_NUM_DATA_POINTERS] 
)

Get dimension information of frame to be sent to encoder for encoding. Caller usually retrieves this info and uses it in the call to ni_encoder_frame_buffer_alloc for buffer allocation. The returned stride and height info will take into account both min resolution and alignment requirements.


Parameters
[in]widthsource frame width
[in]heightsource frame height
[in]pix_fmtni pixel format
[out]plane_stridesize (in bytes) of each plane width
[out]plane_heightsize of each plane height
Returns
stride and height info

Parameters
[in]widthsource frame width
[in]heightsource frame height
[in]pix_fmtni pixel format
[out]plane_stridesize (in bytes) of each plane width
[out]plane_heightsize of each plane height
Returns
stride and height info

Definition at line 2884 of file ni_util.c.

◆ ni_get_rc_txt()

LIB_API const char * ni_get_rc_txt ( ni_retcode_t  rc)

Get text string for the provided error.


Returns
char pointer for the provided error

Returns
char pointer for the provided error

Definition at line 4440 of file ni_util.c.

◆ ni_gettime_ns()

LIB_API uint64_t ni_gettime_ns ( void  )

Definition at line 2701 of file ni_util.c.

◆ ni_gettimeofday()

LIB_API int32_t ni_gettimeofday ( struct timeval *  p_tp,
void *  p_tzp 
)

Get time for logs with microsecond timestamps.


Parameters
[in/out]p_tp timeval struct
[in]p_tzpvoid *
Returns
return 0 for success, -1 for error

Parameters
[in/out]p_tp timeval struct
[in]p_tzpvoid *
Returns
return 0 for success, -1 for error

Definition at line 147 of file ni_util.c.

◆ ni_insert_emulation_prevent_bytes()

LIB_API int ni_insert_emulation_prevent_bytes ( uint8_t *  buf,
int  size 
)

Insert emulation prevention byte(s) as needed into the data buffer.


Parameters
bufdata buffer to be worked on - new byte(s) will be inserted size number of bytes starting from buf to check
Returns
the number of emulation prevention bytes inserted into buf, 0 if none.

Note: caller MUST ensure for newly inserted bytes, buf has enough free space starting from buf + size


Parameters
bufdata buffer to be worked on - new byte(s) will be inserted size number of bytes starting from buf to check
Returns
the number of emulation prevention bytes inserted into buf, 0 if none.

Note: caller MUST ensure for newly inserted bytes, buf has enough free space starting from buf + size

Definition at line 3295 of file ni_util.c.

◆ ni_localtime()

LIB_API struct tm * ni_localtime ( struct tm *  dest,
const time_t *  src 
)

Definition at line 1018 of file ni_util.c.

◆ ni_network_convert_data_to_tensor()

LIB_API ni_retcode_t ni_network_convert_data_to_tensor ( float *  dst,
uint32_t  dst_len,
uint8_t *  src,
uint32_t  src_len,
ni_network_layer_params_t p_param 
)

Definition at line 3963 of file ni_util.c.

◆ ni_network_convert_tensor_to_data()

LIB_API ni_retcode_t ni_network_convert_tensor_to_data ( uint8_t *  dst,
uint32_t  dst_len,
float *  src,
uint32_t  src_len,
ni_network_layer_params_t p_param 
)

Definition at line 3953 of file ni_util.c.

◆ ni_network_layer_convert_output()

LIB_API ni_retcode_t ni_network_layer_convert_output ( float *  dst,
uint32_t  num,
ni_packet_t p_packet,
ni_network_data_t p_network,
uint32_t  layer 
)

Definition at line 3788 of file ni_util.c.

◆ ni_network_layer_convert_tensor()

LIB_API ni_retcode_t ni_network_layer_convert_tensor ( uint8_t *  dst,
uint32_t  dst_len,
const char *  tensor_file,
ni_network_layer_params_t p_param 
)

Definition at line 3943 of file ni_util.c.

◆ ni_param_get_key_value()

LIB_API int ni_param_get_key_value ( char *  p_str,
char *  key,
char *  value 
)

Retrieve key and value from 'key=value' pair.


Parameters
[in]p_strpointer to string to extract pair from
[out]keypointer to key
[out]valuepointer to value
Returns
return 0 if successful, otherwise 1

Retrieve key and value from 'key=value' pair.


Parameters
[in]p_strpointer to string to extract pair from
[out]keypointer to key
[out]valuepointer to value
Returns
return 0 if successful, otherwise 1

Definition at line 4464 of file ni_util.c.

◆ ni_parse_name()

int32_t ni_parse_name ( const char *  arg,
const char *const *  names,
bool *  b_error 
)

Parse name.


Parameters

return

Definition at line 2673 of file ni_util.c.

◆ ni_posix_memalign()

LIB_API int ni_posix_memalign ( void **  memptr,
size_t  alignment,
size_t  size 
)

Allocate aligned memory.


Parameters
[in/out]memptr The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *). If size is 0, then the value placed is either NULL, or a unique pointer value that can later be successfully passed to free.
[in]alignmentThe alignment value of the allocated value.
[in]sizeThe allocated memory size.
Returns
0 for success, ENOMEM for error

Parameters
[in/out]memptr The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *). If size is 0, then the value placed is either NULL, or a unique pointer value that can later be successfully passed to free.
[in]alignmentThe alignment value of the allocated value.
[in]sizeThe allocated memory size.
Returns
0 for success, ENOMEM for error

Definition at line 206 of file ni_util.c.

◆ ni_pthread_cond_broadcast()

LIB_API int ni_pthread_cond_broadcast ( ni_pthread_cond_t *  cond)

broadcast a condition


Parameters
[in]condcondition variable
Returns
On success returns 0 On failure returns <0

Parameters
[in]condcondition variable
Returns
On success returns 0 On failure returns <0

Definition at line 4925 of file ni_util.c.

◆ ni_pthread_cond_destroy()

LIB_API int ni_pthread_cond_destroy ( ni_pthread_cond_t *  cond)

destroy condition variables


Parameters
[in]condcondition variable
Returns
On success returns 0 On failure returns <0

Parameters
[in]condcondition variable
Returns
On success returns 0 On failure returns <0

Definition at line 4907 of file ni_util.c.

◆ ni_pthread_cond_init()

LIB_API int ni_pthread_cond_init ( ni_pthread_cond_t *  cond,
const ni_pthread_condattr_t *  attr 
)

initialize condition variables


Parameters
[in]condcondition variable
[in]attrattribute to the condvar
Returns
On success returns 0 On failure returns <0

Parameters
[in]condcondition variable
[in]attrattribute to the condvar
Returns
On success returns 0 On failure returns <0

Definition at line 4888 of file ni_util.c.

◆ ni_pthread_cond_signal()

LIB_API int ni_pthread_cond_signal ( ni_pthread_cond_t *  cond)

signal a condition


Parameters
[in]condcondition variable
Returns
On success returns 0 On failure returns <0

Parameters
[in]condcondition variable
Returns
On success returns 0 On failure returns <0

Definition at line 4962 of file ni_util.c.

◆ ni_pthread_cond_timedwait()

LIB_API int ni_pthread_cond_timedwait ( ni_pthread_cond_t *  cond,
ni_pthread_mutex_t *  mutex,
const struct timespec *  abstime 
)

wait on a condition


Parameters
[in]condcondition variable
[in]mutexmutex related to the condvar
[in[abstime abstract value of timeout
Returns
On success returns 0 On failure returns <0

Parameters
[in]condcondition variable
[in]mutexmutex related to the condvar
[in[abstime abstract value of timeout
Returns
On success returns 0 On failure returns <0

Definition at line 4982 of file ni_util.c.

◆ ni_pthread_cond_wait()

LIB_API int ni_pthread_cond_wait ( ni_pthread_cond_t *  cond,
ni_pthread_mutex_t *  mutex 
)

wait on a condition


Parameters
[in]condcondition variable
[in]mutexmutex related to the condvar
Returns
On success returns 0 On failure returns <0

Parameters
[in]condcondition variable
[in]mutexmutex related to the condvar
Returns
On success returns 0 On failure returns <0

Definition at line 4944 of file ni_util.c.

◆ ni_pthread_create()

LIB_API int ni_pthread_create ( ni_pthread_t *  thread,
const ni_pthread_attr_t *  attr,
void *(*)(void *)  start_routine,
void *  arg 
)

create a new thread


Parameters
[in]threadthread id
[in]attrattributes to the new thread
[in]start_routineentry of the thread routine
[in]argsole argument of the routine
Returns
On success returns 0 On failure returns <0

Parameters
[in]threadthread id
[in]attrattributes to the new thread
[in]start_routineentry of the thread routine
[in]argsole argument of the routine
Returns
On success returns 0 On failure returns <0

Definition at line 4832 of file ni_util.c.

◆ ni_pthread_join()

LIB_API int ni_pthread_join ( ni_pthread_t  thread,
void **  value_ptr 
)

join with a terminated thread


Parameters
[in]threadthread id
[out]value_ptrreturn status
Returns
On success returns 0 On failure returns <0

Parameters
[in]threadthread id
[out]value_ptrreturn status
Returns
On success returns 0 On failure returns <0

Definition at line 4859 of file ni_util.c.

◆ ni_pthread_mutex_destroy()

LIB_API int ni_pthread_mutex_destroy ( ni_pthread_mutex_t *  mutex)

destory a mutex


Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Definition at line 4750 of file ni_util.c.

◆ ni_pthread_mutex_init()

LIB_API int ni_pthread_mutex_init ( ni_pthread_mutex_t *  mutex)

initialize a mutex


Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Definition at line 4712 of file ni_util.c.

◆ ni_pthread_mutex_lock()

LIB_API int ni_pthread_mutex_lock ( ni_pthread_mutex_t *  mutex)

thread mutex lock


Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Definition at line 4768 of file ni_util.c.

◆ ni_pthread_mutex_unlock()

LIB_API int ni_pthread_mutex_unlock ( ni_pthread_mutex_t *  mutex)

thread mutex unlock


Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Parameters
[in]threadmutex
Returns
On success returns 0 On failure returns <0

Definition at line 4794 of file ni_util.c.

◆ ni_pthread_sigmask()

LIB_API int ni_pthread_sigmask ( int  how,
const ni_sigset_t *  set,
ni_sigset_t *  oldset 
)

examine and change mask of blocked signals


Parameters
[in]howbehavior of this call, can be value of SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK
[in]setcurrent value of the signal mask. If NULL, the mask keeps unchanged.
[in]old_setprevious value of the signal mask, can be NULL.
Returns
On success returns 0 On failure returns <0

Parameters
[in]howbehavior of this call, can be value of SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK
[in]setcurrent value of the signal mask. If NULL, the mask keeps unchanged.
[in]old_setprevious value of the signal mask, can be NULL.
Returns
On success returns 0 On failure returns <0

Definition at line 5016 of file ni_util.c.

◆ ni_quadra_card_identify_precheck()

ni_retcode_t ni_quadra_card_identify_precheck ( const char *  p_dev)

precheck a device can be read by ni_device_capability_query() INFO OR ERROR logs will not be printed in this function


Parameters
[in]p_devdevice path string. eg: "/dev/nvme1n2"
Returns
returns NI_RETCODE_FAILURE when the device can not be read by ni_device_capability_query()

returns NI_RETCODE_SUCCESS when the device can not be read by ni_device_capability_query() or the result can not be determined to prevent query failures due to some reasons such as missing commands on the system


Parameters
[in]p_devdevice path string. eg: "/dev/nvme1n2"
Returns
returns NI_RETCODE_FAILURE when the device can not be read by ni_device_capability_query()

returns NI_RETCODE_SUCCESS when

  1. the device can not be read by ni_device_capability_query()
  2. the result can not be determined to prevent query failures due to some reasons such as missing commands on the system

Definition at line 5435 of file ni_util.c.

◆ ni_queue_free()

ni_retcode_t ni_queue_free ( ni_queue_t p_queue,
ni_queue_buffer_pool_t p_buffer_pool 
)

Free xcoder queue.


Parameters

return

Definition at line 2453 of file ni_util.c.

◆ ni_queue_init()

ni_retcode_t ni_queue_init ( ni_session_context_t p_ctx,
ni_queue_t p_queue,
const char *  name 
)

Initialize xcoder queue.


Parameters

return

Definition at line 2154 of file ni_util.c.

◆ ni_queue_pop()

ni_retcode_t ni_queue_pop ( ni_queue_t p_queue,
uint64_t  frame_info,
int64_t *  p_timestamp,
int32_t  threshold,
int32_t  print,
ni_queue_buffer_pool_t p_buffer_pool 
)

Pop from the xcoder queue.


Parameters

return

If only one entry, retrieve timestamp without checking

Definition at line 2252 of file ni_util.c.

◆ ni_queue_pop_threshold()

ni_retcode_t ni_queue_pop_threshold ( ni_queue_t p_queue,
uint64_t  frame_offset,
int64_t *  p_timestamp,
int32_t  threshold,
int32_t  print,
ni_queue_buffer_pool_t p_buffer_pool 
)

If only one entry, retrieve timestamp without checking

Definition at line 2358 of file ni_util.c.

◆ ni_queue_print()

ni_retcode_t ni_queue_print ( ni_queue_t p_queue)

Print xcoder queue info.


Parameters

return

Definition at line 2493 of file ni_util.c.

◆ ni_queue_push()

ni_retcode_t ni_queue_push ( ni_queue_buffer_pool_t p_buffer_pool,
ni_queue_t p_queue,
uint64_t  frame_info,
int64_t  timestamp 
)

Push into xcoder queue.


Parameters

return

Definition at line 2181 of file ni_util.c.

◆ ni_remove_emulation_prevent_bytes()

LIB_API int ni_remove_emulation_prevent_bytes ( uint8_t *  buf,
int  size 
)

Remove emulation prevention byte(s) as needed from the data buffer.


Parameters
bufdata buffer to be worked on - emu prevent byte(s) will be removed from. size number of bytes starting from buf to check
Returns
the number of emulation prevention bytes removed from buf, 0 if none.

Note: buf will be modified if emu prevent byte(s) found and removed.


Parameters
bufdata buffer to be worked on - emu prevent byte(s) will be removed from. size number of bytes starting from buf to check
Returns
the number of emulation prevention bytes removed from buf, 0 if none.

Note: buf will be modified if emu prevent byte(s) found and removed.

Definition at line 3348 of file ni_util.c.

◆ ni_retrieve_decoder_params()

LIB_API int ni_retrieve_decoder_params ( char  xcoderParams[],
ni_xcoder_params_t params,
ni_session_context_t ctx 
)

Retrieve decoder config parameter values from –decoder-params.


Parameters
[in]xcoderParamspointer to string containing xcoder params
[out]paramspointer to xcoder params to fill out
[out]ctxpointer to session context
Returns
return 0 if successful, -1 otherwise

Retrieve decoder config parameter values from –decoder-params.


Parameters
[in]xcoderParamspointer to string containing xcoder params
[out]paramspointer to xcoder params to fill out
[out]ctxpointer to session context
Returns
return 0 if successful, -1 otherwise

Definition at line 4642 of file ni_util.c.

◆ ni_retrieve_xcoder_gop()

LIB_API int ni_retrieve_xcoder_gop ( char  xcoderGop[],
ni_xcoder_params_t params,
ni_session_context_t ctx 
)

Retrieve custom gop config values from –xcoder-gop.


Parameters
[in]xcoderGoppointer to string containing xcoder gop
[out]paramspointer to xcoder params to fill out
[out]ctxpointer to session context
Returns
return 0 if successful, -1 otherwise

Parameters
[in]xcoderGoppointer to string containing xcoder gop
[out]paramspointer to xcoder params to fill out
[out]ctxpointer to session context
Returns
return 0 if successful, -1 otherwise

Definition at line 4571 of file ni_util.c.

◆ ni_retrieve_xcoder_params()

LIB_API int ni_retrieve_xcoder_params ( char  xcoderParams[],
ni_xcoder_params_t params,
ni_session_context_t ctx 
)

Retrieve encoder config parameter values from –xcoder-params.


Parameters
[in]xcoderParamspointer to string containing xcoder params
[out]paramspointer to xcoder params to fill out
[out]ctxpointer to session context
Returns
return 0 if successful, -1 otherwise

Retrieve encoder config parameter values from –xcoder-params.


Parameters
[in]xcoderParamspointer to string containing xcoder params
[out]paramspointer to xcoder params to fill out
[out]ctxpointer to session context
Returns
return 0 if successful, -1 otherwise

Definition at line 4497 of file ni_util.c.

◆ ni_round_up()

uint32_t ni_round_up ( uint32_t  number_to_round,
uint32_t  multiple 
)

Definition at line 177 of file ni_util.c.

◆ ni_sprintf()

LIB_API int ni_sprintf ( char *  dest,
size_t  dmax,
const char *  fmt,
  ... 
)

Definition at line 1077 of file ni_util.c.

◆ ni_strcat()

LIB_API ni_retcode_t ni_strcat ( char *  dest,
size_t  dmax,
const char *  src 
)

Definition at line 704 of file ni_util.c.

◆ ni_strcpy()

LIB_API ni_retcode_t ni_strcpy ( char *  dest,
size_t  dmax,
const char *  src 
)

Definition at line 460 of file ni_util.c.

◆ ni_strerror()

LIB_API ni_retcode_t ni_strerror ( char *  dest,
size_t  dmax,
int  errnum 
)

Definition at line 663 of file ni_util.c.

◆ ni_strncat()

LIB_API ni_retcode_t ni_strncat ( char *  dest,
size_t  dmax,
const char *  src,
size_t  slen 
)

Definition at line 822 of file ni_util.c.

◆ ni_strncpy()

LIB_API ni_retcode_t ni_strncpy ( char *  dest,
size_t  dmax,
const char *  src,
size_t  slen 
)

Definition at line 525 of file ni_util.c.

◆ ni_strtod_val()

LIB_API ni_retcode_t ni_strtod_val ( const char *  str,
double *  out_val 
)

Safely convert a decimal string to a double with full validation. Trailing whitespace is tolerated.


Parameters
strNull-terminated string to convert
out_valPointer to store the converted value on success
Returns
NI_RETCODE_SUCCESS on success, NI_RETCODE_INVALID_PARAM if str is NULL/empty, contains non-numeric characters, or the value overflows double range

Definition at line 2612 of file ni_util.c.

◆ ni_strtoi()

LIB_API ni_retcode_t ni_strtoi ( const char *  str,
int32_t *  out_val 
)

Safely convert a decimal string to a 32-bit integer with full validation. Trailing whitespace is tolerated.


Parameters
strNull-terminated string to convert (base 10)
out_valPointer to store the converted value on success
Returns
NI_RETCODE_SUCCESS on success, NI_RETCODE_INVALID_PARAM if str is NULL/empty, contains non-numeric characters, or the value overflows int32_t

Definition at line 2577 of file ni_util.c.

◆ ni_strtok()

LIB_API char * ni_strtok ( char *  s,
const char *  delim,
char **  saveptr 
)

Definition at line 429 of file ni_util.c.

◆ ni_timestamp_done()

ni_retcode_t ni_timestamp_done ( ni_timestamp_table_t p_table,
ni_queue_buffer_pool_t p_buffer_pool 
)

Clean up timestamp handling.


Parameters

return

Definition at line 1988 of file ni_util.c.

◆ ni_timestamp_get()

ni_retcode_t ni_timestamp_get ( ni_timestamp_table_t p_table,
uint64_t  frame_info,
int64_t *  p_timestamp,
int32_t  threshold,
int32_t  print,
ni_queue_buffer_pool_t p_buffer_pool 
)

Retrieve timestamp from table based on frameoffset info.


Parameters

return

Definition at line 2040 of file ni_util.c.

◆ ni_timestamp_get_v2()

ni_retcode_t ni_timestamp_get_v2 ( ni_timestamp_table_t p_table,
uint64_t  frame_offset,
int64_t *  p_timestamp,
int32_t  threshold,
ni_queue_buffer_pool_t p_buffer_pool 
)

Retrieve timestamp from table based on frameoffset info.


Parameters

return

Definition at line 2116 of file ni_util.c.

◆ ni_timestamp_get_with_threshold()

ni_retcode_t ni_timestamp_get_with_threshold ( ni_timestamp_table_t p_table,
uint64_t  frame_info,
int64_t *  p_timestamp,
int32_t  threshold,
int32_t  print,
ni_queue_buffer_pool_t p_buffer_pool 
)

Definition at line 2064 of file ni_util.c.

◆ ni_timestamp_init()

ni_retcode_t ni_timestamp_init ( ni_session_context_t p_ctx,
ni_timestamp_table_t **  pp_table,
const char *  name 
)

Initialize timestamp handling.


Parameters

return

Definition at line 1948 of file ni_util.c.

◆ ni_timestamp_register()

ni_retcode_t ni_timestamp_register ( ni_queue_buffer_pool_t p_buffer_pool,
ni_timestamp_table_t p_table,
int64_t  timestamp,
uint64_t  data_info 
)

Register timestamp in timestamp/frameoffset table.


Parameters

return

Definition at line 2013 of file ni_util.c.

◆ ni_timestamp_scan_cleanup()

void ni_timestamp_scan_cleanup ( ni_timestamp_table_t pts_list,
ni_timestamp_table_t dts_list,
ni_queue_buffer_pool_t p_buffer_pool 
)

Definition at line 2072 of file ni_util.c.

◆ ni_usleep()

LIB_API void ni_usleep ( int64_t  usec)

Definition at line 366 of file ni_util.c.

◆ ni_vsprintf()

LIB_API int ni_vsprintf ( char *  dest,
const size_t  dmax,
const char *  fmt,
va_list  args 
)

Definition at line 1054 of file ni_util.c.