 |
libxcoder
5.5.0
|
Go to the documentation of this file.
29 #if __linux__ || __APPLE__
30 #define _GNU_SOURCE //O_DIRECT is Linux-specific. One must define _GNU_SOURCE to obtain its definitions
32 #include <linux/types.h>
35 #include <sys/ioctl.h>
37 #include <sys/types.h>
42 #include <semaphore.h>
85 #if __linux__ || __APPLE__
86 static struct stat g_nvme_stat = { 0 };
88 static int close_fd_zero_atexit = 0;
90 static void close_fd_zero(
void)
112 "ERROR: %s() Failed to allocate memory for session context\n",
141 #ifdef MEASURE_LATENCY
165 int framerate_num = 0;
166 int framerate_denom = 0;
205 "ERROR %s(): init xcoder_low_delay_sync_mutex fail return\n",
212 "ERROR %s(): init xcoder_low_delay_sync_cond fail return\n",
243 p_ctx->debug_write_ptr = NULL;
244 p_ctx->debug_write_index_ptr = NULL;
245 p_ctx->debug_write_sent_size = 0;
248 #ifdef MEASURE_LATENCY
282 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
288 event_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
289 if (event_handle == NULL)
293 return NI_INVALID_EVENT_HANDLE;
297 return NI_INVALID_EVENT_HANDLE;
309 if ( NI_INVALID_DEVICE_HANDLE == event_handle )
322 retval = CloseHandle(event_handle);
336 err = close(event_handle);
339 char error_message[100] = {
'\0'};
340 char unknown_error_message[20] = {
'\0'};
341 ni_sprintf(error_message, 100,
"ERROR: %s(): ", __func__);
345 ni_strcat(error_message, 100,
"EBADF\n");
348 ni_strcat(error_message, 100,
"EINTR\n");
354 ni_sprintf(unknown_error_message, 20,
"Unknown error %d\n", err);
355 ni_strcat(error_message, 100, unknown_error_message);
363 #ifndef DEPRECATION_AS_ERROR
378 HANDLE device_handle;
383 return NI_INVALID_DEVICE_HANDLE;
393 device_handle = CreateFile(p_dev, GENERIC_READ | GENERIC_WRITE,
394 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
395 OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
398 if (INVALID_HANDLE_VALUE == device_handle)
400 retval = GetLastError();
407 return device_handle;
410 ni_device_handle_t fd = NI_INVALID_DEVICE_HANDLE;
421 *p_max_io_size_out = ni_get_kernel_max_io_size(p_dev);
423 *p_max_io_size_out = MAX_IO_TRANSFER_SIZE;
432 fd = open(p_dev, O_RDWR | O_SYNC | O_DIRECT);
435 fd = open(p_dev, O_RDWR | O_SYNC);
445 fd = NI_INVALID_DEVICE_HANDLE;
458 if(close_fd_zero_atexit == 0)
460 close_fd_zero_atexit = 1;
461 atexit(close_fd_zero);
465 ni_log(
NI_LOG_ERROR,
"libxcoder has held the fd=0, but open fd=0 again, maybe fd=0 was closed accidently.");
467 fd = NI_INVALID_DEVICE_HANDLE;
472 retval = fcntl(fd, F_NOCACHE, 1);
478 fd = NI_INVALID_DEVICE_HANDLE;
483 retval = fstat(fd, &g_nvme_stat);
489 fd = NI_INVALID_DEVICE_HANDLE;
493 if (!S_ISCHR(g_nvme_stat.st_mode) && !S_ISBLK(g_nvme_stat.st_mode))
499 fd = NI_INVALID_DEVICE_HANDLE;
525 HANDLE device_handle;
526 DWORD dwDesiredAccess = 0;
531 return NI_INVALID_DEVICE_HANDLE;
539 dwDesiredAccess = GENERIC_READ;
543 dwDesiredAccess = GENERIC_WRITE;
548 dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
552 device_handle = CreateFile(p_dev, dwDesiredAccess,
553 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
554 OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
557 if (INVALID_HANDLE_VALUE == device_handle)
559 retval = GetLastError();
566 return device_handle;
569 ni_device_handle_t fd = NI_INVALID_DEVICE_HANDLE;
586 open_flags = O_RDONLY;
590 open_flags = O_WRONLY;
599 open_flags |= O_SYNC;
601 open_flags |= O_DIRECT;
606 fd = open(p_dev, open_flags);
612 fd = NI_INVALID_DEVICE_HANDLE;
618 retval = fcntl(fd, F_NOCACHE, 1);
624 fd = NI_INVALID_DEVICE_HANDLE;
629 retval = fstat(fd, &g_nvme_stat);
635 fd = NI_INVALID_DEVICE_HANDLE;
639 if (!S_ISCHR(g_nvme_stat.st_mode) && !S_ISBLK(g_nvme_stat.st_mode))
645 fd = NI_INVALID_DEVICE_HANDLE;
667 if ( NI_INVALID_DEVICE_HANDLE == device_handle )
674 if(device_handle == 0)
691 retval = CloseHandle(device_handle);
695 "ERROR: %s(): closing device device_handle %p failed, error: %d\n",
706 err = close(device_handle);
709 char error_message[100] = {
'\0'};
710 char unknown_error_message[20] = {
'\0'};
711 ni_sprintf(error_message, 100,
"ERROR: %s(): ", __func__);
715 ni_strcat(error_message, 100,
"EBADF\n");
718 ni_strcat(error_message, 100,
"EINTR\n");
724 ni_sprintf(unknown_error_message, 20,
"Unknown error %d\n", err);
725 ni_strcat(error_message, 100, unknown_error_message);
736 #ifndef DEPRECATION_AS_ERROR
754 void * p_buffer = NULL;
756 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
760 if ( (NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_cap) )
816 void * p_buffer = NULL;
818 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
822 if ( (NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_cap) )
889 bool use_model_load =
true;
893 uint32_t num_sw_instances = 0;
894 uint32_t pixel_load = 0xFFFFFFFFU;
895 int user_handles =
false;
896 ni_lock_handle_t lock = NI_INVALID_LOCK_HANDLE;
897 ni_device_handle_t handle = NI_INVALID_DEVICE_HANDLE;
898 ni_device_handle_t handle1 = NI_INVALID_DEVICE_HANDLE;
911 if (!IsUserAnAdmin())
926 "device_type %d, session id %d\n",
978 for (i = 0; i < 120; i++)
987 "%s: device type %d hw_id %d blk_dev_name: %s dev_xcoder_name: %s.\n",
1007 "%s: block device name %s type %d guid %d is to "
1008 "override passed in guid %d\n",
1009 __func__, p_ctx->
blk_dev_name, device_type, tmp_guid_id,
1011 p_ctx->
hw_id = tmp_guid_id;
1022 if ((handle1 == NI_INVALID_DEVICE_HANDLE) && (handle == NI_INVALID_DEVICE_HANDLE))
1024 if (p_ctx->
hw_id >=0)
1046 user_handles =
true;
1065 user_handles =
true;
1084 use_model_load =
false;
1123 for (i = 0; i < num_coders; i++)
1128 if (p_device_context == NULL)
1131 "ERROR: %s() ni_rsrc_get_device_context() failed\n",
1142 if (NI_INVALID_DEVICE_HANDLE == p_session_context.
device_handle)
1151 if (NI_INVALID_DEVICE_HANDLE != p_session_context.
device_handle)
1159 g_device_type_str[query_type],
1186 curr_load = p_dev_info->
load;
1189 if (i == 0 || curr_load < least_load ||
1190 (curr_load == least_load &&
1194 least_load = curr_load;
1206 NI_INVALID_DEVICE_HANDLE)
1220 p_ctx->
hw_id = guid;
1242 p_ctx->
hw_id = guid;
1250 else if((handle1 == NI_INVALID_DEVICE_HANDLE) || (handle == NI_INVALID_DEVICE_HANDLE))
1258 user_handles =
true;
1262 "Finish open the session dev:%s guid:%d handle:%p handle1:%p\n",
1269 if (p_device_context == NULL)
1272 "ERROR: %s() ni_rsrc_get_device_context() failed\n",
1274 if (user_handles !=
true)
1300 "ERROR: %s() cannot retrieve DDR configuration\n",
1302 if (user_handles !=
true)
1316 "ERROR: %s() keep_alive_timeout was 0, should be between 1-100. "
1317 "Setting to default of %u\n",
1321 switch (device_type)
1326 if (user_handles !=
true)
1349 if (p_enc_params && p_enc_params->
hwframes &&
1365 if (user_handles !=
true)
1383 if (user_handles !=
true)
1401 if (user_handles !=
true)
1419 if (user_handles !=
true)
1436 if (user_handles !=
true)
1446 __func__, device_type);
1512 p_device_pool = NULL;
1571 "join keep alive thread fail! : sid %u ret %d\n",
1582 switch (device_type)
1613 __func__, device_type);
1688 switch (device_type)
1704 __func__, device_type);
1746 0 == memcmp(p_ctx->
p_hdr_buf, hdr_data, hdr_size))
1758 memcpy(p_ctx->
p_hdr_buf, hdr_data, hdr_size);
1835 if (!p_ctx || !p_data)
1851 "ERROR: %s() keep alive thread has been closed, "
1852 "hw:%d, session:%d\n",
1869 switch (device_type)
1890 __func__, device_type);
1935 if ((!p_ctx) || (!p_data))
1952 "ERROR: %s() keep alive thread has been closed, "
1953 "hw:%d, session:%d\n",
1970 switch (device_type)
1974 int seq_change_read_count = 0;
1984 uint32_t aligned_width;
1994 if (0 == retval && seq_change_read_count)
1997 "%s (decoder): seq change NO data, next time.\n", __func__);
2003 else if (retval < 0)
2019 "%s (decoder): resolution change, frame size %ux%u -> %ux%u, "
2020 "width %u bit %d, pix_fromat_changed %d, actual_video_width %d, continue read ...\n",
2029 seq_change_read_count++;
2052 __func__, device_type);
2100 __func__, device_type);
2140 __func__, device_type);
2180 __func__, device_type);
2201 uint32_t namespace_num, uint32_t sriov_index)
2204 __func__, namespace_num, sriov_index);
2225 __func__, device_handle, mode);
2244 ni_device_handle_t device_handle_t,
2245 uint32_t over_provision)
2248 float f_over_provision = 0;
2249 memcpy(&f_over_provision, &over_provision,
sizeof(int32_t));
2251 __func__, device_handle, device_handle_t, f_over_provision);
2287 int video_height,
int alignment,
2288 int metadata_flag,
int factor,
2289 int hw_frame_count,
int is_planar)
2291 void* p_buffer = NULL;
2292 int metadata_size = 0;
2294 int width_aligned = video_width;
2295 int height_aligned = video_height;
2297 if ((!p_frame) || ((factor!=1) && (factor!=2) && (factor !=4))
2302 "factor %d, video_width %d, video_height %d\n",
2303 __func__, factor, video_width, video_height);
2318 width_aligned = ((((video_width * factor) + 127) / 128) * 128) / factor;
2319 height_aligned = ((video_height + 1) / 2) * 2;
2324 height_aligned = ((video_height + 1) / 2) * 2;
2332 width_aligned = ((video_width + 31) / 32) * 32;
2333 height_aligned = ((video_height + 7) / 8) * 8;
2336 height_aligned = ((video_height + 15) / 16) * 16;
2340 int luma_size = width_aligned * height_aligned * factor;
2345 int chroma_width_aligned = ((((video_width / 2 * factor) + 127) / 128) * 128) / factor;
2349 chroma_width_aligned =
2350 ((((video_width * factor) + 127) / 128) * 128) / factor;
2352 int chroma_height_aligned = height_aligned / 2;
2353 chroma_b_size = chroma_r_size = chroma_width_aligned * chroma_height_aligned * factor;
2361 chroma_b_size = chroma_r_size = 0;
2367 chroma_b_size = luma_size / 4;
2368 chroma_r_size = chroma_b_size;
2373 if (hw_frame_count == 0)
2374 buffer_size = luma_size + chroma_b_size + chroma_r_size + metadata_size;
2388 "%s: free current p_frame, p_frame->buffer_size=%u\n", __func__,
2426 p_frame->
data_len[1] = chroma_b_size;
2427 p_frame->
data_len[2] = chroma_r_size;
2446 ni_log(
NI_LOG_DEBUG,
"ni_frame_buffer_alloc: p_buffer %p p_data [%p %p %p %p] data_len [%d %d %d %d] video_width %d video_height %d\n", p_frame->
p_buffer, p_frame->
p_data[0], p_frame->
p_data[1], p_frame->
p_data[2], p_frame->
p_data[3], p_frame->
data_len[0], p_frame->
data_len[1], p_frame->
data_len[2], p_frame->
data_len[3], p_frame->
video_width, p_frame->
video_height);
2485 int video_height,
int alignment,
2486 int metadata_flag,
int factor,
2487 int hw_frame_count,
int is_planar,
2494 if (((factor!=1) && (factor!=2) && (factor !=4))
2499 "factor %d, video_width %d, video_height %d\n",
2500 __func__, factor, video_width, video_height);
2527 dst_stride, height_aligned);
2535 video_height, dst_stride, alignment,
2557 int video_height,
int pixel_format)
2559 void *p_buffer = NULL;
2561 int width_aligned = video_width;
2562 int height_aligned = video_height;
2570 (video_height <= 0))
2573 "ERROR: %s passed parameters are null or not supported, "
2574 "video_width %d, video_height %d\n",
2575 __func__, video_width, video_height);
2579 switch (pixel_format)
2585 luma_size = width_aligned * height_aligned;
2588 chroma_r_size = chroma_b_size;
2594 luma_size = width_aligned * height_aligned * 2;
2596 chroma_r_size = chroma_b_size;
2602 luma_size = width_aligned * height_aligned;
2603 chroma_b_size = width_aligned * height_aligned / 2;
2610 luma_size = width_aligned * height_aligned * 2;
2616 height_aligned = video_height;
2618 luma_size = width_aligned * height_aligned;
2619 chroma_b_size = luma_size;
2625 height_aligned = video_height;
2627 luma_size = width_aligned * height_aligned * 2;
2637 height_aligned = video_height;
2639 luma_size = width_aligned * height_aligned * 4;
2645 height_aligned = video_height;
2647 luma_size = width_aligned * height_aligned;
2648 chroma_b_size = luma_size;
2649 chroma_r_size = luma_size;
2657 buffer_size = luma_size + chroma_b_size + chroma_r_size;
2663 __func__, luma_size, chroma_b_size, chroma_r_size, buffer_size);
2669 "%s: free current p_frame, p_frame->buffer_size=%u\n", __func__,
2681 "ERROR %d: %s() Cannot allocate p_frame buffer.\n",
NI_ERRNO,
2699 p_frame->
data_len[1] = chroma_b_size;
2700 p_frame->
data_len[2] = chroma_r_size;
2751 int video_width,
int video_height,
2752 int alignment,
int factor,
2760 if ((!p_frame) || ((factor!=1) && (factor!=2))
2765 "factor %d, video_width %d, video_height %d\n",
2766 __func__, factor, video_width, video_height);
2772 width_aligned = ((((video_width * factor) + 127) / 128) * 128) / factor;
2773 height_aligned = video_height;
2777 width_aligned = ((video_width + 31) / 32) * 32;
2778 height_aligned = ((video_height + 7) / 8) * 8;
2781 height_aligned = ((video_height + 15) / 16) * 16;
2786 width_aligned, height_aligned, video_width, video_height);
2788 int luma_size = width_aligned * height_aligned * factor;
2793 int chroma_width_aligned = ((((video_width / 2 * factor) + 127) / 128) * 128) / factor;
2796 chroma_width_aligned =
2797 ((((video_width * factor) + 127) / 128) * 128) / factor;
2799 int chroma_height_aligned = height_aligned / 2;
2800 chroma_b_size = chroma_r_size = chroma_width_aligned * chroma_height_aligned * factor;
2808 chroma_b_size = luma_size / 4;
2809 chroma_r_size = chroma_b_size;
2811 int buffer_size = luma_size + chroma_b_size + chroma_r_size +
2853 p_frame->
p_data[2] = p_frame->
p_data[1] + chroma_b_size;
2854 p_frame->
p_data[3] = p_frame->
p_data[2] + chroma_r_size;
2862 p_frame->
data_len[1] = chroma_b_size;
2863 p_frame->
data_len[2] = chroma_r_size;
2898 int width,
int height,
2899 const int linesize[],
2903 if ((!p_enc_ctx) || (!p_enc_params) || (!linesize)
2909 "p_enc_ctx %p, p_enc_params %p, linesize %p, "
2910 "width %d, height %d linesize[0] %d\n",
2911 __func__, p_enc_ctx, p_enc_params, linesize,
2912 width, height, (linesize) ? linesize[0] : 0);
2921 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s: not supported on device with FW API version < 6.Q\n", __func__);
2925 bool isrgba =
false;
2926 bool isplanar =
false;
2927 bool issemiplanar =
false;
2937 issemiplanar =
true;
2956 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s: semi-planar not supported on device with FW API version < 6.q\n", __func__);
2965 bool ishwframe = (p_enc_params->
hwframes) ?
true :
false;
2968 "p_enc_ctx %p, p_enc_params %p, linesize %p, "
2969 "width %d, height %d, linesize[0] %d linesize[1] %d\n",
2970 __func__, isrgba, issemiplanar, ishwframe, p_enc_ctx, p_enc_params, linesize,
2971 width, height, linesize[0], linesize[1]);
2973 if (linesize[0] <= max_linesize &&
2974 linesize[0] % 2 == 0 &&
2975 linesize[1] % 2 == 0 &&
2982 (!isplanar || linesize[2] == linesize[1])
3000 "luma_linesize %d, chroma_linesize %d, "
3001 "linesize[0] %d, linesize[1] %d\n",
3003 linesize[0], linesize[1]);
3010 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"%s: linesize changed from %u %u to %u %u - resolution change?\n", __func__,
3012 linesize[0], linesize[1]);
3044 int video_width,
int video_height,
3045 const int linesize[],
const uint8_t *data[],
3050 if ((!p_frame) || (!linesize) || (!data))
3053 "p_frame %p, linesize %p, data %p\n",
3054 __func__, p_frame, linesize, data);
3059 "%s: resolution=%dx%d linesize=%d/%d/%d "
3060 "data=%p %p %p extra_len=%d\n",
3061 __func__, video_width, video_height,
3062 linesize[0], linesize[1], linesize[2],
3063 data[0], data[1], data[2], extra_len);
3071 p_frame->
p_buffer = (uint8_t *)data[0];
3072 p_frame->
p_data[0] = (uint8_t *)data[0];
3073 p_frame->
p_data[1] = (uint8_t *)data[1];
3074 p_frame->
p_data[2] = (uint8_t *)data[2];
3076 int luma_size = linesize[0] * video_height;
3077 int chroma_b_size = 0;
3078 int chroma_r_size = 0;
3082 chroma_b_size = linesize[1] * (video_height / 2);
3085 chroma_r_size = linesize[2] * (video_height / 2);
3089 uint32_t start_offset;
3090 uint32_t total_start_len = 0;
3096 if ((data[1] && (data[0] + luma_size != data[1]))
3097 || (data[2] && (data[1] + chroma_b_size != data[2])))
3108 total_start_len += p_frame->
start_len[i];
3116 total_start_len = p_frame->
start_len[0];
3129 if (total_start_len)
3141 int start_buffer_offset = 0;
3148 start_buffer_offset += p_frame->
start_len[i];
3154 p_frame->
data_len[1] = chroma_b_size;
3155 p_frame->
data_len[2] = chroma_r_size;
3162 "%s: success: p_metadata_buffer %p metadata_buffer_size %u "
3163 "p_start_buffer %p start_buffer_size %u data_len %u %u %u\n",
3193 int width,
int height,
3194 const int linesize[],
int pixel_format)
3197 if ((!p_upl_ctx) || (!linesize)
3203 "p_enc_ctx %p, linesize %p, "
3204 "width %d, height %d linesize[0] %d\n",
3205 __func__, p_upl_ctx, linesize,
3206 width, height, (linesize) ? linesize[0] : 0);
3215 ni_log2(p_upl_ctx,
NI_LOG_DEBUG,
"%s: not supported on device with FW API version < 6.S\n", __func__);
3225 "p_upl_ctx %p, linesize %p, "
3226 "width %d, height %d, linesize[0] %d\n",
3227 __func__, pixel_format, p_upl_ctx, linesize,
3228 width, height, linesize[0]);
3230 int bit_depth_factor;
3231 bool isrgba =
false;
3232 bool isplanar =
false;
3233 bool issemiplanar =
false;
3235 switch (pixel_format)
3239 bit_depth_factor = 1;
3243 bit_depth_factor = 2;
3246 issemiplanar =
true;
3247 bit_depth_factor = 1;
3250 issemiplanar =
true;
3251 bit_depth_factor = 2;
3258 bit_depth_factor = 4;
3271 ni_log2(p_upl_ctx,
NI_LOG_DEBUG,
"%s: semi-planar not supported on device with FW API version < 6.q\n", __func__);
3276 if (linesize[0] <= max_linesize &&
3285 linesize[2] == linesize[1])
3291 linesize[1] == linesize[0])
3326 int video_height,
int linesize[],
3327 int alignment,
int extra_len,
3328 bool alignment_2pass_wa)
3330 void* p_buffer = NULL;
3339 "p_frame %p, linesize %p, video_width %d, video_height %d\n",
3340 __func__, p_frame, linesize, video_width, video_height);
3346 height_aligned = ((video_height + 1) / 2) * 2;
3349 height_aligned = ((video_height + 7) / 8) * 8;
3353 height_aligned = ((video_height + 15) / 16) * 16;
3362 "%s: aligned=%dx%d org=%dx%d linesize=%d/%d/%d "
3364 __func__, video_width, height_aligned, video_width, video_height,
3365 linesize[0], linesize[1], linesize[2], extra_len);
3367 int luma_size = linesize[0] * height_aligned;
3372 chroma_b_size = chroma_r_size = linesize[1] * (height_aligned / 2);
3373 if (alignment_2pass_wa)
3376 chroma_r_size = linesize[1] * (((height_aligned + 31) / 32) * 32) / 2;
3382 chroma_b_size = luma_size / 4;
3383 chroma_r_size = luma_size / 4;
3387 int buffer_size = luma_size + chroma_b_size + chroma_r_size + extra_len;
3395 "%s: free current p_frame, "
3396 "p_frame->buffer_size=%u\n",
3413 memset(p_buffer, 0, buffer_size);
3424 p_frame->
p_data[1] = (uint8_t*)p_frame->
p_data[0] + luma_size;
3425 p_frame->
p_data[2] = (uint8_t*)p_frame->
p_data[1] + chroma_b_size;
3433 p_frame->
data_len[1] = chroma_b_size;
3434 p_frame->
data_len[2] = chroma_r_size;
3441 "%s: success: p_frame->p_buffer %p "
3442 "p_frame->buffer_size=%u\n",
3562 int video_height,
int linesize[],
3563 int extra_len,
bool alignment_2pass_wa)
3565 void* p_buffer = NULL;
3574 "p_frame %p, linesize %p, video_width %d, video_height %d\n",
3575 __func__, p_frame, linesize, video_width, video_height);
3579 height_aligned = ((video_height + 1) / 2) * 2;
3587 "%s: aligned=%dx%d org=%dx%d linesize=%d/%d/%d extra_len=%d\n",
3588 __func__, video_width, height_aligned, video_width, video_height,
3589 linesize[0], linesize[1], linesize[2], extra_len);
3591 int luma_size = linesize[0] * height_aligned;
3592 int chroma_br_size = luma_size / 2;
3594 if (alignment_2pass_wa)
3597 chroma_br_size = linesize[0] * ((((height_aligned + 31) / 32) * 32) / 2);
3601 int buffer_size = luma_size + chroma_br_size + extra_len;
3625 memset(p_buffer, 0, buffer_size);
3637 p_frame->
p_data[1] = (uint8_t*)p_frame->
p_data[0] + luma_size;
3638 p_frame->
p_data[2] = (uint8_t*)p_frame->
p_data[1] + chroma_br_size;
3645 p_frame->
data_len[1] = chroma_br_size;
3696 int video_width,
int video_height,
3697 int linesize[],
int alignment,
3699 bool alignment_2pass_wa)
3704 linesize, alignment, extra_len,
3705 alignment_2pass_wa);
3710 linesize, extra_len,
3711 alignment_2pass_wa);
3753 "%s: close p_surface->dma_buf_fd %d "
3754 "ui16FrameIdx %u\n",
3770 p_frame->
p_data[i] = NULL;
3839 p_frame->
p_data[i] = NULL;
3879 void* p_buffer = NULL;
3880 int metadata_size = 0;
3887 packet_size + metadata_size);
3889 if (!p_packet || !packet_size)
3914 "%s: free current p_packet, p_packet->buffer_size=%u\n", __func__,
3920 __func__, buffer_size);
3977 if (!p_buffer || !p_packet || !buffer_size)
3985 ni_log(
NI_LOG_INFO,
"Info: %s: Warning buffer not 4k aligned = %p!. Will do an extra copy\n",
3986 __func__, p_buffer);
4064 "%s(): no need to free previous av1 packet buffers\n", __func__);
4100 int ni_packet_copy(
void* p_destination,
const void*
const p_source,
int cur_size,
void* p_leftover,
int* p_prev_size)
4103 int padding_size = 0;
4104 int prev_size = p_prev_size == NULL? 0 : *p_prev_size;
4106 int total_size = cur_size + prev_size;
4107 uint8_t* p_src = (uint8_t*)p_source;
4108 uint8_t* p_dst = (uint8_t*)p_destination;
4109 uint8_t* p_lftover = (uint8_t*)p_leftover;
4118 if ((0 == cur_size) && (0 == prev_size))
4123 if (((0 != cur_size) && (!p_source)) || (!p_destination) || (!p_leftover))
4130 if (copy_size > total_size)
4132 padding_size = copy_size - total_size;
4137 memcpy(p_dst, p_lftover, prev_size);
4142 memcpy(p_dst, p_src, cur_size);
4147 memset(p_dst, 0, padding_size);
4151 "%s(): exit, cur_size=%d, copy_size=%d, "
4152 "prev_size=%d, padding_size=%d\n", __func__, cur_size,
4153 copy_size, *p_prev_size, padding_size);
4178 "ERROR: %s No memory or exceeding max aux_data number !\n",
4184 ret->
size = data_size;
4185 ret->
data = calloc(1, data_size);
4211 const uint8_t *raw_data,
4217 memcpy(ret->
data, raw_data, data_size);
4261 if (aux->
type == type)
4312 int fps_num,
int fps_denom,
4313 long bit_rate,
int width,
4464 p_param->
bitrate = (int)bit_rate;
4564 p_enc->
qcomp = (float)0.6;
4656 ni_log(
NI_LOG_ERROR,
"AV1 Picture Width not aligned to %d - picture will be cropped\n",
4661 ni_log(
NI_LOG_ERROR,
"AV1 Picture Height not aligned to %d - picture will be cropped\n",
4730 int fps_num,
int fps_denom,
4731 long bit_rate,
int width,
4757 if(fps_num <= 0 || fps_denom <= 0)
4761 ni_log(
NI_LOG_INFO,
"%s(): FPS is not set, setting the default FPS to 30\n", __func__);
4818 p_param->
bitrate = (int)bit_rate;
4850 char keyChar[10] =
"";
4852 char valChar[10] =
"";
4858 FILE *reconf = NULL;
4867 ni_fopen(&reconf, reconf_file,
"r");
4876 while ((readc = fgetc(reconf)) != EOF)
4883 ni_strncat(keyChar, 10, (
const char *)(&readc), 1);
4887 ni_strncat(valChar, 10, (
const char *)(&readc), 1);
4890 else if (readc ==
':')
4893 key =
atoi(keyChar);
4894 hash_map[idx][0] = key;
4896 else if (readc ==
',')
4901 "ERROR: Number of entries per line in reconfig file is greater then the "
4907 val =
atoi(valChar);
4908 hash_map[idx][valIdx] = val;
4910 memset(valChar, 0, 10);
4912 else if (readc ==
'\n')
4917 "ERROR: Number of lines in reconfig file is greater then the "
4924 val =
atoi (valChar);
4925 hash_map[idx][valIdx] = val;
4927 memset(keyChar,0,10);
4928 memset(valChar,0,10);
4933 ni_log(
NI_LOG_ERROR,
"ERROR: character %c in reconfig file. this may lead to mistaken reconfiguration values\n", readc);
4942 "ERROR %d: %s(): Incorrect format / "
4943 "incomplete Key/Value pair in reconfig_file: %s\n",
4954 char valChar[5] =
"";
4960 FILE *reconf = NULL;
4962 if (!customize_file)
4969 ni_fopen(&reconf, customize_file,
"r");
4973 NI_ERRNO, __func__, customize_file);
4978 while ((readc = fgetc(reconf)) != EOF)
4983 ni_strncat(valChar, 5, (
const char *)(&readc), 1);
4985 else if (readc ==
'-') {
4988 else if (readc ==
',')
4993 "ERROR: Number of qpIdx %d greater then the limit of %d or"
4994 "Number of levelIdx %d greater then the limit of %d\n",
5001 qp_map[levelIdx][qpIdx] = val;
5003 val = clip3(0, 32,
atoi(valChar));
5004 qp_map[levelIdx][qpIdx] = val * -1;
5007 memset(valChar, 0, 5);
5010 else if (readc ==
'\n')
5015 "ERROR: Number of qpIdx %d greater then the limit of %d or"
5016 "Number of levelIdx %d greater then the limit of %d\n",
5023 qp_map[levelIdx][qpIdx] = val;
5025 val = clip3(0, 32,
atoi(valChar));
5026 qp_map[levelIdx][qpIdx] = val * -1;
5029 memset(valChar, 0, 5);
5035 ni_log(
NI_LOG_ERROR,
"ERROR: character %c in reconfig file. this may lead to mistaken reconfiguration values\n", readc);
5046 #define atoi(p_str) ni_atoi(p_str, &b_error)
5047 #define atof(p_str) ni_atof(p_str, &b_error)
5048 #define atobool(p_str) (ni_atobool(p_str, &b_error))
5065 const char *name,
char *value)
5067 bool b_error =
false;
5068 bool bNameWasBool =
false;
5069 bool bValueWasNull = !value;
5071 char nameBuf[64] = { 0 };
5072 const char delim[2] =
",";
5073 const char xdelim[2] =
"x";
5095 if (name[0] ==
'-' && name[1] ==
'-')
5101 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
5104 ni_strcpy(nameBuf,
sizeof(nameBuf), name);
5105 while ((c = strchr(nameBuf,
'_')) != 0)
5116 else if (value[0] ==
'=')
5121 #if defined(_MSC_VER)
5122 #define OPT(STR) else if (!_stricmp(name, STR))
5123 #define OPT2(STR1, STR2) \
5124 else if (!_stricmp(name, STR1) || !_stricmp(name, STR2))
5126 #define OPT(STR) else if (!strcasecmp(name, STR))
5127 #define OPT2(STR1, STR2) else if (!strcasecmp(name, STR1) || !strcasecmp(name, STR2))
5132 if (!strncmp(value,
"hw",
sizeof(
"hw"))){
5135 else if (!strncmp(value,
"sw",
sizeof(
"sw"))) {
5146 if (
atoi(value) == 1)
5151 if (
atoi(value) == 1)
5156 if (
atoi(value) == 1)
5161 if (
atoi(value) == 1)
5166 if (
atoi(value) == 1)
5171 if (
atoi(value) == 1 ||
atoi(value) == 2)
5176 if (
atoi(value) == 1 ||
atoi(value) == 2)
5181 if (
atoi(value) == 1 ||
atoi(value) == 2)
5186 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5189 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5194 "ERROR: %s():cropMode0 input can only be <manual,auto> got %s\n",
5201 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5204 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5209 "ERROR: %s():cropMode1 input can only be <manual,auto> got %s\n",
5216 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5219 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5224 "ERROR: %s():cropMode2 input can only be <manual,auto> got %s\n",
5231 char *saveptr = NULL;
5232 chunk =
ni_strtok(value, delim, &saveptr);
5233 for (i = 0; i < 4; i++)
5240 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5242 p_dec->
cr_expr[0][i][k] = chunk[j];
5250 chunk =
ni_strtok(NULL, delim, &saveptr);
5267 char *saveptr = NULL;
5268 chunk =
ni_strtok(value, delim, &saveptr);
5269 for (i = 0; i < 4; i++)
5276 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5278 p_dec->
cr_expr[1][i][k] = chunk[j];
5286 chunk =
ni_strtok(NULL, delim, &saveptr);
5304 char *saveptr = NULL;
5305 chunk =
ni_strtok(value, delim, &saveptr);
5306 for (i = 0; i < 4; i++)
5313 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5315 p_dec->
cr_expr[2][i][k] = chunk[j];
5323 chunk =
ni_strtok(NULL, delim, &saveptr);
5344 if (*chunk == xdelim[0]) {
5353 char *saveptr = NULL;
5354 chunk =
ni_strtok(value, xdelim, &saveptr);
5355 for (i = 0; i < 2; i++)
5362 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5364 p_dec->
sc_expr[0][i][k] = chunk[j];
5372 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5385 if (*chunk == xdelim[0]) {
5394 char *saveptr = NULL;
5395 chunk =
ni_strtok(value, xdelim, &saveptr);
5396 for (i = 0; i < 2; i++)
5403 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5405 p_dec->
sc_expr[1][i][k] = chunk[j];
5413 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5426 if (*chunk == xdelim[0]) {
5435 char *saveptr = NULL;
5436 chunk =
ni_strtok(value, xdelim, &saveptr);
5437 for (i = 0; i < 2; i++)
5444 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5446 p_dec->
sc_expr[2][i][k] = chunk[j];
5454 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5464 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5472 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5480 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5488 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5491 "and must be even number and less than or equal to 128. Got: %s\n",
5500 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5503 "and must be even number and less than or equal to 128. Got: %s\n",
5511 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5514 "and must be even number and less than or equal to 128. Got: %s\n",
5522 if (!strncmp(value,
"up",
sizeof(
"up"))){
5525 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5536 if (!strncmp(value,
"up",
sizeof(
"up"))){
5539 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5550 if (!strncmp(value,
"up",
sizeof(
"up"))){
5553 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5564 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5572 if (
atoi(value) < 0)
5589 if (
atoi(value) < 0)
5597 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5605 if (
atoi(value) < 0)
5613 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5656 if (strncmp(value,
"tolerant",
sizeof(
"tolerant")) == 0) {
5658 }
else if (strncmp(value,
"ignore",
sizeof(
"ignore")) == 0) {
5660 }
else if (strncmp(value,
"skip",
sizeof(
"skip")) == 0) {
5662 }
else if (strncmp(value,
"best_effort",
sizeof(
"best_effort")) == 0) {
5664 }
else if (strncmp(value,
"limited_error",
sizeof(
"limited_error")) == 0) {
5666 }
else if (strncmp(value,
"best_effort_out_dc",
sizeof(
"best_effort_out_dc")) == 0) {
5674 if (
atoi(value) != 0 &&
5684 if (
atoi(value) < 0 || (
atoi(value) > 100))
5692 if (
atoi(value) < 0 || (
atoi(value) > 2))
5700 if (
atoi(value) < 0 || (
atoi(value) > 1))
5708 if (
atoi(value) < 0 ||
atoi(value) > 255)
5716 if (
atoi(value) < 0 ||
atoi(value) > 1)
5724 if (
atoi(value) != 0 &&
atoi(value) != 1)
5732 if (
atoi(value) < 0 ||
5741 if (
atoi(value) != 0 &&
atoi(value) != 1)
5749 if (
atoi(value) < 0 ||
5758 if (
atoi(value) < 0 ||
atoi(value) > 1)
5766 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5774 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5782 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5797 b_error |= bValueWasNull && !bNameWasBool;
5806 #define atoi(p_str) ni_atoi(p_str, &b_error)
5807 #define atof(p_str) ni_atof(p_str, &b_error)
5808 #define atobool(p_str) (ni_atobool(p_str, &b_error))
5825 const char *name,
const char *value)
5827 bool b_error =
false;
5828 bool bNameWasBool =
false;
5829 bool bValueWasNull = !value;
5831 char nameBuf[64] = { 0 };
5851 if (name[0] ==
'-' && name[1] ==
'-')
5857 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
5860 ni_strcpy(nameBuf,
sizeof(nameBuf), name);
5861 while ((c = strchr(nameBuf,
'_')) != 0)
5872 else if (value[0] ==
'=')
5877 #if defined(_MSC_VER)
5878 #define OPT(STR) else if (!_stricmp(name, STR))
5879 #define OPT2(STR1, STR2) \
5880 else if (!_stricmp(name, STR1) || !_stricmp(name, STR2))
5882 #define OPT(STR) else if (!strcasecmp(name, STR))
5883 #define OPT2(STR1, STR2) else if (!strcasecmp(name, STR1) || !strcasecmp(name, STR2))
5885 #define COMPARE(STR1, STR2, STR3) \
5886 if ((atoi(STR1) > (STR2)) || (atoi(STR1) < (STR3))) \
5888 return NI_RETCODE_PARAM_ERROR_OOR; \
5929 if (0 >
atoi(value))
5937 if (0 !=
atoi(value) && 1 !=
atoi(value))
5947 #ifndef DEPRECATION_AS_ERROR
5950 if (0 !=
atoi(value) && 1 !=
atoi(value))
5961 if (0 !=
atoi(value) && 1 !=
atoi(value))
5984 if (
atof(value) <= 10)
6142 #ifndef DEPRECATION_AS_ERROR
6145 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6184 if (0 !=
atoi(value) && 1 !=
atoi(value))
6191 #ifndef DEPRECATION_AS_ERROR
6198 if (!_strnicmp(value,
"ratio", 5))
6200 if (!strncasecmp(value,
"ratio", 5))
6203 char value_buf[32] = {0};
6204 for (i = 0; i <
sizeof(value_buf); i++)
6206 if (value[i+6] ==
']')
6210 value_buf[i] = value[i+6];
6212 if (i ==
sizeof(value_buf) ||
atoi(value_buf) < 0)
6221 int size =
atoi(value);
6232 if (!_strnicmp(value,
"ratio", 5))
6234 if (!strncasecmp(value,
"ratio", 5))
6237 char value_buf[32] = {0};
6238 for (i = 0; i <
sizeof(value_buf); i++)
6240 if (value[i+6] ==
']')
6244 value_buf[i] = value[i+6];
6246 if (i ==
sizeof(value_buf) ||
atoi(value_buf) < 0)
6255 int size =
atoi(value) / 8;
6265 if (0 !=
atoi(value) && 1 !=
atoi(value))
6310 if (
atoi(value) <= 0 )
6320 if (
atoi(value) <= 0)
6368 if (0 !=
atoi(value) && 1 !=
atoi(value))
6397 if (0 !=
atoi(value) && 1 !=
atoi(value))
6427 if ((
atoi(value) > 255) || (
atoi(value) < 0))
6435 if (
atoi(value) != 0 &&
atoi(value) != 5)
6443 if ((
atoi(value) > 3) || (
atoi(value) < 1))
6451 const char delim[2] =
",";
6454 char *v = _strdup(value);
6456 char *v = strdup(value);
6458 char *saveptr = NULL;
6462 if ((
atoi(chunk) > 65535) || (
atoi(chunk) < 0))
6468 chunk =
ni_strtok(NULL, delim, &saveptr);
6471 if ((
atoi(chunk) > 65535) || (
atoi(chunk) < 0))
6496 #define STRDUP(value) _strdup(value);
6498 #define STRDUP(value) strdup(value);
6500 const char G[2] =
"G";
6501 const char B[2] =
"B";
6502 const char R[2] =
"R";
6503 const char W[2] =
"W";
6504 const char L[2] =
"L";
6505 const char P[2] =
"P";
6506 const char parL[2] =
"(";
6507 const char comma[2] =
",";
6508 const char parR[2] =
")";
6509 int synCheck_GBRWLPCP[8];
6510 int posCheck_GBRWL[5] = {0};
6515 for (i = 0; i<8; i++)
6517 synCheck_GBRWLPCP[i] = 0;
6526 synCheck_GBRWLPCP[0]++;
6527 posCheck_GBRWL[0] = i;
6529 else if (*chunk == B[0])
6531 synCheck_GBRWLPCP[1]++;
6532 posCheck_GBRWL[1] = i;
6534 else if (*chunk == R[0])
6536 synCheck_GBRWLPCP[2]++;
6537 posCheck_GBRWL[2] = i;
6539 else if (*chunk == W[0])
6541 synCheck_GBRWLPCP[3]++;
6542 posCheck_GBRWL[3] = i;
6544 else if (*chunk == L[0])
6546 synCheck_GBRWLPCP[4]++;
6547 posCheck_GBRWL[4] = i;
6549 else if (*chunk == parL[0])
6551 synCheck_GBRWLPCP[5]++;
6553 else if (*chunk == comma[0])
6555 synCheck_GBRWLPCP[6]++;
6557 else if (*chunk == parR[0])
6559 synCheck_GBRWLPCP[7]++;
6565 if (synCheck_GBRWLPCP[0] != 1 || synCheck_GBRWLPCP[1] != 1 || synCheck_GBRWLPCP[2] != 1 ||
6566 synCheck_GBRWLPCP[3] != 1 || synCheck_GBRWLPCP[4] != 1 || synCheck_GBRWLPCP[5] != 5 ||
6567 synCheck_GBRWLPCP[6] != 5 || synCheck_GBRWLPCP[7] != 5)
6573 #define GBRWLPARSE(OUT1,OUT2,OFF,IDX) \
6575 char *v = STRDUP(value); \
6576 chunk = v + posCheck_GBRWL[IDX]; \
6578 while (chunk != NULL) \
6580 if (*chunk == parL[0] && i == 1+(OFF)) \
6584 if((OFF) == 1 && *chunk != P[0] && i == 1) \
6588 if (*chunk == parR[0]) \
6599 return NI_RETCODE_PARAM_INVALID_VALUE; \
6601 subchunk = malloc(i - 1 - (OFF)); \
6602 if (subchunk == NULL) \
6605 return NI_RETCODE_ERROR_MEM_ALOC; \
6607 memcpy(subchunk, v + posCheck_GBRWL[IDX] + 2 + (OFF), i - 2 - (OFF)); \
6608 subchunk[i - 2 - (OFF)] = '\0'; \
6609 char *saveptr = NULL; \
6610 chunk = ni_strtok(subchunk, comma, &saveptr); \
6611 if (chunk != NULL) \
6613 if(atoi(chunk) < 0) \
6616 if(subchunk != NULL){ \
6619 return NI_RETCODE_PARAM_INVALID_VALUE; \
6621 *(OUT1) = atoi(chunk); \
6623 chunk = ni_strtok(NULL, comma, &saveptr); \
6624 if (chunk != NULL) \
6626 if(atoi(chunk) < 0) \
6629 if(subchunk != NULL){ \
6632 return NI_RETCODE_PARAM_INVALID_VALUE; \
6634 *(OUT2) = atoi(chunk); \
6648 if (
atoi(value)!= 0 && ((
atoi(value) > 40 ) || (
atoi(value) < 4)))
6656 if (
atoi(value) != 0 &&
atoi(value) != 1)
6664 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6672 if (
atoi(value) != 0 &&
atoi(value) != 1)
6680 if (
atoi(value) != 0 &&
atoi(value) != 1)
6692 if (
atoi(value) < 1 ||
atoi(value) > 2)
6700 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6713 if ((
atoi(value) < 0) || (
atoi(value) > 3))
6735 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6764 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6772 if ((
atoi(value) < 0) || (
atoi(value) > 9))
6780 if ((
atoi(value) > 12) || (
atoi(value) < -12))
6790 if ((
atoi(value) > 300) || (
atoi(value) < 1))
6798 if ((
atoi(value) > 2) || (
atoi(value) < 0))
6806 if ((
atoi(value) > 15) || (
atoi(value) < 0))
6814 if ((
atoi(value) > 500) || (
atoi(value) < 0))
6822 if ((
atoi(value) > 1) || (
atoi(value) < 0))
6830 if ((
atoi(value) > 1) || (
atoi(value) < 0))
6877 if (
atoi(value) != 0 &&
atoi(value) != 1)
6885 if (
atoi(value) < 0 ||
atoi(value) > 3)
6893 if (
atoi(value) < 1)
6901 if (
atoi(value) < 0 ||
atoi(value) > 1)
6909 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6917 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6925 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6937 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6945 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6951 ni_log(
NI_LOG_ERROR,
"Cannot set enableAIEnhance and enableHVSPlus at same time, just enableHVSPlus\n");
6957 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6965 if ((
atoi(value) != 0) && (
atoi(value) != 1) && (
atoi(value) != -1))
6973 if ((
atoi(value) == 0) || (
atoi(value) > 3))
6981 if ((
atoi(value) == 0) || (
atoi(value) > 2))
7007 if ((
atoi(value) < 0) ||
7016 if ((
atoi(value) < 0) ||
7025 if ((
atoi(value) > 51) || (
atoi(value) < -1))
7033 if ((
atof(value) > 1.0) || (
atof(value) < 0.0))
7041 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7049 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7057 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7065 if ((
atoi(value) > 10) || (
atoi(value) < 1))
7073 if ((
atof(value) > 10.0) || (
atof(value) < 0.01))
7081 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7089 if ((
atof(value) > 10.0) || (
atof(value) < 0.01))
7097 if ((
atof(value) > 1.0) || (
atof(value) < 0.1))
7105 if ((
atoi(value) > 51) || (
atoi(value) < -1))
7122 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7130 if ((
atoi(value) > 51) || (
atoi(value) < -1))
7138 if (((
atof(value) < 0.0) && (
atof(value) != -1.0)) ||
7139 (
atof(value) > 51.00))
7147 if ((
atoi(value) < 0) || (
atoi(value) > 31))
7155 if (
atoi(value) != 0 &&
atoi(value) != 1 &&
atoi(value) != 6)
7166 if ((
atoi(value) < 0 ||
atoi(value) > 6))
7177 if ((
atoi(value) < 0 ||
atoi(value) > 10))
7185 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7193 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7201 if (
atoi(value) < 0 ||
atoi(value) > 1)
7209 if (
atoi(value) < 0)
7217 if (
atoi(value) < 0 ||
atoi(value) > 255)
7225 if (
atoi(value) != 0 &&
atoi(value) != 1)
7233 if (
atoi(value) <= 0)
7241 if ((
atoi(value) < 0 ||
atoi(value) > 2) &&
7242 atoi(value) != 5 &&
atoi(value) != 6)
7254 if (
atoi(value) != 0 &&
atoi(value) != 1)
7262 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7270 if ((
atof(value) > 1.0) || (
atof(value) < 0.0))
7278 if (
atoi(value) < 0 ||
atoi(value) > 2)
7286 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7312 if (
atoi(value) < 0 ||
atoi(value) > 2)
7329 if (
atoi(value) < 1 ||
atoi(value) > 4)
7337 if (
atoi(value) < 0 ||
atoi(value) > 1)
7345 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7353 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7361 if (
atoi(value)!= 0 && ((
atoi(value) > 40 ) || (
atoi(value) < 4)))
7369 if (
atoi(value) != 0 &&
atoi(value) != 1)
7377 if (
atoi(value) != 0 &&
atoi(value) != 1)
7385 if (
atoi(value) != 0 &&
atoi(value) != 1)
7393 if (
atoi(value) < 0 ||
atoi(value) > 100)
7401 if (
atoi(value) < 0 ||
atoi(value) > 100)
7409 const char delim[2] =
",";
7412 char *v = _strdup(value);
7414 char *v = strdup(value);
7416 char *saveptr = NULL;
7427 chunk =
ni_strtok(NULL, delim, &saveptr);
7434 const char delim[2] =
",";
7437 char *v = _strdup(value);
7439 char *v = strdup(value);
7441 char *saveptr = NULL;
7449 if (
atof(chunk) <= 10)
7457 chunk =
ni_strtok(NULL, delim, &saveptr);
7464 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7472 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7492 if (
atoi(value) < 0 ||
atoi(value) > 3)
7500 if (
atoi(value) < 0 ||
atoi(value) > 1)
7508 if (
atoi(value) < 0 ||
atoi(value) > 3)
7522 b_error |= bValueWasNull && !bNameWasBool;
7531 #define atoi(p_str) ni_atoi(p_str, &b_error)
7532 #define atof(p_str) ni_atof(p_str, &b_error)
7533 #define atobool(p_str) (ni_atobool(p_str, &b_error))
7554 bool b_error =
false;
7555 bool bNameWasBool =
false;
7556 bool bValueWasNull = !value;
7559 char nameBuf[64] = { 0 };
7580 if (name[0] ==
'-' && name[1] ==
'-')
7586 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
7589 ni_strcpy(nameBuf,
sizeof(nameBuf), name);
7590 while ((c = strchr(nameBuf,
'_')) != 0)
7601 else if (value[0] ==
'=')
7606 #if defined(_MSC_VER)
7607 #define OPT(STR) else if (!_stricmp(name, STR))
7609 #define OPT(STR) else if (!strcasecmp(name, STR))
7634 OPT(NI_ENC_GOP_PARAMS_G0_PIC_QP)
7638 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC_L0)
7642 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L0)
7646 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L1)
7663 OPT(NI_ENC_GOP_PARAMS_G1_PIC_QP)
7667 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC_L0)
7671 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L0)
7675 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L1)
7692 OPT(NI_ENC_GOP_PARAMS_G2_PIC_QP)
7696 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC_L0)
7700 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L0)
7704 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L1)
7721 OPT(NI_ENC_GOP_PARAMS_G3_PIC_QP)
7725 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC_L0)
7729 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L0)
7733 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L1)
7750 OPT(NI_ENC_GOP_PARAMS_G4_PIC_QP)
7754 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC_L0)
7758 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L0)
7762 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L1)
7779 OPT(NI_ENC_GOP_PARAMS_G5_PIC_QP)
7783 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC_L0)
7787 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L0)
7791 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L1)
7808 OPT(NI_ENC_GOP_PARAMS_G6_PIC_QP)
7812 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC_L0)
7816 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L0)
7820 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L1)
7837 OPT(NI_ENC_GOP_PARAMS_G7_PIC_QP)
7841 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC_L0)
7845 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L0)
7849 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L1)
8350 b_error |= bValueWasNull && !bNameWasBool;
8400 if ((!p_ctx) || (!p_data))
8417 "ERROR: %s() keep alive thread has been closed, "
8418 "hw:%d, session:%d\n",
8435 switch (device_type)
8439 int seq_change_read_count = 0;
8450 uint32_t aligned_width;
8462 ", DFVWxDFVH %u x %u, AlWid %u, AVW x AVH %u x %u\n",
8467 if (0 == retval && seq_change_read_count)
8476 else if (retval < 0)
8492 "%s (decoder): resolution change, frame size %ux%u -> %ux%u, "
8493 "width %u bit %d, pix_fromat_changed %d, actual_video_width %d, continue read ...\n",
8502 seq_change_read_count++;
8534 __func__, device_type);
8566 if ((!hwdesc) || (!p_data))
8594 bool use_external_mutex =
false;
8595 uint32_t orig_session_id = p_ctx->
session_id;
8596 ni_device_handle_t orig_blk_io_handle = p_ctx->
blk_io_handle;
8601 ni_pthread_mutex_t *p_ctx_mutex = &(p_ctx->
mutex);
8607 use_external_mutex =
true;
8620 if (use_external_mutex)
8665 "%s function not supported in FW API version < 6rt\n",
8670 switch (device_type)
8719 if ((!hwdesc) || (!p_src_data))
8753 int video_height,
int extra_len)
8755 void* p_buffer = NULL;
8756 int height_aligned = video_height;
8792 memset(p_buffer, 0, buffer_size);
8804 p_frame->
p_data[0] = NULL;
8805 p_frame->
p_data[1] = NULL;
8806 p_frame->
p_data[2] = NULL;
8841 int32_t device_handle)
8849 "%s(): ui16FrameIdx=%d sessionId=%d device_handle=0x%x\n",
8873 int32_t saved_dma_buf_fd;
8883 "%s(): ui16FrameIdx=%d sessionId=%d device_handle=0x%x\n",
8918 uint32_t pool_size, uint32_t pool)
8980 "ERROR: %s function not supported in FW API version < 6r3\n",
8987 "ERROR: can't free or expand framepool of session 0x%x "
8988 "before init framepool\n", p_ctx->
session_id);
9029 if (!p_ctx || !p_params)
9057 void *p_scaler_config = NULL;
9060 uint32_t ui32LBA = 0;
9064 if (!p_ctx || !p_params)
9066 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() passed parameters are null!, return\n", __func__);
9088 memset(p_scaler_config, 0, buffer_size);
9094 memcpy(p_scaler_config, p_params, buffer_size);
9097 p_scaler_config, buffer_size, ui32LBA) < 0)
9100 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
9101 ", hw_id, %d, xcoder_inst_id: %d\n",
9108 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
9109 "hw_id, %d, xcoder_inst_id: %d\n",
9137 void *p_scaler_config = NULL;
9140 uint32_t ui32LBA = 0;
9144 if (!p_ctx || !p_params)
9146 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() passed parameters are null!, return\n", __func__);
9168 memset(p_scaler_config, 0, buffer_size);
9174 memcpy(p_scaler_config, p_params, buffer_size);
9177 p_scaler_config, buffer_size, ui32LBA) < 0)
9180 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
9181 ", hw_id, %d, xcoder_inst_id: %d\n",
9188 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
9189 "hw_id, %d, xcoder_inst_id: %d\n",
9238 int rectangle_width,
9239 int rectangle_height,
9257 switch (device_type)
9261 rectangle_width, rectangle_height,
9262 rectangle_x, rectangle_y,
9263 rgba_color, frame_index);
9315 switch (device_type)
9367 "Error: %s function not supported on device with FW API version < 6rL\n",
9407 if (!p_ctx || !p_cfg)
9455 if (!p_ctx || !p_cfg_in)
9499 const int linesize[])
9504 int luma, chroma_b, chroma_r;
9511 switch (pixel_format)
9550 switch (pixel_format)
9554 luma = linesize[0] * alignedh;
9555 chroma_b = linesize[1] * alignedh / 2;
9556 chroma_r = linesize[2] * alignedh / 2;
9563 luma = linesize[0] * alignedh;
9564 chroma_b = linesize[1] * alignedh / 2;
9606 int video_width,
int video_height,
9607 int linesize[],
int alignment,
9611 void *p_buffer = NULL;
9615 int chroma_b_size = 0;
9616 int chroma_r_size = 0;
9624 switch (pixel_format)
9695 switch (pixel_format)
9699 luma_size = linesize[0] * height_aligned;
9703 chroma_b_size = linesize[1] * height_aligned / 2;
9704 chroma_r_size = linesize[2] * height_aligned / 2;
9708 chroma_b_size = luma_size / 4;
9709 chroma_r_size = luma_size / 4;
9718 luma_size = linesize[0] * video_height;
9727 luma_size = linesize[0] * height_aligned;
9728 chroma_b_size = linesize[1] * height_aligned / 2;
9735 luma_size = linesize[0] * video_height;
9736 chroma_b_size = linesize[1] * video_height;
9744 luma_size = linesize[0] * video_height;
9763 buffer_size = luma_size + chroma_b_size + chroma_r_size + extra_len;
9785 memset(p_buffer, 0, buffer_size);
9795 switch (pixel_format)
9801 p_frame->
p_data[2] = p_frame->
p_data[1] + chroma_b_size;
9802 p_frame->
p_data[3] = NULL;
9805 p_frame->
data_len[1] = chroma_b_size;
9806 p_frame->
data_len[2] = chroma_r_size;
9817 p_frame->
p_data[1] = NULL;
9818 p_frame->
p_data[2] = NULL;
9819 p_frame->
p_data[3] = NULL;
9833 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9834 p_frame->
p_data[2] = NULL;
9835 p_frame->
p_data[3] = NULL;
9838 p_frame->
data_len[1] = chroma_b_size;
9849 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9850 p_frame->
p_data[2] = NULL;
9851 p_frame->
p_data[3] = NULL;
9854 p_frame->
data_len[1] = chroma_b_size;
9867 p_frame->
p_data[1] = NULL;
9868 p_frame->
p_data[2] = NULL;
9869 p_frame->
p_data[3] = NULL;
9882 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9883 p_frame->
p_data[2] = (uint8_t *)p_frame->
p_data[1] + chroma_b_size;
9884 p_frame->
p_data[3] = NULL;
9887 p_frame->
data_len[1] = chroma_b_size;
9888 p_frame->
data_len[2] = chroma_r_size;
9903 __func__, video_width, video_height, buffer_size);
9920 struct stat file_stat;
9922 unsigned char *buffer = NULL;
9935 if (stat(file, &file_stat) != 0)
9944 if (file_stat.st_size == 0)
9961 buffer = malloc(file_stat.st_size);
9969 if (fread(buffer, file_stat.st_size, 1, fp) != 1)
10021 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: hvsplus filter not supported on device with FW API version < 6ro\n");
10057 uint32_t buffer_size = 0;
10058 void *p_buffer = NULL;
10060 uint32_t i, this_size;
10063 if (!p_frame || !p_network)
10069 p_linfo = &p_network->
linfo;
10070 for (i = 0; i < p_network->
input_num; i++)
10078 "ERROR: %s(): invalid buffer_size of network\n", __func__);
10081 buffer_size += this_size;
10085 p_frame->
data_len[0] = buffer_size;
10118 p_frame->
p_data[1] = NULL;
10119 p_frame->
p_data[2] = NULL;
10120 p_frame->
p_data[3] = NULL;
10122 p_frame->
iovec = NULL;
10141 void *p_buffer = NULL;
10143 uint32_t buffer_size = 0;
10144 uint32_t i, data_size;
10147 if (!p_packet || !p_network)
10154 p_linfo = &p_network->
linfo;
10163 "ERROR: %s(): invalid buffer_size of network\n", __func__);
10166 buffer_size += data_size;
10168 data_size = buffer_size;
10186 "%s(): free current p_packet, p_packet->buffer_size=%u\n",
10191 __func__, buffer_size);
10230 if (!p_ctx || bitrate < NI_MIN_BITRATE || bitrate >
NI_MAX_BITRATE)
10233 __func__, bitrate);
10242 "Warning: %s(): bitrate %d overwriting current one %d\n",
10269 int32_t intra_period)
10271 if (!p_ctx || intra_period < 0 || intra_period > 1024)
10274 __func__, intra_period);
10283 "Warning: %s(): intraPeriod %d overwriting current one %d\n",
10414 int32_t ltr_interval)
10471 if (!p_ctx || framerate_num <= 0 || framerate_denom <= 0)
10474 "ERROR: %s(): invalid framerate passed in (%d/%d)\n", __func__,
10475 framerate_num, framerate_denom);
10479 if ((framerate_num % framerate_denom) != 0)
10481 uint32_t numUnitsInTick = 1000;
10482 framerate_num = framerate_num / framerate_denom;
10483 framerate_denom = numUnitsInTick + 1;
10484 framerate_num += 1;
10485 framerate_num *= numUnitsInTick;
10488 framerate_num = framerate_num / framerate_denom;
10489 framerate_denom = 1;
10492 if (((framerate_num + framerate_denom - 1) / framerate_denom) >
10496 "ERROR: %s(): invalid framerate passed in (%d/%d)\n", __func__,
10507 "Warning: %s(): framerate (%d/%d) overwriting current "
10509 __func__, framerate_num, framerate_denom,
10538 int32_t bitrate, framerate_num, framerate_denom;
10539 uint32_t maxFrameSize = (uint32_t)max_frame_size / 2000;
10540 uint32_t min_maxFrameSize;
10544 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10553 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size is valid only when lowDelay mode is enabled\n",
10554 __func__, max_frame_size);
10567 framerate_num = (int32_t) api_param->
fps_number;
10571 min_maxFrameSize = (((uint32_t)bitrate / framerate_num * framerate_denom) / 8) / 2000;
10573 if (maxFrameSize < min_maxFrameSize)
10576 __func__, max_frame_size);
10589 "Warning: %s(): max_frame_size %d overwriting current one %d\n",
10613 int32_t minQpI, maxQpI, maxDeltaQp, minQpPB, maxQpPB;
10615 if (!p_ctx || !p_min_max_qp)
10617 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_min_max_qp pointer\n",
10622 minQpI = p_min_max_qp->
minQpI;
10623 maxQpI = p_min_max_qp->
maxQpI;
10625 minQpPB = p_min_max_qp->
minQpPB;
10626 maxQpPB = p_min_max_qp->
maxQpPB;
10628 if (minQpI > maxQpI || minQpPB > maxQpPB ||
10629 maxQpI > 51 || minQpI < 0 || maxQpPB > 51 || minQpPB < 0)
10632 __func__, minQpI, maxQpI, maxDeltaQp, minQpPB, maxQpPB);
10667 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10676 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %d is valid only in CRF mode\n",
10681 if (crf < 0 || crf > 51)
10683 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %d is invalid (valid range in [0..51])\n",
10695 "Warning: %s(): crf reconfig value %d overwriting current reconfig_crf %d\n",
10724 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10733 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %f is valid only in CRF mode\n",
10738 if (crf < 0.0 || crf > 51.0)
10740 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %f is invalid (valid range in [0..51])\n",
10752 "Warning: %s(): crf reconfig value %d overwriting current "
10753 "reconfig_crf %d, reconfig_crf_decimal %d\n", __func__,
10778 int32_t vbvMaxRate, int32_t vbvBufferSize)
10783 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10787 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
10790 __func__, vbvBufferSize);
10794 if (api_param->
bitrate > 0 && vbvMaxRate > 0 && vbvMaxRate < api_param->bitrate) {
10796 vbvMaxRate, api_param->
bitrate);
10799 if (vbvBufferSize == 0 && vbvMaxRate > 0) {
10801 "vbvBufferSize is 0, force vbvMaxRate to 0\n",
10830 int32_t bitrate, framerate_num, framerate_denom;
10831 uint32_t min_maxFrameSize, maxFrameSize;
10835 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10844 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size_ratio is valid only when lowDelay mode is enabled\n",
10845 __func__, max_frame_size_ratio);
10849 if (max_frame_size_ratio < 1) {
10851 max_frame_size_ratio);
10864 framerate_num = (int32_t) api_param->
fps_number;
10868 min_maxFrameSize = (((uint32_t)bitrate / framerate_num * framerate_denom) / 8) / 2000;
10879 "Warning: %s(): max_frame_size %d overwriting current one %d\n",
10907 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10916 ni_log2(p_ctx,
NI_LOG_ERROR,
"%s():not support to reconfig slice_arg when slice_mode disable.\n",
10927 int max_num_ctu_mb_row = (api_param->
source_height + ctu_mb_size - 1) / ctu_mb_size;
10928 if (sliceArg < 1 || sliceArg > max_num_ctu_mb_row)
10966 int ret, is_semi_planar;
10972 if (p_ctx == NULL || p_frame == NULL || p_frame->
p_data[3] == NULL)
11019 uexp.
fn = p_ctx->
fn;
11030 *p_surface = hwdesc;
11060 int is_semi_planar;
11066 if (p_ctx == NULL || p_frame == NULL || p_frame->
p_data[3] == NULL)
11098 *p_surface = hwdesc;
11127 struct pollfd pfds[1] = {0};
11130 if (p_upl_ctx == NULL || p_frame == NULL)
11136 if (p_frame->
p_data[3] == NULL)
11145 pfds[0].events = POLLIN;
11146 pfds[0].revents = 0;
11148 ret = poll(pfds, 1, -1);
11164 "%s: failed to attach dmabuf read fence errno %s\n", __func__,
11190 if ((p_upl_ctx == NULL) || (p_frame == NULL))
11193 p_upl_ctx, p_frame);
11199 if (p_surface == NULL)
11232 uint8_t *p_data, uint32_t len,
11239 if (p_upl_ctx == NULL || p_data == NULL || p_hwframe == NULL)
11245 if (p_hwframe->
p_data[3] == NULL)
11262 "%s: Failed to request dmabuf rendering errno %d\n", __func__,
11287 uint8_t *p_data, uint32_t
len,
11291 char bar4_name[128];
11306 snprintf(bar4_name, 128,
11307 "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/resource4",
11310 bar4_fd = open(bar4_name, O_RDWR | O_SYNC);
11317 bar4_name, errmsg);
11321 if (fstat(bar4_fd, &stat) != 0)
11330 bar4_mm = mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, bar4_fd, 0);
11332 if (bar4_mm == MAP_FAILED)
11342 memcpy(bar4_mm + offset, p_data, len);
11344 munmap(bar4_mm, 0);
11366 if (p_frame == NULL)
11373 if (p_surface == NULL)
11399 unsigned int offset;
11418 uexp.
fn = p_ctx->
fn;
11453 int width,
int height,
11454 int bit_depth,
int src_endian,
11460 if (p_enc_ctx == NULL || p_enc_params == NULL)
11466 if (!(bit_depth == 8) && !(bit_depth == 10))
11498 alignedw = ((width + 1) / 2) * 2;
11500 (alignedw - width) / 2 * 2;
11513 alignedh = ((height + 1) / 2) * 2;
11515 (alignedh - height) / 2 * 2;
11540 int width,
int height,
11543 if (p_upl_ctx == NULL)
11549 switch (pixel_format)
11580 p_upl_ctx->
isP2P = isP2P;
11605 int bytes_read = 0;
11621 bytes_read += (rx_size - (int)p_ctx->
meta_size);
11626 }
else if (rx_size != 0)
11655 if (p_frame == NULL)
11663 if (p_surface == NULL)
11691 int width,
int height,
int bit_depth_factor,
ni_device_type_t device_type)
11701 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: %s function not supported on device with FW API version < 5.4\n", __func__);
11712 resolution.
width = width;
11713 resolution.
height = height;
11725 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Config sequence change not supported when spatialLayers > 1\n");
11738 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: resolution change config - width %d height %d bit_depth_factor %d "
11739 "luma_linesize %d chroma_linesize %d\n", __func__,
11743 switch (device_type)
11754 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Config sequence change not supported for device type: %d", device_type);
11772 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11775 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_info))
11786 "ERROR: %s function not supported on device with FW API version < 6.h\n",
11800 memset(buffer, 0, size);
11852 "ERROR: %s function not supported on device with FW API version < 6.O\n",
11866 memset(buffer, 0, size);
11895 void *p_buffer = NULL;
11897 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11899 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_ns_vf))
11910 "ERROR: %s function not supported on device with FW API version < 6.m\n",
11923 memset(p_buffer, 0, size);
11937 p_dev_ns_vf->
vf_id = p_dev_ns_vf_data->
vf_id;
11938 p_dev_ns_vf->
ns_id = p_dev_ns_vf_data->
ns_id;
11948 void *p_buffer = NULL;
11950 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11952 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_temp))
11963 "ERROR: %s function not supported on device with FW API version < 6rC\n",
11976 memset(p_buffer, 0, size);
11993 ni_log(
NI_LOG_DEBUG,
"%s(): current composite temperature %d on board temperature %d on die temperature %d\n",
12003 void *p_buffer = NULL;
12005 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
12007 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_extra_info))
12018 "ERROR: %s function not supported on device with FW API version < 6rC\n",
12031 memset(p_buffer, 0, size);
12054 p_dev_extra_info->
fw_flavour = (uint8_t)
'-';
12077 ni_log(
NI_LOG_DEBUG,
"%s(): current composite temperature %d on board temperature %d "
12078 "on die temperature %d power consumption %d current consumption %d\n",
12106 bool is_ext_buf =
true;
12107 if (*p_log_buffer == NULL)
12115 is_ext_buf =
false;
12118 if(*p_log_buffer != NULL){
12146 uint32_t ctu, i, j;
12150 int importanceLevelCentre = p_param->
roi_demo_mode == 1 ? 40 : 10;
12151 int importanceLevelRest = p_param->
roi_demo_mode == 1 ? 10 : 40;
12156 uint32_t block_size, max_cu_size, customMapSize;
12160 uint32_t roiMapBlockUnitSize;
12161 uint32_t entryPerMb;
12167 linesize_aligned = (linesize_aligned / 8) * 8;
12168 height_aligned = (height_aligned / 8) * 8;
12174 ((linesize_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) *
12175 ((height_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
12179 customMapSize = ((block_size + 63) & (~63));
12195 ((linesize_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
12196 roiMapBlockUnitSize;
12198 ((height_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
12199 roiMapBlockUnitSize;
12200 numMbs = mbWidth * mbHeight;
12204 entryPerMb = (roiMapBlockUnitSize / 8) * (roiMapBlockUnitSize / 8);
12206 for (i = 0; i < numMbs; i++)
12208 bool bIsCenter = (i % mbWidth > mbWidth / 3) && (i % mbWidth < mbWidth * 2 / 3);
12209 for (j = 0; j < entryPerMb; j++)
12219 p_enc_ctx->
roi_map[i * entryPerMb + j]
12222 bIsCenter ? importanceLevelCentre : importanceLevelRest;
12226 p_enc_ctx->
roi_len = customMapSize;
12229 (sumQp + (numMbs >> 1)) / numMbs;
12237 uint32_t mbWidth = (linesize_aligned + 16 - 1) >> 4;
12239 uint32_t mbHeight = (height_aligned + 16 - 1) >> 4;
12240 uint32_t numMbs = mbWidth * mbHeight;
12241 uint32_t customMapSize =
12251 for (i = 0; i < numMbs; i++)
12253 if ((i % mbWidth > mbWidth / 3) && (i % mbWidth < mbWidth * 2 / 3))
12263 p_enc_ctx->
roi_len = customMapSize;
12265 (sumQp + (numMbs >> 1)) / numMbs;
12273 uint32_t ctuWidth = (linesize_aligned + 64 - 1) >> 6;
12275 uint32_t ctuHeight = (height_aligned + 64 - 1) >> 6;
12277 uint32_t subCtuWidth = ctuWidth * 2;
12279 uint32_t subCtuHeight = ctuHeight * 2;
12280 uint32_t numSubCtus = subCtuWidth * subCtuHeight;
12287 for (i = 0; i < numSubCtus; i++)
12289 if ((i % subCtuWidth > subCtuWidth / 3) &&
12290 (i % subCtuWidth < subCtuWidth * 2 / 3))
12306 for (i = 0; i < ctuHeight; i++)
12309 for (j = 0; j < ctuWidth; j++, ptr += 2)
12311 ctu = (i * ctuWidth + j);
12315 *(ptr + subCtuWidth);
12317 *(ptr + subCtuWidth + 1);
12327 (sumQp + (numSubCtus >> 1)) / numSubCtus;
12357 *((int32_t *)aux_data->data) =
12379 int32_t intraprd = *((int32_t *)aux_data->data) =
12382 "xcoder_send_frame: frame #%lu reconf "
12383 "intraPeriod %d\n",
12417 "xcoder_send_frame: frame #%lu reconf "
12418 "vui colorDescPresent %d colorPrimaries %d "
12419 "colorTrc %d colorSpace %d aspectRatioWidth %d "
12420 "aspectRatioHeight %d videoFullRange %d\n",
12451 "xcoder_send_frame: frame #%lu metadata "
12452 "use_cur_src_as_long_term_pic %d use_long_term_ref "
12492 *((int32_t *)aux_data->data) =
12495 "xcoder_send_frame: frame #%lu reconf "
12496 "ltrInterval %d\n",
12513 *((int32_t *)aux_data->data) =
12516 "xcoder_send_frame: frame #%lu reconf "
12517 "invalidFrameNum %d\n",
12543 "xcoder_send_frame: frame #%lu reconf "
12544 "framerate (%d/%d)\n",
12558 *((int32_t *)aux_data->data) =
12561 "xcoder_send_frame: frame #%lu reconf "
12562 "maxFrameSize %d\n",
12577 *((int32_t *)aux_data->data) =
12580 "xcoder_send_frame: frame #%lu reconf "
12598 *((
float *)aux_data->data) = crf;
12600 "xcoder_send_frame: frame #%lu reconf "
12612 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
12615 __func__, vbvBufferSize);
12618 if (p_param->
bitrate > 0 && vbvMaxRate > 0 && vbvMaxRate < p_param->bitrate) {
12620 vbvMaxRate, p_param->
bitrate);
12623 if (vbvBufferSize == 0 && vbvMaxRate > 0) {
12625 "vbvBufferSize is 0, force vbvMaxRate to 0\n",
12635 *((int32_t *)aux_data->data) = vbvMaxRate;
12641 *((int32_t *)aux_data->data) = vbvBufferSize;
12643 "xcoder_send_frame: frame #%lu reconfig vbvMaxRate %d vbvBufferSize "
12644 "%d by frame aux data\n",
12645 p_enc_ctx->
frame_num, vbvMaxRate, vbvBufferSize);
12654 if (maxFrameSizeRatio < 1) {
12656 maxFrameSizeRatio);
12665 int32_t bitrate, framerate_num, framerate_denom;
12666 uint32_t min_maxFrameSize, maxFrameSize;
12676 framerate_num = (int32_t) p_param->
fps_number;
12680 min_maxFrameSize = ((uint32_t)bitrate / framerate_num * framerate_denom) / 8;
12683 *((int32_t *)aux_data->data) = maxFrameSize;
12685 "xcoder_send_frame: frame #%lu reconf "
12686 "maxFrameSizeRatio %d maxFrameSize %d\n",
12687 p_enc_ctx->
frame_num, maxFrameSizeRatio, maxFrameSize);
12700 *((int16_t *)aux_data->data) =
12703 "xcoder_send_frame: frame #%lu reconf "
12717 "xcoder_send_frame: frame #%lu force IDR frame\n",
12732 "xcoder_send_frame: frame #%lu API reconfig BR %d\n",
12748 "xcoder_send_frame: frame #%lu API reconfig intraPeriod %d\n",
12777 "xcoder_send_frame: frame #%lu reconf "
12778 "vui colorDescPresent %d colorPrimaries %d "
12779 "colorTrc %d colorSpace %d aspectRatioWidth %d "
12780 "aspectRatioHeight %d videoFullRange %d\n",
12797 if ((retval =
ni_set_ltr(p_enc_ctx, <r))) {
12801 "xcoder_send_frame(): frame #%lu API set LTR\n",
12820 "%s(): frame %d minQpI %d maxQpI %d maxDeltaQp %d minQpPB %d maxQpPB %d\n",
12835 "xcoder_send_frame(): frame #%lu API set LTR interval %d\n",
12850 "xcoder_send_frame(): frame #%lu API set frame ref invalid "
12869 "xcoder_send_frame: frame #%lu API reconfig framerate "
12886 "xcoder_send_frame: frame #%lu API reconfig maxFrameSize %d\n",
12901 "xcoder_send_frame: frame #%lu API reconfig crf %d\n",
12917 "xcoder_send_frame: frame #%lu API reconfig crf %f\n",
12932 "xcoder_send_frame: frame #%lu API reconfig vbvMaxRate %d vbvBufferSize %d\n",
12949 "xcoder_send_frame: frame #%lu reconf maxFrameSizeRatio %d\n",
12963 "xcoder_send_frame: frame #%lu API reconfig sliceArg %d\n",
12981 static int ni_tolower(
int c)
12983 if (c >=
'A' && c <=
'Z')
12993 c1 = ni_tolower(*a++);
12994 c2 = ni_tolower(*b++);
12995 }
while (c1 && c1 == c2);
13147 "g%drefPic%d specified without g%drefPic%dUsed specified!\n",
13165 #ifndef DEPRECATION_AS_ERROR
13179 uint64_t ui64DestAddr,
13180 uint32_t ui32FrameSize)
13185 (void) ui64DestAddr;
13186 (void) ui32FrameSize;
13211 uint64_t ui64DestAddr, uint32_t ui32FrameSize)
13215 if ((pSession == NULL) || (source == NULL))
13231 ni_log2(pSession,
NI_LOG_ERROR,
"%s(): Can't DMA to destination (%d)\n", __func__, retval);
13259 if ((pSession == NULL) || (dmaAddrs == NULL) || (pDstFrame == NULL))
13268 "%s: FW doesn't support this operation\n", __func__);
13277 "%s(): Can't DMA from source (%d)\n", __func__, retval);
13316 switch (device_type)
13324 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: %s function not supported on device with FW API version < 5.4\n", __func__);
13336 if (video_width < NI_MIN_WIDTH || video_width >
NI_MAX_WIDTH ||
13337 video_height < NI_MIN_HEIGHT || video_height >
NI_MAX_HEIGHT)
13340 __func__, video_width, video_height);
13343 resolution.
width = video_width;
13344 resolution.
height = video_height;
13360 ni_log(
NI_LOG_ERROR,
"Failed to reconfig config the encoder session (status = %d)\n", retval);
13376 __func__, device_type);
13395 int ret = 0, i = 0;
13396 if (!p_session_ctx || !p_param || !p_ppu_config)
13403 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s: Warning ignore ppu reconfig before last config done!\n", __func__);
13412 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s: not supported on device with FW API version < 6sF\n", __func__);
13419 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): only supported for h264 and h265 decoder\n", __func__);
13424 if (p_dec_input_param->
hwframes != 1)
13431 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): not supported when disable_adaptive_buffers is disabled\n", __func__);
13434 if (p_dec_input_param->
mcmode)
13436 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): not supported when MulticoreJointMode is enabled\n", __func__);
13442 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): Error reconfig ppu1 while ppu1 is not enabled\n", __func__);
13448 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): Error reconfig ppu2 while ppu2 is not enabled\n", __func__);
13461 "out of range\n", __func__, i, p_ppu_config->
ppu_w[i], p_ppu_config->
ppu_h[i]);
13465 if ((p_ppu_config->
ppu_w[i] & 1) || (p_ppu_config->
ppu_h[i] & 1))
13468 __func__, i, p_ppu_config->
ppu_w[i], p_ppu_config->
ppu_h[i]);
@ XCODER_TEST_RECONF_LTR_INTERVAL_API
#define NI_ENC_GOP_PARAMS_G2_TEMPORAL_ID
#define CONFIG_INSTANCE_SetScalerWatermarkPara_W(sid, instance)
ni_retcode_t ni_device_alloc_and_get_firmware_logs(ni_session_context_t *p_ctx, void **p_log_buffer, bool gen_log_file)
Allocate log buffer if needed and retrieve firmware logs from device.
uint8_t use_long_term_ref
#define NI_ENC_PARAM_ROI_DEMO_MODE
@ NI_ENC_MEM_ALLOCATE_STRATEGY_INVALID_MAX
ni_retcode_t ni_set_demo_roi_map(ni_session_context_t *p_enc_ctx)
Set up hard coded demo ROI map.
#define NI_ENC_PARAM_LINK_FRAME_MAX_INTRA_RATIO
int ni_encoder_session_read_stream_header(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data)
Read encoder stream header from the device.
Utility definitions for measuring frame/packet processing time in NETINT video processing devices.
#define NI_ENC_PARAM_AV1_ERROR_RESILIENT_MODE
ni_retcode_t ni_send_to_target(ni_session_context_t *p_ctx, niFrameSurface1_t *source, uint64_t ui64DestAddr, uint32_t ui32FrameSize)
int ni_pthread_mutex_unlock(ni_pthread_mutex_t *mutex)
thread mutex unlock
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC0
#define NI_DEC_PARAM_SCALE_0_RES_CEIL
@ NI_FRAME_AUX_DATA_MAX_FRAME_SIZE
int ni_pthread_cond_init(ni_pthread_cond_t *cond, const ni_pthread_condattr_t *attr)
initialize condition variables
#define NI_ENC_PARAM_ZEROCOPY_MODE
ni_aux_data_t * ni_frame_get_aux_data(const ni_frame_t *frame, ni_aux_data_type_t type)
Retrieve from the frame auxiliary data of a given type if exists.
ni_retcode_t ni_scaler_set_params(ni_session_context_t *p_ctx, ni_scaler_params_t *p_params)
Set parameters on the device for the 2D engine.
ni_retcode_t ni_device_get_ddr_configuration(ni_session_context_t *p_ctx)
Get DDR configuration of Quadra device.
int ni_encoder_session_write(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Send a YUV p_frame to encoder.
NI_DEPRECATED ni_retcode_t ni_device_capability_query(ni_device_handle_t device_handle, ni_device_capability_t *p_cap)
Query device and return device capability structure This function had been replaced by ni_device_capa...
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC0_USED
#define NI_DEC_PARAM_SKIP_PTS_GUESS
#define NI_MAX_RESOLUTION_HEIGHT
uint8_t * hevc_sub_ctu_roi_buf
ni_retcode_t ni_encoder_params_set_value(ni_xcoder_params_t *p_params, const char *name, const char *value)
Set value referenced by name in encoder parameters structure.
#define NI_ENC_PARAM_MAX_FRAME_SIZE_LOW_DELAY
#define NI_DEC_PARAM_SCALE_2_RES_CEIL
ni_retcode_t ni_strerror(char *dest, size_t dmax, int errnum)
const char *const g_xcoder_log_names[NI_XCODER_LOG_NAMES_ARRAY_LEN]
@ XCODER_TEST_RECONF_CRF_FLOAT
#define NI_ENC_PARAM_USE_RECOMMENDED_ENC_PARAMS
#define NI_MIN_MAX_NUM_MERGE
#define NI_ENC_PARAM_CUSTOMIZE_ROI_QP_LEVEL
#define NI_DEC_PARAM_SCALE_0
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC3_USED
#define NI_ENC_PARAM_CONF_WIN_RIGHT
ni_retcode_t ni_device_config_qos_op(ni_device_handle_t device_handle, ni_device_handle_t device_handle_t, uint32_t over_provision)
Send qos over provisioning mode to target namespace with specified logic block address.
ni_retcode_t ni_ai_config_network_binary(ni_session_context_t *p_ctx, ni_network_data_t *p_network, const char *file)
configure a network context based with the network binary
ni_pthread_mutex_t * p_mutex
#define NI_ENC_PARAM_TOL_RC_INTRA
#define NI_EC_POLICY_SKIP
#define QUERY_GET_NVME_STATUS_R
ni_retcode_t ni_strncat(char *dest, size_t dmax, const char *src, size_t slen)
union _ni_enc_avc_roi_custom_map ni_enc_avc_roi_custom_map_t
encoder AVC ROI custom map (1 MB = 8bits)
int enable_dynamic_32x32_merge
#define NI_ENC_PARAM_GET_PSNR_MODE
void ni_rsrc_free_device_pool(ni_device_pool_t *p_device_pool)
Free all resources taken by the device pool.
#define NI_ENC_PARAM_LTR_REF_INTERVAL
#define NI_ENC_PARAM_ENABLE_ALL_SEI_PASSTHRU
encoder AVC ROI custom map (1 MB = 8bits)
#define NI_ENC_PARAM_INTRA_REFRESH_MODE
ni_retcode_t ni_decoder_session_read_desc(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Retrieve a hw desc p_frame from decoder.
#define NI_XCODER_LOG_NAME_WARN
#define NI_MAX_DYNAMIC_MERGE
#define NI_ENC_PARAM_CONF_WIN_LEFT
ni_retcode_t ni_frame_buffer_free(ni_frame_t *p_frame)
Free frame buffer that was previously allocated with either ni_frame_buffer_alloc or ni_encoder_frame...
#define NI_XCODER_PRESET_NAME_SLOW
#define NI_ENC_GOP_PARAMS_G5_PIC_TYPE
#define NI_XCODER_PRESET_NAME_FAST
#define NI_ENC_PARAM_TRANS_RATE
#define NI_DEC_PARAM_PKT_PTS_UNCHANGE
#define NI_ENC_PARAM_DISABLE_AV1_TIMING_INFO
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC3
ni_retcode_t ni_scaler_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t *p_cfg)
config a frame in the scaler
ni_device_handle_t ni_device_open2(const char *p_dev, ni_device_mode_t mode)
Open device and return device device_handle if successful.
ni_network_layer_params_t * in_param
#define NI_ENC_BLOCK_RC_SIZE
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE
#define NI_ENC_PARAM_ENABLE_CPU_AFFINITY
LIB_API ni_device_context_t * ni_rsrc_get_device_context(ni_device_type_t type, int guid)
Allocates and returns a pointer to ni_device_context_t struct based on provided device_type and guid....
#define NI_PARAM_AV1_MAX_AREA
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC1_USED
ni_retcode_t ni_config_instance_hvsplus(ni_session_context_t *p_ctx)
ni_retcode_t ni_frame_buffer_alloc_nv(ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int extra_len, bool alignment_2pass_wa)
Allocate memory for the frame buffer based on provided parameters taking into account pic line size a...
ni_retcode_t ni_ai_alloc_dst_frame(ni_session_context_t *p_ctx, niFrameSurface1_t *p_out_surface)
uint8_t fw_share_mem_usage
#define NI_ENC_GOP_PARAMS_G4_QP_OFFSET
#define NI_DEC_PARAM_LOW_DELAY
#define NI_XCODER_LOG_NAME_FULL
#define NI_MIN_KEEP_ALIVE_TIMEOUT
ni_retcode_t ni_device_multi_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t p_cfg_in[], int numInCfgs, ni_frame_config_t *p_cfg_out)
Configure the 2D engine to work based on provided parameters.
#define NI_DEC_PARAM_ENABLE_OUT_2
char dev_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
#define NI_ENC_NEW_RC_ENABLE
#define NI_ENC_PARAM_TEMPORAL_LAYERS_ENABLE
#define NI_INVALID_IO_SIZE
ni_retcode_t ni_device_session_query(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Query session data from the device - If device_type is valid, will query session data from specified ...
@ XCODER_TEST_RECONF_LTR_INTERVAL
int statistic_output_level
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC3_USED
ni_retcode_t ni_device_config_ns_qos(ni_device_handle_t device_handle, uint32_t key, uint32_t value)
Send namespace num / Opmode and SRIOv index/value to the device with specified logic block address.
#define NI_ENC_PARAM_MAX_NUM_MERGE
#define NI_ENC_PARAM_CRF_MAX_IFRAME_ENABLE
@ XCODER_TEST_RECONF_FRAMERATE_API
#define NI_ENC_PARAM_MAX_QP
Private definitions used by ni_device_api.c for video processing tasks.
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC0
uint32_t metadata_buffer_size
#define NI_ENC_PARAM_BITRATE
int temporal_layers_enable
ni_retcode_t ni_clear_instance_buf(niFrameSurface1_t *surface)
clear a particular xcoder instance buffer/data
#define NI_ENC_PARAM_LONG_TERM_REFERENCE_INTERVAL
void ni_device_close(ni_device_handle_t device_handle)
Close device and release resources.
#define NI_NUM_OF_PIXELS_1080P
struct _ni_enc_avc_roi_custom_map::@5 field
@ SESSION_RUN_STATE_FLUSHING
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC2_USED
#define NI_ENC_PARAM_ALLOCATE_STRAEGY
ni_retcode_t ni_force_idr_frame_type(ni_session_context_t *p_ctx)
Force next frame to be IDR frame during encoding.
ni_retcode_t ni_scaler_p2p_frame_acquire(ni_session_context_t *p_ctx, niFrameSurface1_t *p_surface, int data_len)
Acquire the scaler P2P DMA buffer for read/write.
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC3_USED
#define NI_ENC_PARAM_CU_SIZE_MODE
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_API
#define NI_MIN_INTRA_QP_DELTA
ni_input_frame input_frame_fifo[120]
encoder:calculate PSNR start
#define NI_ENC_GOP_PARAMS_G1_TEMPORAL_ID
struct _ni_instance_mgr_general_status ni_instance_mgr_general_status_t
ni_retcode_t ni_strcpy(char *dest, size_t dmax, const char *src)
#define NI_XCODER_PRESET_NAME_MEDIUM
ni_retcode_t ni_scaler_session_read_hwdesc(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
read a hardware descriptor from a scaler session
@ NI_RETCODE_ERROR_GET_DEVICE_POOL
int ni_rsrc_lock_and_open(int device_type, ni_lock_handle_t *lock)
lock a file lock and open a session on a device
#define NI_DEC_PARAM_ENABLE_FOLLOW_IFRAME
#define NI_PARAM_AV1_MAX_WIDTH
#define NI_ENC_PARAM_GDR_DURATION
ni_retcode_t ni_reconfig_intraprd(ni_session_context_t *p_ctx, int32_t intra_period)
Reconfigure intraPeriod dynamically during encoding.
@ NI_SCALER_OPCODE_WATERMARK
ni_retcode_t ni_query_vf_ns_id(ni_device_handle_t device_handle, ni_device_vf_ns_id_t *p_dev_ns_vf, uint8_t fw_rev[])
Query VF and NS id from device.
ni_retcode_t ni_device_session_update_framepool(ni_session_context_t *p_ctx, uint32_t pool_size)
Sends frame pool change info to device.
ni_retcode_t ni_config_instance_network_binary(ni_session_context_t *p_ctx, void *nb_data, uint32_t nb_size)
ni_retcode_t ni_device_session_sequence_change(ni_session_context_t *p_ctx, int width, int height, int bit_depth_factor, ni_device_type_t device_type)
Send sequence change information to device.
#define NI_ENC_PARAM_CONF_WIN_TOP
@ QOS_OP_CONFIG_REC_OP_CODE
#define NI_ENC_PARAM_NO_HW_MULTIPASS_SUPPORT
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC2
#define NI_DEC_PARAM_ENABLE_CPU_AFFINITY
#define NI_DEC_PARAM_FORCE_8BIT_1
#define NI_ENC_PARAM_BITRATE_MODE
#define NI_EC_POLICY_IGNORE
#define NI_ENC_PARAM_COLOR_PRIMARY
#define NI_ENC_PARAM_LONG_TERM_REFERENCE_ENABLE
#define NI_ENC_PARAM_ENABLE_HVS_QP_SCALE
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC3
ni_retcode_t ni_frame_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, int alignment, int metadata_flag, int factor, int hw_frame_count, int is_planar)
Allocate preliminary memory for the frame buffer based on provided parameters. Applicable to YUV420 P...
#define NI_MAX_RESOLUTION_RGBA_WIDTH
#define NI_ENC_GOP_PARAMS_G7_PIC_TYPE
ni_codec_format_t src_codec
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC1
ni_long_term_ref_t ltr_to_set
#define NI_DEC_PARAM_SCALE_1
#define NI_ENC_PARAM_NO_MBTREE
int crf_max_iframe_enable
#define NI_MIN_DYNAMIC_MERGE
@ XCODER_TEST_RECONF_SLICE_ARG
#define NI_XCODER_LOG_NAME_NONE
uint32_t active_video_width
#define NI_ENC_PARAM_CROP_HEIGHT
#define NI_ENC_PARAM_LTR_FIRST_GAP
ni_retcode_t ni_ai_session_open(ni_session_context_t *p_ctx)
ni_retcode_t ni_encoder_sw_frame_buffer_alloc(bool planar, ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int alignment, int extra_len, bool alignment_2pass_wa)
This API is a wrapper for ni_encoder_frame_buffer_alloc(), used for planar pixel formats,...
ni_session_context_t * ni_device_session_context_alloc_init(void)
Allocate and initialize a new ni_session_context_t struct.
NI_DEPRECATED ni_device_handle_t g_dev_handle
ni_retcode_t ni_reconfig_framerate(ni_session_context_t *p_ctx, ni_framerate_t *framerate)
Reconfigure framerate dynamically during encoding.
ni_frame_pool_type_t pool_type
ni_region_of_interest_t * av_rois
#define NI_DEC_PARAM_FORCE_8BIT_2
#define NI_INVALID_SESSION_ID
struct _ni_log_fl_fw_versions ni_log_fl_fw_versions_t
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC1
#define NI_MAX_CU_SIZE_MODE
#define NI_XCODER_LOG_NAME_INFO
#define NI_ENC_PARAM_AV1_OP_LEVEL
#define NI_ENC_PARAM_LOOK_AHEAD_DEPTH
int ni_xcoder_session_query_detail(ni_session_context_t *p_ctx, ni_device_type_t device_type, void *detail_data, int ver)
Query current xcoder status.
#define NI_ENC_PARAM_LTR_NEXT_INTERVAL
#define NI_PARAM_MIN_WIDTH
uint32_t actual_video_width
@ XCODER_TEST_RECONF_VUI_HRD
uint64_t ni_gettime_ns(void)
#define NI_KEEP_ALIVE_TIMEOUT
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_REDUNDANT
ni_retcode_t ni_parse_customize_qpoffset_file(const char *customize_file, int8_t qp_map[][NI_CUSTOMIZE_ROI_QP_NUM])
#define NI_ENC_GOP_PARAMS_G5_TEMPORAL_ID
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC1_USED
#define NI_EC_POLICY_LIMITED_ERROR
ni_retcode_t ni_config_instance_set_decoder_ppu_params(ni_session_context_t *p_ctx, void *p_dec_ppu_config, int buffer_size)
Send a p_config command to configure decoding parameters.
#define NETINT_IOCTL_ATTACH_RFENCE
#define NI_MIN_CUSTOM_SEI_PASSTHRU
Public definitions for managing NETINT video processing devices.
ni_retcode_t ni_set_frame_ref_invalid(ni_session_context_t *p_ctx, int32_t frame_num)
Set frame reference invalidation.
ni_event_handle_t event_handle
@ XCODER_TEST_RECONF_FRAMERATE
#define NI_ENC_PARAM_RDO_QUANT
struct _ni_scaler_multi_watermark_params_t ni_scaler_multi_watermark_params_t
#define NI_MAX_FILTER_POOL_SIZE
#define NI_ENC_GOP_PARAMS_G2_POC_OFFSET
ni_aux_data_t * aux_data[NI_MAX_NUM_AUX_DATA_PER_FRAME]
int ni_pthread_cond_destroy(ni_pthread_cond_t *cond)
destroy condition variables
uint8_t fl_ver_nor_flash[8]
#define NI_ENC_PARAM_STATIC_MMAP_THRESHOLD
ni_retcode_t ni_config_instance_set_scaler_params(ni_session_context_t *p_ctx, ni_scaler_params_t *p_params)
Send a p_config command to configure scaling parameters.
ni_retcode_t ni_reconfig_crf(ni_session_context_t *p_ctx, int32_t crf)
Reconfigure crf value dynamically during encoding.
enum _ni_frame_aux_data_type ni_aux_data_type_t
#define NI_ENC_GOP_PARAMS_G3_TEMPORAL_ID
#define NI_ENC_PARAM_ENABLE_AUD
@ XCODER_TEST_RECONF_INTRAPRD
ni_retcode_t ni_scaler_multi_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t p_cfg_in[], int numInCfgs, ni_frame_config_t *p_cfg_out)
config multiple frames in the scaler
#define NI_ENC_GOP_PARAMS_CUSTOM_GOP_SIZE
#define NI_ENC_PARAM_PRE_INTRA_HANDLING
ni_retcode_t ni_packet_buffer_free(ni_packet_t *p_packet)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc.
ni_device_handle_t blk_io_handle
ni_retcode_t ni_config_read_inout_layers(ni_session_context_t *p_ctx, ni_network_data_t *p_network)
uint32_t start_len[NI_MAX_NUM_DATA_POINTERS]
ni_retcode_t ni_scaler_set_drawbox_params(ni_session_context_t *p_ctx, ni_scaler_drawbox_params_t *p_params)
Send a p_config command to configure scaling drawbox parameters.
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC2
#define NI_ENC_PARAM_MAX_FRAME_SIZE_BITS_LOW_DELAY
@ NI_RETCODE_PARAM_ERROR_AREA_TOO_BIG
int pastFrameMaxIntraRatio
void ni_close_event(ni_event_handle_t event_handle)
Close event and release resources (Windows only)
ni_device_queue_t * p_device_queue
#define NI_ENC_PARAM_ENABLE_IP_RATIO
int spatialLayerBitrate[NI_MAX_SPATIAL_LAYERS]
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC1_USED
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC3
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC3
uint8_t separate_metadata
int16_t reconfig_slice_arg
ni_retcode_t ni_device_dec_session_flush(ni_session_context_t *p_ctx)
Flush a decoder session to get ready to continue decoding. Note: this is different from ni_device_ses...
ni_retcode_t ni_uploader_frame_buffer_lock(ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame)
Lock a hardware P2P frame prior to encoding.
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC0
void ni_rsrc_update_record(ni_device_context_t *p_device_context, ni_session_context_t *p_session_ctx)
ni_network_layer_offset_t * outset
struct _ni_device_temp ni_device_temp_t
#define NI_EC_POLICY_BEST_EFFORT
int use_recommend_enc_params
int32_t ni_parse_name(const char *arg, const char *const *names, bool *b_error)
Parse name.
ni_retcode_t ni_encoder_frame_zerocopy_check(ni_session_context_t *p_enc_ctx, ni_xcoder_params_t *p_enc_params, int width, int height, const int linesize[], bool set_linesize)
Check if incoming frame is encoder zero copy compatible or not.
#define NI_MAX_USE_RECOMMENDED_ENC_PARAMS
#define NI_ENC_PARAM_ENABLE_DYNAMIC_16X16_MERGE
uint32_t fw_share_mem_usage
#define NI_DEC_PARAM_SKIP_EXTRA_HEADERS
@ NI_FRAME_AUX_DATA_SLICE_ARG
#define NI_UPLOADER_FLAG_LM
#define NI_ENC_PARAM_HIGH_TIER
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC2_USED
#define NI_ENC_PARAM_ADAPTIVE_LAMDA_MODE
ni_retcode_t ni_scaler_alloc_frame(ni_session_context_t *p_ctx, int width, int height, int format, int options, int rectangle_width, int rectangle_height, int rectangle_x, int rectangle_y, int rgba_color, int frame_index)
allocate a frame in the scaler
#define NI_SCALER_FLAG_IO
uint8_t * av1_p_data[MAX_AV1_ENCODER_GOP_NUM]
#define NI_DEC_PARAM_CROP_MODE_2
int av1OpLevel[NI_MAX_SPATIAL_LAYERS]
#define NETINT_IOCTL_EXPORT_DMABUF
@ NI_ENC_MEM_ALLOCATE_STRATEGY_INVALID_MIN
ni_retcode_t ni_query_nvme_status(ni_session_context_t *p_ctx, ni_load_query_t *p_load_query)
Query NVMe load from the device.
ni_pthread_mutex_t low_delay_sync_mutex
int intra_mb_refresh_mode
#define NI_ENC_PARAM_TOL_RC_INTER
#define NI_MIN_RESOLUTION_WIDTH_SCALER
#define QUERY_GET_EXTTRA_INFO_R
ni_retcode_t ni_ai_config_hvsplus(ni_session_context_t *p_ctx, ni_network_data_t *p_network)
configure a hvsplus filter
uint32_t av1_buffer_size[MAX_AV1_ENCODER_GOP_NUM]
#define NI_ENC_GOP_PARAMS_G6_PIC_TYPE
#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR_FLOAT
ni_retcode_t ni_reconfig_vbv_value(ni_session_context_t *p_ctx, int32_t vbvMaxRate, int32_t vbvBufferSize)
Reconfigure vbv buffer size and vbv max rate dynamically during encoding.
#define NI_ENC_INLOOP_DS_RATIO
#define NI_ENC_PARAM_CONF_WIN_BOTTOM
int video_full_range_flag
#define NI_VERSION_CHARACTER_COUNT
#define NI_EC_POLICY_BEST_EFFORT_OUT_DC
@ NI_RETCODE_INVALID_PARAM
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC3
ni_enc_avc_roi_custom_map_t * avc_roi_map
int ni_decoder_session_write(ni_session_context_t *p_ctx, ni_packet_t *p_packet)
Send a video p_packet to decoder.
ni_retcode_t ni_ai_session_write(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
uint64_t ppu_reconfig_pkt_pos
int16_t buffered_frame_index
#define NI_FRAME_BIG_ENDIAN
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC1_USED
#define NI_ENC_PARAM_HVS_BASE_MB_COMPLEXITY
struct _ni_encoder_cfg_params::@16 rc
#define NI_ENC_PARAM_JPEG_QLEVEL
@ XCODER_TEST_INVALID_REF_FRAME
#define NI_DEFAULT_KEEP_ALIVE_TIMEOUT
#define NI_ENC_PARAM_DDR_PRIORITY_MODE
#define NI_ENC_PARAM_SPATIAL_LAYER_BITRATE
#define NI_ENC_PARAM_GOP_LOW_DELAY
int ni_decoder_session_read(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Retrieve a YUV p_frame from decoder.
uint32_t av1_data_len[MAX_AV1_ENCODER_GOP_NUM]
#define NI_ENC_PARAM_DOLBY_VISION_PROFILE
ni_retcode_t ni_device_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t *p_cfg)
Configure the 2D engine to work based on provided parameters.
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_API_REDUNDANT
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC1_USED
#define NI_ENC_PARAM_INTRA_REFRESH_MIN_PERIOD
This is a data structure for encoding parameters that have changed.
#define NI_DEC_PARAM_SCALE_0_LONG_SHORT_ADAPT
uint8_t last_ran_fl_version[NI_VERSION_CHARACTER_COUNT]
ni_retcode_t ni_config_instance_set_uploader_params(ni_session_context_t *p_ctx, uint32_t pool_size, uint32_t pool)
Send a p_config command to configure uploading parameters.
#define NI_ENC_PARAM_BASE_LAYER_ONLY
#define NI_ENC_REPEAT_HEADERS_FIRST_IDR
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC0_USED
#define NI_ENC_PARAM_ENABLE_DYNAMIC_32X32_MERGE
@ NI_FRAME_AUX_DATA_VBV_BUFFER_SIZE
ni_retcode_t ni_reconfig_crf2(ni_session_context_t *p_ctx, float crf)
Reconfigure crf float point value dynamically during encoding.
#define NI_XCODER_PRESET_NAME_VERYFAST
@ NI_FRAME_AUX_DATA_VBV_MAX_RATE
#define NI_DEC_PARAM_CROP_MODE_0
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC3_USED
#define NI_ENC_PARAM_IP_RATIO
#define NI_DEC_PARAM_MULTICORE_JOINT_MODE
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_retcode_t ni_scaler_input_frame_alloc(ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params, niFrameSurface1_t *p_src_surface)
allocate device input frame by hw descriptor. This call won't actually allocate a frame but sends the...
uint16_t ppu_w[NI_MAX_NUM_OF_DECODER_OUTPUTS]
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC3_USED
#define NI_ENABLE_USR_DATA_SEI_PASSTHRU
#define NI_ENC_GOP_PARAMS_G0_PIC_TYPE
@ NI_RETCODE_PARAM_ERROR_HEIGHT_TOO_BIG
char dev_name[NI_MAX_DEVICE_NAME_LEN]
#define NI_VPU_ALIGN64(_x)
#define NI_ENC_GOP_PARAMS_G4_PIC_TYPE
#define NI_DEC_PARAM_ENABLE_OUT_1
int reconfig_intra_period
#define NI_ENC_PARAM_FORCE_FRAME_TYPE
@ NI_RETCODE_ERROR_MEM_ALOC
@ NI_FRAME_AUX_DATA_MAX_MIN_QP
ni_retcode_t ni_device_clone_hwframe(ni_session_context_t *p_ctx, ni_frameclone_desc_t *p_frameclone_desc)
Copy the data of src hwframe to dst hwframe.
void ni_populate_device_capability_struct(ni_device_capability_t *p_cap, void *p_data, ni_device_handle_t device_handle, bool device_in_ctxt)
Get info from received xcoder capability.
#define NI_ENC_PARAM_MAX_FRAME_SIZE_BYTES_LOW_DELAY
#define NI_MAX_KEEP_ALIVE_TIMEOUT
#define NI_MAX_DECODING_REFRESH_TYPE
ni_retcode_t ni_uploader_frame_buffer_unlock(ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame)
Unlock a hardware P2P frame after encoding.
@ SESSION_RUN_STATE_SEQ_CHANGE_DRAINING
#define NI_FW_META_DATA_SZ
int32_t ni_nvme_send_write_cmd(ni_device_handle_t handle, ni_event_handle_t event_handle, void *p_data, uint32_t data_len, uint32_t lba)
Compose a io write command.
#define NI_DEC_PARAM_SEMI_PLANAR_1
int ni_pthread_join(ni_pthread_t thread, void **value_ptr)
join with a terminated thread
@ SESSION_RUN_STATE_NORMAL
ni_retcode_t ni_packet_buffer_alloc(ni_packet_t *p_packet, int packet_size)
Allocate memory for the packet buffer based on provided packet size.
#define NI_ENC_GOP_PARAMS_G1_QP_OFFSET
ni_aux_data_t * ni_frame_new_aux_data(ni_frame_t *frame, ni_aux_data_type_t type, int data_size)
Add a new auxiliary data to a frame.
#define NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE
#define NI_ENC_PARAM_MIN_FRAMES_DELAY
ni_retcode_t ni_ai_session_query_metrics(ni_session_context_t *p_ctx, ni_network_perf_metrics_t *p_metrics)
@ NI_RETCODE_PARAM_INVALID_VALUE
#define NI_ENC_PARAM_MAX_CLL
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC1
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC0_USED
int reconfig_vbv_buffer_size
ni_retcode_t ni_decoder_session_flush(ni_session_context_t *p_ctx)
Flush decoder output.
ni_pthread_mutex_t * pext_mutex
ni_device_handle_t device_handle
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC2
#define NI_MAX_NUM_AUX_DATA_PER_FRAME
ni_retcode_t ni_scaler_dest_frame_alloc(ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params, niFrameSurface1_t *p_surface)
allocate device destination frame from scaler hwframe pool
#define NI_MAX_SPATIAL_LAYERS
ni_retcode_t ni_device_config_namespace_num(ni_device_handle_t device_handle, uint32_t namespace_num, uint32_t sriov_index)
Send namespace num and SRIOv index to the device with specified logic block address.
#define NI_PARAM_MAX_HEIGHT
#define NI_ENC_PARAM_CACHE_ROI
ni_retcode_t ni_encoder_session_open(ni_session_context_t *p_ctx)
Open a xcoder encoder instance.
LIB_API ni_device_pool_t * ni_rsrc_get_device_pool(void)
Create and return the allocated ni_device_pool_t struct.
int reconfig_vbv_max_rate
#define NI_ENC_PARAM_SPATIAL_LAYERS
#define NI_ENC_PARAM_INTRA_REFRESH_ARG
ni_retcode_t ni_hwframe_clone(ni_session_context_t *p_ctx, ni_frameclone_desc_t *p_frameclone_desc)
Copy a src hw frame to a dst hw frame.
int ni_device_session_acquire(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Acquire a P2P frame buffer from the hwupload session.
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PICS
#define NI_DEC_PARAM_CROP_PARAM_0
#define NI_DEC_PARAM_CROP_PARAM_1
ni_retcode_t ni_query_extra_info(ni_device_handle_t device_handle, ni_device_extra_info_t *p_dev_extra_info, uint8_t fw_rev[])
Query CompositeTemp from device.
#define NI_XCODER_PRESET_NAME_VERYSLOW
#define NI_ENC_PARAM_ENABLE_RATE_CONTROL
#define NI_ENC_PARAM_VBV_BUFFER_REENCODE
#define NI_ENC_GOP_PARAMS_G5_QP_OFFSET
#define NI_APP_ENC_FRAME_META_DATA_SIZE
ni_retcode_t ni_decoder_frame_buffer_alloc(ni_buf_pool_t *p_pool, ni_frame_t *p_frame, int alloc_mem, int video_width, int video_height, int alignment, int factor, int is_planar)
Allocate memory for decoder frame buffer based on provided parameters; the memory is retrieved from a...
@ XCODER_TEST_RECONF_BR_API
int32_t xcoders[NI_DEVICE_TYPE_XCODER_MAX][NI_MAX_DEVICE_CNT]
#define NI_MIN_CU_SIZE_MODE
#define IS_XCODER_DEVICE_TYPE(t)
ni_pic_type_t ni_pict_type
ni_buf_t * ni_buf_pool_get_buffer(ni_buf_pool_t *p_buffer_pool)
#define NI_MAX_RESOLUTION_WIDTH
#define NI_VPU_ALIGN16(_x)
int ni_scaler_session_open(ni_session_context_t *p_ctx)
Open a xcoder scaler instance.
ni_network_layer_info_t linfo
@ NI_SCALER_OPCODE_OVERLAY
@ NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
#define NI_MIN_DECODING_REFRESH_TYPE
ni_encoder_cfg_params_t cfg_enc_params
#define NI_ENC_PARAM_RDO_LEVEL
ni_retcode_t ni_ai_packet_buffer_alloc(ni_packet_t *p_packet, ni_network_data_t *p_network)
Allocate output layers memory for the packet buffer based on provided network.
#define NI_ENC_PARAM_PROFILE
ni_retcode_t ni_device_session_query_detail_v1(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_detail_status_v1_t *detail_data)
Query detail session data from the device - If device_type is valid, will query session data from spe...
#define NI_ENC_PARAM_INTRA_COMPENSATE_MODE
void ni_buf_pool_return_buffer(ni_buf_t *buf, ni_buf_pool_t *p_buffer_pool)
ni_retcode_t ni_encoder_gop_params_set_value(ni_xcoder_params_t *p_params, const char *name, const char *value)
Set GOP parameter value referenced by name in encoder parameters structure.
@ XCODER_TEST_RECONF_INTRAPRD_API
uint32_t data_len[NI_MAX_NUM_DATA_POINTERS]
ni_retcode_t ni_decoder_session_copy_internal(ni_session_context_t *src_p_ctx, ni_session_context_t *dst_p_ctx)
Copy a xcoder decoder worker thread info.
@ NI_RETCODE_ERROR_UNLOCK_DEVICE
#define QUERY_GET_VERSIONS_R
uint8_t fw_rev_nor_flash[8]
#define NI_ENC_GOP_PARAMS_G3_QP_OFFSET
Definitions related to NETINT P2P kernel driver interface.
int max_consecutive_skip_num
int ni_device_session_hwup(ni_session_context_t *p_ctx, ni_session_data_io_t *p_src_data, niFrameSurface1_t *hwdesc)
Sends raw YUV input to uploader instance and retrieves a HW descriptor to represent it.
#define NI_MIN_USE_RECOMMENDED_ENC_PARAMS
#define NI_ENC_PARAM_INTRA_MB_REFRESH_ARG
#define NI_DEC_PARAM_SCALE_0_ROUND
void ni_gop_params_check_set(ni_xcoder_params_t *p_param, char *value)
Set custom gop and prepare to check if success.
int ni_hwupload_session_read_hwdesc(ni_session_context_t *p_ctx, niFrameSurface1_t *hwdesc)
Retrieve a HW descriptor of uploaded frame.
struct _ni_buf_pool_t * pool
int8_t customize_roi_qp_map[NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL][NI_CUSTOMIZE_ROI_QP_NUM]
ni_retcode_t ni_scaler_session_close(ni_session_context_t *p_ctx, int eos_received)
close a scaler session
ni_retcode_t ni_encoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height, ni_codec_format_t codec_format)
Initialize default encoder parameters.
ni_aux_data_t * ni_frame_new_aux_data_from_raw_data(ni_frame_t *frame, ni_aux_data_type_t type, const uint8_t *raw_data, int data_size)
Add a new auxiliary data to a frame and copy in the raw data.
int reconf_hash[NI_BITRATE_RECONFIG_FILE_MAX_LINES][NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE]
@ NI_FRAME_AUX_DATA_FRAMERATE
#define NI_ENC_PARAM_LTR_REF_QPOFFSET
ni_retcode_t ni_scaler_frame_pool_alloc(ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params)
init output pool of scaler frames
@ NI_RETCODE_ERROR_NVME_CMD_FAILED
#define NI_ENC_PARAM_ENABLE_AI_ENHANCE
#define NI_ENC_PARAM_TUNE_BFRAME_VISUAL
ni_retcode_t ni_dec_reconfig_ppu_params(ni_session_context_t *p_session_ctx, ni_xcoder_params_t *p_param, ni_ppu_config_t *p_ppu_config)
Send a p_config command to reconfigure decoding ppu params.
#define NI_ENC_GOP_PARAMS_G2_PIC_TYPE
int enable_dynamic_8x8_merge
uint8_t fl_ver_last_ran[8]
#define NI_ENC_PARAM_MASTER_DISPLAY
uint32_t keep_alive_timeout
#define NI_ENC_PARAM_SAR_NUM
#define NI_MEM_PAGE_ALIGNMENT
#define NI_ENC_PARAM_CTB_RC_MODE
int long_term_ref_interval
#define GBRWLPARSE(OUT1, OUT2, OFF, IDX)
ni_retcode_t ni_decoder_session_open(ni_session_context_t *p_ctx)
Open a xcoder decoder instance.
#define NI_ENC_PARAM_PB_RATIO
#define NI_ENC_PARAM_INTRA_MB_REFRESH_MODE
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC3_USED
ni_retcode_t ni_scaler_set_watermark_params(ni_session_context_t *p_ctx, ni_scaler_watermark_params_t *p_params)
Send a p_config command to configure scaling watermark parameters.
#define NI_ENC_PARAM_ENABLE_FILLER
#define NI_ENC_PARAM_ENABLE_HVS_QP
struct _ni_device_extra_info ni_device_extra_info_t
int ni_pthread_mutex_lock(ni_pthread_mutex_t *mutex)
thread mutex lock
#define NI_ENC_GOP_PARAMS_G0_POC_OFFSET
int ni_hwdownload_session_read(ni_session_context_t *p_ctx, ni_frame_t *p_frame, niFrameSurface1_t *hwdesc)
Retrieve a YUV p_frame from decoder.
ni_device_handle_t device_handle
ni_encoder_change_params_t * enc_change_params
void ni_rsrc_free_device_context(ni_device_context_t *p_device_context)
Free previously allocated device context.
#define NI_DEC_PARAM_ENABLE_CUSTOM_SEI_PASSTHRU
@ XCODER_TEST_RECONF_SLICE_ARG_API
#define NI_ENC_PARAM_CHROMA_QP_OFFSET
uint8_t * av1_p_buffer[MAX_AV1_ENCODER_GOP_NUM]
#define NI_DEC_PARAM_ENABLE_PPU_SCALE_LIMIT
#define NI_EC_POLICY_TOLERANT
#define NI_ENC_PARAM_RECONF_DEMO_MODE
#define NI_ENC_GOP_PARAMS_G5_POC_OFFSET
#define NI_ENC_PARAM_INTRA_QP_DELTA
ni_retcode_t ni_ai_session_read_metrics(ni_session_context_t *p_ctx, ni_network_perf_metrics_t *p_metrics)
Fetch perf metrics of inferences from device.
ni_retcode_t ni_decoder_params_set_value(ni_xcoder_params_t *p_params, const char *name, char *value)
Set value referenced by name in decoder parameters structure.
#define NI_ENC_PARAM_VBV_MAXRAE
ni_retcode_t ni_uploader_session_open(ni_session_context_t *p_ctx)
Open a xcoder upload instance.
ni_retcode_t ni_enc_prep_reconf_demo_data(ni_session_context_t *p_enc_ctx, ni_frame_t *p_frame)
Convert various reconfig and demo modes (stored in encoder configuration) to aux data and store them ...
#define NI_MAX_CUSTOM_SEI_PASSTHRU
#define NI_ENC_PARAM_MAX_DELTA_QP
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC1_USED
#define NI_ENC_PARAM_USE_LOW_DELAY_POC_TYPE
struct _ni_enc_quad_roi_custom_map::@6 field
#define NI_ENC_PARAM_ENABLE_SMOOTH_CRF
#define NI_DEC_PARAM_SVC_T_DECODING_LAYER
NI_DEPRECATED ni_device_handle_t ni_device_open(const char *p_dev, uint32_t *p_max_io_size_out)
Open device and return device device_handle if successful.
struct _ni_scaler_multi_drawbox_params_t ni_scaler_multi_drawbox_params_t
#define NI_DEC_PARAM_SCALE_1_RES_CEIL
#define NI_ENC_GOP_PARAMS_G7_POC_OFFSET
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC0_USED
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
ni_retcode_t ni_ai_session_close(ni_session_context_t *p_ctx, int eos_recieved)
#define NI_XCODER_REVISION_API_MAJOR_VER_IDX
ni_device_handle_t sender_handle
int ni_hwdownload_by_frame_idx(niFrameSurface1_t *hwdesc, ni_frame_t *p_frame, int is_auto_dl)
Retrieve a YUV p_frame by frame index.
#define NI_ENC_PARAM_AI_ENHANCE_LEVEL
ni_retcode_t ni_enc_frame_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, int alignment, int metadata_flag, int factor, int hw_frame_count, int is_planar, ni_pix_fmt_t pix_fmt)
Wrapper function for ni_frame_buffer_alloc. Meant to handle RGBA min. resoulution considerations for ...
ni_retcode_t ni_frame_buffer_alloc_pixfmt(ni_frame_t *p_frame, int pixel_format, int video_width, int video_height, int linesize[], int alignment, int extra_len)
Allocate memory for the frame buffer based on provided parameters taking into account the pixel forma...
ni_retcode_t ni_hwframe_p2p_buffer_recycle(ni_frame_t *p_frame)
Recycle hw P2P frames.
int ni_rsrc_unlock(int device_type, ni_lock_handle_t lock)
unlock a file lock
#define NI_CUSTOMIZE_ROI_QP_NUM
Max number of entries per line supported for the qp number.
uint32_t keep_alive_timeout
ni_retcode_t ni_reconfig_bitrate(ni_session_context_t *p_ctx, int32_t bitrate)
Reconfigure bitrate dynamically during encoding.
int customize_roi_qp_level
ni_retcode_t ni_ai_session_read(ni_session_context_t *p_ctx, ni_packet_t *p_packet)
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC2
void ni_frame_free_aux_data(ni_frame_t *frame, ni_aux_data_type_t type)
If auxiliary data of the given type exists in the frame, free it and remove it from the frame.
ni_retcode_t ni_packet_buffer_free_av1(ni_packet_t *p_packet)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc for AV1 packets merge.
ni_retcode_t ni_ai_frame_buffer_alloc(ni_frame_t *p_frame, ni_network_data_t *p_network)
Allocate input layers memory for AI frame buffer based on provided parameters taking into account wid...
#define NI_ENC_PARAM_LONG_TERM_REFERENCE_COUNT
ni_retcode_t ni_parse_reconf_file(const char *reconf_file, int hash_map[][NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE])
#define NI_MAX_UPLOAD_INSTANCE_FRAMEPOOL
#define NI_ENC_PARAM_HRD_ENABLE
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC3
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC1_USED
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC0
#define NI_DEC_PARAM_ENABLE_ADVANCED_EC
#define NI_ENC_PARAM_DISABLE_BFRAME_RDOQ
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC1
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC2_USED
#define NI_ENC_GOP_PARAMS_G7_TEMPORAL_ID
ni_retcode_t ni_uploader_set_frame_format(ni_session_context_t *p_upl_ctx, int width, int height, ni_pix_fmt_t pixel_format, int isP2P)
Set the outgoing frame format for the uploader.
void ni_usleep(int64_t usec)
ni_retcode_t ni_query_fl_fw_versions(ni_device_handle_t device_handle, ni_device_info_t *p_dev_info)
Query firmware loader and firmware versions from the device.
int scene_change_detect_level
ni_retcode_t ni_ai_multi_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t p_cfg_in[], int numInCfgs, ni_frame_config_t *p_cfg_out)
#define NI_ENC_PARAM_PADDING
@ NI_RETCODE_ERROR_PERMISSION_DENIED
struct _niFrameSurface1 niFrameSurface1_t
#define NI_AI_HW_ALIGN_SIZE
#define NI_ENC_PARAM_CPLX_DECAY
ni_retcode_t ni_encoder_frame_zerocopy_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, const int linesize[], const uint8_t *data[], int extra_len)
Allocate memory for encoder zero copy (metadata, etc.) for encoding based on given parameters,...
enum _ni_device_mode ni_device_mode_t
Device access mode enumeration.
#define NI_VPU_ALIGN32(_x)
@ NI_PIXEL_PLANAR_FORMAT_SEMIPLANAR
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC0_USED
int ni_packet_copy(void *p_destination, const void *const p_source, int cur_size, void *p_leftover, int *p_prev_size)
Copy video packet accounting for alignment.
struct _ni_device_vf_ns_id ni_device_vf_ns_id_t
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC2_USED
#define NI_ENC_PARAM_HORIZONTAL_OFFSET
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC0
@ NI_RETCODE_PARAM_WARNING_DEPRECATED
#define NI_VPU_ALIGN128(_x)
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP
#define NI_ENC_PARAM_CU_TREE_FACTOR
#define NI_ENC_PARAM_VIDEO_FULL_RANGE_FLAG
#define NI_DEC_PARAM_SCALE_2_ROUND
#define NI_DATA_BUFFER_LEN
#define NI_ENC_PARAM_MOTION_CONSTRAINED_MODE
void ni_device_session_context_clear(ni_session_context_t *p_ctx)
Clear already allocated session context.
int32_t ni_get_dma_buf_file_descriptor(const ni_frame_t *p_frame)
Get the DMA buffer file descriptor from the P2P frame.
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC3_USED
ni_retcode_t ni_scaler_session_query_buffer_avail(ni_session_context_t *p_ctx)
Query and acquire buffer from xcoder scaler instance.
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC1
ni_device_context_t * ni_rsrc_allocate_simple_direct(ni_device_type_t device_type, int guid)
Allocate resources for decoding/encoding, by designating explicitly the device to use....
ni_enc_quad_roi_custom_map * roi_map
ni_retcode_t ni_decoder_session_send_eos(ni_session_context_t *p_ctx)
Send end of stream signal to the decoder.
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC2_USED
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 ...
#define NI_VPU_ALIGN8(_x)
#define NI_DEC_PARAM_SCALE_2_LONG_SHORT_ADAPT
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC2_USED
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PICS
@ NI_RETCODE_PARAM_ERROR_TOO_BIG
#define NI_ENC_PARAM_RECONF_FILE
ni_retcode_t ni_encoder_set_input_frame_format(ni_session_context_t *p_enc_ctx, ni_xcoder_params_t *p_enc_params, int width, int height, int bit_depth, int src_endian, int planar)
Set the incoming frame format for the encoder.
ni_retcode_t ni_recv_from_target(ni_session_context_t *p_ctx, const ni_p2p_sgl_t *dmaAddrs, ni_frame_t *pDstFrame)
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
#define NI_ENC_GOP_PARAMS_G7_QP_OFFSET
ni_custom_gop_params_t custom_gop_params
#define NI_VPU_CEIL(_data, _align)
int ni_pthread_create(ni_pthread_t *thread, const ni_pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
create a new thread
#define NI_EC_POLICY_DEFAULT
ni_retcode_t ni_hwframe_buffer_recycle2(niFrameSurface1_t *surface)
Recycle a frame buffer on card, only hwframe descriptor is needed.
ni_retcode_t ni_device_config_qos(ni_device_handle_t device_handle, uint32_t mode)
Send qos mode to the device with specified logic block address.
ni_retcode_t ni_device_alloc_frame(ni_session_context_t *p_ctx, int width, int height, int format, int options, int rectangle_width, int rectangle_height, int rectangle_x, int rectangle_y, int rgba_color, int frame_index, ni_device_type_t device_type)
Allocate a frame on the device for 2D engine or AI engine to work on based on provided parameters.
char blk_name[NI_MAX_DEVICE_NAME_LEN]
int ni_strcasecmp(const char *a, const char *b)
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC0
@ XCODER_TEST_RECONF_VBV_API
@ XCODER_TEST_FORCE_IDR_FRAME
#define NI_ENC_PARAM_ADAPTIVE_CRF_MODE
#define NI_XCODER_LOG_NAMES_ARRAY_LEN
ni_retcode_t ni_decoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default decoder parameters.
bool enable_all_sei_passthru
ni_retcode_t ni_encoder_session_close(ni_session_context_t *p_ctx, int eos_recieved)
Close a xcoder encoder instance.
#define NI_ENC_PARAM_STATISTIC_OUTPUT_LEVEL
bool disable_adaptive_buffers
#define NI_ENC_PARAM_SKIP_FRAME_INTERVAL
@ NI_RETCODE_PARAM_ERROR_WIDTH_TOO_BIG
#define NI_DEC_PARAM_EC_POLICY
#define NI_DEC_PARAM_ERROR_THRESHOLD
int enable_dynamic_16x16_merge
#define NI_ENC_PARAM_COLOR_TRANSFER_CHARACTERISTIC
NI_DEPRECATED ni_retcode_t ni_p2p_xfer(ni_session_context_t *pSession, niFrameSurface1_t *source, uint64_t ui64DestAddr, uint32_t ui32FrameSize)
Initiate P2P transfer (P2P write) (deprecated)
#define NI_PARAM_AV1_ALIGN_WIDTH_HEIGHT
#define NI_ENC_PARAM_SKIP_FRAME_ENABLE
#define ni_memfree(p_memptr)
#define NI_ENC_PARAM_FORCED_HEADER_ENABLE
#define NI_ENC_PARAM_BITRATE_WINDOW
#define NI_ENC_PARAM_ENABLE_VFR
ni_retcode_t ni_device_session_query_detail(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_detail_status_t *detail_data)
Query detail session data from the device - If device_type is valid, will query session data from spe...
int ni_device_session_read(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data packet from decoder If ...
#define NI_ENC_PARAM_ENABLE_DYNAMIC_8X8_MERGE
#define NI_EC_ERR_THRESHOLD_DEFAULT
ni_retcode_t ni_frame_buffer_alloc_hwenc(ni_frame_t *p_frame, int video_width, int video_height, int extra_len)
Allocate memory for the hwDescriptor buffer based on provided parameters taking into account pic size...
#define NI_MAX_NUM_DATA_POINTERS
ni_retcode_t ni_device_session_restart(ni_session_context_t *p_ctx, int video_width, int video_height, ni_device_type_t device_type)
Send a restart command after flush command Only support Encoder now.
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC3
@ NI_XCODER_GENERAL_STATE
#define NI_ENC_PARAM_INTRA_REFRESH_RESET
#define NI_PARAM_AV1_MAX_HEIGHT
int32_t ni_nvme_send_read_cmd(ni_device_handle_t handle, ni_event_handle_t event_handle, void *p_data, uint32_t data_len, uint32_t lba)
Compose an io read command.
int ni_pthread_mutex_init(ni_pthread_mutex_t *mutex)
initialize a mutex
union _ni_session_data_io::@19 data
#define NI_PARAM_AV1_MIN_WIDTH
char blk_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
#define NI_ENC_GOP_PARAMS_G0_QP_OFFSET
#define NI_ENC_PARAM_PAST_FRAME_MAX_INTRA_RATIO
#define NI_ENC_PARAM_SCENE_CHANG_DETECT_LEVEL
#define NI_ENC_PARAM_IFRAME_SIZE_RATIO
ni_retcode_t ni_device_session_open(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Open a new device session depending on the device_type parameter If device_type is NI_DEVICE_TYPE_DEC...
int linkFrameMaxIntraRatio
void ni_device_session_context_free(ni_session_context_t *p_ctx)
Free previously allocated session context.
@ XCODER_TEST_RECONF_VUI_HRD_API
ni_gop_rps_t rps[NI_MAX_REF_PIC]
#define CONFIG_INSTANCE_SetScalerDrawBoxPara_W(sid, instance)
Private definitions used by ni_rsrc_api.cpp for management of NETINT video processing devices.
int force_pic_qp_demo_mode
@ NI_DEC_CROP_MODE_MANUAL
@ XCODER_TEST_RECONF_LONG_TERM_REF
#define NI_ENC_PARAM_GOP_PRESET_IDX
#define NI_ENC_PARAM_ENTROPY_CODING_MODE
ni_lat_meas_q_t * ni_lat_meas_q_create(int capacity)
Create a latency measurement queue object of a given capacity.
#define NI_VPU_ALIGN4096(_x)
@ NI_RETCODE_ERROR_INVALID_SESSION
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC3
int ni_hwupload_session_write(ni_session_context_t *p_ctx, ni_frame_t *p_frame, niFrameSurface1_t *hwdesc)
Send a YUV p_frame to upload session.
char * ni_strtok(char *s, const char *delim, char **saveptr)
ni_retcode_t ni_device_session_copy(ni_session_context_t *src_p_ctx, ni_session_context_t *dst_p_ctx)
Copy existing decoding session params for hw frame usage.
struct _ni_enc_hevc_roi_custom_map::@4 field
uint32_t total_pixel_load
#define QUERY_GET_NS_VF_R
#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR
ni_retcode_t ni_reconfig_max_frame_size(ni_session_context_t *p_ctx, int32_t max_frame_size)
Reconfigure maxFrameSize dynamically during encoding.
#define NI_ENC_PARAM_MULTICORE_JOINT_MODE
#define NI_DEC_PARAM_CROP_PARAM_2
@ NI_RETCODE_PARAM_ERROR_WIDTH_TOO_SMALL
#define NI_ENC_PARAM_PREFERRED_TRANSFER_CHARACTERISTICS
#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR_MAX
@ NI_XCODER_READ_DESC_STATE
ni_retcode_t ni_device_dec_session_save_hdrs(ni_session_context_t *p_ctx, uint8_t *hdr_data, uint8_t hdr_size)
Save a stream's headers in a decoder session that can be used later for continuous decoding from the ...
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC2_USED
#define NI_ENC_PARAM_COLOR_SPACE
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC2
ni_pthread_cond_t low_delay_sync_cond
#define NI_ENC_PARAM_STILL_IMAGE_DETECT_LEVEL
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC1
int motionConstrainedMode
ni_retcode_t ni_hwupload_session_query_buffer_avail(ni_session_context_t *p_ctx)
Query and acquire buffer from xcoder upload instance.
#define NI_ENC_GOP_PARAMS_G4_POC_OFFSET
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO_API
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC2_USED
ni_event_handle_t thread_event_handle
#define NI_PARAM_AV1_MIN_HEIGHT
int decoding_refresh_type
#define NI_XCODER_LOG_NAME_ERROR
int ni_xcoder_session_query(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Query current xcoder status.
ni_retcode_t ni_encoder_start_buffer_alloc(ni_frame_t *p_frame)
Allocate memory for the non-4k-aligned part at the start of YUV data for encoder input data.
#define NI_MIN_FRAME_SIZE
#define NI_DEC_PARAM_SEMI_PLANAR_0
ni_retcode_t ni_reconfig_max_frame_size_ratio(ni_session_context_t *p_ctx, int32_t max_frame_size_ratio)
Reconfigure maxFrameSizeRatio dynamically during encoding.
#define NI_ENC_PARAM_FRAME_RATE_DENOM
ni_retcode_t ni_reconfig_vui(ni_session_context_t *p_ctx, ni_vui_hrd_t *vui)
Reconfigure VUI HRD dynamically during encoding.
#define NI_ENC_PARAM_AVCC_HVCC
#define NI_XCODER_PRESET_NAME_SLOWER
#define NI_DEC_PARAM_SURVIVE_STREAM_ERR
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC0
#define NI_ENC_PARAM_QCOMP
#define NI_MAX_PPU_PARAM_EXPR_CHAR
@ XCODER_TEST_RECONF_LTR_API
ni_retcode_t ni_encoder_metadata_buffer_alloc(ni_frame_t *p_frame, int extra_len)
Allocate memory for the metadata header and auxillary data for encoder input data.
ni_retcode_t ni_uploader_session_close(ni_session_context_t *p_ctx)
Close an xcoder upload instance.
#define NI_XCODER_PRESET_NAME_FASTER
#define NI_MAX_NUM_OF_DECODER_OUTPUTS
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_API
#define NI_ENC_PARAM_SPATIAL_LAYERS_REF_BASE_LAYER
int ni_sprintf(char *dest, size_t dmax, const char *fmt,...)
int ni_posix_memalign(void **memptr, size_t alignment, size_t size)
Allocate aligned memory.
@ NI_RETCODE_ERROR_UNSUPPORTED_FEATURE
#define NI_DEC_PARAM_ENABLE_USR_DATA_SEI_PASSTHRU
#define NI_ENC_GOP_PARAMS_G6_POC_OFFSET
ni_retcode_t ni_device_alloc_dst_frame(ni_session_context_t *p_ctx, niFrameSurface1_t *p_out_surface, ni_device_type_t device_type)
Allocate a frame on the device and return the frame index.
#define NI_DEC_PARAM_FORCE_8BIT_0
void ni_log2(const void *p_context, ni_log_level_t level, const char *fmt,...)
print log message and additional information using ni_log_callback,
#define NI_XCODER_PRESET_NAMES_ARRAY_LEN
#define NI_DISABLE_USR_DATA_SEI_PASSTHRU
float forceBframeQpfactor
#define NI_DEC_PARAM_MAX_EXTRA_HW_FRAME_CNT
@ XCODER_TEST_CRF_FLOAT_API
int ni_calculate_total_frame_size(const ni_session_context_t *p_upl_ctx, const int linesize[])
Calculate the total size of a frame based on the upload context attributes and includes rounding up t...
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO
#define NI_DEC_PARAM_REDUCE_DPB_DELAY
#define QUERY_GET_TEMPERATURE_R
ni_retcode_t ni_set_ltr_interval(ni_session_context_t *p_ctx, int32_t ltr_interval)
Set Long Term Reference interval.
ni_device_info_t * p_device_info
Private definitions for interfacing with NETINT video processing devices over NVMe.
#define NI_DEC_PARAM_SCALE_2
ni_retcode_t ni_strncpy(char *dest, size_t dmax, const char *src, size_t slen)
int ni_device_session_acquire_for_read(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Acquire a P2P frame buffer from the hwupload session for P2P read.
#define NI_ENC_GOP_PARAMS_G3_POC_OFFSET
#define NI_ENC_PARAM_FORCE_PIC_QP_DEMO_MODE
#define NI_ENC_PARAM_ENABLE_8X8_TRANSFORM
uint8_t nor_flash_fw_revision[NI_VERSION_CHARACTER_COUNT]
ni_event_handle_t thread_event_handle
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PICS
ni_pthread_t keep_alive_thread
ni_load_query_t load_query
#define NI_ENC_GOP_PARAMS_G3_PIC_TYPE
#define NI_ENC_PARAM_CROP_WIDTH
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC2
ni_retcode_t ni_query_temperature(ni_device_handle_t device_handle, ni_device_temp_t *p_dev_temp, uint8_t fw_rev[])
Query CompositeTemp from device.
#define NI_ENC_PARAM_ENABLE_AI_HVSPLUS
#define NI_ENC_PARAM_INTRA_QP
#define NI_SCALER_FLAG_P2
#define NI_ENC_RC_QP_DELTA_RANGE
uint64_t session_timestamp
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC0_USED
#define NI_ENC_GOP_PARAMS_G6_TEMPORAL_ID
uint32_t ni_decode_power_measurement(uint32_t current_data, const uint8_t *serial_number)
decode the raw current obtained and determine power
#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC3_USED
@ NI_FRAME_AUX_DATA_LTR_INTERVAL
ni_retcode_t ni_encoder_frame_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int alignment, int extra_len, bool alignment_2pass_wa)
Allocate memory for the frame buffer for encoding based on given parameters, taking into account pic ...
#define NI_MAX_NUM_SW_FRAME_DATA_POINTERS
#define NI_ENC_GOP_PARAMS_G2_QP_OFFSET
#define NI_ENC_PARAM_SAR_DENOM
#define NI_DEC_PARAM_SAVE_PKT
#define NI_INVALID_SVCT_DECODING_LAYER
#define NI_ENC_PARAM_LEVEL
@ NI_RETCODE_PARAM_INVALID_NAME
ni_thread_arg_struct_t * keep_alive_thread_args
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PICS
ni_event_handle_t ni_create_event(void)
Create event and return event handle if successful (Windows only)
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PICS
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC2
#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC0_USED
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....
#define NI_PARAM_MAX_WIDTH
encoder HEVC ROI custom map (1 CTU = 64bits)
#define NI_DEC_PARAM_SCALE_1_ROUND
ni_network_layer_offset_t * inset
ni_retcode_t ni_custom_packet_buffer_alloc(void *p_buffer, ni_packet_t *p_packet, int buffer_size)
Allocate packet buffer using a user provided pointer, the memory is expected to have already been all...
#define NI_ENC_PARAM_VERTICAL_OFFSET
ni_retcode_t ni_reconfig_min_max_qp(ni_session_context_t *p_ctx, ni_rc_min_max_qp *p_min_max_qp)
Reconfigure min&max qp dynamically during encoding.
#define NI_ENC_PARAM_GET_RECONSTRUCTED_MODE
#define NI_ENC_PARAM_SLICE_ARG
#define NI_MAX_MAX_NUM_MERGE
#define NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL
Max number of lines supported for qpoffset level.
ni_ddr_priority_mode_t ddr_priority_mode
ni_retcode_t ni_encoder_session_send_eos(ni_session_context_t *p_ctx)
Flush encoder output.
uint16_t ppu_h[NI_MAX_NUM_OF_DECODER_OUTPUTS]
uint32_t active_video_height
#define NI_ENC_PARAM_INTRA_PERIOD
int ni_pthread_mutex_destroy(ni_pthread_mutex_t *mutex)
destory a mutex
ni_retcode_t ni_device_session_query_buffer_avail(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Query the session if a buffer is available.
ni_retcode_t ni_p2p_recv(ni_session_context_t *pSession, const ni_p2p_sgl_t *dmaAddrs, ni_frame_t *pDstFrame)
Initiate a P2P transfer (P2P read)
ni_retcode_t ni_dump_log_all_cores(ni_session_context_t *p_ctx, void *p_data, bool gen_log_file)
@ NI_FRAME_AUX_DATA_LONG_TERM_REF
#define NI_ENC_PARAM_VBV_BUFFER_SIZE
int av1_error_resilient_mode
void * ni_session_keep_alive_thread(void *arguments)
decoder keep alive thread function triggers every 1 second
bool ni_gop_params_check(ni_xcoder_params_t *p_param)
Check custom gop params set.
#define NI_MAX_FRAME_SIZE
union _ni_enc_hevc_roi_custom_map ni_enc_hevc_roi_custom_map_t
encoder HEVC ROI custom map (1 CTU = 64bits)
char blk_dev_name[NI_MAX_DEVICE_NAME_LEN]
#define NI_ENC_PARAM_RC_INIT_DELAY
ni_session_run_state_t session_run_state
#define NI_NVME_IDENTITY_CMD_DATA_SZ
uint8_t use_cur_src_as_long_term_pic
int enable_low_delay_check
#define NI_ENC_PARAM_HVS_QP_SCALE
#define NI_DEC_PARAM_ENABLE_ALL_SEI_PASSTHRU
#define NI_ENC_PARAM_DECODING_REFRESH_TYPE
#define NI_ENC_GOP_PARAMS_G1_PIC_TYPE
int ni_device_session_write(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Sends data to the device If device_type is NI_DEVICE_TYPE_DECODER sends data packet to decoder If dev...
void ni_lat_meas_q_destroy(ni_lat_meas_q_t *frame_time_q)
Destroy a latency measurement queue object.
ni_network_layer_params_t * out_param
@ XCODER_TEST_INVALID_REF_FRAME_API
encoder AVC ROI custom map (1 MB = 8bits)
Public definitions for operating NETINT video processing devices for video processing.
uint8_t serial_number[20]
#define NI_ENC_PARAM_LOW_DELAY
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC0
#define NI_ENC_PARAM_ENABLE_ACQUIRE_LIMIT
uint32_t meta_size
Params used in VFR mode Done///.
ni_retcode_t ni_hwframe_buffer_recycle(niFrameSurface1_t *surface, int32_t device_handle)
Recycle a frame buffer on card.
#define NI_ENC_PARAM_PPS_INIT_QP
uint64_t session_timestamp
int still_image_detect_level
#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC0_USED
uint32_t max_nvme_io_size
#define NI_BEST_REAL_LOAD_STR
#define NI_ENC_PARAM_GEN_HDRS
ni_retcode_t ni_strcat(char *dest, size_t dmax, const char *src)
#define NI_ENC_PARAM_PSNR_INTERVAL
#define NI_ENC_GOP_PARAMS_G4_TEMPORAL_ID
ni_retcode_t ni_ai_alloc_hwframe(ni_session_context_t *p_ctx, int width, int height, int options, int pool_size, int frame_index)
#define NI_ENC_PARAM_ROI_ENABLE
#define NI_BEST_MODEL_LOAD_STR
#define NI_ENC_PARAM_MIN_QP
#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC1
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PICS
@ NI_RETCODE_PARAM_ERROR_HEIGHT_TOO_SMALL
#define NI_ENC_PARAM_VBV_MINRATE
uint8_t nor_flash_fl_version[NI_VERSION_CHARACTER_COUNT]
int32_t aspectRatioHeight
uint8_t inconsecutive_transfer
ni_framerate_t last_framerate
#define NI_ENC_PARAM_FRAME_RATE
int32_t ltr_frame_ref_invalid
#define NI_SCALER_FLAG_PC
#define NETINT_IOCTL_ISSUE_REQ
@ NI_RETCODE_PARAM_ERROR_TOO_SMALL
ni_retcode_t ni_device_capability_query2(ni_device_handle_t device_handle, ni_device_capability_t *p_cap, bool device_in_ctxt)
Query device and return device capability structure This function had replaced ni_device_capability_q...
enum _ni_codec_format ni_codec_format_t
This is an enumeration for supported codec formats.
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC2
#define NI_ENC_PARAM_LOG_LEVEL
#define COMPARE(STR1, STR2, STR3)
#define NI_ENC_PARAM_GOP_SIZE
int ni_device_session_hwdl(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, niFrameSurface1_t *hwdesc)
Reads YUV data from hw descriptor stored location on device.
int ni_device_session_read_hwdesc(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data hwdesc from decoder If ...
ni_retcode_t ni_get_memory_offset(ni_session_context_t *p_ctx, const niFrameSurface1_t *hwdesc, uint32_t *p_offset)
Get an address offset from a hw descriptor.
#define NI_ENC_PARAM_FORCE_BFRAME_QPFACTOR
#define NI_ENC_PARAM_DISABLE_ADAPTIVE_BUFFERS
#define NI_ENC_PARAM_ENABLE_TIMECODE
uint8_t * p_metadata_buffer
#define TOTAL_CPU_LOG_BUFFER_SIZE
NI_DEPRECATED bool g_device_in_ctxt
#define NI_ENC_PARAM_ENABLE_2PASS_GOP
int lower_pixel_rate(const ni_load_query_t *pQuery, uint32_t ui32CurrentLowest)
#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC1
#define NI_ENC_CTB_ROW_QP_STEP
ni_retcode_t ni_frame_buffer_alloc_dl(ni_frame_t *p_frame, int video_width, int video_height, int pixel_format)
Allocate preliminary memory for the frame buffer based on provided parameters.
@ NI_RETCODE_ERROR_INVALID_HANDLE
#define NI_XCODER_LOG_NAME_DEBUG
#define NI_ENC_PARAM_ENABLE_MB_LEVEL_RC
@ NI_FRAME_AUX_DATA_CRF_FLOAT
#define AV_CODEC_DEFAULT_BITRATE
ni_enc_hevc_roi_custom_map_t * hevc_roi_map
ni_gop_params_t pic_param[NI_MAX_GOP_NUM]
#define NI_ENC_PARAM_ENABLE_PIC_SKIP
int ni_encoder_session_read(ni_session_context_t *p_ctx, ni_packet_t *p_packet)
#define ni_aligned_free(p_memptr)
#define NI_MAX_GOP_PRESET_IDX
ni_retcode_t ni_uploader_p2p_test_load(ni_session_context_t *p_upl_ctx, uint8_t *p_data, uint32_t len, ni_frame_t *p_hwframe)
Special P2P test API function. Copies video data from the software frame to the hardware P2P frame on...
#define NI_ENC_PARAM_ENABLE_COMPENSATE_QP
ni_retcode_t ni_device_session_flush(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a flush command to the device If device_type is NI_DEVICE_TYPE_DECODER sends EOS command to deco...
@ NI_RETCODE_PARAM_ERROR_ZERO
#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC1_USED
#define NI_ENC_ENABLE_SSIM
int enable_cu_level_rate_control
ni_retcode_t ni_ai_session_read_hwdesc(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
read a hardware descriptor from a scaler session
#define NI_ENC_GOP_PARAMS_G6_QP_OFFSET
@ NI_FRAME_AUX_DATA_INVALID_REF_FRAME
volatile uint64_t * plast_access_time
#define NETINT_IOCTL_SIGNAL_RFENCE
uint32_t start_buffer_size
#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PICS
@ NI_RETCODE_PARAM_ERROR_OOR
#define NI_ENC_GOP_PARAMS_G1_POC_OFFSET
#define NI_FRAME_LITTLE_ENDIAN
#define NI_DEC_PARAM_FORCE_LOW_DELAY
ni_retcode_t ni_device_session_context_init(ni_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
ni_retcode_t ni_uploader_frame_zerocopy_check(ni_session_context_t *p_upl_ctx, int width, int height, const int linesize[], int pixel_format)
Check if incoming frame is hwupload zero copy compatible or not.
int preferred_transfer_characteristics
int ni_device_session_init_framepool(ni_session_context_t *p_ctx, uint32_t pool_size, uint32_t pool)
Sends frame pool setup info to device.
int use_low_delay_poc_type
uint32_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
#define NI_ENC_PARAM_TOTAL_CUTREE_DEPTH
#define NI_ENC_PARAM_PASS1_QP
#define NI_ENC_GOP_PARAMS_G0_TEMPORAL_ID
uint32_t ni_ai_network_layer_size(ni_network_layer_params_t *p_param)
#define NI_DEC_PARAM_DDR_PRIORITY_MODE
#define MAX_CHAR_IN_DEVICE_NAME
const char *const g_xcoder_preset_names[NI_XCODER_PRESET_NAMES_ARRAY_LEN]
#define NI_ENC_PARAM_CUSTOMIZE_ROI_QP_MAP
ni_retcode_t ni_p2p_send(ni_session_context_t *pSession, niFrameSurface1_t *source, uint64_t ui64DestAddr, uint32_t ui32FrameSize)
Initiate P2P transfer (P2P write)
#define NI_DEC_PARAM_ENABLE_LOW_DELAY_CHECK
@ NI_PIXEL_PLANAR_FORMAT_TILED4X4
#define NI_ENC_PARAM_SLICE_MODE
ni_retcode_t ni_uploader_p2p_test_send(ni_session_context_t *p_upl_ctx, uint8_t *p_data, uint32_t len, ni_frame_t *p_hwframe)
Special P2P test API function. Copies YUV data from the software frame to the hardware P2P frame on t...
#define NI_MAX_RESOLUTION_LINESIZE
@ NI_FRAME_AUX_DATA_INTRAPRD
#define NI_ENC_REPEAT_HEADERS_ALL_I_FRAMES
void ni_decoder_frame_buffer_pool_return_buf(ni_buf_t *buf, ni_buf_pool_t *p_buffer_pool)
Return a memory buffer to memory buffer pool.
ni_decoder_input_params_t dec_input_params
int color_transfer_characteristic
ni_retcode_t ni_device_session_close(ni_session_context_t *p_ctx, int eos_recieved, ni_device_type_t device_type)
Close device session that was previously opened by calling ni_device_session_open() If device_type is...
#define NI_DEC_PARAM_ENABLE_PPU_SCALE_ADAPT
#define NI_PARAM_MIN_HEIGHT
@ NI_PIXEL_PLANAR_FORMAT_PLANAR
#define NI_DEFAULT_CU_SIZE_MODE
ni_retcode_t ni_encoder_session_sequence_change(ni_session_context_t *p_ctx, ni_resolution_t *p_resolution)
Send sequnce change to a xcoder encoder instance.
ni_retcode_t ni_fopen(FILE **fp, const char *filename, const char *mode)
#define NI_MIN_GOP_PRESET_IDX
#define NI_ENC_PARAM_PRESET
#define NI_ENC_PARAM_ENABLE_CU_LEVEL_RATE_CONTROL
#define NI_DEC_PARAM_SEMI_PLANAR_2
ni_retcode_t ni_set_ltr(ni_session_context_t *p_ctx, ni_long_term_ref_t *ltr)
Set a frame's support of Long Term Reference frame during encoding.
#define NI_MAX_INTRA_QP_DELTA
ni_retcode_t ni_decoder_frame_buffer_free(ni_frame_t *p_frame)
Free decoder frame buffer that was previously allocated with ni_decoder_frame_buffer_alloc,...
ni_retcode_t ni_decoder_session_close(ni_session_context_t *p_ctx, int eos_recieved)
Close a xcoder decoder instance.
#define NI_MAX_ASPECTRATIO
ni_retcode_t ni_reconfig_slice_arg(ni_session_context_t *p_ctx, int16_t sliceArg)
Reconfigure sliceArg dynamically during encoding.
#define NI_BITRATE_RECONFIG_FILE_MAX_LINES
Max number of lines supported for the bitrate reconfig file.
uint32_t force_low_delay_cnt
#define NI_MAX_RESOLUTION_AREA
ni_frame_t * p_first_frame
@ NI_DMABUF_WRITE_TO_DEVICE
#define NI_ENC_PARAM_HVSPLUS_LEVEL
#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PICS
void * p_master_display_meta_data
int ni_rsrc_get_device_by_block_name(const char *blk_name, ni_device_type_t device_type)
Get GUID of the device by block device name and type.
#define NI_DEC_PARAM_DISABLE_ADAPTIVE_BUFFERS
#define NI_DEC_PARAM_MIN_PACKETS_DELAY
int spatial_layers_ref_base_layer
@ NI_FRAME_AUX_DATA_BITRATE
@ NI_RETCODE_ERROR_LOCK_DOWN_DEVICE
#define NI_ENC_PARAM_ADAPTIVE_CUTREE
#define IDENTIFY_DEVICE_R
#define NI_DEC_PARAM_SCALE_1_LONG_SHORT_ADAPT
@ NI_RETCODE_ERROR_OPEN_DEVICE
#define NI_ENC_PARAM_MAX_CONSUTIVE_SKIP_FRAME_NUMBER
void ni_frame_wipe_aux_data(ni_frame_t *frame)
Free and remove all auxiliary data from the frame.
volatile uint64_t last_access_time
#define NI_DEC_PARAM_CROP_MODE_1