 |
libxcoder
5.2.0
|
Go to the documentation of this file.
31 #define _SC_PAGESIZE 4096
44 #define NI_INVALID_POWER 0xFFFFFFFF
46 #define TPS25940_IMON_OS 0.8f
47 #define TPS25940_GAIN_IMON 52.0f
48 #define TPS25940_R_IMON 5.6f
51 #define TPS25946_GAIN_IMON 182.0f
52 #define TPS25946_GAIN_IMON_T1M 105.5f
53 #define TPS25946_R_IMON_T2A 1000.0f
54 #define TPS25946_R_IMON_T1U_UA 1130.0f
55 #define TPS25946_R_IMON_T1S 562.0f
56 #define TPS25946_R_IMON_T1M 750.0f
59 #define MAX15162AAWE_C_IRATIO 4000.0f
60 #define MAX15162AAWE_R_IMON 1500.0f
63 #define MAX17613B_R_ISET_TOTAL 1510.0f
64 #define MAX17613B_R_ISET_R2 1000.0f
65 #define MAX17613B_C_IRATIO 3000.0f
67 #define MCU_FSR_ADC 4096.0f
68 #define MCU_REF_VOLTAGE 2500.0f //mV
70 static inline int ni_min(
int a,
int b)
75 static inline int ni_max(
int a,
int b)
80 static inline float ni_minf(
float a,
float b)
85 static inline float ni_maxf(
float a,
float b)
90 static inline int clip3(
int min,
int max,
int a)
92 return ni_min(ni_max(min, a), max);
95 static inline float clip3f(
float min,
float max,
float a)
97 return ni_minf(ni_maxf(min, a), max);
100 #define NIALIGN(x, a) (((x) + (a)-1) & ~((a)-1))
102 #define COMPILE_ASSERT(condition) ((void)sizeof(char[1 - 2 * !(condition)]))
104 #define XCODER_MAX_NUM_TS_TABLE 32
105 #define XCODER_FRAME_OFFSET_DIFF_THRES 100
106 #define XCODER_MAX_ENC_PACKETS_PER_READ 16
107 #define XCODER_MAX_NUM_QUEUE_ENTRIES 6000
108 #define XCODER_MAX_NUM_TEMPORAL_LAYER 7
109 #define BUFFER_POOL_SZ_PER_CONTEXT 300
112 #define XCODER_MIN_ENC_PIC_WIDTH 144
113 #define XCODER_MIN_ENC_PIC_HEIGHT 128
114 #define XCODER_MAX_ENC_PIC_WIDTH 8192
115 #define XCODER_MAX_ENC_PIC_HEIGHT 8192
117 #define NI_DEC_FRAME_BUF_POOL_SIZE_INIT 20
118 #define NI_DEC_FRAME_BUF_POOL_SIZE_EXPAND 20
156 int32_t
ni_atobool(
const char *p_str,
bool *b_error);
157 int32_t
ni_atoi(
const char *p_str,
bool *b_error);
158 double ni_atof(
const char *p_str,
bool *b_error);
159 int32_t
ni_parse_name(
const char *arg,
const char *
const *names,
bool *b_error);
267 int width,
int height,
int bit_depth_factor,
268 int is_semiplanar,
int conf_win_right,
296 int frame_width,
int frame_height,
332 int width,
int height,
int factor,
390 uint32_t
ni_round_up(uint32_t number_to_round, uint32_t multiple);
393 #define ni_aligned_free(p_memptr) \
395 _aligned_free(p_memptr); \
399 #define ni_aligned_free(p_memptr) \
408 #define ni_memfree(p_memptr) \
414 #if __linux__ || __APPLE__
415 uint32_t ni_get_kernel_max_io_size(
const char * p_dev);
427 uint8_t *dst, uint32_t dst_len,
const char *tensor_file,
430 uint8_t *dst, uint32_t dst_len,
float *src, uint32_t src_len,
433 float *dst, uint32_t dst_len, uint8_t *src, uint32_t src_len,
437 size_t ui32DataLength, uint8_t aui8Hash[]);
552 const ni_pthread_attr_t *attr,
553 void *(*start_routine)(
void *),
void *arg);
576 const ni_pthread_condattr_t *attr);
608 ni_pthread_mutex_t *mutex);
631 ni_pthread_mutex_t *mutex,
632 const struct timespec *abstime);
647 ni_sigset_t *oldset);
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 ...
LIB_API uint64_t ni_gettime_ns(void)
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 us...
LIB_API char * ni_strtok(char *s, const char *delim, char **saveptr)
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)
const LIB_API char * ni_get_rc_txt(ni_retcode_t rc)
Get text string for the provided error.
ni_retcode_t ni_check_dev_name(const char *p_dev)
check dev name
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)
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_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_queue_init(ni_session_context_t *p_ctx, ni_queue_t *p_queue, const char *name)
Initialize xcoder queue.
void ni_buffer_pool_free(ni_queue_buffer_pool_t *p_buffer_pool)
LIB_API NI_DEPRECATED char * ni_get_compat_fw_api_ver(void)
Get FW API version libxcoder is compatible with.
LIB_API int ni_pthread_mutex_destroy(ni_pthread_mutex_t *mutex)
destory a mutex
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_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.
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.
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 a...
LIB_API int ni_pthread_sigmask(int how, const ni_sigset_t *set, ni_sigset_t *oldset)
examine and change mask of blocked signals
double ni_atof(const char *p_str, bool *b_error)
Convert string to floating.
LIB_API uint32_t ni_ai_network_layer_dims(ni_network_layer_params_t *p_param)
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....
LIB_API int ni_pthread_mutex_init(ni_pthread_mutex_t *mutex)
initialize a mutex
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 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 char * ni_get_libxcoder_api_ver(void)
Get libxcoder API version.
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
ni_retcode_t ni_timestamp_init(ni_session_context_t *p_ctx, ni_timestamp_table_t **pp_table, const char *name)
Initialize timestamp handling.
LIB_API int ni_param_get_key_value(char *p_str, char *key, char *value)
Retrieve key and value from 'key=value' pair.
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)
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.
LIB_API void ni_usleep(int64_t usec)
Common NETINT definitions used by all modules.
void ni_dec_fme_buffer_pool_free(ni_buf_pool_t *p_buffer_pool)
LIB_API int ni_pthread_mutex_lock(ni_pthread_mutex_t *mutex)
thread mutex lock
ni_retcode_t ni_timestamp_done(ni_timestamp_table_t *p_table, ni_queue_buffer_pool_t *p_buffer_pool)
Clean up timestamp handling.
void ni_buf_pool_return_buffer(ni_buf_t *buf, ni_buf_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.
LIB_API int ni_pthread_cond_broadcast(ni_pthread_cond_t *cond)
broadcast a condition
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 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....
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 f...
ni_buf_t * ni_buf_pool_get_buffer(ni_buf_pool_t *p_buffer_pool)
LIB_API int ni_pthread_mutex_unlock(ni_pthread_mutex_t *mutex)
thread mutex unlock
LIB_API int32_t ni_gettimeofday(struct timeval *p_tp, void *p_tzp)
Get time for logs with microsecond timestamps.
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.
LIB_API int ni_posix_memalign(void **memptr, size_t alignment, size_t size)
Allocate aligned memory.
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_retrieve_xcoder_params(char xcoderParams[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
Retrieve encoder config parameter values from –xcoder-params.
ni_retcode_t ni_queue_print(ni_queue_t *p_queue)
Print xcoder queue info.
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)
#define NI_MAX_NUM_DATA_POINTERS
int32_t ni_atoi(const char *p_str, bool *b_error)
Convert string to integer.
ni_buf_t * ni_buf_pool_allocate_buffer(ni_buf_pool_t *p_buffer_pool, int buffer_size)
const LIB_API char * ni_ai_errno_to_str(int rc)
return error string according to error code from firmware
LIB_API uint32_t ni_ai_network_layer_size(ni_network_layer_params_t *p_param)
int32_t ni_atobool(const char *p_str, bool *b_error)
Convert string to boolean.
LIB_API void ni_calculate_sha256(const uint8_t aui8Data[], size_t ui32DataLength, uint8_t aui8Hash[])
int32_t ni_parse_name(const char *arg, const char *const *names, bool *b_error)
Parse name.
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)
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 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....
uint32_t ni_round_up(uint32_t number_to_round, uint32_t multiple)
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 int ni_remove_emulation_prevent_bytes(uint8_t *buf, int size)
Remove emulation prevention byte(s) as needed from the data buffer.
LIB_API int ni_pthread_cond_signal(ni_pthread_cond_t *cond)
signal a condition
LIB_API char * ni_get_libxcoder_release_ver(void)
Get libxcoder SW release version.
LIB_API int ni_pthread_join(ni_pthread_t thread, void **value_ptr)
join with a terminated thread
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 ...
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.
Public definitions for operating NETINT video processing devices for video processing.
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 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 ...
LIB_API int ni_pthread_cond_destroy(ni_pthread_cond_t *cond)
destroy condition variables
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....
LIB_API int ni_pthread_cond_wait(ni_pthread_cond_t *cond, ni_pthread_mutex_t *mutex)
wait on a condition