 |
libxcoder
5.4.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>
79 #if __linux__ || __APPLE__
80 static struct stat g_nvme_stat = { 0 };
82 static int close_fd_zero_atexit = 0;
84 static void close_fd_zero(
void)
106 "ERROR: %s() Failed to allocate memory for session context\n",
135 #ifdef MEASURE_LATENCY
159 int framerate_num = 0;
160 int framerate_denom = 0;
199 "ERROR %s(): init xcoder_low_delay_sync_mutex fail return\n",
206 "ERROR %s(): init xcoder_low_delay_sync_cond fail return\n",
236 p_ctx->debug_write_ptr = NULL;
237 p_ctx->debug_write_index_ptr = NULL;
238 p_ctx->debug_write_sent_size = 0;
241 #ifdef MEASURE_LATENCY
275 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
281 event_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
282 if (event_handle == NULL)
286 return NI_INVALID_EVENT_HANDLE;
290 return NI_INVALID_EVENT_HANDLE;
302 if ( NI_INVALID_DEVICE_HANDLE == event_handle )
315 retval = CloseHandle(event_handle);
329 err = close(event_handle);
332 char error_message[100] = {
'\0'};
333 char unknown_error_message[20] = {
'\0'};
334 ni_sprintf(error_message, 100,
"ERROR: %s(): ", __func__);
338 ni_strcat(error_message, 100,
"EBADF\n");
341 ni_strcat(error_message, 100,
"EINTR\n");
347 ni_sprintf(unknown_error_message, 20,
"Unknown error %d\n", err);
348 ni_strcat(error_message, 100, unknown_error_message);
366 ni_device_handle_t
ni_device_open(
const char * p_dev, uint32_t * p_max_io_size_out)
370 HANDLE device_handle;
375 return NI_INVALID_DEVICE_HANDLE;
385 device_handle = CreateFile(p_dev, GENERIC_READ | GENERIC_WRITE,
386 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
387 OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
390 if (INVALID_HANDLE_VALUE == device_handle)
392 retval = GetLastError();
399 return device_handle;
402 ni_device_handle_t fd = NI_INVALID_DEVICE_HANDLE;
413 *p_max_io_size_out = ni_get_kernel_max_io_size(p_dev);
415 *p_max_io_size_out = MAX_IO_TRANSFER_SIZE;
424 fd = open(p_dev, O_RDWR | O_SYNC | O_DIRECT);
427 fd = open(p_dev, O_RDWR | O_SYNC);
437 fd = NI_INVALID_DEVICE_HANDLE;
450 if(close_fd_zero_atexit == 0)
452 close_fd_zero_atexit = 1;
453 atexit(close_fd_zero);
457 ni_log(
NI_LOG_ERROR,
"libxcoder has held the fd=0, but open fd=0 again, maybe fd=0 was closed accidently.");
459 fd = NI_INVALID_DEVICE_HANDLE;
464 retval = fcntl(fd, F_NOCACHE, 1);
470 fd = NI_INVALID_DEVICE_HANDLE;
475 retval = fstat(fd, &g_nvme_stat);
481 fd = NI_INVALID_DEVICE_HANDLE;
485 if (!S_ISCHR(g_nvme_stat.st_mode) && !S_ISBLK(g_nvme_stat.st_mode))
491 fd = NI_INVALID_DEVICE_HANDLE;
513 if ( NI_INVALID_DEVICE_HANDLE == device_handle )
520 if(device_handle == 0)
537 retval = CloseHandle(device_handle);
541 "ERROR: %s(): closing device device_handle %p failed, error: %d\n",
552 err = close(device_handle);
555 char error_message[100] = {
'\0'};
556 char unknown_error_message[20] = {
'\0'};
557 ni_sprintf(error_message, 100,
"ERROR: %s(): ", __func__);
561 ni_strcat(error_message, 100,
"EBADF\n");
564 ni_strcat(error_message, 100,
"EINTR\n");
570 ni_sprintf(unknown_error_message, 20,
"Unknown error %d\n", err);
571 ni_strcat(error_message, 100, unknown_error_message);
582 #ifndef DEPRECATION_AS_ERROR
600 void * p_buffer = NULL;
602 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
606 if ( (NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_cap) )
662 void * p_buffer = NULL;
664 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
668 if ( (NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_cap) )
735 bool use_model_load =
true;
739 uint32_t num_sw_instances = 0;
740 uint32_t pixel_load = 0xFFFFFFFFU;
741 int user_handles =
false;
742 ni_lock_handle_t lock = NI_INVALID_LOCK_HANDLE;
743 ni_device_handle_t handle = NI_INVALID_DEVICE_HANDLE;
744 ni_device_handle_t handle1 = NI_INVALID_DEVICE_HANDLE;
746 uint32_t dummy_io_size = 0;
758 if (!IsUserAnAdmin())
773 "device_type %d, session id %d\n",
825 for (i = 0; i < 120; i++)
843 "%s: device type %d hw_id %d blk_dev_name: %s dev_xcoder_name: %s.\n",
863 "%s: block device name %s type %d guid %d is to "
864 "override passed in guid %d\n",
865 __func__, p_ctx->
blk_dev_name, device_type, tmp_guid_id,
867 p_ctx->
hw_id = tmp_guid_id;
878 if ((handle1 == NI_INVALID_DEVICE_HANDLE) && (handle == NI_INVALID_DEVICE_HANDLE))
880 if (p_ctx->
hw_id >=0)
895 &dummy_io_size)) == NI_INVALID_DEVICE_HANDLE)
941 use_model_load =
false;
972 for (i = 0; i < num_coders; i++)
977 if (p_device_context == NULL)
980 "ERROR: %s() ni_rsrc_get_device_context() failed\n",
991 if (NI_INVALID_DEVICE_HANDLE == p_session_context.
device_handle)
1000 if (NI_INVALID_DEVICE_HANDLE != p_session_context.
device_handle)
1008 g_device_type_str[query_type],
1035 curr_load = p_dev_info->
load;
1038 if (i == 0 || curr_load < least_load ||
1039 (curr_load == least_load &&
1043 least_load = curr_load;
1055 NI_INVALID_DEVICE_HANDLE)
1070 p_ctx->
hw_id = guid;
1092 p_ctx->
hw_id = guid;
1100 else if((handle1 == NI_INVALID_DEVICE_HANDLE) || (handle == NI_INVALID_DEVICE_HANDLE))
1108 user_handles =
true;
1112 "Finish open the session dev:%s guid:%d handle:%p handle1:%p\n",
1118 if (p_device_context == NULL)
1121 "ERROR: %s() ni_rsrc_get_device_context() failed\n",
1123 if (user_handles !=
true)
1149 "ERROR: %s() cannot retrieve DDR configuration\n",
1151 if (user_handles !=
true)
1165 "ERROR: %s() keep_alive_timeout was 0, should be between 1-100. "
1166 "Setting to default of %u\n",
1170 switch (device_type)
1175 if (user_handles !=
true)
1198 if (p_enc_params && p_enc_params->
hwframes &&
1214 if (user_handles !=
true)
1232 if (user_handles !=
true)
1250 if (user_handles !=
true)
1268 if (user_handles !=
true)
1285 if (user_handles !=
true)
1295 __func__, device_type);
1361 p_device_pool = NULL;
1420 "join keep alive thread fail! : sid %u ret %d\n",
1431 switch (device_type)
1462 __func__, device_type);
1537 switch (device_type)
1553 __func__, device_type);
1595 0 == memcmp(p_ctx->
p_hdr_buf, hdr_data, hdr_size))
1607 memcpy(p_ctx->
p_hdr_buf, hdr_data, hdr_size);
1684 if (!p_ctx || !p_data)
1700 "ERROR: %s() keep alive thread has been closed, "
1701 "hw:%d, session:%d\n",
1718 switch (device_type)
1739 __func__, device_type);
1784 if ((!p_ctx) || (!p_data))
1801 "ERROR: %s() keep alive thread has been closed, "
1802 "hw:%d, session:%d\n",
1819 switch (device_type)
1823 int seq_change_read_count = 0;
1833 uint32_t aligned_width;
1843 if (0 == retval && seq_change_read_count)
1846 "%s (decoder): seq change NO data, next time.\n", __func__);
1852 else if (retval < 0)
1868 "%s (decoder): resolution change, frame size %ux%u -> %ux%u, "
1869 "width %u bit %d, pix_fromat_changed %d, actual_video_width %d, continue read ...\n",
1878 seq_change_read_count++;
1901 __func__, device_type);
1949 __func__, device_type);
1989 __func__, device_type);
2029 __func__, device_type);
2050 uint32_t namespace_num, uint32_t sriov_index)
2053 __func__, namespace_num, sriov_index);
2074 __func__, device_handle, mode);
2093 ni_device_handle_t device_handle_t,
2094 uint32_t over_provision)
2097 float f_over_provision = 0;
2098 memcpy(&f_over_provision, &over_provision,
sizeof(int32_t));
2100 __func__, device_handle, device_handle_t, f_over_provision);
2136 int video_height,
int alignment,
2137 int metadata_flag,
int factor,
2138 int hw_frame_count,
int is_planar)
2140 void* p_buffer = NULL;
2141 int metadata_size = 0;
2143 int width_aligned = video_width;
2144 int height_aligned = video_height;
2146 if ((!p_frame) || ((factor!=1) && (factor!=2) && (factor !=4))
2151 "factor %d, video_width %d, video_height %d\n",
2152 __func__, factor, video_width, video_height);
2167 width_aligned = ((((video_width * factor) + 127) / 128) * 128) / factor;
2168 height_aligned = ((video_height + 1) / 2) * 2;
2173 height_aligned = ((video_height + 1) / 2) * 2;
2181 width_aligned = ((video_width + 31) / 32) * 32;
2182 height_aligned = ((video_height + 7) / 8) * 8;
2185 height_aligned = ((video_height + 15) / 16) * 16;
2189 int luma_size = width_aligned * height_aligned * factor;
2194 int chroma_width_aligned = ((((video_width / 2 * factor) + 127) / 128) * 128) / factor;
2198 chroma_width_aligned =
2199 ((((video_width * factor) + 127) / 128) * 128) / factor;
2201 int chroma_height_aligned = height_aligned / 2;
2202 chroma_b_size = chroma_r_size = chroma_width_aligned * chroma_height_aligned * factor;
2210 chroma_b_size = chroma_r_size = 0;
2216 chroma_b_size = luma_size / 4;
2217 chroma_r_size = chroma_b_size;
2222 if (hw_frame_count == 0)
2223 buffer_size = luma_size + chroma_b_size + chroma_r_size + metadata_size;
2237 "%s: free current p_frame, p_frame->buffer_size=%u\n", __func__,
2275 p_frame->
data_len[1] = chroma_b_size;
2276 p_frame->
data_len[2] = chroma_r_size;
2295 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);
2334 int video_height,
int alignment,
2335 int metadata_flag,
int factor,
2336 int hw_frame_count,
int is_planar,
2343 if (((factor!=1) && (factor!=2) && (factor !=4))
2348 "factor %d, video_width %d, video_height %d\n",
2349 __func__, factor, video_width, video_height);
2376 dst_stride, height_aligned);
2384 video_height, dst_stride, alignment,
2406 int video_height,
int pixel_format)
2408 void *p_buffer = NULL;
2410 int width_aligned = video_width;
2411 int height_aligned = video_height;
2419 (video_height <= 0))
2422 "ERROR: %s passed parameters are null or not supported, "
2423 "video_width %d, video_height %d\n",
2424 __func__, video_width, video_height);
2428 switch (pixel_format)
2434 luma_size = width_aligned * height_aligned;
2437 chroma_r_size = chroma_b_size;
2443 luma_size = width_aligned * height_aligned * 2;
2445 chroma_r_size = chroma_b_size;
2451 luma_size = width_aligned * height_aligned;
2452 chroma_b_size = width_aligned * height_aligned / 2;
2459 luma_size = width_aligned * height_aligned * 2;
2465 height_aligned = video_height;
2467 luma_size = width_aligned * height_aligned;
2468 chroma_b_size = luma_size;
2474 height_aligned = video_height;
2476 luma_size = width_aligned * height_aligned * 2;
2486 height_aligned = video_height;
2488 luma_size = width_aligned * height_aligned * 4;
2494 height_aligned = video_height;
2496 luma_size = width_aligned * height_aligned;
2497 chroma_b_size = luma_size;
2498 chroma_r_size = luma_size;
2506 buffer_size = luma_size + chroma_b_size + chroma_r_size;
2512 __func__, luma_size, chroma_b_size, chroma_r_size, buffer_size);
2518 "%s: free current p_frame, p_frame->buffer_size=%u\n", __func__,
2530 "ERROR %d: %s() Cannot allocate p_frame buffer.\n",
NI_ERRNO,
2548 p_frame->
data_len[1] = chroma_b_size;
2549 p_frame->
data_len[2] = chroma_r_size;
2600 int video_width,
int video_height,
2601 int alignment,
int factor,
2609 if ((!p_frame) || ((factor!=1) && (factor!=2))
2614 "factor %d, video_width %d, video_height %d\n",
2615 __func__, factor, video_width, video_height);
2621 width_aligned = ((((video_width * factor) + 127) / 128) * 128) / factor;
2622 height_aligned = video_height;
2626 width_aligned = ((video_width + 31) / 32) * 32;
2627 height_aligned = ((video_height + 7) / 8) * 8;
2630 height_aligned = ((video_height + 15) / 16) * 16;
2635 width_aligned, height_aligned, video_width, video_height);
2637 int luma_size = width_aligned * height_aligned * factor;
2642 int chroma_width_aligned = ((((video_width / 2 * factor) + 127) / 128) * 128) / factor;
2645 chroma_width_aligned =
2646 ((((video_width * factor) + 127) / 128) * 128) / factor;
2648 int chroma_height_aligned = height_aligned / 2;
2649 chroma_b_size = chroma_r_size = chroma_width_aligned * chroma_height_aligned * factor;
2657 chroma_b_size = luma_size / 4;
2658 chroma_r_size = chroma_b_size;
2660 int buffer_size = luma_size + chroma_b_size + chroma_r_size +
2702 p_frame->
p_data[2] = p_frame->
p_data[1] + chroma_b_size;
2703 p_frame->
p_data[3] = p_frame->
p_data[2] + chroma_r_size;
2711 p_frame->
data_len[1] = chroma_b_size;
2712 p_frame->
data_len[2] = chroma_r_size;
2747 int width,
int height,
2748 const int linesize[],
2752 if ((!p_enc_ctx) || (!p_enc_params) || (!linesize)
2758 "p_enc_ctx %p, p_enc_params %p, linesize %p, "
2759 "width %d, height %d linesize[0] %d\n",
2760 __func__, p_enc_ctx, p_enc_params, linesize,
2761 width, height, (linesize) ? linesize[0] : 0);
2770 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s: not supported on device with FW API version < 6.Q\n", __func__);
2774 bool isrgba =
false;
2775 bool isplanar =
false;
2776 bool issemiplanar =
false;
2786 issemiplanar =
true;
2805 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s: semi-planar not supported on device with FW API version < 6.q\n", __func__);
2814 bool ishwframe = (p_enc_params->
hwframes) ?
true :
false;
2817 "p_enc_ctx %p, p_enc_params %p, linesize %p, "
2818 "width %d, height %d, linesize[0] %d linesize[1] %d\n",
2819 __func__, isrgba, issemiplanar, ishwframe, p_enc_ctx, p_enc_params, linesize,
2820 width, height, linesize[0], linesize[1]);
2822 if (linesize[0] <= max_linesize &&
2823 linesize[0] % 2 == 0 &&
2824 linesize[1] % 2 == 0 &&
2831 (!isplanar || linesize[2] == linesize[1])
2849 "luma_linesize %d, chroma_linesize %d, "
2850 "linesize[0] %d, linesize[1] %d\n",
2852 linesize[0], linesize[1]);
2859 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"%s: linesize changed from %u %u to %u %u - resolution change?\n", __func__,
2861 linesize[0], linesize[1]);
2893 int video_width,
int video_height,
2894 const int linesize[],
const uint8_t *data[],
2899 if ((!p_frame) || (!linesize) || (!data))
2902 "p_frame %p, linesize %p, data %p\n",
2903 __func__, p_frame, linesize, data);
2908 "%s: resolution=%dx%d linesize=%d/%d/%d "
2909 "data=%p %p %p extra_len=%d\n",
2910 __func__, video_width, video_height,
2911 linesize[0], linesize[1], linesize[2],
2912 data[0], data[1], data[2], extra_len);
2920 p_frame->
p_buffer = (uint8_t *)data[0];
2921 p_frame->
p_data[0] = (uint8_t *)data[0];
2922 p_frame->
p_data[1] = (uint8_t *)data[1];
2923 p_frame->
p_data[2] = (uint8_t *)data[2];
2925 int luma_size = linesize[0] * video_height;
2926 int chroma_b_size = 0;
2927 int chroma_r_size = 0;
2931 chroma_b_size = linesize[1] * (video_height / 2);
2934 chroma_r_size = linesize[2] * (video_height / 2);
2938 uint32_t start_offset;
2939 uint32_t total_start_len = 0;
2945 if ((data[1] && (data[0] + luma_size != data[1]))
2946 || (data[2] && (data[1] + chroma_b_size != data[2])))
2957 total_start_len += p_frame->
start_len[i];
2965 total_start_len = p_frame->
start_len[0];
2978 if (total_start_len)
2990 int start_buffer_offset = 0;
2997 start_buffer_offset += p_frame->
start_len[i];
3003 p_frame->
data_len[1] = chroma_b_size;
3004 p_frame->
data_len[2] = chroma_r_size;
3011 "%s: success: p_metadata_buffer %p metadata_buffer_size %u "
3012 "p_start_buffer %p start_buffer_size %u data_len %u %u %u\n",
3042 int width,
int height,
3043 const int linesize[],
int pixel_format)
3046 if ((!p_upl_ctx) || (!linesize)
3052 "p_enc_ctx %p, linesize %p, "
3053 "width %d, height %d linesize[0] %d\n",
3054 __func__, p_upl_ctx, linesize,
3055 width, height, (linesize) ? linesize[0] : 0);
3064 ni_log2(p_upl_ctx,
NI_LOG_DEBUG,
"%s: not supported on device with FW API version < 6.S\n", __func__);
3074 "p_upl_ctx %p, linesize %p, "
3075 "width %d, height %d, linesize[0] %d\n",
3076 __func__, pixel_format, p_upl_ctx, linesize,
3077 width, height, linesize[0]);
3079 int bit_depth_factor;
3080 bool isrgba =
false;
3081 bool isplanar =
false;
3082 bool issemiplanar =
false;
3084 switch (pixel_format)
3088 bit_depth_factor = 1;
3092 bit_depth_factor = 2;
3095 issemiplanar =
true;
3096 bit_depth_factor = 1;
3099 issemiplanar =
true;
3100 bit_depth_factor = 2;
3107 bit_depth_factor = 4;
3120 ni_log2(p_upl_ctx,
NI_LOG_DEBUG,
"%s: semi-planar not supported on device with FW API version < 6.q\n", __func__);
3125 if (linesize[0] <= max_linesize &&
3134 linesize[2] == linesize[1])
3140 linesize[1] == linesize[0])
3175 int video_height,
int linesize[],
3176 int alignment,
int extra_len,
3177 bool alignment_2pass_wa)
3179 void* p_buffer = NULL;
3188 "p_frame %p, linesize %p, video_width %d, video_height %d\n",
3189 __func__, p_frame, linesize, video_width, video_height);
3195 height_aligned = ((video_height + 1) / 2) * 2;
3198 height_aligned = ((video_height + 7) / 8) * 8;
3202 height_aligned = ((video_height + 15) / 16) * 16;
3211 "%s: aligned=%dx%d org=%dx%d linesize=%d/%d/%d "
3213 __func__, video_width, height_aligned, video_width, video_height,
3214 linesize[0], linesize[1], linesize[2], extra_len);
3216 int luma_size = linesize[0] * height_aligned;
3221 chroma_b_size = chroma_r_size = linesize[1] * (height_aligned / 2);
3222 if (alignment_2pass_wa)
3225 chroma_r_size = linesize[1] * (((height_aligned + 31) / 32) * 32) / 2;
3231 chroma_b_size = luma_size / 4;
3232 chroma_r_size = luma_size / 4;
3236 int buffer_size = luma_size + chroma_b_size + chroma_r_size + extra_len;
3244 "%s: free current p_frame, "
3245 "p_frame->buffer_size=%u\n",
3262 memset(p_buffer, 0, buffer_size);
3273 p_frame->
p_data[1] = (uint8_t*)p_frame->
p_data[0] + luma_size;
3274 p_frame->
p_data[2] = (uint8_t*)p_frame->
p_data[1] + chroma_b_size;
3282 p_frame->
data_len[1] = chroma_b_size;
3283 p_frame->
data_len[2] = chroma_r_size;
3290 "%s: success: p_frame->p_buffer %p "
3291 "p_frame->buffer_size=%u\n",
3411 int video_height,
int linesize[],
3412 int extra_len,
bool alignment_2pass_wa)
3414 void* p_buffer = NULL;
3423 "p_frame %p, linesize %p, video_width %d, video_height %d\n",
3424 __func__, p_frame, linesize, video_width, video_height);
3428 height_aligned = ((video_height + 1) / 2) * 2;
3436 "%s: aligned=%dx%d org=%dx%d linesize=%d/%d/%d extra_len=%d\n",
3437 __func__, video_width, height_aligned, video_width, video_height,
3438 linesize[0], linesize[1], linesize[2], extra_len);
3440 int luma_size = linesize[0] * height_aligned;
3441 int chroma_br_size = luma_size / 2;
3443 if (alignment_2pass_wa)
3446 chroma_br_size = linesize[0] * ((((height_aligned + 31) / 32) * 32) / 2);
3450 int buffer_size = luma_size + chroma_br_size + extra_len;
3474 memset(p_buffer, 0, buffer_size);
3486 p_frame->
p_data[1] = (uint8_t*)p_frame->
p_data[0] + luma_size;
3487 p_frame->
p_data[2] = (uint8_t*)p_frame->
p_data[1] + chroma_br_size;
3494 p_frame->
data_len[1] = chroma_br_size;
3545 int video_width,
int video_height,
3546 int linesize[],
int alignment,
3548 bool alignment_2pass_wa)
3553 linesize, alignment, extra_len,
3554 alignment_2pass_wa);
3559 linesize, extra_len,
3560 alignment_2pass_wa);
3602 "%s: close p_surface->dma_buf_fd %d "
3603 "ui16FrameIdx %u\n",
3619 p_frame->
p_data[i] = NULL;
3688 p_frame->
p_data[i] = NULL;
3728 void* p_buffer = NULL;
3729 int metadata_size = 0;
3736 packet_size + metadata_size);
3738 if (!p_packet || !packet_size)
3763 "%s: free current p_packet, p_packet->buffer_size=%u\n", __func__,
3769 __func__, buffer_size);
3826 if (!p_buffer || !p_packet || !buffer_size)
3834 ni_log(
NI_LOG_INFO,
"Info: %s: Warning buffer not 4k aligned = %p!. Will do an extra copy\n",
3835 __func__, p_buffer);
3913 "%s(): no need to free previous av1 packet buffers\n", __func__);
3949 int ni_packet_copy(
void* p_destination,
const void*
const p_source,
int cur_size,
void* p_leftover,
int* p_prev_size)
3952 int padding_size = 0;
3953 int prev_size = p_prev_size == NULL? 0 : *p_prev_size;
3955 int total_size = cur_size + prev_size;
3956 uint8_t* p_src = (uint8_t*)p_source;
3957 uint8_t* p_dst = (uint8_t*)p_destination;
3958 uint8_t* p_lftover = (uint8_t*)p_leftover;
3967 if ((0 == cur_size) && (0 == prev_size))
3972 if (((0 != cur_size) && (!p_source)) || (!p_destination) || (!p_leftover))
3979 if (copy_size > total_size)
3981 padding_size = copy_size - total_size;
3986 memcpy(p_dst, p_lftover, prev_size);
3991 memcpy(p_dst, p_src, cur_size);
3996 memset(p_dst, 0, padding_size);
4000 "%s(): exit, cur_size=%d, copy_size=%d, "
4001 "prev_size=%d, padding_size=%d\n", __func__, cur_size,
4002 copy_size, *p_prev_size, padding_size);
4027 "ERROR: %s No memory or exceeding max aux_data number !\n",
4033 ret->
size = data_size;
4034 ret->
data = calloc(1, data_size);
4060 const uint8_t *raw_data,
4066 memcpy(ret->
data, raw_data, data_size);
4110 if (aux->
type == type)
4161 int fps_num,
int fps_denom,
4162 long bit_rate,
int width,
4313 p_param->
bitrate = (int)bit_rate;
4413 p_enc->
qcomp = (float)0.6;
4499 ni_log(
NI_LOG_ERROR,
"AV1 Picture Width not aligned to %d - picture will be cropped\n",
4504 ni_log(
NI_LOG_ERROR,
"AV1 Picture Height not aligned to %d - picture will be cropped\n",
4573 int fps_num,
int fps_denom,
4574 long bit_rate,
int width,
4600 if(fps_num <= 0 || fps_denom <= 0)
4604 ni_log(
NI_LOG_INFO,
"%s(): FPS is not set, setting the default FPS to 30\n", __func__);
4661 p_param->
bitrate = (int)bit_rate;
4693 char keyChar[10] =
"";
4695 char valChar[10] =
"";
4701 FILE *reconf = NULL;
4710 ni_fopen(&reconf, reconf_file,
"r");
4719 while ((readc = fgetc(reconf)) != EOF)
4726 ni_strncat(keyChar, 10, (
const char *)(&readc), 1);
4730 ni_strncat(valChar, 10, (
const char *)(&readc), 1);
4733 else if (readc ==
':')
4736 key =
atoi(keyChar);
4737 hash_map[idx][0] = key;
4739 else if (readc ==
',')
4744 "ERROR: Number of entries per line in reconfig file is greater then the "
4750 val =
atoi(valChar);
4751 hash_map[idx][valIdx] = val;
4753 memset(valChar, 0, 10);
4755 else if (readc ==
'\n')
4760 "ERROR: Number of lines in reconfig file is greater then the "
4767 val =
atoi (valChar);
4768 hash_map[idx][valIdx] = val;
4770 memset(keyChar,0,10);
4771 memset(valChar,0,10);
4776 ni_log(
NI_LOG_ERROR,
"ERROR: character %c in reconfig file. this may lead to mistaken reconfiguration values\n", readc);
4785 "ERROR %d: %s(): Incorrect format / "
4786 "incomplete Key/Value pair in reconfig_file: %s\n",
4797 char valChar[5] =
"";
4803 FILE *reconf = NULL;
4805 if (!customize_file)
4812 ni_fopen(&reconf, customize_file,
"r");
4816 NI_ERRNO, __func__, customize_file);
4821 while ((readc = fgetc(reconf)) != EOF)
4826 ni_strncat(valChar, 5, (
const char *)(&readc), 1);
4828 else if (readc ==
'-') {
4831 else if (readc ==
',')
4836 "ERROR: Number of qpIdx %d greater then the limit of %d or"
4837 "Number of levelIdx %d greater then the limit of %d\n",
4844 qp_map[levelIdx][qpIdx] = val;
4846 val = clip3(0, 32,
atoi(valChar));
4847 qp_map[levelIdx][qpIdx] = val * -1;
4850 memset(valChar, 0, 5);
4853 else if (readc ==
'\n')
4858 "ERROR: Number of qpIdx %d greater then the limit of %d or"
4859 "Number of levelIdx %d greater then the limit of %d\n",
4866 qp_map[levelIdx][qpIdx] = val;
4868 val = clip3(0, 32,
atoi(valChar));
4869 qp_map[levelIdx][qpIdx] = val * -1;
4872 memset(valChar, 0, 5);
4878 ni_log(
NI_LOG_ERROR,
"ERROR: character %c in reconfig file. this may lead to mistaken reconfiguration values\n", readc);
4889 #define atoi(p_str) ni_atoi(p_str, &b_error)
4890 #define atof(p_str) ni_atof(p_str, &b_error)
4891 #define atobool(p_str) (ni_atobool(p_str, &b_error))
4908 const char *name,
char *value)
4910 bool b_error =
false;
4911 bool bNameWasBool =
false;
4912 bool bValueWasNull = !value;
4914 char nameBuf[64] = { 0 };
4915 const char delim[2] =
",";
4916 const char xdelim[2] =
"x";
4938 if (name[0] ==
'-' && name[1] ==
'-')
4944 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
4947 ni_strcpy(nameBuf,
sizeof(nameBuf), name);
4948 while ((c = strchr(nameBuf,
'_')) != 0)
4959 else if (value[0] ==
'=')
4964 #if defined(_MSC_VER)
4965 #define OPT(STR) else if (!_stricmp(name, STR))
4966 #define OPT2(STR1, STR2) \
4967 else if (!_stricmp(name, STR1) || !_stricmp(name, STR2))
4969 #define OPT(STR) else if (!strcasecmp(name, STR))
4970 #define OPT2(STR1, STR2) else if (!strcasecmp(name, STR1) || !strcasecmp(name, STR2))
4975 if (!strncmp(value,
"hw",
sizeof(
"hw"))){
4978 else if (!strncmp(value,
"sw",
sizeof(
"sw"))) {
4989 if (
atoi(value) == 1)
4994 if (
atoi(value) == 1)
4999 if (
atoi(value) == 1)
5004 if (
atoi(value) == 1)
5009 if (
atoi(value) == 1)
5014 if (
atoi(value) == 1 ||
atoi(value) == 2)
5019 if (
atoi(value) == 1 ||
atoi(value) == 2)
5024 if (
atoi(value) == 1 ||
atoi(value) == 2)
5029 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5032 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5037 "ERROR: %s():cropMode0 input can only be <manual,auto> got %s\n",
5044 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5047 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5052 "ERROR: %s():cropMode1 input can only be <manual,auto> got %s\n",
5059 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5062 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5067 "ERROR: %s():cropMode2 input can only be <manual,auto> got %s\n",
5074 char *saveptr = NULL;
5075 chunk =
ni_strtok(value, delim, &saveptr);
5076 for (i = 0; i < 4; i++)
5083 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5085 p_dec->
cr_expr[0][i][k] = chunk[j];
5093 chunk =
ni_strtok(NULL, delim, &saveptr);
5110 char *saveptr = NULL;
5111 chunk =
ni_strtok(value, delim, &saveptr);
5112 for (i = 0; i < 4; i++)
5119 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5121 p_dec->
cr_expr[1][i][k] = chunk[j];
5129 chunk =
ni_strtok(NULL, delim, &saveptr);
5147 char *saveptr = NULL;
5148 chunk =
ni_strtok(value, delim, &saveptr);
5149 for (i = 0; i < 4; i++)
5156 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5158 p_dec->
cr_expr[2][i][k] = chunk[j];
5166 chunk =
ni_strtok(NULL, delim, &saveptr);
5187 if (*chunk == xdelim[0]) {
5196 char *saveptr = NULL;
5197 chunk =
ni_strtok(value, xdelim, &saveptr);
5198 for (i = 0; i < 2; i++)
5205 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5207 p_dec->
sc_expr[0][i][k] = chunk[j];
5215 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5228 if (*chunk == xdelim[0]) {
5237 char *saveptr = NULL;
5238 chunk =
ni_strtok(value, xdelim, &saveptr);
5239 for (i = 0; i < 2; i++)
5246 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5248 p_dec->
sc_expr[1][i][k] = chunk[j];
5256 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5269 if (*chunk == xdelim[0]) {
5278 char *saveptr = NULL;
5279 chunk =
ni_strtok(value, xdelim, &saveptr);
5280 for (i = 0; i < 2; i++)
5287 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5289 p_dec->
sc_expr[2][i][k] = chunk[j];
5297 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5307 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5315 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5323 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5331 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5334 "and must be even number and less than or equal to 128. Got: %s\n",
5343 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5346 "and must be even number and less than or equal to 128. Got: %s\n",
5354 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5357 "and must be even number and less than or equal to 128. Got: %s\n",
5365 if (!strncmp(value,
"up",
sizeof(
"up"))){
5368 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5379 if (!strncmp(value,
"up",
sizeof(
"up"))){
5382 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5393 if (!strncmp(value,
"up",
sizeof(
"up"))){
5396 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5407 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5415 if (
atoi(value) < 0)
5432 if (
atoi(value) < 0)
5440 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5448 if (
atoi(value) < 0)
5456 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5499 if (strncmp(value,
"tolerant",
sizeof(
"tolerant")) == 0) {
5501 }
else if (strncmp(value,
"ignore",
sizeof(
"ignore")) == 0) {
5503 }
else if (strncmp(value,
"skip",
sizeof(
"skip")) == 0) {
5505 }
else if (strncmp(value,
"best_effort",
sizeof(
"best_effort")) == 0) {
5507 }
else if (strncmp(value,
"limited_error",
sizeof(
"limited_error")) == 0) {
5509 }
else if (strncmp(value,
"best_effort_out_dc",
sizeof(
"best_effort_out_dc")) == 0) {
5517 if (
atoi(value) != 0 &&
5527 if (
atoi(value) < 0 || (
atoi(value) > 100))
5535 if (
atoi(value) < 0 || (
atoi(value) > 2))
5543 if (
atoi(value) < 0 || (
atoi(value) > 1))
5551 if (
atoi(value) < 0 ||
atoi(value) > 255)
5559 if (
atoi(value) < 0 ||
atoi(value) > 1)
5567 if (
atoi(value) != 0 &&
atoi(value) != 1)
5575 if (
atoi(value) < 0 ||
5584 if (
atoi(value) != 0 &&
atoi(value) != 1)
5592 if (
atoi(value) < 0 ||
5601 if (
atoi(value) < 0 ||
atoi(value) > 1)
5609 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5617 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5625 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5640 b_error |= bValueWasNull && !bNameWasBool;
5649 #define atoi(p_str) ni_atoi(p_str, &b_error)
5650 #define atof(p_str) ni_atof(p_str, &b_error)
5651 #define atobool(p_str) (ni_atobool(p_str, &b_error))
5668 const char *name,
const char *value)
5670 bool b_error =
false;
5671 bool bNameWasBool =
false;
5672 bool bValueWasNull = !value;
5674 char nameBuf[64] = { 0 };
5694 if (name[0] ==
'-' && name[1] ==
'-')
5700 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
5703 ni_strcpy(nameBuf,
sizeof(nameBuf), name);
5704 while ((c = strchr(nameBuf,
'_')) != 0)
5715 else if (value[0] ==
'=')
5720 #if defined(_MSC_VER)
5721 #define OPT(STR) else if (!_stricmp(name, STR))
5722 #define OPT2(STR1, STR2) \
5723 else if (!_stricmp(name, STR1) || !_stricmp(name, STR2))
5725 #define OPT(STR) else if (!strcasecmp(name, STR))
5726 #define OPT2(STR1, STR2) else if (!strcasecmp(name, STR1) || !strcasecmp(name, STR2))
5728 #define COMPARE(STR1, STR2, STR3) \
5729 if ((atoi(STR1) > (STR2)) || (atoi(STR1) < (STR3))) \
5731 return NI_RETCODE_PARAM_ERROR_OOR; \
5772 if (0 >
atoi(value))
5780 if (0 !=
atoi(value) && 1 !=
atoi(value))
5790 #ifndef DEPRECATION_AS_ERROR
5793 if (0 !=
atoi(value) && 1 !=
atoi(value))
5804 if (0 !=
atoi(value) && 1 !=
atoi(value))
5827 if (
atof(value) <= 10)
5985 #ifndef DEPRECATION_AS_ERROR
5988 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6027 if (0 !=
atoi(value) && 1 !=
atoi(value))
6034 #ifndef DEPRECATION_AS_ERROR
6041 if (!_strnicmp(value,
"ratio", 5))
6043 if (!strncasecmp(value,
"ratio", 5))
6046 char value_buf[32] = {0};
6047 for (i = 0; i <
sizeof(value_buf); i++)
6049 if (value[i+6] ==
']')
6053 value_buf[i] = value[i+6];
6055 if (i ==
sizeof(value_buf) ||
atoi(value_buf) < 0)
6064 int size =
atoi(value);
6075 if (!_strnicmp(value,
"ratio", 5))
6077 if (!strncasecmp(value,
"ratio", 5))
6080 char value_buf[32] = {0};
6081 for (i = 0; i <
sizeof(value_buf); i++)
6083 if (value[i+6] ==
']')
6087 value_buf[i] = value[i+6];
6089 if (i ==
sizeof(value_buf) ||
atoi(value_buf) < 0)
6098 int size =
atoi(value) / 8;
6108 if (0 !=
atoi(value) && 1 !=
atoi(value))
6153 if (
atoi(value) <= 0 )
6163 if (
atoi(value) <= 0)
6211 if (0 !=
atoi(value) && 1 !=
atoi(value))
6240 if (0 !=
atoi(value) && 1 !=
atoi(value))
6270 if ((
atoi(value) > 255) || (
atoi(value) < 0))
6278 if (
atoi(value) != 0 &&
atoi(value) != 5)
6286 if ((
atoi(value) > 3) || (
atoi(value) < 1))
6294 const char delim[2] =
",";
6297 char *v = _strdup(value);
6299 char *v = strdup(value);
6301 char *saveptr = NULL;
6305 if ((
atoi(chunk) > 65535) || (
atoi(chunk) < 0))
6311 chunk =
ni_strtok(NULL, delim, &saveptr);
6314 if ((
atoi(chunk) > 65535) || (
atoi(chunk) < 0))
6339 #define STRDUP(value) _strdup(value);
6341 #define STRDUP(value) strdup(value);
6343 const char G[2] =
"G";
6344 const char B[2] =
"B";
6345 const char R[2] =
"R";
6346 const char W[2] =
"W";
6347 const char L[2] =
"L";
6348 const char P[2] =
"P";
6349 const char parL[2] =
"(";
6350 const char comma[2] =
",";
6351 const char parR[2] =
")";
6352 int synCheck_GBRWLPCP[8];
6353 int posCheck_GBRWL[5] = {0};
6358 for (i = 0; i<8; i++)
6360 synCheck_GBRWLPCP[i] = 0;
6369 synCheck_GBRWLPCP[0]++;
6370 posCheck_GBRWL[0] = i;
6372 else if (*chunk == B[0])
6374 synCheck_GBRWLPCP[1]++;
6375 posCheck_GBRWL[1] = i;
6377 else if (*chunk == R[0])
6379 synCheck_GBRWLPCP[2]++;
6380 posCheck_GBRWL[2] = i;
6382 else if (*chunk == W[0])
6384 synCheck_GBRWLPCP[3]++;
6385 posCheck_GBRWL[3] = i;
6387 else if (*chunk == L[0])
6389 synCheck_GBRWLPCP[4]++;
6390 posCheck_GBRWL[4] = i;
6392 else if (*chunk == parL[0])
6394 synCheck_GBRWLPCP[5]++;
6396 else if (*chunk == comma[0])
6398 synCheck_GBRWLPCP[6]++;
6400 else if (*chunk == parR[0])
6402 synCheck_GBRWLPCP[7]++;
6408 if (synCheck_GBRWLPCP[0] != 1 || synCheck_GBRWLPCP[1] != 1 || synCheck_GBRWLPCP[2] != 1 ||
6409 synCheck_GBRWLPCP[3] != 1 || synCheck_GBRWLPCP[4] != 1 || synCheck_GBRWLPCP[5] != 5 ||
6410 synCheck_GBRWLPCP[6] != 5 || synCheck_GBRWLPCP[7] != 5)
6416 #define GBRWLPARSE(OUT1,OUT2,OFF,IDX) \
6418 char *v = STRDUP(value); \
6419 chunk = v + posCheck_GBRWL[IDX]; \
6421 while (chunk != NULL) \
6423 if (*chunk == parL[0] && i == 1+(OFF)) \
6427 if((OFF) == 1 && *chunk != P[0] && i == 1) \
6431 if (*chunk == parR[0]) \
6442 return NI_RETCODE_PARAM_INVALID_VALUE; \
6444 subchunk = malloc(i - 1 - (OFF)); \
6445 if (subchunk == NULL) \
6448 return NI_RETCODE_ERROR_MEM_ALOC; \
6450 memcpy(subchunk, v + posCheck_GBRWL[IDX] + 2 + (OFF), i - 2 - (OFF)); \
6451 subchunk[i - 2 - (OFF)] = '\0'; \
6452 char *saveptr = NULL; \
6453 chunk = ni_strtok(subchunk, comma, &saveptr); \
6454 if (chunk != NULL) \
6456 if(atoi(chunk) < 0) \
6459 if(subchunk != NULL){ \
6462 return NI_RETCODE_PARAM_INVALID_VALUE; \
6464 *(OUT1) = atoi(chunk); \
6466 chunk = ni_strtok(NULL, comma, &saveptr); \
6467 if (chunk != NULL) \
6469 if(atoi(chunk) < 0) \
6472 if(subchunk != NULL){ \
6475 return NI_RETCODE_PARAM_INVALID_VALUE; \
6477 *(OUT2) = atoi(chunk); \
6491 if (
atoi(value)!= 0 && ((
atoi(value) > 40 ) || (
atoi(value) < 4)))
6499 if (
atoi(value) != 0 &&
atoi(value) != 1)
6507 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6515 if (
atoi(value) != 0 &&
atoi(value) != 1)
6523 if (
atoi(value) != 0 &&
atoi(value) != 1)
6535 if (
atoi(value) < 1 ||
atoi(value) > 2)
6543 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6556 if ((
atoi(value) < 0) || (
atoi(value) > 3))
6578 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6607 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6615 if ((
atoi(value) < 0) || (
atoi(value) > 9))
6623 if ((
atoi(value) > 12) || (
atoi(value) < -12))
6633 if ((
atoi(value) > 300) || (
atoi(value) < 1))
6641 if ((
atoi(value) > 2) || (
atoi(value) < 0))
6649 if ((
atoi(value) > 15) || (
atoi(value) < 0))
6657 if ((
atoi(value) > 500) || (
atoi(value) < 0))
6665 if ((
atoi(value) > 1) || (
atoi(value) < 0))
6673 if ((
atoi(value) > 1) || (
atoi(value) < 0))
6720 if (
atoi(value) != 0 &&
atoi(value) != 1)
6728 if (
atoi(value) < 0 ||
atoi(value) > 3)
6736 if (
atoi(value) < 1)
6744 if (
atoi(value) < 0 ||
atoi(value) > 1)
6752 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6760 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6768 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6780 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6788 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6794 ni_log(
NI_LOG_ERROR,
"Cannot set enableAIEnhance and enableHVSPlus at same time, just enableHVSPlus\n");
6800 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6808 if ((
atoi(value) != 0) && (
atoi(value) != 1) && (
atoi(value) != -1))
6816 if ((
atoi(value) == 0) || (
atoi(value) > 3))
6824 if ((
atoi(value) == 0) || (
atoi(value) > 2))
6850 if ((
atoi(value) < 0) ||
6859 if ((
atoi(value) < 0) ||
6868 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6876 if ((
atof(value) > 1.0) || (
atof(value) < 0.0))
6884 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6892 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6900 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6908 if ((
atoi(value) > 10) || (
atoi(value) < 1))
6916 if ((
atof(value) > 10.0) || (
atof(value) < 0.01))
6924 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6932 if ((
atof(value) > 10.0) || (
atof(value) < 0.01))
6940 if ((
atof(value) > 1.0) || (
atof(value) < 0.1))
6948 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6965 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6973 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6981 if (((
atof(value) < 0.0) && (
atof(value) != -1.0)) ||
6982 (
atof(value) > 51.00))
6990 if ((
atoi(value) < 0) || (
atoi(value) > 31))
6998 if (
atoi(value) != 0 &&
atoi(value) != 1 &&
atoi(value) != 6)
7009 if ((
atoi(value) < 0 ||
atoi(value) > 6))
7020 if ((
atoi(value) < 0 ||
atoi(value) > 10))
7028 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7036 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7044 if (
atoi(value) < 0 ||
atoi(value) > 1)
7052 if (
atoi(value) < 0)
7060 if (
atoi(value) < 0 ||
atoi(value) > 255)
7068 if (
atoi(value) != 0 &&
atoi(value) != 1)
7076 if (
atoi(value) <= 0)
7084 if ((
atoi(value) < 0 ||
atoi(value) > 2) &&
7085 atoi(value) != 5 &&
atoi(value) != 6)
7097 if (
atoi(value) != 0 &&
atoi(value) != 1)
7105 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7113 if ((
atof(value) > 1.0) || (
atof(value) < 0.0))
7121 if (
atoi(value) < 0 ||
atoi(value) > 2)
7129 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7155 if (
atoi(value) < 0 ||
atoi(value) > 2)
7172 if (
atoi(value) < 1 ||
atoi(value) > 4)
7180 if (
atoi(value) < 0 ||
atoi(value) > 1)
7188 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7196 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7204 if (
atoi(value)!= 0 && ((
atoi(value) > 40 ) || (
atoi(value) < 4)))
7212 if (
atoi(value) != 0 &&
atoi(value) != 1)
7220 if (
atoi(value) != 0 &&
atoi(value) != 1)
7228 if (
atoi(value) != 0 &&
atoi(value) != 1)
7236 if (
atoi(value) < 0 ||
atoi(value) > 100)
7244 if (
atoi(value) < 0 ||
atoi(value) > 100)
7252 const char delim[2] =
",";
7255 char *v = _strdup(value);
7257 char *v = strdup(value);
7259 char *saveptr = NULL;
7270 chunk =
ni_strtok(NULL, delim, &saveptr);
7277 const char delim[2] =
",";
7280 char *v = _strdup(value);
7282 char *v = strdup(value);
7284 char *saveptr = NULL;
7292 if (
atof(chunk) <= 10)
7300 chunk =
ni_strtok(NULL, delim, &saveptr);
7307 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7315 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7329 b_error |= bValueWasNull && !bNameWasBool;
7338 #define atoi(p_str) ni_atoi(p_str, &b_error)
7339 #define atof(p_str) ni_atof(p_str, &b_error)
7340 #define atobool(p_str) (ni_atobool(p_str, &b_error))
7361 bool b_error =
false;
7362 bool bNameWasBool =
false;
7363 bool bValueWasNull = !value;
7366 char nameBuf[64] = { 0 };
7387 if (name[0] ==
'-' && name[1] ==
'-')
7393 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
7396 ni_strcpy(nameBuf,
sizeof(nameBuf), name);
7397 while ((c = strchr(nameBuf,
'_')) != 0)
7408 else if (value[0] ==
'=')
7413 #if defined(_MSC_VER)
7414 #define OPT(STR) else if (!_stricmp(name, STR))
7416 #define OPT(STR) else if (!strcasecmp(name, STR))
7441 OPT(NI_ENC_GOP_PARAMS_G0_PIC_QP)
7445 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC_L0)
7449 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L0)
7453 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L1)
7470 OPT(NI_ENC_GOP_PARAMS_G1_PIC_QP)
7474 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC_L0)
7478 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L0)
7482 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L1)
7499 OPT(NI_ENC_GOP_PARAMS_G2_PIC_QP)
7503 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC_L0)
7507 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L0)
7511 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L1)
7528 OPT(NI_ENC_GOP_PARAMS_G3_PIC_QP)
7532 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC_L0)
7536 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L0)
7540 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L1)
7557 OPT(NI_ENC_GOP_PARAMS_G4_PIC_QP)
7561 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC_L0)
7565 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L0)
7569 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L1)
7586 OPT(NI_ENC_GOP_PARAMS_G5_PIC_QP)
7590 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC_L0)
7594 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L0)
7598 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L1)
7615 OPT(NI_ENC_GOP_PARAMS_G6_PIC_QP)
7619 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC_L0)
7623 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L0)
7627 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L1)
7644 OPT(NI_ENC_GOP_PARAMS_G7_PIC_QP)
7648 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC_L0)
7652 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L0)
7656 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L1)
8157 b_error |= bValueWasNull && !bNameWasBool;
8207 if ((!p_ctx) || (!p_data))
8224 "ERROR: %s() keep alive thread has been closed, "
8225 "hw:%d, session:%d\n",
8242 switch (device_type)
8246 int seq_change_read_count = 0;
8257 uint32_t aligned_width;
8269 ", DFVWxDFVH %u x %u, AlWid %u, AVW x AVH %u x %u\n",
8274 if (0 == retval && seq_change_read_count)
8283 else if (retval < 0)
8299 "%s (decoder): resolution change, frame size %ux%u -> %ux%u, "
8300 "width %u bit %d, pix_fromat_changed %d, actual_video_width %d, continue read ...\n",
8309 seq_change_read_count++;
8341 __func__, device_type);
8373 if ((!hwdesc) || (!p_data))
8401 bool use_external_mutex =
false;
8402 uint32_t orig_session_id = p_ctx->
session_id;
8403 ni_device_handle_t orig_blk_io_handle = p_ctx->
blk_io_handle;
8408 ni_pthread_mutex_t *p_ctx_mutex = &(p_ctx->
mutex);
8414 use_external_mutex =
true;
8427 if (use_external_mutex)
8472 "%s function not supported in FW API version < 6rt\n",
8477 switch (device_type)
8526 if ((!hwdesc) || (!p_src_data))
8560 int video_height,
int extra_len)
8562 void* p_buffer = NULL;
8563 int height_aligned = video_height;
8599 memset(p_buffer, 0, buffer_size);
8611 p_frame->
p_data[0] = NULL;
8612 p_frame->
p_data[1] = NULL;
8613 p_frame->
p_data[2] = NULL;
8648 int32_t device_handle)
8656 "%s(): ui16FrameIdx=%d sessionId=%d device_handle=0x%x\n",
8680 int32_t saved_dma_buf_fd;
8690 "%s(): ui16FrameIdx=%d sessionId=%d device_handle=0x%x\n",
8725 uint32_t pool_size, uint32_t pool)
8787 "ERROR: %s function not supported in FW API version < 6r3\n",
8794 "ERROR: can't free or expand framepool of session 0x%x "
8795 "before init framepool\n", p_ctx->
session_id);
8836 if (!p_ctx || !p_params)
8864 void *p_scaler_config = NULL;
8867 uint32_t ui32LBA = 0;
8871 if (!p_ctx || !p_params)
8873 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() passed parameters are null!, return\n", __func__);
8895 memset(p_scaler_config, 0, buffer_size);
8901 memcpy(p_scaler_config, p_params, buffer_size);
8904 p_scaler_config, buffer_size, ui32LBA) < 0)
8907 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
8908 ", hw_id, %d, xcoder_inst_id: %d\n",
8915 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
8916 "hw_id, %d, xcoder_inst_id: %d\n",
8944 void *p_scaler_config = NULL;
8947 uint32_t ui32LBA = 0;
8951 if (!p_ctx || !p_params)
8953 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() passed parameters are null!, return\n", __func__);
8975 memset(p_scaler_config, 0, buffer_size);
8981 memcpy(p_scaler_config, p_params, buffer_size);
8984 p_scaler_config, buffer_size, ui32LBA) < 0)
8987 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
8988 ", hw_id, %d, xcoder_inst_id: %d\n",
8995 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
8996 "hw_id, %d, xcoder_inst_id: %d\n",
9045 int rectangle_width,
9046 int rectangle_height,
9064 switch (device_type)
9068 rectangle_width, rectangle_height,
9069 rectangle_x, rectangle_y,
9070 rgba_color, frame_index);
9122 switch (device_type)
9174 "Error: %s function not supported on device with FW API version < 6rL\n",
9214 if (!p_ctx || !p_cfg)
9262 if (!p_ctx || !p_cfg_in)
9306 const int linesize[])
9311 int luma, chroma_b, chroma_r;
9318 switch (pixel_format)
9357 switch (pixel_format)
9361 luma = linesize[0] * alignedh;
9362 chroma_b = linesize[1] * alignedh / 2;
9363 chroma_r = linesize[2] * alignedh / 2;
9370 luma = linesize[0] * alignedh;
9371 chroma_b = linesize[1] * alignedh / 2;
9413 int video_width,
int video_height,
9414 int linesize[],
int alignment,
9418 void *p_buffer = NULL;
9422 int chroma_b_size = 0;
9423 int chroma_r_size = 0;
9431 switch (pixel_format)
9502 switch (pixel_format)
9506 luma_size = linesize[0] * height_aligned;
9510 chroma_b_size = linesize[1] * height_aligned / 2;
9511 chroma_r_size = linesize[2] * height_aligned / 2;
9515 chroma_b_size = luma_size / 4;
9516 chroma_r_size = luma_size / 4;
9525 luma_size = linesize[0] * video_height;
9534 luma_size = linesize[0] * height_aligned;
9535 chroma_b_size = linesize[1] * height_aligned / 2;
9542 luma_size = linesize[0] * video_height;
9543 chroma_b_size = linesize[1] * video_height;
9551 luma_size = linesize[0] * video_height;
9570 buffer_size = luma_size + chroma_b_size + chroma_r_size + extra_len;
9592 memset(p_buffer, 0, buffer_size);
9602 switch (pixel_format)
9608 p_frame->
p_data[2] = p_frame->
p_data[1] + chroma_b_size;
9609 p_frame->
p_data[3] = NULL;
9612 p_frame->
data_len[1] = chroma_b_size;
9613 p_frame->
data_len[2] = chroma_r_size;
9624 p_frame->
p_data[1] = NULL;
9625 p_frame->
p_data[2] = NULL;
9626 p_frame->
p_data[3] = NULL;
9640 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9641 p_frame->
p_data[2] = NULL;
9642 p_frame->
p_data[3] = NULL;
9645 p_frame->
data_len[1] = chroma_b_size;
9656 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9657 p_frame->
p_data[2] = NULL;
9658 p_frame->
p_data[3] = NULL;
9661 p_frame->
data_len[1] = chroma_b_size;
9674 p_frame->
p_data[1] = NULL;
9675 p_frame->
p_data[2] = NULL;
9676 p_frame->
p_data[3] = NULL;
9689 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9690 p_frame->
p_data[2] = (uint8_t *)p_frame->
p_data[1] + chroma_b_size;
9691 p_frame->
p_data[3] = NULL;
9694 p_frame->
data_len[1] = chroma_b_size;
9695 p_frame->
data_len[2] = chroma_r_size;
9710 __func__, video_width, video_height, buffer_size);
9727 struct stat file_stat;
9729 unsigned char *buffer = NULL;
9742 if (stat(file, &file_stat) != 0)
9751 if (file_stat.st_size == 0)
9768 buffer = malloc(file_stat.st_size);
9776 if (fread(buffer, file_stat.st_size, 1, fp) != 1)
9828 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: hvsplus filter not supported on device with FW API version < 6ro\n");
9864 uint32_t buffer_size = 0;
9865 void *p_buffer = NULL;
9867 uint32_t i, this_size;
9870 if (!p_frame || !p_network)
9876 p_linfo = &p_network->
linfo;
9877 for (i = 0; i < p_network->
input_num; i++)
9885 "ERROR: %s(): invalid buffer_size of network\n", __func__);
9888 buffer_size += this_size;
9892 p_frame->
data_len[0] = buffer_size;
9925 p_frame->
p_data[1] = NULL;
9926 p_frame->
p_data[2] = NULL;
9927 p_frame->
p_data[3] = NULL;
9929 p_frame->
iovec = NULL;
9948 void *p_buffer = NULL;
9950 uint32_t buffer_size = 0;
9951 uint32_t i, data_size;
9954 if (!p_packet || !p_network)
9961 p_linfo = &p_network->
linfo;
9970 "ERROR: %s(): invalid buffer_size of network\n", __func__);
9973 buffer_size += data_size;
9975 data_size = buffer_size;
9993 "%s(): free current p_packet, p_packet->buffer_size=%u\n",
9998 __func__, buffer_size);
10037 if (!p_ctx || bitrate < NI_MIN_BITRATE || bitrate >
NI_MAX_BITRATE)
10040 __func__, bitrate);
10049 "Warning: %s(): bitrate %d overwriting current one %d\n",
10076 int32_t intra_period)
10078 if (!p_ctx || intra_period < 0 || intra_period > 1024)
10081 __func__, intra_period);
10090 "Warning: %s(): intraPeriod %d overwriting current one %d\n",
10221 int32_t ltr_interval)
10278 if (!p_ctx || framerate_num <= 0 || framerate_denom <= 0)
10281 "ERROR: %s(): invalid framerate passed in (%d/%d)\n", __func__,
10282 framerate_num, framerate_denom);
10286 if ((framerate_num % framerate_denom) != 0)
10288 uint32_t numUnitsInTick = 1000;
10289 framerate_num = framerate_num / framerate_denom;
10290 framerate_denom = numUnitsInTick + 1;
10291 framerate_num += 1;
10292 framerate_num *= numUnitsInTick;
10295 framerate_num = framerate_num / framerate_denom;
10296 framerate_denom = 1;
10299 if (((framerate_num + framerate_denom - 1) / framerate_denom) >
10303 "ERROR: %s(): invalid framerate passed in (%d/%d)\n", __func__,
10314 "Warning: %s(): framerate (%d/%d) overwriting current "
10316 __func__, framerate_num, framerate_denom,
10345 int32_t bitrate, framerate_num, framerate_denom;
10346 uint32_t maxFrameSize = (uint32_t)max_frame_size / 2000;
10347 uint32_t min_maxFrameSize;
10351 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10360 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size is valid only when lowDelay mode is enabled\n",
10361 __func__, max_frame_size);
10374 framerate_num = (int32_t) api_param->
fps_number;
10378 min_maxFrameSize = (((uint32_t)bitrate / framerate_num * framerate_denom) / 8) / 2000;
10380 if (maxFrameSize < min_maxFrameSize)
10383 __func__, max_frame_size);
10396 "Warning: %s(): max_frame_size %d overwriting current one %d\n",
10420 int32_t minQpI, maxQpI, maxDeltaQp, minQpPB, maxQpPB;
10422 if (!p_ctx || !p_min_max_qp)
10424 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_min_max_qp pointer\n",
10429 minQpI = p_min_max_qp->
minQpI;
10430 maxQpI = p_min_max_qp->
maxQpI;
10432 minQpPB = p_min_max_qp->
minQpPB;
10433 maxQpPB = p_min_max_qp->
maxQpPB;
10435 if (minQpI > maxQpI || minQpPB > maxQpPB ||
10436 maxQpI > 51 || minQpI < 0 || maxQpPB > 51 || minQpPB < 0)
10439 __func__, minQpI, maxQpI, maxDeltaQp, minQpPB, maxQpPB);
10474 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10483 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %d is valid only in CRF mode\n",
10488 if (crf < 0 || crf > 51)
10490 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %d is invalid (valid range in [0..51])\n",
10502 "Warning: %s(): crf reconfig value %d overwriting current reconfig_crf %d\n",
10531 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10540 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %f is valid only in CRF mode\n",
10545 if (crf < 0.0 || crf > 51.0)
10547 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %f is invalid (valid range in [0..51])\n",
10559 "Warning: %s(): crf reconfig value %d overwriting current "
10560 "reconfig_crf %d, reconfig_crf_decimal %d\n", __func__,
10585 int32_t vbvMaxRate, int32_t vbvBufferSize)
10590 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10594 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
10597 __func__, vbvBufferSize);
10601 if (api_param->
bitrate > 0 && vbvMaxRate > 0 && vbvMaxRate < api_param->bitrate) {
10603 vbvMaxRate, api_param->
bitrate);
10606 if (vbvBufferSize == 0 && vbvMaxRate > 0) {
10608 "vbvBufferSize is 0, force vbvMaxRate to 0\n",
10637 int32_t bitrate, framerate_num, framerate_denom;
10638 uint32_t min_maxFrameSize, maxFrameSize;
10642 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10651 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size_ratio is valid only when lowDelay mode is enabled\n",
10652 __func__, max_frame_size_ratio);
10656 if (max_frame_size_ratio < 1) {
10658 max_frame_size_ratio);
10671 framerate_num = (int32_t) api_param->
fps_number;
10675 min_maxFrameSize = (((uint32_t)bitrate / framerate_num * framerate_denom) / 8) / 2000;
10686 "Warning: %s(): max_frame_size %d overwriting current one %d\n",
10714 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10723 ni_log2(p_ctx,
NI_LOG_ERROR,
"%s():not support to reconfig slice_arg when slice_mode disable.\n",
10734 int max_num_ctu_mb_row = (api_param->
source_height + ctu_mb_size - 1) / ctu_mb_size;
10735 if (sliceArg < 1 || sliceArg > max_num_ctu_mb_row)
10773 int ret, is_semi_planar;
10779 if (p_ctx == NULL || p_frame == NULL || p_frame->
p_data[3] == NULL)
10826 uexp.
fn = p_ctx->
fn;
10837 *p_surface = hwdesc;
10867 int is_semi_planar;
10873 if (p_ctx == NULL || p_frame == NULL || p_frame->
p_data[3] == NULL)
10905 *p_surface = hwdesc;
10934 struct pollfd pfds[1] = {0};
10937 if (p_upl_ctx == NULL || p_frame == NULL)
10943 if (p_frame->
p_data[3] == NULL)
10952 pfds[0].events = POLLIN;
10953 pfds[0].revents = 0;
10955 ret = poll(pfds, 1, -1);
10971 "%s: failed to attach dmabuf read fence errno %s\n", __func__,
10997 if ((p_upl_ctx == NULL) || (p_frame == NULL))
11000 p_upl_ctx, p_frame);
11006 if (p_surface == NULL)
11039 uint8_t *p_data, uint32_t len,
11046 if (p_upl_ctx == NULL || p_data == NULL || p_hwframe == NULL)
11052 if (p_hwframe->
p_data[3] == NULL)
11069 "%s: Failed to request dmabuf rendering errno %d\n", __func__,
11094 uint8_t *p_data, uint32_t
len,
11098 char bar4_name[128];
11113 snprintf(bar4_name, 128,
11114 "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/resource4",
11117 bar4_fd = open(bar4_name, O_RDWR | O_SYNC);
11124 bar4_name, errmsg);
11128 if (fstat(bar4_fd, &stat) != 0)
11137 bar4_mm = mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, bar4_fd, 0);
11139 if (bar4_mm == MAP_FAILED)
11149 memcpy(bar4_mm + offset, p_data, len);
11151 munmap(bar4_mm, 0);
11173 if (p_frame == NULL)
11180 if (p_surface == NULL)
11206 unsigned int offset;
11225 uexp.
fn = p_ctx->
fn;
11260 int width,
int height,
11261 int bit_depth,
int src_endian,
11267 if (p_enc_ctx == NULL || p_enc_params == NULL)
11273 if (!(bit_depth == 8) && !(bit_depth == 10))
11305 alignedw = ((width + 1) / 2) * 2;
11307 (alignedw - width) / 2 * 2;
11320 alignedh = ((height + 1) / 2) * 2;
11322 (alignedh - height) / 2 * 2;
11347 int width,
int height,
11350 if (p_upl_ctx == NULL)
11356 switch (pixel_format)
11387 p_upl_ctx->
isP2P = isP2P;
11412 int bytes_read = 0;
11428 bytes_read += (rx_size - (int)p_ctx->
meta_size);
11433 }
else if (rx_size != 0)
11462 if (p_frame == NULL)
11470 if (p_surface == NULL)
11498 int width,
int height,
int bit_depth_factor,
ni_device_type_t device_type)
11508 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: %s function not supported on device with FW API version < 5.4\n", __func__);
11519 resolution.
width = width;
11520 resolution.
height = height;
11532 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Config sequence change not supported when spatialLayers > 1\n");
11545 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: resolution change config - width %d height %d bit_depth_factor %d "
11546 "luma_linesize %d chroma_linesize %d\n", __func__,
11550 switch (device_type)
11561 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Config sequence change not supported for device type: %d", device_type);
11579 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11582 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_info))
11593 "ERROR: %s function not supported on device with FW API version < 6.h\n",
11607 memset(buffer, 0, size);
11659 "ERROR: %s function not supported on device with FW API version < 6.O\n",
11673 memset(buffer, 0, size);
11702 void *p_buffer = NULL;
11704 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11706 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_ns_vf))
11717 "ERROR: %s function not supported on device with FW API version < 6.m\n",
11730 memset(p_buffer, 0, size);
11744 p_dev_ns_vf->
vf_id = p_dev_ns_vf_data->
vf_id;
11745 p_dev_ns_vf->
ns_id = p_dev_ns_vf_data->
ns_id;
11755 void *p_buffer = NULL;
11757 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11759 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_temp))
11770 "ERROR: %s function not supported on device with FW API version < 6rC\n",
11783 memset(p_buffer, 0, size);
11800 ni_log(
NI_LOG_DEBUG,
"%s(): current composite temperature %d on board temperature %d on die temperature %d\n",
11810 void *p_buffer = NULL;
11812 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11814 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_extra_info))
11825 "ERROR: %s function not supported on device with FW API version < 6rC\n",
11838 memset(p_buffer, 0, size);
11876 ni_log(
NI_LOG_DEBUG,
"%s(): current composite temperature %d on board temperature %d "
11877 "on die temperature %d power consumption %d current consumption %d\n",
11905 bool is_ext_buf =
true;
11906 if (*p_log_buffer == NULL)
11914 is_ext_buf =
false;
11917 if(*p_log_buffer != NULL){
11945 uint32_t ctu, i, j;
11949 int importanceLevelCentre = p_param->
roi_demo_mode == 1 ? 40 : 10;
11950 int importanceLevelRest = p_param->
roi_demo_mode == 1 ? 10 : 40;
11955 uint32_t block_size, max_cu_size, customMapSize;
11959 uint32_t roiMapBlockUnitSize;
11960 uint32_t entryPerMb;
11966 linesize_aligned = (linesize_aligned / 8) * 8;
11967 height_aligned = (height_aligned / 8) * 8;
11973 ((linesize_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) *
11974 ((height_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
11978 customMapSize = ((block_size + 63) & (~63));
11994 ((linesize_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
11995 roiMapBlockUnitSize;
11997 ((height_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
11998 roiMapBlockUnitSize;
11999 numMbs = mbWidth * mbHeight;
12003 entryPerMb = (roiMapBlockUnitSize / 8) * (roiMapBlockUnitSize / 8);
12005 for (i = 0; i < numMbs; i++)
12007 bool bIsCenter = (i % mbWidth > mbWidth / 3) && (i % mbWidth < mbWidth * 2 / 3);
12008 for (j = 0; j < entryPerMb; j++)
12018 p_enc_ctx->
roi_map[i * entryPerMb + j]
12021 bIsCenter ? importanceLevelCentre : importanceLevelRest;
12025 p_enc_ctx->
roi_len = customMapSize;
12028 (sumQp + (numMbs >> 1)) / numMbs;
12036 uint32_t mbWidth = (linesize_aligned + 16 - 1) >> 4;
12038 uint32_t mbHeight = (height_aligned + 16 - 1) >> 4;
12039 uint32_t numMbs = mbWidth * mbHeight;
12040 uint32_t customMapSize =
12050 for (i = 0; i < numMbs; i++)
12052 if ((i % mbWidth > mbWidth / 3) && (i % mbWidth < mbWidth * 2 / 3))
12062 p_enc_ctx->
roi_len = customMapSize;
12064 (sumQp + (numMbs >> 1)) / numMbs;
12072 uint32_t ctuWidth = (linesize_aligned + 64 - 1) >> 6;
12074 uint32_t ctuHeight = (height_aligned + 64 - 1) >> 6;
12076 uint32_t subCtuWidth = ctuWidth * 2;
12078 uint32_t subCtuHeight = ctuHeight * 2;
12079 uint32_t numSubCtus = subCtuWidth * subCtuHeight;
12086 for (i = 0; i < numSubCtus; i++)
12088 if ((i % subCtuWidth > subCtuWidth / 3) &&
12089 (i % subCtuWidth < subCtuWidth * 2 / 3))
12105 for (i = 0; i < ctuHeight; i++)
12108 for (j = 0; j < ctuWidth; j++, ptr += 2)
12110 ctu = (i * ctuWidth + j);
12114 *(ptr + subCtuWidth);
12116 *(ptr + subCtuWidth + 1);
12126 (sumQp + (numSubCtus >> 1)) / numSubCtus;
12156 *((int32_t *)aux_data->data) =
12178 int32_t intraprd = *((int32_t *)aux_data->data) =
12181 "xcoder_send_frame: frame #%lu reconf "
12182 "intraPeriod %d\n",
12216 "xcoder_send_frame: frame #%lu reconf "
12217 "vui colorDescPresent %d colorPrimaries %d "
12218 "colorTrc %d colorSpace %d aspectRatioWidth %d "
12219 "aspectRatioHeight %d videoFullRange %d\n",
12250 "xcoder_send_frame: frame #%lu metadata "
12251 "use_cur_src_as_long_term_pic %d use_long_term_ref "
12291 *((int32_t *)aux_data->data) =
12294 "xcoder_send_frame: frame #%lu reconf "
12295 "ltrInterval %d\n",
12312 *((int32_t *)aux_data->data) =
12315 "xcoder_send_frame: frame #%lu reconf "
12316 "invalidFrameNum %d\n",
12342 "xcoder_send_frame: frame #%lu reconf "
12343 "framerate (%d/%d)\n",
12357 *((int32_t *)aux_data->data) =
12360 "xcoder_send_frame: frame #%lu reconf "
12361 "maxFrameSize %d\n",
12376 *((int32_t *)aux_data->data) =
12379 "xcoder_send_frame: frame #%lu reconf "
12397 *((
float *)aux_data->data) = crf;
12399 "xcoder_send_frame: frame #%lu reconf "
12411 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
12414 __func__, vbvBufferSize);
12417 if (p_param->
bitrate > 0 && vbvMaxRate > 0 && vbvMaxRate < p_param->bitrate) {
12419 vbvMaxRate, p_param->
bitrate);
12422 if (vbvBufferSize == 0 && vbvMaxRate > 0) {
12424 "vbvBufferSize is 0, force vbvMaxRate to 0\n",
12434 *((int32_t *)aux_data->data) = vbvMaxRate;
12440 *((int32_t *)aux_data->data) = vbvBufferSize;
12442 "xcoder_send_frame: frame #%lu reconfig vbvMaxRate %d vbvBufferSize "
12443 "%d by frame aux data\n",
12444 p_enc_ctx->
frame_num, vbvMaxRate, vbvBufferSize);
12453 if (maxFrameSizeRatio < 1) {
12455 maxFrameSizeRatio);
12464 int32_t bitrate, framerate_num, framerate_denom;
12465 uint32_t min_maxFrameSize, maxFrameSize;
12475 framerate_num = (int32_t) p_param->
fps_number;
12479 min_maxFrameSize = ((uint32_t)bitrate / framerate_num * framerate_denom) / 8;
12482 *((int32_t *)aux_data->data) = maxFrameSize;
12484 "xcoder_send_frame: frame #%lu reconf "
12485 "maxFrameSizeRatio %d maxFrameSize %d\n",
12486 p_enc_ctx->
frame_num, maxFrameSizeRatio, maxFrameSize);
12499 *((int16_t *)aux_data->data) =
12502 "xcoder_send_frame: frame #%lu reconf "
12516 "xcoder_send_frame: frame #%lu force IDR frame\n",
12531 "xcoder_send_frame: frame #%lu API reconfig BR %d\n",
12547 "xcoder_send_frame: frame #%lu API reconfig intraPeriod %d\n",
12576 "xcoder_send_frame: frame #%lu reconf "
12577 "vui colorDescPresent %d colorPrimaries %d "
12578 "colorTrc %d colorSpace %d aspectRatioWidth %d "
12579 "aspectRatioHeight %d videoFullRange %d\n",
12596 if ((retval =
ni_set_ltr(p_enc_ctx, <r))) {
12600 "xcoder_send_frame(): frame #%lu API set LTR\n",
12619 "%s(): frame %d minQpI %d maxQpI %d maxDeltaQp %d minQpPB %d maxQpPB %d\n",
12634 "xcoder_send_frame(): frame #%lu API set LTR interval %d\n",
12649 "xcoder_send_frame(): frame #%lu API set frame ref invalid "
12668 "xcoder_send_frame: frame #%lu API reconfig framerate "
12685 "xcoder_send_frame: frame #%lu API reconfig maxFrameSize %d\n",
12700 "xcoder_send_frame: frame #%lu API reconfig crf %d\n",
12716 "xcoder_send_frame: frame #%lu API reconfig crf %f\n",
12731 "xcoder_send_frame: frame #%lu API reconfig vbvMaxRate %d vbvBufferSize %d\n",
12748 "xcoder_send_frame: frame #%lu reconf maxFrameSizeRatio %d\n",
12762 "xcoder_send_frame: frame #%lu API reconfig sliceArg %d\n",
12780 static int ni_tolower(
int c)
12782 if (c >=
'A' && c <=
'Z')
12792 c1 = ni_tolower(*a++);
12793 c2 = ni_tolower(*b++);
12794 }
while (c1 && c1 == c2);
12946 "g%drefPic%d specified without g%drefPic%dUsed specified!\n",
12964 #ifndef DEPRECATION_AS_ERROR
12978 uint64_t ui64DestAddr,
12979 uint32_t ui32FrameSize)
12984 (void) ui64DestAddr;
12985 (void) ui32FrameSize;
13010 uint64_t ui64DestAddr, uint32_t ui32FrameSize)
13014 if ((pSession == NULL) || (source == NULL))
13030 ni_log2(pSession,
NI_LOG_ERROR,
"%s(): Can't DMA to destination (%d)\n", __func__, retval);
13058 if ((pSession == NULL) || (dmaAddrs == NULL) || (pDstFrame == NULL))
13067 "%s: FW doesn't support this operation\n", __func__);
13076 "%s(): Can't DMA from source (%d)\n", __func__, retval);
13115 switch (device_type)
13123 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: %s function not supported on device with FW API version < 5.4\n", __func__);
13135 if (video_width < NI_MIN_WIDTH || video_width >
NI_MAX_WIDTH ||
13136 video_height < NI_MIN_HEIGHT || video_height >
NI_MAX_HEIGHT)
13139 __func__, video_width, video_height);
13142 resolution.
width = video_width;
13143 resolution.
height = video_height;
13159 ni_log(
NI_LOG_ERROR,
"Failed to reconfig config the encoder session (status = %d)\n", retval);
13175 __func__, device_type);
13194 int ret = 0, i = 0;
13195 if (!p_session_ctx || !p_param || !p_ppu_config)
13202 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s: Warning ignore ppu reconfig before last config done!\n", __func__);
13211 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s: not supported on device with FW API version < 6sF\n", __func__);
13218 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): only supported for h264 and h265 decoder\n", __func__);
13223 if (p_dec_input_param->
hwframes != 1)
13230 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): not supported when disable_adaptive_buffers is disabled\n", __func__);
13233 if (p_dec_input_param->
mcmode)
13235 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): not supported when MulticoreJointMode is enabled\n", __func__);
13241 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): Error reconfig ppu1 while ppu1 is not enabled\n", __func__);
13247 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s(): Error reconfig ppu2 while ppu2 is not enabled\n", __func__);
13260 "out of range\n", __func__, i, p_ppu_config->
ppu_w[i], p_ppu_config->
ppu_h[i]);
13264 if ((p_ppu_config->
ppu_w[i] & 1) || (p_ppu_config->
ppu_h[i] & 1))
13267 __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)
#define NI_XCODER_PRESET_NAME_CUSTOM
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_ENC_GOP_PARAMS_G5_PIC_TYPE
#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_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)
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
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
@ NI_RETCODE_ERROR_GET_DEVICE_POOL
#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
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.
#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
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.
@ 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_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...
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
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,...
#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_XCODER_PRESET_NAME_DEFAULT
#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_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_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_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_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