29 #if defined(__linux__) || defined(__APPLE__)
30 #include <sys/ioctl.h>
32 #include <sys/ioctl.h>
34 #include <sys/types.h>
45 #ifdef XCODER_SIM_ENABLED
46 static int32_t sim_run_count = 0;
47 static int32_t sim_eos_flag = 0;
60 SYSTEMTIME system_time;
61 ULARGE_INTEGER ularge;
63 static const unsigned __int64 epoch = ((
unsigned __int64)116444736000000000ULL);
67 GetSystemTime(&system_time);
68 SystemTimeToFileTime(&system_time, &file_time);
69 ularge.LowPart = file_time.dwLowDateTime;
70 ularge.HighPart = file_time.dwHighDateTime;
72 p_tp->tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L);
73 p_tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
77 return gettimeofday(p_tp, p_tzp);
84 LARGE_INTEGER frequency;
86 uint64_t time_sec, time_nsec;
89 QueryPerformanceFrequency(&frequency);
91 QueryPerformanceCounter(&count);
93 time_sec = count.QuadPart / frequency.QuadPart;
94 time_nsec = (count.QuadPart - time_sec * frequency.QuadPart) * 1000000000LL / frequency.QuadPart;
96 return (time_sec * 1000000000LL + time_nsec);
99 clock_gettime(CLOCK_REALTIME, &ts);
100 return ts.tv_sec * 1000000000LL + ts.tv_nsec;
110 return number_to_round;
113 remainder = number_to_round % multiple;
116 return number_to_round;
119 return number_to_round + multiple - remainder;
125 *pp_memptr = malloc(size);
126 if (NULL == *pp_memptr)
132 ZeroMemory(*pp_memptr, size);
136 return posix_memalign(pp_memptr, alignment, size);
141 static inline int ni_logan_min(
int a,
int b)
143 return a < b ? a : b;
146 static inline int ni_logan_max(
int a,
int b)
148 return a > b ? a : b;
158 uint32_t ni_logan_get_kernel_max_io_size(
const char * p_dev)
161 char file_name[KERNEL_NVME_FILE_NAME_MAX_SZ];
162 uint32_t max_segments = 0, min_io_size = 0, max_hw_sectors_kb = 0;
163 uint32_t io_size = DEFAULT_IO_TRANSFER_SIZE;
164 int len = 0, err = 0;
173 len = strlen(p_dev) - 5;
174 if(len < MIN_NVME_BLK_NAME_LEN)
181 memset(file_name,0,
sizeof(file_name));
182 memcpy(file_name,SYS_PARAMS_PREFIX_PATH,SYS_PREFIX_SZ);
184 if (strstr(p_dev,
"block"))
186 strncat(file_name, (
char*)(p_dev + 11) ,
sizeof(file_name) - SYS_PREFIX_SZ);
190 strncat(file_name, (
char*)(p_dev + 5) ,
sizeof(file_name) - SYS_PREFIX_SZ);
192 strncat(file_name, KERNEL_NVME_MAX_SEG_PATH,
sizeof(file_name) - SYS_PREFIX_SZ - len);
194 p_file = fopen(file_name,
"r");
202 err = fscanf(p_file,
"%u",&max_segments);
213 memset(file_name,0,
sizeof(file_name));
214 memcpy(file_name,SYS_PARAMS_PREFIX_PATH,SYS_PREFIX_SZ);
215 if (strstr(p_dev,
"block"))
217 strncat(file_name, (
char*)(p_dev + 11) ,
sizeof(file_name) - SYS_PREFIX_SZ);
221 strncat(file_name, (
char*)(p_dev + 5) ,
sizeof(file_name) - SYS_PREFIX_SZ);
223 strncat(file_name, KERNEL_NVME_MIN_IO_SZ_PATH,
sizeof(file_name) - SYS_PREFIX_SZ - len);
225 p_file = fopen(file_name,
"r");
233 err = fscanf(p_file,
"%u",&min_io_size);
243 memset(file_name,0,
sizeof(file_name));
244 memcpy(file_name,SYS_PARAMS_PREFIX_PATH,SYS_PREFIX_SZ);
245 if (strstr(p_dev,
"block"))
247 strncat(file_name, (
char*)(p_dev + 11) ,
sizeof(file_name) - SYS_PREFIX_SZ);
251 strncat(file_name, (
char*)(p_dev + 5) ,
sizeof(file_name) - SYS_PREFIX_SZ);
253 strncat(file_name, KERNEL_NVME_MAX_HW_SEC_KB_PATH,
sizeof(file_name) - SYS_PREFIX_SZ - len);
255 p_file = fopen(file_name,
"r");
263 err = fscanf(p_file,
"%u",&max_hw_sectors_kb);
270 if( ni_logan_min(min_io_size * max_segments, max_hw_sectors_kb * 1024) > MAX_IO_TRANSFER_SIZE )
272 io_size = MAX_IO_TRANSFER_SIZE;
276 io_size = ni_logan_min( min_io_size * max_segments, max_hw_sectors_kb * 1024);
280 "and will be used unless overwritten by user settings\n", io_size);
301 LARGE_INTEGER Count_;
302 LARGE_INTEGER Frequency;
303 QueryPerformanceCounter(&Count);
304 QueryPerformanceFrequency(&Frequency);
305 Count_.QuadPart = Count.QuadPart + usec*(Frequency.QuadPart/1000000);
308 QueryPerformanceCounter(&Count);
309 }
while(Count.QuadPart<Count_.QuadPart);
314 LARGE_INTEGER ft = { 0 };
317 ft.QuadPart = -(10 * usec);
319 timer = CreateWaitableTimer(NULL, TRUE, NULL);
322 retval = SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
325 WaitForSingleObject(timer, INFINITE);
335 if (usec < 0xFFFFFFFF)
369 if (NULL == p_buffer_pool)
374 ni_logan_pthread_mutex_lock(&(p_buffer_pool->
mutex));
388 ni_logan_pthread_mutex_unlock(&(p_buffer_pool->
mutex));
421 ni_logan_pthread_mutex_unlock(&(p_buffer_pool->
mutex));
447 ni_logan_pthread_mutex_lock(&(p_buffer_pool->
mutex));
496 "current total: %u\n",
512 ni_logan_pthread_mutex_unlock(&(p_buffer_pool->
mutex));
522 if (NULL != p_buffer_pool &&
536 p_buffer->
buf = p_buf;
537 p_buffer->
pool = p_buffer_pool;
561 int32_t number_of_buffers,
568 int width_aligned = width;
569 int height_aligned = height;
573 width_aligned = ((width + 31) / 32) * 32;
574 height_aligned = ((height + 7) / 8) * 8;
577 height_aligned = ((height + 15) / 16) * 16;
580 uint32_t luma_size = width_aligned * height_aligned * factor;
581 uint32_t chroma_b_size = luma_size / 4;
582 uint32_t chroma_r_size = chroma_b_size;
583 uint32_t buffer_size = luma_size + chroma_b_size + chroma_r_size +
599 "(existing buffer size), re-allocating !\n", width, height,
606 "(existing buffer size), continue !\n", width, height,
625 __FUNCTION__, number_of_buffers, buffer_size);
628 for (i = 0; i < number_of_buffers; i++)
645 int32_t count_free = 0;
653 ni_logan_pthread_mutex_lock(&(p_buffer_pool->
mutex));
666 ni_logan_pthread_mutex_unlock(&(p_buffer_pool->
mutex));
688 __FUNCTION__, count_free);
691 p_buffer_pool = NULL;
739 p_buffer_pool = NULL;
802 for (i = 0; i < number_of_buffers; i++)
818 for (i = 0; i < 200; i++)
823 ni_log(
NI_LOG_ERROR,
"FATAL ERROR: Failed to allocate pool buffer for pool :%p\n", pool);
835 if( NULL == p_buffer_pool)
889 if( (!buf) || !(p_buffer_pool) )
947 static inline int char_match(
char s,
char p)
949 return s == p || p ==
'#' && isdigit(s);
952 static char *ni_logan_remove_substring_pattern(
char *str,
char *pattern)
958 if (!str || !pattern || *start ==
'\0' || *p ==
'\0' || *p ==
'+')
964 while (*end !=
'\0' || *p ==
'+')
975 if (char_match(end[-1], p[-1]) && char_match(end[0], p[-1]))
984 else if (char_match(end[0], p[0]))
1019 static ni_logan_retcode_t ni_logan_search_file(
const char *p_dev,
char *cmd,
char *cmd_ret,
int cmd_ret_len)
1023 if (access(p_dev, F_OK) == -1)
1029 cmd_fp = popen(cmd,
"r");
1035 if (fgets(cmd_ret, cmd_ret_len, cmd_fp) == NULL)
1041 ni_logan_remove_substring_pattern(cmd_ret,
"c#+");
1063 char cmd[128] = {
'\0'};
1064 char cmd_ret[22] = {
'\0'};
1066 if (!p_dev || !p_out_buf)
1073 snprintf(p_out_buf, out_buf_len,
"%s", p_dev);
1075 #elif defined(XCODER_LINUX_VIRTIO_DRIVER_ENABLED)
1076 ni_log(
NI_LOG_TRACE,
"The device is already considered as a block divice in Linux virtual machine with VirtIO driver.\n");
1077 snprintf(p_out_buf, out_buf_len,
"%s", p_dev);
1079 #elif defined(__APPLE__)
1080 snprintf(p_out_buf, out_buf_len,
"%s", p_dev);
1087 snprintf(cmd,
sizeof(cmd) - 1,
"ls /sys/class/nvme/%s/ | grep %s", &p_dev[5],
NI_LOGAN_NVME_PREFIX);
1090 snprintf(cmd,
sizeof(cmd) - 1,
"ls /sys/`udevadm info -q path -n %s` | grep -m 1 -P \"%s(\\d+c)?\\d+n\\d+\"",
1095 if (access(p_dev, F_OK) == -1)
1101 cmd_fp = popen(cmd,
"r");
1107 if (fgets(cmd_ret,
sizeof(cmd_ret)/
sizeof(cmd_ret[0]), cmd_fp) == NULL)
1110 snprintf(p_out_buf, out_buf_len,
"%sn1", p_dev);
1114 cmd_ret[strcspn(cmd_ret,
"\r\n")] = 0;
1115 ni_logan_remove_substring_pattern(cmd_ret,
"c#+");
1118 snprintf(cmd,
sizeof(cmd) - 1,
"ls /dev/ | grep %s", cmd_ret);
1119 int cmd_ret_len =
sizeof(cmd_ret)/
sizeof(cmd_ret[0]);
1120 ret = ni_logan_search_file(p_dev, cmd, cmd_ret, cmd_ret_len);
1124 if ((tmp = strstr(cmd_ret,
"\n")))
1128 snprintf(p_out_buf, out_buf_len,
"/dev/%s", cmd_ret);
1132 snprintf(cmd,
sizeof(cmd) - 1,
"ls /dev/block/ | grep %s", cmd_ret);
1133 ret = ni_logan_search_file(p_dev, cmd, cmd_ret, cmd_ret_len);
1137 if ((tmp = strstr(cmd_ret,
"\n")))
1141 snprintf(p_out_buf, out_buf_len,
"/dev/block/%s", cmd_ret);
1146 __FUNCTION__, cmd_ret);
1165 snprintf(p_out_buf, out_buf_len,
"/dev/%s", cmd_ret);
1190 if (*pp_table != NULL)
1278 uint64_t frame_info,
1279 int64_t *p_timestamp,
1287 __FUNCTION__, frame_info);
1296 "err=%d\n", __FUNCTION__, *p_timestamp, frame_info, err);
1302 uint64_t frame_info,
1303 int64_t *p_timestamp,
1317 time_t now = time(NULL);
1319 if (!pts_list || !dts_list)
1326 p_queue = &dts_list->
list;
1359 uint64_t frame_offset,
1360 int64_t *p_timestamp,
1366 if( (!p_table) || (!p_timestamp) || (!p_buffer_pool) )
1373 __FUNCTION__, frame_offset);
1382 "err=%d\n", __FUNCTION__, *p_timestamp, frame_offset, err);
1402 if (!p_queue || !name)
1406 p_queue->
name[0] =
'\0';
1407 strncat(p_queue->
name, name, strlen(name));
1428 uint64_t frame_info,
1473 __FUNCTION__, p_queue->
count);
1497 uint64_t frame_info,
1498 int64_t *p_timestamp,
1509 if (!p_queue || !p_timestamp)
1517 if ( NULL == p_queue->
p_first )
1540 while (temp && !found)
1542 if (frame_info < temp->frame_info)
1561 temp_prev = temp->
p_prev;
1577 p_queue->
p_last = temp_prev;
1595 __FUNCTION__, p_queue->
name, count);
1597 if (p_queue->
count < 0)
1600 __FUNCTION__, p_queue->
count);
1615 uint64_t frame_info,
1616 int64_t *p_timestamp,
1627 if ( (!p_queue) || (!p_timestamp) )
1656 while (temp && !found)
1658 if (llabs(frame_info - temp->
frame_info) <= threshold)
1675 p_queue->
p_last = temp_prev;
1692 __FUNCTION__, p_queue->
name, count);
1695 if (p_queue->
count < 0)
1698 __FUNCTION__, p_queue->
count);
1735 temp_next = temp->
p_next;
1742 left, p_queue->
count);
1761 struct tm* ltime = NULL;
1762 char buff[20] = { 0 };
1785 strftime(buff, 20,
"%Y-%m-%d %H:%M:%S", ltime);
1827 ni_logan_pthread_mutex_init(&(p_fifo->
mutex));
1832 p_fifo->
buffer = malloc(number_of_buffers * size);
1833 if (p_fifo->
buffer == NULL)
1840 memset(p_fifo->
buffer,0,(number_of_buffers * size));
1861 ni_logan_pthread_mutex_destroy(&(p_fifo->
mutex));
1914 ni_logan_pthread_mutex_lock(&(p_fifo->
mutex));
1920 ni_logan_pthread_mutex_unlock(&(p_fifo->
mutex));
1943 ni_logan_pthread_mutex_lock(&(p_fifo->
mutex));
1948 ni_logan_pthread_mutex_unlock(&(p_fifo->
mutex));
1970 ni_logan_pthread_mutex_lock(&(p_fifo->
mutex));
1975 ni_logan_pthread_mutex_unlock(&(p_fifo->
mutex));
1988 if (!strcmp(p_str,
"1") ||
1989 !strcmp(p_str,
"true") ||
1990 !strcmp(p_str,
"yes"))
1995 if (!strcmp(p_str,
"0") ||
1996 !strcmp(p_str,
"false") ||
1997 !strcmp(p_str,
"no"))
2016 int32_t v = strtol(p_str, &end, 0);
2018 if (end == p_str || *end !=
'\0')
2036 double v = strtod(p_str, &end);
2038 if (end == p_str || *end !=
'\0')
2056 for (i = 0; names[i]; i++)
2058 if (!strcmp(arg, names[i]))
2085 ni_logan_pthread_mutex_lock(&pool->
pmutex);
2088 while (pool->
first == NULL && !pool->
quit)
2091 ni_logan_pthread_cond_wait(&pool->
pcond, &pool->
pmutex);
2097 if (pool->
first != NULL)
2101 ni_logan_pthread_mutex_unlock(&pool->
pmutex);
2104 ni_logan_pthread_mutex_lock(&pool->
pmutex);
2112 ni_logan_pthread_cond_signal(&pool->
pcond);
2114 ni_logan_pthread_mutex_unlock(&pool->
pmutex);
2117 ni_logan_pthread_mutex_unlock(&pool->
pmutex);
2135 ni_logan_pthread_mutex_init(&pool->
pmutex);
2136 ni_logan_pthread_cond_init(&pool->
pcond, NULL);
2160 void *(*run)(
void *arg),
2175 newtask->
next = NULL;
2178 ni_logan_pthread_mutex_lock(&pool->
pmutex);
2180 if (pool->
first == NULL)
2182 pool->
first = newtask;
2188 pool->
last = newtask;
2194 ni_logan_pthread_cond_signal(&pool->
pcond);
2216 while (pool->
idle == 0)
2220 ni_logan_pthread_cond_signal(&pool->
pcond);
2224 ni_logan_pthread_mutex_unlock(&pool->
pmutex);
2254 newtask->
next = NULL;
2257 ni_logan_pthread_mutex_lock(&pool->
pmutex);
2259 if (pool->
first == NULL)
2261 pool->
first = newtask;
2267 pool->
last = newtask;
2273 ni_logan_pthread_cond_signal(&pool->
pcond);
2289 ni_logan_pthread_mutex_unlock(&pool->
pmutex);
2311 ni_logan_pthread_mutex_lock(&pool->
pmutex);
2321 ni_logan_pthread_cond_broadcast(&pool->
pcond);
2326 ni_logan_pthread_cond_wait(&pool->
pcond, &pool->
pmutex);
2329 ni_logan_pthread_mutex_unlock(&pool->
pmutex);
2330 ni_logan_pthread_mutex_destroy(&pool->
pmutex);
2331 ni_logan_pthread_cond_destroy(&pool->
pcond);
2358 plane_stride[0] = ((width + 31) / 32) * 32;
2363 plane_stride[0] *= bit_depth_factor;
2364 plane_stride[1] = plane_stride[2] = plane_stride[0] / 2;
2367 plane_height[0] = ((height + 7) / 8) * 8;
2370 plane_height[0] = ((height + 15) / 16) * 16;
2376 plane_height[1] = plane_height[2] = plane_height[0] / 2;
2399 int frame_width,
int frame_height,
int bit_depth_factor,
2406 if (p_dst[0] == p_src[0] && p_dst[1] == p_src[1] && p_dst[2] == p_src[2])
2413 "%d/%d/%d src_height %d/%d/%d\n", __FUNCTION__,
2414 dst_stride[0], dst_stride[1], dst_stride[2],
2415 src_stride[0], src_stride[1], src_stride[2],
2416 dst_height[0], dst_height[1], dst_height[2],
2417 src_height[0], src_height[1], src_height[2]);
2420 int pad_len = 0, pad_len_bytes;
2425 int height = src_height[i] < dst_height[i] ? src_height[i] : dst_height[i];
2426 uint8_t *dst = p_dst[i];
2427 const uint8_t *src = (
const uint8_t *)p_src[i];
2431 pad_len = dst_stride[i] / bit_depth_factor - frame_width;
2437 pad_len = ((pad_len + 1) / 2) * 2;
2440 pad_len_bytes = (i == 0 ? pad_len * bit_depth_factor :
2441 pad_len * bit_depth_factor / 2);
2443 "copy height: %d.\n", __FUNCTION__, i, pad_len, pad_len_bytes, height);
2445 if(pad_len || src_stride[i] != dst_stride[i])
2447 for (; height > 0; height--)
2449 memcpy(dst, src, (src_stride[i] < dst_stride[i] ?
2450 src_stride[i] : dst_stride[i]));
2451 dst += dst_stride[i];
2455 if (2 == bit_depth_factor)
2459 uint8_t *tmp_dst = dst - pad_len_bytes;
2460 for (j = 0; j < pad_len_bytes / 2; j++)
2462 memcpy(tmp_dst, dst - pad_len_bytes - 2, 2);
2468 memset(dst - pad_len_bytes, *(dst - pad_len_bytes - 1),
2471 src += src_stride[i];
2476 int copy_stride = dst_stride[i];
2477 memcpy(dst, src, copy_stride * height);
2478 dst += copy_stride * height;
2482 int padding_height = dst_height[i] - src_height[i];
2483 if (padding_height > 0)
2486 __FUNCTION__, i, padding_height);
2487 src = dst - dst_stride[i];
2488 for (; padding_height > 0; padding_height--)
2490 memcpy(dst, src, dst_stride[i]);
2491 dst += dst_stride[i];
2513 int insert_bytes = 0;
2514 uint8_t *buf_curr = buf;
2515 uint8_t *buf_end = buf + size - 1;
2516 int zeros = 0, insert_ep3_byte = 0;
2520 for (; buf_curr <= buf_end; buf_curr++)
2524 insert_ep3_byte = (*buf_curr <= 3);
2525 if (insert_ep3_byte)
2528 memmove(buf_curr + 1, buf_curr, buf_end - buf_curr + 1);
2549 return insert_bytes;
2566 int remove_bytes = 0;
2567 uint8_t *buf_curr = buf;
2568 uint8_t *buf_end = buf + size - 1;
2569 int zeros = 0, remove_ep3_byte;
2573 for (; buf_curr < buf_end; buf_curr++)
2577 remove_ep3_byte = (*buf_curr == 0x03 && *(buf_curr + 1) <= 3);
2578 if (remove_ep3_byte)
2581 memmove(buf_curr, buf_curr + 1, buf_end - buf_curr);
2601 return remove_bytes;
2618 int pos_byte = (pos/8);
2619 int pos_in_byte = pos%8;
2620 int remaining_bytes_in_current_byte = 8 - pos_in_byte;
2622 if (pos_in_byte == 0)
2624 buf[pos_byte] = (uint8_t)(value >> 24);
2625 buf[pos_byte+1] = (uint8_t)(value >> 16);
2626 buf[pos_byte+2] = (uint8_t)(value >> 8);
2627 buf[pos_byte+3] = (uint8_t)(value);
2631 buf[pos_byte] = buf[pos_byte] + (uint8_t)(value >> (32-remaining_bytes_in_current_byte));
2632 buf[pos_byte+1] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-8));
2633 buf[pos_byte+2] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-16));
2634 buf[pos_byte+3] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-24));
2635 buf[pos_byte+4] = buf[pos_byte+4] + ((uint8_t)(value << remaining_bytes_in_current_byte));
2639 #ifdef MEASURE_LATENCY
2659 queue->
rear = capacity - 1;
2663 ni_log(
NI_LOG_ERROR,
"ERROR %d: Failed to allocate memory for lat_meas_queue queue->array",
2702 if (queue->
size == 0)
2709 return dequeue_item;
2722 return queue->
size == 0 ? NULL : &queue->
array[queue->
rear];
2754 return ni_logan_lat_meas_q_enqueue(dec_frame_time_q, entry);
2772 uint32_t dequeue_count = 0;
2780 if (entry->
ts_time == ts_time)
2782 ni_logan_lat_meas_q_dequeue(dec_frame_time_q);
2787 while (entry->
ts_time < ts_time)
2790 entry = ni_logan_lat_meas_q_dequeue(dec_frame_time_q);
2805 else if (entry->
ts_time > ts_time)
2810 else if (entry->
ts_time == ts_time)
@ NI_LOGAN_RETCODE_INVALID_PARAM
@ NI_LOGAN_RETCODE_ERROR_MEM_ALOC
@ NI_LOGAN_RETCODE_SUCCESS
@ NI_LOGAN_RETCODE_FAILURE
#define NI_LOGAN_MAX_NUM_DATA_POINTERS
#define ni_logan_assert(expression)
#define NI_LOGAN_MEM_PAGE_ALIGNMENT
#define NI_LOGAN_FW_META_DATA_SZ
#define NI_LOGAN_MIN_WIDTH
#define NI_LOGAN_MAX_SEI_DATA
#define NI_LOGAN_MIN_HEIGHT
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
Definitions related to working with NI T-408 over NVME interface.
ni_logan_buf_t * ni_logan_buf_pool_expand(ni_logan_buf_pool_t *pool)
ni_logan_buf_t * ni_logan_buf_pool_allocate_buffer(ni_logan_buf_pool_t *p_buffer_pool, int buffer_size)
allocate a memory buffer and place it in the pool
uint8_t * ni_logan_fifo_generic_read(ni_logan_fifo_buffer_t *p_fifo)
Get first filled buffer to read in the fifo.
uint32_t ni_logan_round_up(uint32_t number_to_round, uint32_t multiple)
ni_logan_retcode_t ni_logan_timestamp_get(ni_logan_timestamp_table_t *p_table, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Retrieve timestamp from table based on frameoffset info.
uint8_t * ni_logan_fifo_generic_write(ni_logan_fifo_buffer_t *p_fifo)
Get free buffer to write in the fifo.
int threadpool_auto_add_task_thread(threadpool_t *pool, void *(*run)(void *arg), void *arg, int newThread)
add task to threadpool using newThread control it
ni_logan_queue_node_t * ni_logan_buffer_pool_expand(ni_logan_queue_buffer_pool_t *pool)
ni_logan_retcode_t ni_logan_queue_push(ni_logan_queue_buffer_pool_t *p_buffer_pool, ni_logan_queue_t *p_queue, uint64_t frame_info, int64_t timestamp)
Push into xcoder queue.
void ni_logan_timestamp_scan_cleanup(ni_logan_timestamp_table_t *pts_list, ni_logan_timestamp_table_t *dts_list, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Timestamp queue clean up.
int32_t ni_logan_dec_fme_buffer_pool_initialize(ni_logan_session_context_t *p_ctx, int32_t number_of_buffers, int width, int height, int height_align, int factor)
decoder frame buffer pool init & free
int32_t ni_logan_posix_memalign(void **pp_memptr, size_t alignment, size_t size)
ni_logan_retcode_t ni_logan_queue_free(ni_logan_queue_t *p_queue, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Free xcoder queue.
int32_t ni_logan_atobool(const char *p_str, bool *b_error)
Convert string to boolean.
ni_logan_retcode_t ni_logan_queue_pop(ni_logan_queue_t *p_queue, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Pop from the xcoder queue.
ni_logan_retcode_t ni_logan_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...
void ni_logan_copy_hw_yuv420p(uint8_t *p_dst[NI_LOGAN_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_LOGAN_MAX_NUM_DATA_POINTERS], int frame_width, int frame_height, int bit_depth_factor, int dst_stride[NI_LOGAN_MAX_NUM_DATA_POINTERS], int dst_height[NI_LOGAN_MAX_NUM_DATA_POINTERS], int src_stride[NI_LOGAN_MAX_NUM_DATA_POINTERS], int src_height[NI_LOGAN_MAX_NUM_DATA_POINTERS])
Copy YUV data to Netint HW YUV420p frame layout to be sent to encoder for encoding....
int ni_logan_fifo_return_read(ni_logan_fifo_buffer_t *p_fifo)
Push back the last read buffer to the fifo.
void ni_logan_buffer_pool_free(ni_logan_queue_buffer_pool_t *p_buffer_pool)
free buffer memory pool
ni_logan_queue_node_t * ni_logan_buffer_pool_allocate_buffer(ni_logan_queue_buffer_pool_t *p_buffer_pool)
int32_t ni_logan_parse_name(const char *arg, const char *const *names, bool *b_error)
Parse name.
ni_logan_retcode_t ni_logan_timestamp_done(ni_logan_timestamp_table_t *p_table, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Clean up timestamp handling.
int ni_logan_fifo_is_empty(ni_logan_fifo_buffer_t *p_fifo)
Check if a fifo is empty.
uint64_t ni_logan_gettime_ns(void)
void ni_logan_get_hw_yuv420p_dim(int width, int height, int bit_depth_factor, int is_h264, int plane_stride[NI_LOGAN_MAX_NUM_DATA_POINTERS], int plane_height[NI_LOGAN_MAX_NUM_DATA_POINTERS])
Get dimension information of Netint HW YUV420p frame to be sent to encoder for encoding....
ni_logan_queue_node_t * ni_logan_buffer_pool_get_queue_buffer(ni_logan_queue_buffer_pool_t *p_buffer_pool)
ni_logan_retcode_t ni_logan_timestamp_register(ni_logan_queue_buffer_pool_t *p_buffer_pool, ni_logan_timestamp_table_t *p_table, int64_t timestamp, uint64_t data_info)
Register timestamp in timestamp/frameoffset table.
void ni_logan_usleep(int64_t usec)
void ni_logan_buffer_pool_return_buffer(ni_logan_queue_node_t *buf, ni_logan_queue_buffer_pool_t *p_buffer_pool)
ni_logan_retcode_t ni_logan_timestamp_init(ni_logan_session_context_t *p_ctx, ni_logan_timestamp_table_t **pp_table, const char *name)
Initialize timestamp handling.
int ni_logan_fifo_is_full(ni_logan_fifo_buffer_t *p_fifo)
Check if a fifo is full.
ni_logan_retcode_t ni_logan_queue_pop_threshold(ni_logan_queue_t *p_queue, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Pop from the xcoder queue with respect to threshold.
void ni_logan_buf_pool_return_buffer(ni_logan_buf_t *buf, ni_logan_buf_pool_t *p_buffer_pool)
return a used memory buffer to the pool
ni_logan_retcode_t ni_logan_queue_print(ni_logan_queue_t *p_queue)
Print xcoder queue info.
void ni_logan_dec_fme_buffer_pool_free(ni_logan_buf_pool_t *p_buffer_pool)
free decoder frame buffer pool
int ni_logan_insert_emulation_prevent_bytes(uint8_t *buf, int size)
Insert emulation prevention byte(s) as needed into the data buffer.
int32_t ni_logan_atoi(const char *p_str, bool *b_error)
Convert string to integer.
LIB_API int ni_logan_remove_emulation_prevent_bytes(uint8_t *buf, int size)
Remove emulation prevention byte(s) as needed from the data buffer.
void ni_logan_overwrite_specified_pos(uint8_t *buf, int pos, int value)
overwrite the 32 bits of integer value at bit position pos
ni_logan_fifo_buffer_t * ni_logan_fifo_initialize(uint32_t number_of_buffers, uint32_t size)
Initialize a fifo buffer.
int32_t ni_logan_gettimeofday(struct timeval *p_tp, void *p_tzp)
ni_logan_retcode_t ni_logan_queue_init(ni_logan_session_context_t *p_ctx, ni_logan_queue_t *p_queue, const char *name)
Initialize xcoder queue.
void ni_logan_fifo_free(ni_logan_fifo_buffer_t *p_fifo)
Free a fifo.
void threadpool_destroy(threadpool_t *pool)
destroy threadpool
void * thread_routine(void *arg)
threadpool control
int32_t ni_logan_buffer_pool_initialize(ni_logan_session_context_t *p_ctx, int32_t number_of_buffers)
ni_logan_buf_t * ni_logan_buf_pool_get_buffer(ni_logan_buf_pool_t *p_buffer_pool)
get a free memory buffer from the pool
ni_logan_retcode_t ni_logan_timestamp_get_v2(ni_logan_timestamp_table_t *p_table, uint64_t frame_offset, int64_t *p_timestamp, int32_t threshold, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Retrieve timestamp from table based on frameoffset info.
void threadpool_init(threadpool_t *pool)
Init the threadpool.
double ni_logan_atof(const char *p_str, bool *b_error)
Convert string to floating.
int threadpool_add_task(threadpool_t *pool, void *(*run)(void *arg), void *arg)
add task to threadpool
ni_logan_retcode_t ni_logan_timestamp_get_with_threshold(ni_logan_timestamp_table_t *p_table, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_logan_queue_buffer_pool_t *p_buffer_pool)
Retrieve timestamp from table based on frame offset info with respect to threshold.
Exported utility routines definition.
#define LOGAN_BUFFER_POOL_SZ_PER_CONTEXT
#define NI_LOGAN_NVME_PREFIX
#define NI_LOGAN_DEC_FRAME_BUF_POOL_SIZE_EXPAND
#define LOGAN_XCODER_MAX_NUM_QUEUE_ENTRIES
ni_logan_buf_t * p_free_head
ni_logan_buf_t * p_free_tail
ni_logan_buf_t * p_used_head
ni_logan_buf_t * p_used_tail
uint32_t number_of_buffers
struct _ni_logan_buf_pool_t * pool
struct _ni_logan_buf_t * p_next
struct _ni_logan_buf_t * p_previous_buffer
struct _ni_logan_buf_t * p_prev
struct _ni_logan_buf_t * p_next_buffer
uint32_t number_of_buffers
uint32_t number_of_buffers_used
ni_logan_lat_meas_q_entry_t * array
ni_logan_queue_node_t * p_used_head
ni_logan_queue_node_t * p_used_tail
ni_logan_queue_node_t * p_free_tail
ni_logan_queue_node_t * p_free_head
uint32_t number_of_buffers
struct _ni_logan_queue_node_t * p_previous_buffer
struct _ni_logan_queue_node_t * p_next_buffer
time_t checkout_timestamp
struct _ni_logan_queue_node_t * p_next
struct _ni_logan_queue_node_t * p_prev
ni_logan_queue_node_t * p_last
ni_logan_queue_node_t * p_first
ni_logan_queue_buffer_pool_t * buffer_pool
ni_logan_buf_pool_t * dec_fme_buf_pool
void *(* run)(void *args)
ni_pthread_mutex_t pmutex