 |
libxcoder
5.2.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;
194 "ERROR %s(): init xcoder_low_delay_sync_mutex fail return\n",
201 "ERROR %s(): init xcoder_low_delay_sync_cond fail return\n",
230 p_ctx->debug_write_ptr = NULL;
231 p_ctx->debug_write_index_ptr = NULL;
232 p_ctx->debug_write_sent_size = 0;
235 #ifdef MEASURE_LATENCY
269 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
275 event_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
276 if (event_handle == NULL)
280 return NI_INVALID_EVENT_HANDLE;
284 return NI_INVALID_EVENT_HANDLE;
296 if ( NI_INVALID_DEVICE_HANDLE == event_handle )
309 retval = CloseHandle(event_handle);
323 err = close(event_handle);
326 char error_message[100] = {
'\0'};
327 char unknown_error_message[20] = {
'\0'};
328 sprintf(error_message,
"ERROR: %s(): ", __func__);
332 strcat(error_message,
"EBADF\n");
335 strcat(error_message,
"EINTR\n");
338 strcat(error_message,
"EIO\n");
341 sprintf(unknown_error_message,
"Unknown error %d\n", err);
342 strcat(error_message, unknown_error_message);
360 ni_device_handle_t
ni_device_open(
const char * p_dev, uint32_t * p_max_io_size_out)
364 HANDLE device_handle;
369 return NI_INVALID_DEVICE_HANDLE;
379 device_handle = CreateFile(p_dev, GENERIC_READ | GENERIC_WRITE,
380 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
381 OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
384 if (INVALID_HANDLE_VALUE == device_handle)
386 retval = GetLastError();
393 return device_handle;
396 ni_device_handle_t fd = NI_INVALID_DEVICE_HANDLE;
407 *p_max_io_size_out = ni_get_kernel_max_io_size(p_dev);
409 *p_max_io_size_out = MAX_IO_TRANSFER_SIZE;
418 fd = open(p_dev, O_RDWR | O_SYNC | O_DIRECT);
421 fd = open(p_dev, O_RDWR | O_SYNC);
429 fd = NI_INVALID_DEVICE_HANDLE;
442 if(close_fd_zero_atexit == 0)
444 close_fd_zero_atexit = 1;
445 atexit(close_fd_zero);
449 ni_log(
NI_LOG_ERROR,
"libxcoder has held the fd=0, but open fd=0 again, maybe fd=0 was closed accidently.");
451 fd = NI_INVALID_DEVICE_HANDLE;
456 retval = fcntl(fd, F_NOCACHE, 1);
462 fd = NI_INVALID_DEVICE_HANDLE;
467 retval = fstat(fd, &g_nvme_stat);
473 fd = NI_INVALID_DEVICE_HANDLE;
477 if (!S_ISCHR(g_nvme_stat.st_mode) && !S_ISBLK(g_nvme_stat.st_mode))
483 fd = NI_INVALID_DEVICE_HANDLE;
505 if ( NI_INVALID_DEVICE_HANDLE == device_handle )
512 if(device_handle == 0)
529 retval = CloseHandle(device_handle);
533 "ERROR: %s(): closing device device_handle %p failed, error: %d\n",
544 err = close(device_handle);
547 char error_message[100] = {
'\0'};
548 char unknown_error_message[20] = {
'\0'};
549 sprintf(error_message,
"ERROR: %s(): ", __func__);
553 strcat(error_message,
"EBADF\n");
556 strcat(error_message,
"EINTR\n");
559 strcat(error_message,
"EIO\n");
562 sprintf(unknown_error_message,
"Unknown error %d\n", err);
563 strcat(error_message, unknown_error_message);
589 void * p_buffer = NULL;
591 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
595 if ( (NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_cap) )
650 void * p_buffer = NULL;
652 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
656 if ( (NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_cap) )
723 bool use_model_load =
true;
727 uint32_t num_sw_instances = 0;
728 uint32_t pixel_load = 0xFFFFFFFFU;
729 int user_handles =
false;
730 ni_lock_handle_t lock = NI_INVALID_LOCK_HANDLE;
731 ni_device_handle_t handle = NI_INVALID_DEVICE_HANDLE;
732 ni_device_handle_t handle1 = NI_INVALID_DEVICE_HANDLE;
734 uint32_t dummy_io_size = 0;
746 if (!IsUserAnAdmin())
761 "device_type %d, session id %d\n",
813 for (i = 0; i < 120; i++)
831 "%s: device type %d hw_id %d blk_dev_name: %s dev_xcoder_name: %s.\n",
851 "%s: block device name %s type %d guid %d is to "
852 "override passed in guid %d\n",
853 __func__, p_ctx->
blk_dev_name, device_type, tmp_guid_id,
855 p_ctx->
hw_id = tmp_guid_id;
866 if ((handle1 == NI_INVALID_DEVICE_HANDLE) && (handle == NI_INVALID_DEVICE_HANDLE))
868 if (p_ctx->
hw_id >=0)
883 &dummy_io_size)) == NI_INVALID_DEVICE_HANDLE)
929 use_model_load =
false;
960 for (i = 0; i < num_coders; i++)
965 if (p_device_context == NULL)
968 "ERROR: %s() ni_rsrc_get_device_context() failed\n",
979 if (NI_INVALID_DEVICE_HANDLE == p_session_context.
device_handle)
988 if (NI_INVALID_DEVICE_HANDLE != p_session_context.
device_handle)
996 g_device_type_str[query_type],
1023 curr_load = p_dev_info->
load;
1026 if (i == 0 || curr_load < least_load ||
1027 (curr_load == least_load &&
1031 least_load = curr_load;
1043 NI_INVALID_DEVICE_HANDLE)
1058 p_ctx->
hw_id = guid;
1080 p_ctx->
hw_id = guid;
1088 else if((handle1 == NI_INVALID_DEVICE_HANDLE) || (handle == NI_INVALID_DEVICE_HANDLE))
1096 user_handles =
true;
1100 "Finish open the session dev:%s guid:%d handle:%p handle1:%p\n",
1106 if (p_device_context == NULL)
1109 "ERROR: %s() ni_rsrc_get_device_context() failed\n",
1111 if (user_handles !=
true)
1137 "ERROR: %s() cannot retrieve DDR configuration\n",
1139 if (user_handles !=
true)
1153 "ERROR: %s() keep_alive_timeout was 0, should be between 1-100. "
1154 "Setting to default of %u\n",
1158 switch (device_type)
1163 if (user_handles !=
true)
1186 if (p_enc_params && p_enc_params->
hwframes &&
1202 if (user_handles !=
true)
1220 if (user_handles !=
true)
1238 if (user_handles !=
true)
1256 if (user_handles !=
true)
1273 if (user_handles !=
true)
1283 __func__, device_type);
1349 p_device_pool = NULL;
1408 "join keep alive thread fail! : sid %u ret %d\n",
1419 switch (device_type)
1450 __func__, device_type);
1525 switch (device_type)
1541 __func__, device_type);
1583 0 == memcmp(p_ctx->
p_hdr_buf, hdr_data, hdr_size))
1595 memcpy(p_ctx->
p_hdr_buf, hdr_data, hdr_size);
1672 if (!p_ctx || !p_data)
1688 "ERROR: %s() keep alive thread has been closed, "
1689 "hw:%d, session:%d\n",
1706 switch (device_type)
1727 __func__, device_type);
1772 if ((!p_ctx) || (!p_data))
1789 "ERROR: %s() keep alive thread has been closed, "
1790 "hw:%d, session:%d\n",
1807 switch (device_type)
1811 int seq_change_read_count = 0;
1821 uint32_t aligned_width;
1831 if (0 == retval && seq_change_read_count)
1834 "%s (decoder): seq change NO data, next time.\n", __func__);
1840 else if (retval < 0)
1856 "%s (decoder): resolution change, frame size %ux%u -> %ux%u, "
1857 "width %u bit %d, pix_fromat_changed %d, actual_video_width %d, continue read ...\n",
1866 seq_change_read_count++;
1889 __func__, device_type);
1937 __func__, device_type);
1977 __func__, device_type);
2017 __func__, device_type);
2038 uint32_t namespace_num, uint32_t sriov_index)
2041 __func__, namespace_num, sriov_index);
2062 __func__, device_handle, mode);
2081 ni_device_handle_t device_handle_t,
2082 uint32_t over_provision)
2085 float f_over_provision = 0;
2086 memcpy(&f_over_provision, &over_provision,
sizeof(int32_t));
2088 __func__, device_handle, device_handle_t, f_over_provision);
2124 int video_height,
int alignment,
2125 int metadata_flag,
int factor,
2126 int hw_frame_count,
int is_planar)
2128 void* p_buffer = NULL;
2129 int metadata_size = 0;
2131 int width_aligned = video_width;
2132 int height_aligned = video_height;
2134 if ((!p_frame) || ((factor!=1) && (factor!=2) && (factor !=4))
2139 "factor %d, video_width %d, video_height %d\n",
2140 __func__, factor, video_width, video_height);
2155 width_aligned = ((((video_width * factor) + 127) / 128) * 128) / factor;
2156 height_aligned = ((video_height + 1) / 2) * 2;
2161 height_aligned = ((video_height + 1) / 2) * 2;
2169 width_aligned = ((video_width + 31) / 32) * 32;
2170 height_aligned = ((video_height + 7) / 8) * 8;
2173 height_aligned = ((video_height + 15) / 16) * 16;
2177 int luma_size = width_aligned * height_aligned * factor;
2182 int chroma_width_aligned = ((((video_width / 2 * factor) + 127) / 128) * 128) / factor;
2186 chroma_width_aligned =
2187 ((((video_width * factor) + 127) / 128) * 128) / factor;
2189 int chroma_height_aligned = height_aligned / 2;
2190 chroma_b_size = chroma_r_size = chroma_width_aligned * chroma_height_aligned * factor;
2198 chroma_b_size = chroma_r_size = 0;
2204 chroma_b_size = luma_size / 4;
2205 chroma_r_size = chroma_b_size;
2210 if (hw_frame_count == 0)
2211 buffer_size = luma_size + chroma_b_size + chroma_r_size + metadata_size;
2225 "%s: free current p_frame, p_frame->buffer_size=%u\n", __func__,
2263 p_frame->
data_len[1] = chroma_b_size;
2264 p_frame->
data_len[2] = chroma_r_size;
2283 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);
2322 int video_height,
int alignment,
2323 int metadata_flag,
int factor,
2324 int hw_frame_count,
int is_planar,
2331 if (((factor!=1) && (factor!=2) && (factor !=4))
2336 "factor %d, video_width %d, video_height %d\n",
2337 __func__, factor, video_width, video_height);
2364 dst_stride, height_aligned);
2372 video_height, dst_stride, alignment,
2394 int video_height,
int pixel_format)
2396 void *p_buffer = NULL;
2398 int width_aligned = video_width;
2399 int height_aligned = video_height;
2407 (video_height <= 0))
2410 "ERROR: %s passed parameters are null or not supported, "
2411 "video_width %d, video_height %d\n",
2412 __func__, video_width, video_height);
2416 switch (pixel_format)
2422 luma_size = width_aligned * height_aligned;
2425 chroma_r_size = chroma_b_size;
2431 luma_size = width_aligned * height_aligned * 2;
2433 chroma_r_size = chroma_b_size;
2439 luma_size = width_aligned * height_aligned;
2440 chroma_b_size = width_aligned * height_aligned / 2;
2447 luma_size = width_aligned * height_aligned * 2;
2453 height_aligned = video_height;
2455 luma_size = width_aligned * height_aligned;
2456 chroma_b_size = luma_size;
2462 height_aligned = video_height;
2464 luma_size = width_aligned * height_aligned * 2;
2474 height_aligned = video_height;
2476 luma_size = width_aligned * height_aligned * 4;
2482 height_aligned = video_height;
2484 luma_size = width_aligned * height_aligned;
2485 chroma_b_size = luma_size;
2486 chroma_r_size = luma_size;
2494 buffer_size = luma_size + chroma_b_size + chroma_r_size;
2500 __func__, luma_size, chroma_b_size, chroma_r_size, buffer_size);
2506 "%s: free current p_frame, p_frame->buffer_size=%u\n", __func__,
2518 "ERROR %d: %s() Cannot allocate p_frame buffer.\n",
NI_ERRNO,
2536 p_frame->
data_len[1] = chroma_b_size;
2537 p_frame->
data_len[2] = chroma_r_size;
2588 int video_width,
int video_height,
2589 int alignment,
int factor,
2597 if ((!p_frame) || ((factor!=1) && (factor!=2))
2602 "factor %d, video_width %d, video_height %d\n",
2603 __func__, factor, video_width, video_height);
2609 width_aligned = ((((video_width * factor) + 127) / 128) * 128) / factor;
2610 height_aligned = video_height;
2614 width_aligned = ((video_width + 31) / 32) * 32;
2615 height_aligned = ((video_height + 7) / 8) * 8;
2618 height_aligned = ((video_height + 15) / 16) * 16;
2623 width_aligned, height_aligned, video_width, video_height);
2625 int luma_size = width_aligned * height_aligned * factor;
2630 int chroma_width_aligned = ((((video_width / 2 * factor) + 127) / 128) * 128) / factor;
2633 chroma_width_aligned =
2634 ((((video_width * factor) + 127) / 128) * 128) / factor;
2636 int chroma_height_aligned = height_aligned / 2;
2637 chroma_b_size = chroma_r_size = chroma_width_aligned * chroma_height_aligned * factor;
2645 chroma_b_size = luma_size / 4;
2646 chroma_r_size = chroma_b_size;
2648 int buffer_size = luma_size + chroma_b_size + chroma_r_size +
2690 p_frame->
p_data[2] = p_frame->
p_data[1] + chroma_b_size;
2691 p_frame->
p_data[3] = p_frame->
p_data[2] + chroma_r_size;
2699 p_frame->
data_len[1] = chroma_b_size;
2700 p_frame->
data_len[2] = chroma_r_size;
2735 int width,
int height,
2736 const int linesize[],
2740 if ((!p_enc_ctx) || (!p_enc_params) || (!linesize)
2746 "p_enc_ctx %p, p_enc_params %p, linesize %p, "
2747 "width %d, height %d linesize[0] %d\n",
2748 __func__, p_enc_ctx, p_enc_params, linesize,
2749 width, height, (linesize) ? linesize[0] : 0);
2758 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s: not supported on device with FW API version < 6.Q\n", __func__);
2762 bool isrgba =
false;
2763 bool isplanar =
false;
2764 bool issemiplanar =
false;
2774 issemiplanar =
true;
2793 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s: semi-planar not supported on device with FW API version < 6.q\n", __func__);
2802 bool ishwframe = (p_enc_params->
hwframes) ?
true :
false;
2805 "p_enc_ctx %p, p_enc_params %p, linesize %p, "
2806 "width %d, height %d, linesize[0] %d linesize[1] %d\n",
2807 __func__, isrgba, issemiplanar, ishwframe, p_enc_ctx, p_enc_params, linesize,
2808 width, height, linesize[0], linesize[1]);
2810 if (linesize[0] <= max_linesize &&
2811 linesize[0] % 2 == 0 &&
2812 linesize[1] % 2 == 0 &&
2818 (!isplanar || linesize[2] == linesize[1])
2836 "luma_linesize %d, chroma_linesize %d, "
2837 "linesize[0] %d, linesize[1] %d\n",
2839 linesize[0], linesize[1]);
2846 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"%s: linesize changed from %u %u to %u %u - resolution change?\n", __func__,
2848 linesize[0], linesize[1]);
2880 int video_width,
int video_height,
2881 const int linesize[],
const uint8_t *data[],
2886 if ((!p_frame) || (!linesize) || (!data))
2889 "p_frame %p, linesize %p, data %p\n",
2890 __func__, p_frame, linesize, data);
2895 "%s: resolution=%dx%d linesize=%d/%d/%d "
2896 "data=%p %p %p extra_len=%d\n",
2897 __func__, video_width, video_height,
2898 linesize[0], linesize[1], linesize[2],
2899 data[0], data[1], data[2], extra_len);
2907 p_frame->
p_buffer = (uint8_t *)data[0];
2908 p_frame->
p_data[0] = (uint8_t *)data[0];
2909 p_frame->
p_data[1] = (uint8_t *)data[1];
2910 p_frame->
p_data[2] = (uint8_t *)data[2];
2912 int luma_size = linesize[0] * video_height;
2913 int chroma_b_size = 0;
2914 int chroma_r_size = 0;
2918 chroma_b_size = linesize[1] * (video_height / 2);
2921 chroma_r_size = linesize[2] * (video_height / 2);
2925 uint32_t start_offset;
2926 uint32_t total_start_len = 0;
2932 if ((data[1] && (data[0] + luma_size != data[1]))
2933 || (data[2] && (data[1] + chroma_b_size != data[2])))
2944 total_start_len += p_frame->
start_len[i];
2952 total_start_len = p_frame->
start_len[0];
2965 if (total_start_len)
2977 int start_buffer_offset = 0;
2984 start_buffer_offset += p_frame->
start_len[i];
2990 p_frame->
data_len[1] = chroma_b_size;
2991 p_frame->
data_len[2] = chroma_r_size;
2998 "%s: success: p_metadata_buffer %p metadata_buffer_size %u "
2999 "p_start_buffer %p start_buffer_size %u data_len %u %u %u\n",
3029 int width,
int height,
3030 const int linesize[],
int pixel_format)
3033 if ((!p_upl_ctx) || (!linesize)
3039 "p_enc_ctx %p, linesize %p, "
3040 "width %d, height %d linesize[0] %d\n",
3041 __func__, p_upl_ctx, linesize,
3042 width, height, (linesize) ? linesize[0] : 0);
3051 ni_log2(p_upl_ctx,
NI_LOG_DEBUG,
"%s: not supported on device with FW API version < 6.S\n", __func__);
3061 "p_upl_ctx %p, linesize %p, "
3062 "width %d, height %d, linesize[0] %d\n",
3063 __func__, pixel_format, p_upl_ctx, linesize,
3064 width, height, linesize[0]);
3066 int bit_depth_factor;
3067 bool isrgba =
false;
3068 bool isplanar =
false;
3069 bool issemiplanar =
false;
3071 switch (pixel_format)
3075 bit_depth_factor = 1;
3079 bit_depth_factor = 2;
3082 issemiplanar =
true;
3083 bit_depth_factor = 1;
3086 issemiplanar =
true;
3087 bit_depth_factor = 2;
3094 bit_depth_factor = 4;
3107 ni_log2(p_upl_ctx,
NI_LOG_DEBUG,
"%s: semi-planar not supported on device with FW API version < 6.q\n", __func__);
3112 if (linesize[0] <= max_linesize &&
3121 linesize[2] == linesize[1])
3127 linesize[1] == linesize[0])
3162 int video_height,
int linesize[],
3163 int alignment,
int extra_len,
3164 bool alignment_2pass_wa)
3166 void* p_buffer = NULL;
3175 "p_frame %p, linesize %p, video_width %d, video_height %d\n",
3176 __func__, p_frame, linesize, video_width, video_height);
3182 height_aligned = ((video_height + 1) / 2) * 2;
3185 height_aligned = ((video_height + 7) / 8) * 8;
3189 height_aligned = ((video_height + 15) / 16) * 16;
3198 "%s: aligned=%dx%d org=%dx%d linesize=%d/%d/%d "
3200 __func__, video_width, height_aligned, video_width, video_height,
3201 linesize[0], linesize[1], linesize[2], extra_len);
3203 int luma_size = linesize[0] * height_aligned;
3208 chroma_b_size = chroma_r_size = linesize[1] * (height_aligned / 2);
3209 if (alignment_2pass_wa)
3212 chroma_r_size = linesize[1] * (((height_aligned + 31) / 32) * 32) / 2;
3218 chroma_b_size = luma_size / 4;
3219 chroma_r_size = luma_size / 4;
3223 int buffer_size = luma_size + chroma_b_size + chroma_r_size + extra_len;
3231 "%s: free current p_frame, "
3232 "p_frame->buffer_size=%u\n",
3249 memset(p_buffer, 0, buffer_size);
3260 p_frame->
p_data[1] = (uint8_t*)p_frame->
p_data[0] + luma_size;
3261 p_frame->
p_data[2] = (uint8_t*)p_frame->
p_data[1] + chroma_b_size;
3269 p_frame->
data_len[1] = chroma_b_size;
3270 p_frame->
data_len[2] = chroma_r_size;
3277 "%s: success: p_frame->p_buffer %p "
3278 "p_frame->buffer_size=%u\n",
3398 int video_height,
int linesize[],
3399 int extra_len,
bool alignment_2pass_wa)
3401 void* p_buffer = NULL;
3410 "p_frame %p, linesize %p, video_width %d, video_height %d\n",
3411 __func__, p_frame, linesize, video_width, video_height);
3415 height_aligned = ((video_height + 1) / 2) * 2;
3423 "%s: aligned=%dx%d org=%dx%d linesize=%d/%d/%d extra_len=%d\n",
3424 __func__, video_width, height_aligned, video_width, video_height,
3425 linesize[0], linesize[1], linesize[2], extra_len);
3427 int luma_size = linesize[0] * height_aligned;
3428 int chroma_br_size = luma_size / 2;
3430 if (alignment_2pass_wa)
3433 chroma_br_size = linesize[0] * ((((height_aligned + 31) / 32) * 32) / 2);
3437 int buffer_size = luma_size + chroma_br_size + extra_len;
3461 memset(p_buffer, 0, buffer_size);
3473 p_frame->
p_data[1] = (uint8_t*)p_frame->
p_data[0] + luma_size;
3474 p_frame->
p_data[2] = (uint8_t*)p_frame->
p_data[1] + chroma_br_size;
3481 p_frame->
data_len[1] = chroma_br_size;
3532 int video_width,
int video_height,
3533 int linesize[],
int alignment,
3535 bool alignment_2pass_wa)
3540 linesize, alignment, extra_len,
3541 alignment_2pass_wa);
3546 linesize, extra_len,
3547 alignment_2pass_wa);
3589 "%s: close p_surface->dma_buf_fd %d "
3590 "ui16FrameIdx %u\n",
3606 p_frame->
p_data[i] = NULL;
3675 p_frame->
p_data[i] = NULL;
3715 void* p_buffer = NULL;
3716 int metadata_size = 0;
3723 packet_size + metadata_size);
3725 if (!p_packet || !packet_size)
3750 "%s: free current p_packet, p_packet->buffer_size=%u\n", __func__,
3756 __func__, buffer_size);
3813 if (!p_buffer || !p_packet || !buffer_size)
3821 ni_log(
NI_LOG_INFO,
"Info: %s: Warning buffer not 4k aligned = %p!. Will do an extra copy\n",
3822 __func__, p_buffer);
3900 "%s(): no need to free previous av1 packet buffers\n", __func__);
3936 int ni_packet_copy(
void* p_destination,
const void*
const p_source,
int cur_size,
void* p_leftover,
int* p_prev_size)
3939 int padding_size = 0;
3940 int prev_size = p_prev_size == NULL? 0 : *p_prev_size;
3942 int total_size = cur_size + prev_size;
3943 uint8_t* p_src = (uint8_t*)p_source;
3944 uint8_t* p_dst = (uint8_t*)p_destination;
3945 uint8_t* p_lftover = (uint8_t*)p_leftover;
3954 if ((0 == cur_size) && (0 == prev_size))
3959 if (((0 != cur_size) && (!p_source)) || (!p_destination) || (!p_leftover))
3966 if (copy_size > total_size)
3968 padding_size = copy_size - total_size;
3973 memcpy(p_dst, p_lftover, prev_size);
3978 memcpy(p_dst, p_src, cur_size);
3983 memset(p_dst, 0, padding_size);
3987 "%s(): exit, cur_size=%d, copy_size=%d, "
3988 "prev_size=%d, padding_size=%d\n", __func__, cur_size,
3989 copy_size, *p_prev_size, padding_size);
4014 "ERROR: %s No memory or exceeding max aux_data number !\n",
4020 ret->
size = data_size;
4021 ret->
data = calloc(1, data_size);
4047 const uint8_t *raw_data,
4053 memcpy(ret->
data, raw_data, data_size);
4097 if (aux->
type == type)
4148 int fps_num,
int fps_denom,
4149 long bit_rate,
int width,
4300 p_param->
bitrate = (int)bit_rate;
4399 p_enc->
qcomp = (float)0.6;
4473 ni_log(
NI_LOG_ERROR,
"AV1 Picture Width not aligned to %d - picture will be cropped\n",
4478 ni_log(
NI_LOG_ERROR,
"AV1 Picture Height not aligned to %d - picture will be cropped\n",
4547 int fps_num,
int fps_denom,
4548 long bit_rate,
int width,
4574 if(fps_num <= 0 || fps_denom <= 0)
4578 ni_log(
NI_LOG_INFO,
"%s(): FPS is not set, setting the default FPS to 30\n", __func__);
4635 p_param->
bitrate = (int)bit_rate;
4667 char keyChar[10] =
"";
4669 char valChar[10] =
"";
4675 FILE *reconf = NULL;
4684 reconf = fopen(reconf_file,
"r");
4693 while ((readc = fgetc(reconf)) != EOF)
4700 strncat(keyChar, (
const char *)(&readc), 1);
4704 strncat(valChar, (
const char *)(&readc), 1);
4707 else if (readc ==
':')
4710 key =
atoi(keyChar);
4711 hash_map[idx][0] = key;
4713 else if (readc ==
',')
4718 "ERROR: Number of entries per line in reconfig file is greater then the "
4724 val =
atoi(valChar);
4725 hash_map[idx][valIdx] = val;
4727 memset(valChar, 0, 10);
4729 else if (readc ==
'\n')
4734 "ERROR: Number of lines in reconfig file is greater then the "
4741 val =
atoi (valChar);
4742 hash_map[idx][valIdx] = val;
4744 memset(keyChar,0,10);
4745 memset(valChar,0,10);
4750 ni_log(
NI_LOG_ERROR,
"ERROR: character %c in reconfig file. this may lead to mistaken reconfiguration values\n", readc);
4759 "ERROR %d: %s(): Incorrect format / "
4760 "incomplete Key/Value pair in reconfig_file: %s\n",
4771 char valChar[5] =
"";
4777 FILE *reconf = NULL;
4779 if (!customize_file)
4786 reconf = fopen(customize_file,
"r");
4790 NI_ERRNO, __func__, customize_file);
4795 while ((readc = fgetc(reconf)) != EOF)
4800 strncat(valChar, (
const char *)(&readc), 1);
4802 else if (readc ==
'-') {
4805 else if (readc ==
',')
4810 "ERROR: Number of qpIdx %d greater then the limit of %d or"
4811 "Number of levelIdx %d greater then the limit of %d\n",
4818 qp_map[levelIdx][qpIdx] = val;
4820 val = clip3(0, 32,
atoi(valChar));
4821 qp_map[levelIdx][qpIdx] = val * -1;
4824 memset(valChar, 0, 5);
4827 else if (readc ==
'\n')
4832 "ERROR: Number of qpIdx %d greater then the limit of %d or"
4833 "Number of levelIdx %d greater then the limit of %d\n",
4840 qp_map[levelIdx][qpIdx] = val;
4842 val = clip3(0, 32,
atoi(valChar));
4843 qp_map[levelIdx][qpIdx] = val * -1;
4846 memset(valChar, 0, 5);
4852 ni_log(
NI_LOG_ERROR,
"ERROR: character %c in reconfig file. this may lead to mistaken reconfiguration values\n", readc);
4863 #define atoi(p_str) ni_atoi(p_str, &b_error)
4864 #define atof(p_str) ni_atof(p_str, &b_error)
4865 #define atobool(p_str) (ni_atobool(p_str, &b_error))
4882 const char *name,
char *value)
4884 bool b_error =
false;
4885 bool bNameWasBool =
false;
4886 bool bValueWasNull = !value;
4888 char nameBuf[64] = { 0 };
4889 const char delim[2] =
",";
4890 const char xdelim[2] =
"x";
4912 if (name[0] ==
'-' && name[1] ==
'-')
4918 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
4921 strcpy(nameBuf, name);
4922 while ((c = strchr(nameBuf,
'_')) != 0)
4933 else if (value[0] ==
'=')
4938 #if defined(_MSC_VER)
4939 #define OPT(STR) else if (!_stricmp(name, STR))
4940 #define OPT2(STR1, STR2) \
4941 else if (!_stricmp(name, STR1) || !_stricmp(name, STR2))
4943 #define OPT(STR) else if (!strcasecmp(name, STR))
4944 #define OPT2(STR1, STR2) else if (!strcasecmp(name, STR1) || !strcasecmp(name, STR2))
4949 if (!strncmp(value,
"hw",
sizeof(
"hw"))){
4952 else if (!strncmp(value,
"sw",
sizeof(
"sw"))) {
4963 if (
atoi(value) == 1)
4968 if (
atoi(value) == 1)
4973 if (
atoi(value) == 1)
4978 if (
atoi(value) == 1)
4983 if (
atoi(value) == 1)
4988 if (
atoi(value) == 1 ||
atoi(value) == 2)
4993 if (
atoi(value) == 1 ||
atoi(value) == 2)
4998 if (
atoi(value) == 1 ||
atoi(value) == 2)
5003 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5006 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5011 "ERROR: %s():cropMode0 input can only be <manual,auto> got %s\n",
5018 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5021 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5026 "ERROR: %s():cropMode1 input can only be <manual,auto> got %s\n",
5033 if (!strncmp(value,
"manual",
sizeof(
"manual"))) {
5036 else if (!strncmp(value,
"auto",
sizeof(
"auto"))) {
5041 "ERROR: %s():cropMode2 input can only be <manual,auto> got %s\n",
5048 char *saveptr = NULL;
5049 chunk =
ni_strtok(value, delim, &saveptr);
5050 for (i = 0; i < 4; i++)
5057 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5059 p_dec->
cr_expr[0][i][k] = chunk[j];
5067 chunk =
ni_strtok(NULL, delim, &saveptr);
5071 strcpy(p_dec->
cr_expr[0][i],
"in_w/2-out_w/2");
5075 strcpy(p_dec->
cr_expr[0][i],
"in_h/2-out_h/2");
5084 char *saveptr = NULL;
5085 chunk =
ni_strtok(value, delim, &saveptr);
5086 for (i = 0; i < 4; i++)
5093 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5095 p_dec->
cr_expr[1][i][k] = chunk[j];
5103 chunk =
ni_strtok(NULL, delim, &saveptr);
5108 strcpy(p_dec->
cr_expr[1][i],
"in_w/2-out_w/2");
5112 strcpy(p_dec->
cr_expr[1][i],
"in_h/2-out_h/2");
5122 char *saveptr = NULL;
5123 chunk =
ni_strtok(value, delim, &saveptr);
5124 for (i = 0; i < 4; i++)
5131 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5133 p_dec->
cr_expr[2][i][k] = chunk[j];
5141 chunk =
ni_strtok(NULL, delim, &saveptr);
5146 strcpy(p_dec->
cr_expr[2][i],
"in_w/2-out_w/2");
5150 strcpy(p_dec->
cr_expr[2][i],
"in_h/2-out_h/2");
5163 if (*chunk == xdelim[0]) {
5172 char *saveptr = NULL;
5173 chunk =
ni_strtok(value, xdelim, &saveptr);
5174 for (i = 0; i < 2; i++)
5181 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5183 p_dec->
sc_expr[0][i][k] = chunk[j];
5191 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5204 if (*chunk == xdelim[0]) {
5213 char *saveptr = NULL;
5214 chunk =
ni_strtok(value, xdelim, &saveptr);
5215 for (i = 0; i < 2; i++)
5222 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5224 p_dec->
sc_expr[1][i][k] = chunk[j];
5232 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5245 if (*chunk == xdelim[0]) {
5254 char *saveptr = NULL;
5255 chunk =
ni_strtok(value, xdelim, &saveptr);
5256 for (i = 0; i < 2; i++)
5263 if (chunk[j] !=
'\"' && chunk[j] !=
'\'')
5265 p_dec->
sc_expr[2][i][k] = chunk[j];
5273 chunk =
ni_strtok(NULL, xdelim, &saveptr);
5283 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5291 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5299 if ((
atoi(value) < 0) || (
atoi(value) > 2))
5307 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5310 "and must be even number and less than or equal to 128. Got: %s\n",
5319 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5322 "and must be even number and less than or equal to 128. Got: %s\n",
5330 if (
atoi(value) < 2 ||
atoi(value) % 2 != 0 ||
atoi(value) > 128)
5333 "and must be even number and less than or equal to 128. Got: %s\n",
5341 if (!strncmp(value,
"up",
sizeof(
"up"))){
5344 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5355 if (!strncmp(value,
"up",
sizeof(
"up"))){
5358 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5369 if (!strncmp(value,
"up",
sizeof(
"up"))){
5372 else if (!strncmp(value,
"down",
sizeof(
"down"))) {
5383 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5391 if (
atoi(value) < 0)
5408 if (
atoi(value) < 0)
5416 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5424 if (
atoi(value) < 0)
5432 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5475 if (strncmp(value,
"tolerant",
sizeof(
"tolerant")) == 0) {
5477 }
else if (strncmp(value,
"ignore",
sizeof(
"ignore")) == 0) {
5479 }
else if (strncmp(value,
"skip",
sizeof(
"skip")) == 0) {
5481 }
else if (strncmp(value,
"best_effort",
sizeof(
"best_effort")) == 0) {
5483 }
else if (strncmp(value,
"limited_error",
sizeof(
"limited_error")) == 0) {
5485 }
else if (strncmp(value,
"best_effort_out_dc",
sizeof(
"best_effort_out_dc")) == 0) {
5493 if (
atoi(value) != 0 &&
5503 if (
atoi(value) < 0 || (
atoi(value) > 100))
5511 if (
atoi(value) < 0 || (
atoi(value) > 2))
5519 if (
atoi(value) < 0 || (
atoi(value) > 1))
5527 if (
atoi(value) < 0 ||
atoi(value) > 255)
5535 if (
atoi(value) < 0 ||
atoi(value) > 1)
5543 if (
atoi(value) != 0 &&
atoi(value) != 1)
5551 if (
atoi(value) < 0 ||
5560 if (
atoi(value) != 0 &&
atoi(value) != 1)
5568 if (
atoi(value) < 0 ||
5577 if (
atoi(value) < 0 ||
atoi(value) > 1)
5585 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5593 if ((
atoi(value) != 0) && (
atoi(value) != 1))
5608 b_error |= bValueWasNull && !bNameWasBool;
5617 #define atoi(p_str) ni_atoi(p_str, &b_error)
5618 #define atof(p_str) ni_atof(p_str, &b_error)
5619 #define atobool(p_str) (ni_atobool(p_str, &b_error))
5636 const char *name,
const char *value)
5638 bool b_error =
false;
5639 bool bNameWasBool =
false;
5640 bool bValueWasNull = !value;
5642 char nameBuf[64] = { 0 };
5662 if (name[0] ==
'-' && name[1] ==
'-')
5668 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
5671 strcpy(nameBuf, name);
5672 while ((c = strchr(nameBuf,
'_')) != 0)
5683 else if (value[0] ==
'=')
5688 #if defined(_MSC_VER)
5689 #define OPT(STR) else if (!_stricmp(name, STR))
5690 #define OPT2(STR1, STR2) \
5691 else if (!_stricmp(name, STR1) || !_stricmp(name, STR2))
5693 #define OPT(STR) else if (!strcasecmp(name, STR))
5694 #define OPT2(STR1, STR2) else if (!strcasecmp(name, STR1) || !strcasecmp(name, STR2))
5696 #define COMPARE(STR1, STR2, STR3) \
5697 if ((atoi(STR1) > (STR2)) || (atoi(STR1) < (STR3))) \
5699 return NI_RETCODE_PARAM_ERROR_OOR; \
5740 if (0 >
atoi(value))
5748 if (0 !=
atoi(value) && 1 !=
atoi(value))
5760 if (0 !=
atoi(value) && 1 !=
atoi(value))
5770 if (0 !=
atoi(value) && 1 !=
atoi(value))
5793 if (
atof(value) <= 10)
5953 if ((
atoi(value) > 51) || (
atoi(value) < -1))
5991 if (0 !=
atoi(value) && 1 !=
atoi(value))
6001 if (!_strnicmp(value,
"ratio", 5))
6003 if (!strncasecmp(value,
"ratio", 5))
6006 char value_buf[32] = {0};
6007 for (i = 0; i <
sizeof(value_buf); i++)
6009 if (value[i+6] ==
']')
6013 value_buf[i] = value[i+6];
6015 if (i ==
sizeof(value_buf) ||
atoi(value_buf) < 0)
6024 int size =
atoi(value);
6035 if (!_strnicmp(value,
"ratio", 5))
6037 if (!strncasecmp(value,
"ratio", 5))
6040 char value_buf[32] = {0};
6041 for (i = 0; i <
sizeof(value_buf); i++)
6043 if (value[i+6] ==
']')
6047 value_buf[i] = value[i+6];
6049 if (i ==
sizeof(value_buf) ||
atoi(value_buf) < 0)
6058 int size =
atoi(value) / 8;
6068 if (0 !=
atoi(value) && 1 !=
atoi(value))
6113 if (
atoi(value) <= 0 )
6123 if (
atoi(value) <= 0)
6171 if (0 !=
atoi(value) && 1 !=
atoi(value))
6200 if (0 !=
atoi(value) && 1 !=
atoi(value))
6230 if ((
atoi(value) > 255) || (
atoi(value) < 0))
6238 if (
atoi(value) != 0 &&
atoi(value) != 5)
6246 if ((
atoi(value) > 3) || (
atoi(value) < 1))
6254 const char delim[2] =
",";
6257 char *v = _strdup(value);
6259 char *v = strdup(value);
6261 char *saveptr = NULL;
6265 if ((
atoi(chunk) > 65535) || (
atoi(chunk) < 0))
6271 chunk =
ni_strtok(NULL, delim, &saveptr);
6274 if ((
atoi(chunk) > 65535) || (
atoi(chunk) < 0))
6299 #define STRDUP(value) _strdup(value);
6301 #define STRDUP(value) strdup(value);
6303 const char G[2] =
"G";
6304 const char B[2] =
"B";
6305 const char R[2] =
"R";
6306 const char W[2] =
"W";
6307 const char L[2] =
"L";
6308 const char P[2] =
"P";
6309 const char parL[2] =
"(";
6310 const char comma[2] =
",";
6311 const char parR[2] =
")";
6312 int synCheck_GBRWLPCP[8];
6313 int posCheck_GBRWL[5] = {0};
6318 for (i = 0; i<8; i++)
6320 synCheck_GBRWLPCP[i] = 0;
6329 synCheck_GBRWLPCP[0]++;
6330 posCheck_GBRWL[0] = i;
6332 else if (*chunk == B[0])
6334 synCheck_GBRWLPCP[1]++;
6335 posCheck_GBRWL[1] = i;
6337 else if (*chunk == R[0])
6339 synCheck_GBRWLPCP[2]++;
6340 posCheck_GBRWL[2] = i;
6342 else if (*chunk == W[0])
6344 synCheck_GBRWLPCP[3]++;
6345 posCheck_GBRWL[3] = i;
6347 else if (*chunk == L[0])
6349 synCheck_GBRWLPCP[4]++;
6350 posCheck_GBRWL[4] = i;
6352 else if (*chunk == parL[0])
6354 synCheck_GBRWLPCP[5]++;
6356 else if (*chunk == comma[0])
6358 synCheck_GBRWLPCP[6]++;
6360 else if (*chunk == parR[0])
6362 synCheck_GBRWLPCP[7]++;
6368 if (synCheck_GBRWLPCP[0] != 1 || synCheck_GBRWLPCP[1] != 1 || synCheck_GBRWLPCP[2] != 1 ||
6369 synCheck_GBRWLPCP[3] != 1 || synCheck_GBRWLPCP[4] != 1 || synCheck_GBRWLPCP[5] != 5 ||
6370 synCheck_GBRWLPCP[6] != 5 || synCheck_GBRWLPCP[7] != 5)
6376 #define GBRWLPARSE(OUT1,OUT2,OFF,IDX) \
6378 char *v = STRDUP(value); \
6379 chunk = v + posCheck_GBRWL[IDX]; \
6381 while (chunk != NULL) \
6383 if (*chunk == parL[0] && i == 1+(OFF)) \
6387 if((OFF) == 1 && *chunk != P[0] && i == 1) \
6391 if (*chunk == parR[0]) \
6402 return NI_RETCODE_PARAM_INVALID_VALUE; \
6404 subchunk = malloc(i - 1 - (OFF)); \
6405 if (subchunk == NULL) \
6408 return NI_RETCODE_ERROR_MEM_ALOC; \
6410 memcpy(subchunk, v + posCheck_GBRWL[IDX] + 2 + (OFF), i - 2 - (OFF)); \
6411 subchunk[i - 2 - (OFF)] = '\0'; \
6412 char *saveptr = NULL; \
6413 chunk = ni_strtok(subchunk, comma, &saveptr); \
6414 if (chunk != NULL) \
6416 if(atoi(chunk) < 0) \
6419 if(subchunk != NULL){ \
6422 return NI_RETCODE_PARAM_INVALID_VALUE; \
6424 *(OUT1) = atoi(chunk); \
6426 chunk = ni_strtok(NULL, comma, &saveptr); \
6427 if (chunk != NULL) \
6429 if(atoi(chunk) < 0) \
6432 if(subchunk != NULL){ \
6435 return NI_RETCODE_PARAM_INVALID_VALUE; \
6437 *(OUT2) = atoi(chunk); \
6451 if (
atoi(value)!= 0 && ((
atoi(value) > 40 ) || (
atoi(value) < 4)))
6459 if (
atoi(value) != 0 &&
atoi(value) != 1)
6467 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6475 if (
atoi(value) != 0 &&
atoi(value) != 1)
6483 if (
atoi(value) != 0 &&
atoi(value) != 1)
6495 if (
atoi(value) < 1 ||
atoi(value) > 2)
6503 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6516 if ((
atoi(value) < 0) || (
atoi(value) > 3))
6538 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6567 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6575 if ((
atoi(value) < 0) || (
atoi(value) > 9))
6583 if ((
atoi(value) > 12) || (
atoi(value) < -12))
6593 if ((
atoi(value) > 300) || (
atoi(value) < 1))
6601 if ((
atoi(value) > 2) || (
atoi(value) < 0))
6609 if ((
atoi(value) > 15) || (
atoi(value) < 0))
6617 if ((
atoi(value) > 500) || (
atoi(value) < 0))
6625 if ((
atoi(value) > 1) || (
atoi(value) < 0))
6633 if ((
atoi(value) > 1) || (
atoi(value) < 0))
6680 if (
atoi(value) != 0 &&
atoi(value) != 1)
6688 if (
atoi(value) < 0 ||
atoi(value) > 3)
6696 if (
atoi(value) < 1)
6704 if (
atoi(value) < 0 ||
atoi(value) > 1)
6712 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6720 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6728 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6740 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6748 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6754 ni_log(
NI_LOG_ERROR,
"Cannot set enableAIEnhance and enableHVSPlus at same time, just enableHVSPlus\n");
6760 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6768 if ((
atoi(value) != 0) && (
atoi(value) != 1) && (
atoi(value) != -1))
6776 if ((
atoi(value) == 0) || (
atoi(value) > 3))
6784 if ((
atoi(value) == 0) || (
atoi(value) > 2))
6810 if ((
atoi(value) < 0) ||
6819 if ((
atoi(value) < 0) ||
6828 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6836 if ((
atof(value) > 1.0) || (
atof(value) < 0.0))
6844 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6852 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6860 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6868 if ((
atoi(value) > 10) || (
atoi(value) < 1))
6876 if ((
atof(value) > 10.0) || (
atof(value) < 0.01))
6884 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6892 if ((
atof(value) > 10.0) || (
atof(value) < 0.01))
6900 if ((
atof(value) > 1.0) || (
atof(value) < 0.1))
6908 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6925 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6933 if ((
atoi(value) > 51) || (
atoi(value) < -1))
6941 if (((
atof(value) < 0.0) && (
atof(value) != -1.0)) ||
6942 (
atof(value) > 51.00))
6950 if ((
atoi(value) < 0) || (
atoi(value) > 31))
6958 if (
atoi(value) < 0 ||
atoi(value) > 1)
6969 if ((
atoi(value) < 0 ||
atoi(value) > 6))
6980 if ((
atoi(value) < 0 ||
atoi(value) > 10))
6988 if ((
atoi(value) != 0) && (
atoi(value) != 1))
6996 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7004 if (
atoi(value) < 0 ||
atoi(value) > 1)
7012 if (
atoi(value) < 0)
7020 if (
atoi(value) < 0 ||
atoi(value) > 255)
7028 if (
atoi(value) != 0 &&
atoi(value) != 1)
7036 if (
atoi(value) <= 0)
7044 if (
atoi(value) != 0 &&
atoi(value) != 1)
7056 if (
atoi(value) != 0 &&
atoi(value) != 1)
7064 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7072 if ((
atof(value) > 1.0) || (
atof(value) < 0.0))
7080 if (
atoi(value) < 0 ||
atoi(value) > 2)
7088 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7096 if (
atoi(value) < 0 ||
atoi(value) > 1)
7114 if (
atoi(value) < 0 ||
atoi(value) > 2)
7131 if (
atoi(value) < 1 ||
atoi(value) > 4)
7139 if (
atoi(value) < 0 ||
atoi(value) > 1)
7147 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7155 if ((
atoi(value) != 0) && (
atoi(value) != 1))
7169 b_error |= bValueWasNull && !bNameWasBool;
7178 #define atoi(p_str) ni_atoi(p_str, &b_error)
7179 #define atof(p_str) ni_atof(p_str, &b_error)
7180 #define atobool(p_str) (ni_atobool(p_str, &b_error))
7201 bool b_error =
false;
7202 bool bNameWasBool =
false;
7203 bool bValueWasNull = !value;
7206 char nameBuf[64] = { 0 };
7227 if (name[0] ==
'-' && name[1] ==
'-')
7233 if (strlen(name) + 1 <
sizeof(nameBuf) && strchr(name,
'_'))
7236 strcpy(nameBuf, name);
7237 while ((c = strchr(nameBuf,
'_')) != 0)
7248 else if (value[0] ==
'=')
7253 #if defined(_MSC_VER)
7254 #define OPT(STR) else if (!_stricmp(name, STR))
7256 #define OPT(STR) else if (!strcasecmp(name, STR))
7281 OPT(NI_ENC_GOP_PARAMS_G0_PIC_QP)
7285 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC_L0)
7289 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L0)
7293 OPT(NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L1)
7310 OPT(NI_ENC_GOP_PARAMS_G1_PIC_QP)
7314 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC_L0)
7318 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L0)
7322 OPT(NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L1)
7339 OPT(NI_ENC_GOP_PARAMS_G2_PIC_QP)
7343 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC_L0)
7347 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L0)
7351 OPT(NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L1)
7368 OPT(NI_ENC_GOP_PARAMS_G3_PIC_QP)
7372 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC_L0)
7376 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L0)
7380 OPT(NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L1)
7397 OPT(NI_ENC_GOP_PARAMS_G4_PIC_QP)
7401 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC_L0)
7405 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L0)
7409 OPT(NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L1)
7426 OPT(NI_ENC_GOP_PARAMS_G5_PIC_QP)
7430 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC_L0)
7434 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L0)
7438 OPT(NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L1)
7455 OPT(NI_ENC_GOP_PARAMS_G6_PIC_QP)
7459 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC_L0)
7463 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L0)
7467 OPT(NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L1)
7484 OPT(NI_ENC_GOP_PARAMS_G7_PIC_QP)
7488 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC_L0)
7492 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L0)
7496 OPT(NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L1)
7997 b_error |= bValueWasNull && !bNameWasBool;
8047 if ((!p_ctx) || (!p_data))
8064 "ERROR: %s() keep alive thread has been closed, "
8065 "hw:%d, session:%d\n",
8082 switch (device_type)
8086 int seq_change_read_count = 0;
8097 uint32_t aligned_width;
8109 ", DFVWxDFVH %u x %u, AlWid %u, AVW x AVH %u x %u\n",
8114 if (0 == retval && seq_change_read_count)
8123 else if (retval < 0)
8139 "%s (decoder): resolution change, frame size %ux%u -> %ux%u, "
8140 "width %u bit %d, pix_fromat_changed %d, actual_video_width %d, continue read ...\n",
8149 seq_change_read_count++;
8181 __func__, device_type);
8213 if ((!hwdesc) || (!p_data))
8241 bool use_external_mutex =
false;
8242 uint32_t orig_session_id = p_ctx->
session_id;
8243 ni_device_handle_t orig_blk_io_handle = p_ctx->
blk_io_handle;
8248 ni_pthread_mutex_t *p_ctx_mutex = &(p_ctx->
mutex);
8254 use_external_mutex =
true;
8267 if (use_external_mutex)
8312 "%s function not supported in FW API version < 6rt\n",
8317 switch (device_type)
8366 if ((!hwdesc) || (!p_src_data))
8400 int video_height,
int extra_len)
8402 void* p_buffer = NULL;
8403 int height_aligned = video_height;
8439 memset(p_buffer, 0, buffer_size);
8451 p_frame->
p_data[0] = NULL;
8452 p_frame->
p_data[1] = NULL;
8453 p_frame->
p_data[2] = NULL;
8488 int32_t device_handle)
8496 "%s(): ui16FrameIdx=%d sessionId=%d device_handle=0x%x\n",
8520 int32_t saved_dma_buf_fd;
8530 "%s(): ui16FrameIdx=%d sessionId=%d device_handle=0x%x\n",
8565 uint32_t pool_size, uint32_t pool)
8627 "ERROR: %s function not supported in FW API version < 6r3\n",
8634 "ERROR: can't free or expand framepool of session 0x%x "
8635 "before init framepool\n", p_ctx->
session_id);
8676 if (!p_ctx || !p_params)
8704 void *p_scaler_config = NULL;
8707 uint32_t ui32LBA = 0;
8711 if (!p_ctx || !p_params)
8713 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() passed parameters are null!, return\n", __func__);
8735 memset(p_scaler_config, 0, buffer_size);
8741 memcpy(p_scaler_config, p_params, buffer_size);
8744 p_scaler_config, buffer_size, ui32LBA) < 0)
8747 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
8748 ", hw_id, %d, xcoder_inst_id: %d\n",
8755 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
8756 "hw_id, %d, xcoder_inst_id: %d\n",
8784 void *p_scaler_config = NULL;
8787 uint32_t ui32LBA = 0;
8791 if (!p_ctx || !p_params)
8793 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() passed parameters are null!, return\n", __func__);
8815 memset(p_scaler_config, 0, buffer_size);
8821 memcpy(p_scaler_config, p_params, buffer_size);
8824 p_scaler_config, buffer_size, ui32LBA) < 0)
8827 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
8828 ", hw_id, %d, xcoder_inst_id: %d\n",
8835 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
8836 "hw_id, %d, xcoder_inst_id: %d\n",
8885 int rectangle_width,
8886 int rectangle_height,
8904 switch (device_type)
8908 rectangle_width, rectangle_height,
8909 rectangle_x, rectangle_y,
8910 rgba_color, frame_index);
8962 switch (device_type)
9014 "Error: %s function not supported on device with FW API version < 6rL\n",
9054 if (!p_ctx || !p_cfg)
9102 if (!p_ctx || !p_cfg_in)
9146 const int linesize[])
9151 int luma, chroma_b, chroma_r;
9158 switch (pixel_format)
9197 switch (pixel_format)
9201 luma = linesize[0] * alignedh;
9202 chroma_b = linesize[1] * alignedh / 2;
9203 chroma_r = linesize[2] * alignedh / 2;
9210 luma = linesize[0] * alignedh;
9211 chroma_b = linesize[1] * alignedh / 2;
9253 int video_width,
int video_height,
9254 int linesize[],
int alignment,
9258 void *p_buffer = NULL;
9262 int chroma_b_size = 0;
9263 int chroma_r_size = 0;
9271 switch (pixel_format)
9342 switch (pixel_format)
9346 luma_size = linesize[0] * height_aligned;
9350 chroma_b_size = linesize[1] * height_aligned / 2;
9351 chroma_r_size = linesize[2] * height_aligned / 2;
9355 chroma_b_size = luma_size / 4;
9356 chroma_r_size = luma_size / 4;
9365 luma_size = linesize[0] * video_height;
9374 luma_size = linesize[0] * height_aligned;
9375 chroma_b_size = linesize[1] * height_aligned / 2;
9382 luma_size = linesize[0] * video_height;
9383 chroma_b_size = linesize[1] * video_height;
9391 luma_size = linesize[0] * video_height;
9410 buffer_size = luma_size + chroma_b_size + chroma_r_size + extra_len;
9432 memset(p_buffer, 0, buffer_size);
9442 switch (pixel_format)
9448 p_frame->
p_data[2] = p_frame->
p_data[1] + chroma_b_size;
9449 p_frame->
p_data[3] = NULL;
9452 p_frame->
data_len[1] = chroma_b_size;
9453 p_frame->
data_len[2] = chroma_r_size;
9464 p_frame->
p_data[1] = NULL;
9465 p_frame->
p_data[2] = NULL;
9466 p_frame->
p_data[3] = NULL;
9480 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9481 p_frame->
p_data[2] = NULL;
9482 p_frame->
p_data[3] = NULL;
9485 p_frame->
data_len[1] = chroma_b_size;
9496 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9497 p_frame->
p_data[2] = NULL;
9498 p_frame->
p_data[3] = NULL;
9501 p_frame->
data_len[1] = chroma_b_size;
9514 p_frame->
p_data[1] = NULL;
9515 p_frame->
p_data[2] = NULL;
9516 p_frame->
p_data[3] = NULL;
9529 p_frame->
p_data[1] = (uint8_t *)p_frame->
p_data[0] + luma_size;
9530 p_frame->
p_data[2] = (uint8_t *)p_frame->
p_data[1] + chroma_b_size;
9531 p_frame->
p_data[3] = NULL;
9534 p_frame->
data_len[1] = chroma_b_size;
9535 p_frame->
data_len[2] = chroma_r_size;
9550 __func__, video_width, video_height, buffer_size);
9567 struct stat file_stat;
9569 unsigned char *buffer = NULL;
9581 if (stat(file, &file_stat) != 0)
9589 if (file_stat.st_size == 0)
9596 fp = fopen(file,
"rb");
9605 buffer = malloc(file_stat.st_size);
9613 if (fread(buffer, file_stat.st_size, 1, fp) != 1)
9665 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: hvsplus filter not supported on device with FW API version < 6ro\n");
9701 uint32_t buffer_size = 0;
9702 void *p_buffer = NULL;
9704 uint32_t i, this_size;
9707 if (!p_frame || !p_network)
9713 p_linfo = &p_network->
linfo;
9714 for (i = 0; i < p_network->
input_num; i++)
9722 "ERROR: %s(): invalid buffer_size of network\n", __func__);
9725 buffer_size += this_size;
9729 p_frame->
data_len[0] = buffer_size;
9762 p_frame->
p_data[1] = NULL;
9763 p_frame->
p_data[2] = NULL;
9764 p_frame->
p_data[3] = NULL;
9782 void *p_buffer = NULL;
9784 uint32_t buffer_size = 0;
9785 uint32_t i, data_size;
9788 if (!p_packet || !p_network)
9795 p_linfo = &p_network->
linfo;
9804 "ERROR: %s(): invalid buffer_size of network\n", __func__);
9807 buffer_size += data_size;
9809 data_size = buffer_size;
9827 "%s(): free current p_packet, p_packet->buffer_size=%u\n",
9832 __func__, buffer_size);
9871 if (!p_ctx || bitrate < NI_MIN_BITRATE || bitrate >
NI_MAX_BITRATE)
9883 "Warning: %s(): bitrate %d overwriting current one %d\n",
9910 int32_t intra_period)
9912 if (!p_ctx || intra_period < 0 || intra_period > 1024)
9915 __func__, intra_period);
9924 "Warning: %s(): intraPeriod %d overwriting current one %d\n",
10055 int32_t ltr_interval)
10112 if (!p_ctx || framerate_num <= 0 || framerate_denom <= 0)
10115 "ERROR: %s(): invalid framerate passed in (%d/%d)\n", __func__,
10116 framerate_num, framerate_denom);
10120 if ((framerate_num % framerate_denom) != 0)
10122 uint32_t numUnitsInTick = 1000;
10123 framerate_num = framerate_num / framerate_denom;
10124 framerate_denom = numUnitsInTick + 1;
10125 framerate_num += 1;
10126 framerate_num *= numUnitsInTick;
10129 framerate_num = framerate_num / framerate_denom;
10130 framerate_denom = 1;
10133 if (((framerate_num + framerate_denom - 1) / framerate_denom) >
10137 "ERROR: %s(): invalid framerate passed in (%d/%d)\n", __func__,
10148 "Warning: %s(): framerate (%d/%d) overwriting current "
10150 __func__, framerate_num, framerate_denom,
10179 int32_t bitrate, framerate_num, framerate_denom;
10180 uint32_t maxFrameSize = (uint32_t)max_frame_size / 2000;
10181 uint32_t min_maxFrameSize;
10185 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10194 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size is valid only when lowDelay mode is enabled\n",
10195 __func__, max_frame_size);
10208 framerate_num = (int32_t) api_param->
fps_number;
10212 min_maxFrameSize = (((uint32_t)bitrate / framerate_num * framerate_denom) / 8) / 2000;
10214 if (maxFrameSize < min_maxFrameSize)
10217 __func__, max_frame_size);
10230 "Warning: %s(): max_frame_size %d overwriting current one %d\n",
10254 int32_t minQpI, maxQpI, maxDeltaQp, minQpPB, maxQpPB;
10256 if (!p_ctx || !p_min_max_qp)
10258 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_min_max_qp pointer\n",
10263 minQpI = p_min_max_qp->
minQpI;
10264 maxQpI = p_min_max_qp->
maxQpI;
10266 minQpPB = p_min_max_qp->
minQpPB;
10267 maxQpPB = p_min_max_qp->
maxQpPB;
10269 if (minQpI > maxQpI || minQpPB > maxQpPB ||
10270 maxQpI > 51 || minQpI < 0 || maxQpPB > 51 || minQpPB < 0)
10273 __func__, minQpI, maxQpI, maxDeltaQp, minQpPB, maxQpPB);
10308 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10317 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %d is valid only in CRF mode\n",
10322 if (crf < 0 || crf > 51)
10324 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %d is invalid (valid range in [0..51])\n",
10336 "Warning: %s(): crf reconfig value %d overwriting current reconfig_crf %d\n",
10365 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10374 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %f is valid only in CRF mode\n",
10379 if (crf < 0.0 || crf > 51.0)
10381 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %f is invalid (valid range in [0..51])\n",
10393 "Warning: %s(): crf reconfig value %d overwriting current "
10394 "reconfig_crf %d, reconfig_crf_decimal %d\n", __func__,
10419 int32_t vbvMaxRate, int32_t vbvBufferSize)
10424 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10428 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
10431 __func__, vbvBufferSize);
10435 if (api_param->
bitrate > 0 && vbvMaxRate > 0 && vbvMaxRate < api_param->bitrate) {
10437 vbvMaxRate, api_param->
bitrate);
10440 if (vbvBufferSize == 0 && vbvMaxRate > 0) {
10442 "vbvBufferSize is 0, force vbvMaxRate to 0\n",
10471 int32_t bitrate, framerate_num, framerate_denom;
10472 uint32_t min_maxFrameSize, maxFrameSize;
10476 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10485 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size_ratio is valid only when lowDelay mode is enabled\n",
10486 __func__, max_frame_size_ratio);
10490 if (max_frame_size_ratio < 1) {
10492 max_frame_size_ratio);
10505 framerate_num = (int32_t) api_param->
fps_number;
10509 min_maxFrameSize = (((uint32_t)bitrate / framerate_num * framerate_denom) / 8) / 2000;
10520 "Warning: %s(): max_frame_size %d overwriting current one %d\n",
10548 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid ni_session_context_t or p_session_config pointer\n",
10557 ni_log2(p_ctx,
NI_LOG_ERROR,
"%s():not support to reconfig slice_arg when slice_mode disable.\n",
10568 int max_num_ctu_mb_row = (api_param->
source_height + ctu_mb_size - 1) / ctu_mb_size;
10569 if (sliceArg < 1 || sliceArg > max_num_ctu_mb_row)
10607 int ret, is_semi_planar;
10613 if (p_ctx == NULL || p_frame == NULL || p_frame->
p_data[3] == NULL)
10660 uexp.
fn = p_ctx->
fn;
10671 *p_surface = hwdesc;
10701 int is_semi_planar;
10707 if (p_ctx == NULL || p_frame == NULL || p_frame->
p_data[3] == NULL)
10739 *p_surface = hwdesc;
10768 struct pollfd pfds[1] = {0};
10771 if (p_upl_ctx == NULL || p_frame == NULL)
10777 if (p_frame->
p_data[3] == NULL)
10786 pfds[0].events = POLLIN;
10787 pfds[0].revents = 0;
10789 ret = poll(pfds, 1, -1);
10802 "%s: failed to attach dmabuf read fence errno %s\n", __func__,
10828 if ((p_upl_ctx == NULL) || (p_frame == NULL))
10831 p_upl_ctx, p_frame);
10837 if (p_surface == NULL)
10870 uint8_t *p_data, uint32_t len,
10877 if (p_upl_ctx == NULL || p_data == NULL || p_hwframe == NULL)
10883 if (p_hwframe->
p_data[3] == NULL)
10900 "%s: Failed to request dmabuf rendering errno %d\n", __func__,
10925 uint8_t *p_data, uint32_t
len,
10929 char bar4_name[128];
10944 snprintf(bar4_name, 128,
10945 "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/resource4",
10948 bar4_fd = open(bar4_name, O_RDWR | O_SYNC);
10953 bar4_name, strerror(errno));
10957 if (fstat(bar4_fd, &stat) != 0)
10965 bar4_mm = mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, bar4_fd, 0);
10967 if (bar4_mm == MAP_FAILED)
10976 memcpy(bar4_mm + offset, p_data, len);
10978 munmap(bar4_mm, 0);
11000 if (p_frame == NULL)
11007 if (p_surface == NULL)
11033 unsigned int offset;
11052 uexp.
fn = p_ctx->
fn;
11085 int width,
int height,
11086 int bit_depth,
int src_endian,
11092 if (p_enc_ctx == NULL || p_enc_params == NULL)
11098 if (!(bit_depth == 8) && !(bit_depth == 10))
11130 alignedw = ((width + 1) / 2) * 2;
11132 (alignedw - width) / 2 * 2;
11145 alignedh = ((height + 1) / 2) * 2;
11147 (alignedh - height) / 2 * 2;
11172 int width,
int height,
11175 if (p_upl_ctx == NULL)
11181 switch (pixel_format)
11212 p_upl_ctx->
isP2P = isP2P;
11237 int bytes_read = 0;
11253 bytes_read += (rx_size - (int)p_ctx->
meta_size);
11258 }
else if (rx_size != 0)
11287 if (p_frame == NULL)
11295 if (p_surface == NULL)
11323 int width,
int height,
int bit_depth_factor,
ni_device_type_t device_type)
11333 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: %s function not supported on device with FW API version < 5.4\n", __func__);
11344 resolution.
width = width;
11345 resolution.
height = height;
11356 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: resolution change config - width %d height %d bit_depth_factor %d "
11357 "luma_linesize %d chroma_linesize %d\n", __func__,
11361 switch (device_type)
11372 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Config sequence change not supported for device type: %d", device_type);
11390 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11393 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_info))
11404 "ERROR: %s function not supported on device with FW API version < 6.h\n",
11418 memset(buffer, 0, size);
11470 "ERROR: %s function not supported on device with FW API version < 6.O\n",
11484 memset(buffer, 0, size);
11513 void *p_buffer = NULL;
11515 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11517 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_ns_vf))
11528 "ERROR: %s function not supported on device with FW API version < 6.m\n",
11541 memset(p_buffer, 0, size);
11555 p_dev_ns_vf->
vf_id = p_dev_ns_vf_data->
vf_id;
11556 p_dev_ns_vf->
ns_id = p_dev_ns_vf_data->
ns_id;
11566 void *p_buffer = NULL;
11568 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11570 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_temp))
11581 "ERROR: %s function not supported on device with FW API version < 6rC\n",
11594 memset(p_buffer, 0, size);
11611 ni_log(
NI_LOG_DEBUG,
"%s(): current composite temperature %d on board temperature %d on die temperature %d\n",
11621 void *p_buffer = NULL;
11623 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
11625 if ((NI_INVALID_DEVICE_HANDLE == device_handle) || (!p_dev_extra_info))
11636 "ERROR: %s function not supported on device with FW API version < 6rC\n",
11649 memset(p_buffer, 0, size);
11687 ni_log(
NI_LOG_DEBUG,
"%s(): current composite temperature %d on board temperature %d "
11688 "on die temperature %d power consumption %d current consumption %d\n",
11716 bool is_ext_buf =
true;
11717 if (*p_log_buffer == NULL)
11725 is_ext_buf =
false;
11728 if(*p_log_buffer != NULL){
11755 int sumQp = 0, ctu, i, j;
11759 int importanceLevelCentre = p_param->
roi_demo_mode == 1 ? 40 : 10;
11760 int importanceLevelRest = p_param->
roi_demo_mode == 1 ? 10 : 40;
11765 uint32_t block_size, max_cu_size, customMapSize;
11769 uint32_t roiMapBlockUnitSize;
11770 uint32_t entryPerMb;
11771 uint32_t entryWidth;
11779 linesize_aligned = (linesize_aligned / 8) * 8;
11780 height_aligned = (height_aligned / 8) * 8;
11786 ((linesize_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) *
11787 ((height_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
11791 customMapSize = ((block_size + 63) & (~63));
11807 ((linesize_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
11808 roiMapBlockUnitSize;
11810 ((height_aligned + max_cu_size - 1) & (~(max_cu_size - 1))) /
11811 roiMapBlockUnitSize;
11812 numMbs = mbWidth * mbHeight;
11816 entryPerMb = (roiMapBlockUnitSize / 8) * (roiMapBlockUnitSize / 8);
11817 entryWidth = roiMapBlockUnitSize / 8;
11818 for (i = 0; i < numMbs; i++)
11820 for (j = 0; j < entryPerMb; j++)
11822 entryPos = (i % mbWidth) * entryWidth + j % entryWidth;
11823 bIsCenter = (entryPos >= mbWidth * entryWidth / 3) && (entryPos < mbWidth * entryWidth * 2 / 3);
11832 p_enc_ctx->
roi_map[i * entryPerMb + j]
11835 bIsCenter ? importanceLevelCentre : importanceLevelRest;
11839 p_enc_ctx->
roi_len = customMapSize;
11842 (sumQp + ((numMbs * entryPerMb) >> 1)) / (numMbs * entryPerMb);
11852 uint32_t mbWidth = (linesize_aligned + 16 - 1) >> 4;
11854 uint32_t mbHeight = (height_aligned + 16 - 1) >> 4;
11855 uint32_t numMbs = mbWidth * mbHeight;
11856 uint32_t customMapSize =
11866 for (i = 0; i < numMbs; i++)
11868 if ((i % mbWidth > mbWidth / 3) && (i % mbWidth < mbWidth * 2 / 3))
11878 p_enc_ctx->
roi_len = customMapSize;
11880 (sumQp + (numMbs >> 1)) / numMbs;
11888 uint32_t ctuWidth = (linesize_aligned + 64 - 1) >> 6;
11890 uint32_t ctuHeight = (height_aligned + 64 - 1) >> 6;
11892 uint32_t subCtuWidth = ctuWidth * 2;
11894 uint32_t subCtuHeight = ctuHeight * 2;
11895 uint32_t numSubCtus = subCtuWidth * subCtuHeight;
11902 for (i = 0; i < numSubCtus; i++)
11904 if ((i % subCtuWidth > subCtuWidth / 3) &&
11905 (i % subCtuWidth < subCtuWidth * 2 / 3))
11921 for (i = 0; i < ctuHeight; i++)
11924 for (j = 0; j < ctuWidth; j++, ptr += 2)
11926 ctu = (int)(i * ctuWidth + j);
11930 *(ptr + subCtuWidth);
11932 *(ptr + subCtuWidth + 1);
11942 (sumQp + (numSubCtus >> 1)) / numSubCtus;
11972 *((int32_t *)aux_data->data) =
11994 int32_t intraprd = *((int32_t *)aux_data->data) =
11997 "xcoder_send_frame: frame #%lu reconf "
11998 "intraPeriod %d\n",
12032 "xcoder_send_frame: frame #%lu reconf "
12033 "vui colorDescPresent %d colorPrimaries %d "
12034 "colorTrc %d colorSpace %d aspectRatioWidth %d "
12035 "aspectRatioHeight %d videoFullRange %d\n",
12066 "xcoder_send_frame: frame #%lu metadata "
12067 "use_cur_src_as_long_term_pic %d use_long_term_ref "
12107 *((int32_t *)aux_data->data) =
12110 "xcoder_send_frame: frame #%lu reconf "
12111 "ltrInterval %d\n",
12128 *((int32_t *)aux_data->data) =
12131 "xcoder_send_frame: frame #%lu reconf "
12132 "invalidFrameNum %d\n",
12158 "xcoder_send_frame: frame #%lu reconf "
12159 "framerate (%d/%d)\n",
12173 *((int32_t *)aux_data->data) =
12176 "xcoder_send_frame: frame #%lu reconf "
12177 "maxFrameSize %d\n",
12192 *((int32_t *)aux_data->data) =
12195 "xcoder_send_frame: frame #%lu reconf "
12213 *((
float *)aux_data->data) = crf;
12215 "xcoder_send_frame: frame #%lu reconf "
12227 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
12230 __func__, vbvBufferSize);
12233 if (p_param->
bitrate > 0 && vbvMaxRate > 0 && vbvMaxRate < p_param->bitrate) {
12235 vbvMaxRate, p_param->
bitrate);
12238 if (vbvBufferSize == 0 && vbvMaxRate > 0) {
12240 "vbvBufferSize is 0, force vbvMaxRate to 0\n",
12250 *((int32_t *)aux_data->data) = vbvMaxRate;
12256 *((int32_t *)aux_data->data) = vbvBufferSize;
12258 "xcoder_send_frame: frame #%lu reconfig vbvMaxRate %d vbvBufferSize "
12259 "%d by frame aux data\n",
12260 p_enc_ctx->
frame_num, vbvMaxRate, vbvBufferSize);
12269 if (maxFrameSizeRatio < 1) {
12271 maxFrameSizeRatio);
12280 int32_t bitrate, framerate_num, framerate_denom;
12281 uint32_t min_maxFrameSize, maxFrameSize;
12291 framerate_num = (int32_t) p_param->
fps_number;
12295 min_maxFrameSize = ((uint32_t)bitrate / framerate_num * framerate_denom) / 8;
12298 *((int32_t *)aux_data->data) = maxFrameSize;
12300 "xcoder_send_frame: frame #%lu reconf "
12301 "maxFrameSizeRatio %d maxFrameSize %d\n",
12302 p_enc_ctx->
frame_num, maxFrameSizeRatio, maxFrameSize);
12315 *((int16_t *)aux_data->data) =
12318 "xcoder_send_frame: frame #%lu reconf "
12332 "xcoder_send_frame: frame #%lu force IDR frame\n",
12347 "xcoder_send_frame: frame #%lu API reconfig BR %d\n",
12363 "xcoder_send_frame: frame #%lu API reconfig intraPeriod %d\n",
12392 "xcoder_send_frame: frame #%lu reconf "
12393 "vui colorDescPresent %d colorPrimaries %d "
12394 "colorTrc %d colorSpace %d aspectRatioWidth %d "
12395 "aspectRatioHeight %d videoFullRange %d\n",
12412 if ((retval =
ni_set_ltr(p_enc_ctx, <r))) {
12416 "xcoder_send_frame(): frame #%lu API set LTR\n",
12435 "%s(): frame %d minQpI %d maxQpI %d maxDeltaQp %d minQpPB %d maxQpPB %d\n",
12450 "xcoder_send_frame(): frame #%lu API set LTR interval %d\n",
12465 "xcoder_send_frame(): frame #%lu API set frame ref invalid "
12484 "xcoder_send_frame: frame #%lu API reconfig framerate "
12501 "xcoder_send_frame: frame #%lu API reconfig maxFrameSize %d\n",
12516 "xcoder_send_frame: frame #%lu API reconfig crf %d\n",
12532 "xcoder_send_frame: frame #%lu API reconfig crf %f\n",
12547 "xcoder_send_frame: frame #%lu API reconfig vbvMaxRate %d vbvBufferSize %d\n",
12564 "xcoder_send_frame: frame #%lu reconf maxFrameSizeRatio %d\n",
12578 "xcoder_send_frame: frame #%lu API reconfig sliceArg %d\n",
12596 static int ni_tolower(
int c)
12598 if (c >=
'A' && c <=
'Z')
12608 c1 = ni_tolower(*a++);
12609 c2 = ni_tolower(*b++);
12610 }
while (c1 && c1 == c2);
12762 "g%drefPic%d specified without g%drefPic%dUsed specified!\n",
12793 uint64_t ui64DestAddr,
12794 uint32_t ui32FrameSize)
12799 (void) ui64DestAddr;
12800 (void) ui32FrameSize;
12824 uint64_t ui64DestAddr, uint32_t ui32FrameSize)
12828 if ((pSession == NULL) || (source == NULL))
12844 ni_log2(pSession,
NI_LOG_ERROR,
"%s(): Can't DMA to destination (%d)\n", __func__, retval);
12872 if ((pSession == NULL) || (dmaAddrs == NULL) || (pDstFrame == NULL))
12881 "%s: FW doesn't support this operation\n", __func__);
12890 "%s(): Can't DMA from source (%d)\n", __func__, retval);
12929 switch (device_type)
12937 ni_log2(p_ctx,
NI_LOG_ERROR,
"Error: %s function not supported on device with FW API version < 5.4\n", __func__);
12949 if (video_width < NI_MIN_WIDTH || video_width >
NI_MAX_WIDTH ||
12950 video_height < NI_MIN_HEIGHT || video_height >
NI_MAX_HEIGHT)
12953 __func__, video_width, video_height);
12956 resolution.
width = video_width;
12957 resolution.
height = video_height;
12973 ni_log(
NI_LOG_ERROR,
"Failed to reconfig config the encoder session (status = %d)\n", retval);
12989 __func__, device_type);
@ 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.
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
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
#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_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
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_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_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_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
#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
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
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
#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
#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 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)
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_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_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...
#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
@ NI_DMABUF_WRITE_TO_DEVICE
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
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
#define NI_PARAM_JPEG_MIN_WIDTH
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
#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_DEPRECATED int generate_enc_hdrs
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
#define NI_PARAM_JPEG_MIN_HEIGHT
@ 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_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...
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_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
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.
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
#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_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.
#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
#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 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