31#elif __linux__ || __APPLE__
33#include <linux/types.h>
52#include <sys/syscall.h>
53#include <sys/resource.h>
54#if !defined(_ANDROID) && !defined(__OPENHARMONY__)
77#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
86static const int g_map_preset_to_gopsize[2][18] = {{8, 0, 1, -1, 1, 2, 4, -1, 4, 8, 1, 4, -1, -1, -1, -1, 16},
87 {8, 0, -1, -1, -1, 2, 4, -1, -1, 8, 1, -1, -1, -1, -1, -1, -1}};
88#define MIN(x,y) (((x)>(y))?(y):(x))
89#define MAX(x,y) (((x)<(y))?(y):(x))
90#define HEVC_LEVEL_NUM 13
91#define H264_LEVEL_NUM 20
92#define AV1_LEVEL_NUM 14
94static const uint64_t max_sample_rate_second_h265[
HEVC_LEVEL_NUM ] =
96 552960, 3686400, 7372800, 16588800, 33177600, 66846720, 133693440, 267386880,
97 534773760, 1069547520, 1069547520, 2139095040, 4278190080
99static const uint64_t max_sample_rate_second_h264[
H264_LEVEL_NUM ] =
101 1485*256, 1485*256, 3000*256, 6000*256, 11880*256, 11880*256, 19800*256, 20250*256,
102 40500*256, 108000*256, 216000*256, 245760*256, 245760*256,
103 522240*256, 589824*256, 983040*256, 2073600*256,
104 4177920*256, 8355840*256, 16711680ULL*256
106static const uint64_t max_sample_rate_second_av1[
AV1_LEVEL_NUM ] =
108 5529600, 10454400, 24969600, 39938400, 77856768, 155713536,
109 273715200, 547430400, 1094860800, 1176502272, 1176502272, 2189721600, 4379443200, 4706009088
114 36864, 122880, 245760, 552960, 983040, 2228224, 2228224, 8912896,
115 8912896, 8912896, 35651584, 35651584, 35651584
119 99*256, 99*256, 396*256, 396*256, 396*256, 396*256, 792*256, 1620*256,
120 1620*256, 3600*256, 5120*256, 8192*256, 8192*256,
121 8704*256, 22080*256, 36864*256, 36864*256,
122 139264*256, 139264*256, 139264*256
126 147456, 278784, 665856, 1065024, 2359296, 2359296,
127 8912896, 8912896, 8912896, 8912896, 35651584, 35651584, 35651584, 35651584
132 350000, 1500000, 3000000, 6000000, 10000000, 12000000, 20000000,
133 25000000, 40000000, 60000000, 60000000, 120000000, 240000000
135static const uint32_t max_cpb_hightier_second_h265[
HEVC_LEVEL_NUM ] =
137 350000, 1500000, 3000000, 6000000, 10000000, 30000000, 50000000,
138 100000000, 160000000, 240000000, 240000000, 480000000, 800000000
142 175000, 350000, 500000, 1000000, 2000000, 2000000, 4000000, 4000000,
143 10000000, 14000000, 20000000, 25000000, 62500000,
144 62500000, 135000000, 240000000, 240000000,
145 240000000, 480000000, 800000000
149 1500000, 3000000, 6000000, 10000000, 12000000, 20000000,
150 30000000, 40000000, 60000000, 60000000, 60000000, 100000000, 160000000, 160000000
152static const uint32_t max_cpb_hightier_second_av1[
AV1_LEVEL_NUM ] =
154 0, 0, 0, 0, 30000000, 50000000,
155 100000000, 160000000, 240000000, 240000000, 240000000, 480000000, 800000000, 800000000
159 64000, 128000, 192000, 384000, 768000, 2000000, 4000000, 4000000,
160 10000000, 14000000, 20000000, 20000000, 50000000,
161 50000000, 135000000, 240000000, 240000000,
162 240000000, 480000000, 800000000
165#define MAGIC_P2P_VALUE "p2p"
166#define AI_MODEL_TYPE_HVSPLUS_FILTER 3
167#define AI_MODEL_TYPE_USM_FILTER 4
204 0x00, 0x00, 0x00, 0x01,
222 0x00, 0x00, 0x00, 0x01,
238 0x00, 0x00, 0x00, 0x01,
254 0x00, 0x00, 0x00, 0x01,
272#define NI_XCODER_FAILURES_MAX 25
273#define DP_IPC_PASSTHRU 0xFFFFFFFF
276#ifdef XCODER_SELF_KILL_ERR
277#undef XCODER_SELF_KILL_ERR
288 for (i = 0; i < bytes; i += 2)
290 uint8_t val = buf[i];
298 uint32_t i, words = (bytes + 1) / 2;
300 for (i = 0; i < words; i += 2)
302 uint16_t val = buf[i];
310 uint32_t i, words = (bytes + 3) / 4;
311 for (i = 0; i < words; i += 2)
313 uint32_t val = buf[i];
321 uint64_t i, words = (bytes + 7) / 8;
322 for (i = 0; i < words; i += 2)
324 uint64_t val = buf[i];
330static void memcpyToPelByBits (uint8_t *dst_u8, uint8_t *src,
int width,
int height,
int dst_stride,
int src_stride,
int srcValidBitsDepth)
333 uint8_t bitsDepth = srcValidBitsDepth;
334 uint32_t mask = (1<<bitsDepth)-1;
335 uint16_t *dst = (uint16_t *)dst_u8;
340 for (j = 0; j < height; j ++)
342 for (i = 0; i< width; i ++)
343 dst_u8[i] = src[i] & 0xff;
346 dst_u8 += dst_stride;
352 for (j = 0; j < height; j ++)
354 uint8_t *src_line = src;
355 uint32_t cache = 0, cache_bits = 0;
356 for (i = 0; i< width; i ++)
358 while(cache_bits < bitsDepth)
360 cache |= ((*src_line++) << cache_bits);
364 if (cache_bits >= bitsDepth)
366 dst[i] = cache & mask;
368 cache_bits -= bitsDepth;
393static void trace_recon_tile2raster_y(FILE *fRecon, uint8_t *mem,
int width,
int height,
394 int leftOffset,
int topOffset,
395 int src_stride,
int pixDepth, uint8_t *luma_mem_temp)
398 int write_data_len = 0;
399 int bytesPerPix = (pixDepth == 8 ? 1 : 2);
400 uint8_t *tmp_mem = (uint8_t *)malloc(bytesPerPix*src_stride);
401 int num_tiles = (leftOffset + width + 3) / 4 - leftOffset/4;
404 mem += topOffset/4*4*src_stride + leftOffset/4*16*pixDepth/8;
405 for(i = topOffset/4*4; i < topOffset + height; i += 4) {
406 memcpyToPelByBits(tmp_mem, mem, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
407 if(i >= topOffset && i < topOffset + height){
409 memcpy(luma_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
410 write_data_len += width * bytesPerPix;
412 memcpyToPelByBits(tmp_mem, mem+4*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
413 if(i+1 >= topOffset && i+1 < topOffset + height)
416 memcpy(luma_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
417 write_data_len += width * bytesPerPix;
419 memcpyToPelByBits(tmp_mem, mem+8*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
420 if(i+2 >= topOffset && i+2 < topOffset + height)
423 memcpy(luma_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
424 write_data_len += width * bytesPerPix;
426 memcpyToPelByBits(tmp_mem, mem+12*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
427 if(i+3 >= topOffset && i+3 < topOffset + height)
430 memcpy(luma_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
431 write_data_len += width * bytesPerPix;
438static void trace_recon_tile2raster_uv(FILE *fRecon, uint8_t *mem_uv,
int width,
int height,
439 int leftOffset,
int topOffset,
440 int src_stride,
int pixDepth, uint8_t *ch_mem_temp)
443 int bytesPerPix = (pixDepth == 8 ? 1 : 2);
444 uint8_t *tmp_mem = (uint8_t *)malloc(bytesPerPix*src_stride*2);
445 int num_tiles = 2*((leftOffset + width + 3) / 4 - leftOffset/4);
450 int write_data_len = 0;
451 memset(tmp_mem, 0x00, bytesPerPix * src_stride * 2);
452 for(uv = 0; uv <= 1; uv ++) {
453 mem = mem_uv + topOffset/4*8*src_stride + leftOffset/4*32*pixDepth/8;
454 for(i = topOffset/4*4; i < topOffset + height; i += 4) {
455 if(i >= topOffset && i < topOffset + height) {
456 memcpyToPelByBits(tmp_mem, mem, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
457 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
459 tmp_mem[k] = tmp_mem[j];
461 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
464 memcpy(ch_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
465 write_data_len += width * bytesPerPix;
467 if(i+1 >= topOffset && i+1 < topOffset + height) {
468 memcpyToPelByBits(tmp_mem, mem+4*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
469 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
471 tmp_mem[k] = tmp_mem[j];
473 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
476 memcpy(ch_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
477 write_data_len += width * bytesPerPix;
479 if(i+2 >= topOffset && i+2 < topOffset + height) {
480 memcpyToPelByBits(tmp_mem, mem+8*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
481 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
483 tmp_mem[k] = tmp_mem[j];
485 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
488 memcpy(ch_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
489 write_data_len += width * bytesPerPix;
491 memcpyToPelByBits(tmp_mem, mem+12*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
492 if(i+3 >= topOffset && i+3 < topOffset + height) {
493 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
495 tmp_mem[k] = tmp_mem[j];
497 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
500 memcpy(ch_mem_temp + write_data_len, tmp_mem + (leftOffset & 3) * bytesPerPix, width * bytesPerPix);
501 write_data_len += width * bytesPerPix;
509static double calc_noise(uint8_t *p1, uint8_t *p2,
int size)
516 for (i = 0; i < size; i++)
518 diff = p1[i] - p2[i];
563 FILE *fout_raster = NULL;
581 uint8_t *luma_mem_temp = NULL;
582 uint8_t *ch_mem_temp = NULL;
595 luma_mem_temp = (uint8_t *)malloc(luma_size);
596 memset(luma_mem_temp, 0x00, luma_size);
601 ch_mem_temp = (uint8_t *)malloc(ch_size);
602 memset(ch_mem_temp, 0x00, ch_size);
610 SwapSW16((uint16_t *)luma_mem, lum_sz);
611 SwapSW32((uint32_t *)luma_mem, lum_sz);
612 SwapSW64((uint64_t *)luma_mem, lum_sz);
613 trace_recon_tile2raster_y (fout_raster, luma_mem, width, height,
624 SwapSW16((uint16_t *)ch_mem, chr_sz);
625 SwapSW32((uint32_t *)ch_mem, chr_sz);
626 SwapSW64((uint64_t *)ch_mem, chr_sz);
627 trace_recon_tile2raster_uv(fout_raster, ch_mem, width / 2, height / 2,
646 double noise_y = 0.0, noise_u = 0.0, noise_v = 0.0, noise_yuv = 0.0;
647 double power_y = 0.0, power_u = 0.0, power_v = 0.0, power_yuv = 0.0;
648 double psnr_y = 0.0, psnr_u = 0.0, psnr_v = 0.0, psnr_yuv = 0.0;
658 power_y = 1.0 * max * max * width * height;
659 power_u = power_y / 4.0;
660 power_v = power_y / 4.0;
661 power_yuv = power_y * 3.0 / 2.0;
663 uint8_t *p_y_src_buf = NULL;
664 uint8_t *p_u_src_buf = NULL;
665 uint8_t *p_v_src_buf = NULL;
666 for (
int i = 0; i < 120; i++)
681 if (p_y_src_buf != NULL)
685 noise_y = calc_noise(p_y_src_buf, luma_mem_temp, width * height);
689 noise_y = power_y / pow(10, p_ctx->
psnr_y / 10);
694 noise_u = calc_noise(p_u_src_buf, ch_mem_temp, (width / 2) * (height / 2));
695 noise_v = calc_noise(p_v_src_buf, ch_mem_temp + (width / 2) * (height / 2), (width / 2) * (height / 2));
697 noise_yuv = noise_y + noise_u + noise_v;
701 noise_y = noise_y < 1 ? 1 : noise_y;
702 noise_u = noise_u < 1 ? 1 : noise_u;
703 noise_v = noise_v < 1 ? 1 : noise_v;
704 noise_yuv = noise_yuv < 1 ? 1 : noise_yuv;
708 psnr_y = 10 * log10(power_y / noise_y);
717 psnr_u = 10 * log10(power_u / noise_u);
718 psnr_v = 10 * log10(power_v / noise_v);
720 psnr_yuv = 10 * log10(power_yuv / noise_yuv);
748 luma_mem_temp = NULL;
774 ni_log2(p_ctx,
NI_LOG_DEBUG,
"pkt_num %d psnr_y %.4f psnr_u %.4f psnr_v %.4f psnr_yuv %.4f reconLumaWidth %d width %d height %d reconLumaSize 0x%x reconChromaSize 0x%x\n",
781#define READ_U32_FROM_BUF_2BYTES(buf, byte_offset) \
782 ((uint32_t)(buf)[(byte_offset)] | \
783 ((uint32_t)(buf)[(byte_offset)+1] << 8))
786#define READ_U32_FROM_BUF(buf, byte_offset) \
787 ((uint32_t)(buf)[(byte_offset)] | \
788 ((uint32_t)(buf)[(byte_offset)+1] << 8) | \
789 ((uint32_t)(buf)[(byte_offset)+2] << 16) | \
790 ((uint32_t)(buf)[(byte_offset)+3] << 24))
796 if (!p_ctx || !cuInfoBuf || !pEncCuInfo)
810 if (pEncCuInfo->
cuMode == 1)
819 pEncCuInfo->
cuSize = 8 * (1 << (cuSizeId + 3));
823 if (pEncCuInfo->
cuMode == 1)
843 if (!p_ctx || !p_packet)
851 if (p_meta->cuInfoSize != 0)
855 int total_cu_count = 0;
856 int analyzed_mbs = 0;
857 int num_intra_block_blocks = 0;
858 int num_intra_plane_blocks = 0;
860 uint64_t inter_pred_L0_qp_sum = 0;
861 uint64_t intra_plane_qp_sum = 0;
862 uint64_t intra_block_qp_sum = 0;
863 int inter_pred_L0_count = 0;
870 uint8_t *ctuOffset = (uint8_t *)p_packet->
p_data + p_packet->
data_len - p_meta->cuInfoSize;
871 uint8_t *cuData = ctuOffset + p_meta->cuInfoTableSize + p_meta->aqInfoSize;
872 uint32_t *ctuTable = (uint32_t *)ctuOffset;
878 int iCtuX, iCtuY, nCu, iCu;
884 ctu_per_row = (width + 16 - 1) / 16;
885 ctu_per_column = (height + 16 - 1) / 16;
890 ctu_per_row = (width + 64 - 1) / 64;
891 ctu_per_column = (height + 64 - 1) / 64;
895 for (iCtuY = 0; iCtuY < ctu_per_column; iCtuY++)
897 for (iCtuX = 0; iCtuX < ctu_per_row; iCtuX++)
908 nCu = ctuTable[iCtu];
910 nCu -= ctuTable[iCtu - 1];
916 for (iCu = 0; iCu < nCu; iCu++)
918 parse_cu_info(p_ctx, cuInfoBuf, &cuInfo);
922 max_qp = cuInfo.qp > max_qp ? cuInfo.qp : max_qp;
925 if (cuInfo.cuMode == 1)
927 if (cuInfo.intraPartMode == 0)
930 num_intra_plane_blocks += (cuInfo.cuSize / 4) * (cuInfo.cuSize / 4);
931 intra_plane_qp_sum += 16ULL * cuInfo.qp;
936 num_intra_block_blocks += (cuInfo.cuSize / 4) * (cuInfo.cuSize / 4);
937 intra_block_qp_sum += 16ULL * cuInfo.qp;
945 if (cuInfo.interPredIdc == 0)
947 inter_pred_L0_count += 16;
948 inter_pred_L0_qp_sum += 16ULL * cuInfo.qp;
950 else if (cuInfo.interPredIdc == 1)
962 int32_t gop_preset_index = api_param->cfg_enc_params.gop_preset_index;
964 if (gop_preset_index == 3 || gop_preset_index == 7)
966 inter_pred_L0_count += 16;
967 inter_pred_L0_qp_sum += 16ULL * cuInfo.qp;
985 bitstream_features->average_qp = (float)qp_sum / total_cu_count;
986 bitstream_features->initial_qp = p_meta->ppsInitQp;
987 bitstream_features->max_qp = max_qp;
988 bitstream_features->avg_forward_pred_block_qp = inter_pred_L0_count > 0 ? (float)inter_pred_L0_qp_sum / inter_pred_L0_count : max_qp;
989 bitstream_features->analyzed_mbs = analyzed_mbs;
990 bitstream_features->avg_intra_block_qp = num_intra_block_blocks > 0 ? (float)intra_block_qp_sum / num_intra_block_blocks : max_qp;
991 bitstream_features->avg_intra_plane_qp = num_intra_plane_blocks > 0 ? (float)intra_plane_qp_sum / num_intra_plane_blocks : max_qp;
992 bitstream_features->num_intra_block_blocks = num_intra_block_blocks;
993 bitstream_features->num_intra_plane_blocks = num_intra_plane_blocks;
994 bitstream_features->num_skip_blocks = p_meta->skipCu8Num * 4;
995 bitstream_features->num_forward_pred_blocks = inter_pred_L0_count - bitstream_features->num_skip_blocks;
1008 uint16_t ui16ErrorCount = 0;
1009 uint32_t ui32LastErrorStatus = 0;
1022 ni_device_get_and_print_firmware_logs(ctx);
1034 else if(opt ==
OPT_2){
1036 ni_log2(ctx,
NI_LOG_ERROR,
"ERROR %s(): passed parameters are null!, return\n", __func__);
1038 ni_device_get_and_print_firmware_logs(ctx);
1047 ui16ErrorCount > 0 && !retval &&
1053 else if(opt ==
OPT_3)
1062 "Persistent failures detected, %s() line-%d: session_no 0x%x "
1063 "sess_err_count %u inst_err_no %u\n",
1064 func, line, *(inst_id), ui16ErrorCount,
1065 ui32LastErrorStatus);
1067 ni_device_get_and_print_firmware_logs(ctx);
1069#ifdef XCODER_SELF_KILL_ERR
1072 kill(getpid(), SIGTERM);
1084#define CHECK_ERR_RC(ctx, rc, info, opcode, type, hw_id, inst_id, opt) \
1086 (rc) = check_err_rc(ctx, rc, info, opcode, type, hw_id, inst_id, opt, __func__, __LINE__); \
1087 if((rc) && ((opt) != OPT_3)) LRETURN; \
1090#define CHECK_VPU_RECOVERY(ret) \
1092 if (NI_RETCODE_NVME_SC_VPU_RECOVERY == (ret)) \
1094 ni_log(NI_LOG_ERROR, "Error, vpu reset.\n"); \
1095 (ret) = NI_RETCODE_ERROR_VPU_RECOVERY; \
1105 "decoder" :
"encoder";
1109 uint64_t abs_time_ns;
1116 ts.tv_sec = abs_time_ns / 1000000000LL;
1117 ts.tv_nsec = abs_time_ns % 1000000000LL;
1127 if (ret == ETIMEDOUT)
1139 "decoder" :
"encoder";
1169#elif __linux__ || __APPLE__
1171 char dir_name[128] = {0};
1172 char file_name[512] = {0};
1175 struct dirent *stream_folder;
1176 int curr_stream_idx = 0;
1177 int earliest_stream_idx = 0;
1178 int max_exist_idx = 0;
1179 time_t earliest_time = 0;
1180 struct stat file_stat;
1184 if (!p_device_context)
1191 flock(p_device_context->
lock, LOCK_EX);
1194 if (0 != access(dir_name, F_OK))
1196 if (0 != mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO))
1206 if (NULL == (dir = opendir(dir_name)))
1215 while ((stream_folder = readdir(dir)))
1217 if (!strncmp(stream_folder->d_name,
"stream", strlen(
"stream")))
1220 atoi(&(stream_folder->d_name[strlen(
"stream")]));
1221 if (curr_stream_idx > 0)
1223 if (curr_stream_idx > max_exist_idx)
1225 max_exist_idx = curr_stream_idx;
1240 curr_stream_idx = max_exist_idx + 1;
1244 while ((stream_folder = readdir(dir)))
1248 if (!strncmp(stream_folder->d_name,
"stream", strlen(
"stream")))
1250 snprintf(file_name,
sizeof(file_name),
"%s/%s/pkt-0001.bin",
1251 dir_name, stream_folder->d_name);
1254 atoi(&(stream_folder->d_name[strlen(
"stream")]));
1256 if (curr_stream_idx > 0 && 0 == access(file_name, F_OK))
1259 if (stat(file_name, &file_stat))
1266 if (0 == earliest_stream_idx ||
1267 file_stat.st_mtime < earliest_time)
1269 earliest_stream_idx = curr_stream_idx;
1270 earliest_time = file_stat.st_mtime;
1277 curr_stream_idx = earliest_stream_idx;
1281 snprintf(file_name,
sizeof(file_name),
"%s/stream%03d/pkt-0001.bin",
1282 dir_name, curr_stream_idx);
1283 if (utime(file_name, NULL))
1292 "%s/stream%03d", dir_name, curr_stream_idx);
1311 flock(p_device_context->
lock, LOCK_UN);
1314 snprintf(file_name,
sizeof(file_name),
"%s/process_session_id.txt",
1320 char number[64] = {
'\0'};
1322 snprintf(number,
sizeof(number),
"proc id: %ld\nsession id: %u\n",
1324 fwrite(number, strlen(number), 1, fp);
1333#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OPEN_HARMONY__) && !defined(_ANDROID)
1334#define MAX_BDF_LEN 16
1338static int find_pci_address(
const char *dev_name,
char *pci_addr) {
1339 char sys_block_path[256];
1341 snprintf(sys_block_path,
sizeof(sys_block_path),
"/sys/class/block/%s/device", dev_name);
1343 char *real_sysfs_path = realpath(sys_block_path, NULL);
1344 if (!real_sysfs_path) {
1345 perror(
"realpath failed");
1350 char *p = real_sysfs_path + strlen(real_sysfs_path);
1352 while (p > real_sysfs_path) {
1353 p = strrchr(real_sysfs_path,
'/');
1360 unsigned domain, bus, dev, func;
1361 if (sscanf(segment,
"%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) {
1364 free(real_sysfs_path);
1371 free(real_sysfs_path);
1378#if defined(_WIN32) || defined(__APPLE__) || defined(__OPEN_HARMONY__)
1386 char *dom, *bus, *dev, *fnc;
1398 p_ctx->
netint_fd = open(
"/dev/netint", O_RDWR);
1406 if (stat(p_dev, &bstat) < 0)
1412 if ((bstat.st_mode & S_IFMT) != S_IFBLK)
1419 ret = snprintf(syspath,
sizeof(syspath) - 1,
1420 "/sys/block/%s/device/address",
1422 syspath[ret] =
'\0';
1432 if (fgets(pci_addr,
sizeof(pci_addr), fp) == NULL)
1441 ret = find_pci_address(p_dev + 5, pci_addr);
1452 p_ctx->
domain = strtoul(pci_addr, &dom, 16);
1460 p_ctx->
bus = strtoul(dom + 1, &bus, 16);
1468 p_ctx->
dev = strtoul(bus + 1, &dev, 16);
1477 p_ctx->
fn = strtoul(dev + 1, &fnc, 16);
1493#if __linux__ || __APPLE__
1494#if !defined(_ANDROID) && !defined(__OPENHARMONY__)
1495#ifndef DISABLE_BACKTRACE_PRINT
1496void ni_print_backtrace() {
1497 void* callstack[128];
1498 int frames = backtrace(callstack, 128);
1499 char** strs = backtrace_symbols(callstack, frames);
1502 for (
int i = 0; i < frames; ++i) {
1523 void* p_buffer = NULL;
1524 uint32_t ui32LBA = 0;
1525 char fmt_fw_api_ver1[5], fmt_fw_api_ver2[5];
1545#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
1554 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): not support enableCpuAffinity parameter, "
1555 "enable with [./build.sh -c] on linux\n", __func__);
1593 "ERROR %d: %s() alloc decoder all zero buffer failed\n",
1634 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n", __func__,
1643 uint64_t keep_alive_timeout =
1646 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
1648 keep_alive_timeout);
1659 "ERROR %s(): nvme write keep_alive_timeout command "
1660 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
1676 __func__, fmt_fw_api_ver1, fmt_fw_api_ver2);
1687 "ERROR %s(): nvme write sw_version command "
1688 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
1711 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n", __func__,
1719 "%s(): p_ctx->device_handle=0x%" PRIx64
", p_ctx->hw_id=%d, "
1720 "p_ctx->session_id=%d\n",
1779 ni_log2(p_ctx,
NI_LOG_INFO,
"Warn %s(): forceLowDelay is not available for fw < 6r3\n",
1790 "%s(): p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, "
1791 "p_ctx->session_id=%d\n",
1797 decoder_dump_dir_open(p_ctx);
1800#ifdef XCODER_DUMP_DATA
1801 char dir_name[256] = {0};
1803 snprintf(dir_name,
sizeof(dir_name),
"%ld-%u-dec-fme", (
long)getpid(),
1805 DIR *dir = opendir(dir_name);
1808 mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
1834 uint32_t ui32LBA = 0;
1845 if (NI_INVALID_DEVICE_HANDLE == device_handle)
1858 "session_id=%d\n", __func__, (int64_t)device_handle, session_id);
1864 "SUCCESS %s(): device_handle=%" PRIx64
" , "
1865 "session_id=%d\n", __func__, (int64_t)device_handle, session_id);
1976 void* p_buffer = NULL;
1977 uint32_t ui32LBA = 0;
2009 "Decoder_complete_info:session_id 0x%x, total frames input:%u "
2010 "buffered: %u completed: %u output: %u dropped: %u error: %u corrupted: %u\n",
2021 "Decoder_complete_info:session_id 0x%x, total frames input:%u "
2022 "buffered: %u completed: %u output: %u dropped: %u error: %u\n",
2071 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
2072 "p_ctx->session_id=%d, close_mode=1\n",
2141 low_delay_signal(p_ctx);
2158 uint32_t sent_size = 0;
2159 uint32_t packet_size = 0;
2160 int current_pkt_size;
2165 int query_retry = 0;
2166 uint32_t ui32LBA = 0;
2170 if ((!p_ctx) || (!p_packet))
2187 low_delay_wait(p_ctx);
2189#ifdef MEASURE_LATENCY
2194 abs_time_ns, p_packet->
dts);
2200 current_pkt_size = packet_size;
2203 int max_retry = 200;
2285 "Warning: dec write query fail rc %d or available buf size %u < "
2286 "pkt size %u , retry: %d max_retry_fail_count %d\n",
2289 if (query_retry > max_retry ||
2298 if (query_retry > max_retry)
2317 "size %u >= pkt size %u !\n",
2360 "%s() had data to send: packet_size=%u, "
2361 "p_packet->sent_size=%d, p_packet->data_len=%u, "
2362 "p_packet->start_of_stream=%u, p_packet->end_of_stream=%u, "
2363 "p_packet->video_width=%u, p_packet->video_height=%u\n",
2368 uint8_t *p_data = (uint8_t *)p_packet->
p_data;
2379 p_data, packet_size, ui32LBA);
2399 char dump_file[512] = {0};
2402 snprintf(dump_file,
sizeof(dump_file),
"%s/pkt-%04ld.bin",
2409 fwrite(p_packet->
p_data, sent_size, 1, f);
2450 "%s: (first packet) pkt_index %d i %u "
2451 "pkt_offsets_index_min %" PRIu64
" pkt_offsets_index %" PRIu64
2452 " pts_offsets %" PRId64
"\n",
2464 "%s: pkt_index %d i %u pkt_offsets_index_min "
2465 "%" PRIu64
" pkt_offsets_index %" PRIu64
" pts_offsets %" PRId64
2478 "%s: (wrap) pkt_index %d i %u "
2479 "pkt_offsets_index_min %" PRIu64
" pkt_offsets_index %" PRIu64
2480 " pts_offsets %" PRId64
"\n",
2503 "Error %s: failed to allocate custom SEI buffer for pkt.\n",
2519 "ERROR %s(): ni_timestamp_register() for dts returned %d\n",
2529 "%s(): exit: packets: %" PRIu64
" offset %" PRIx64
""
2530 " sent_size = %u, status=%d\n",
2531 __func__, p_ctx->
pkt_num, (uint64_t)p_packet->
pos, sent_size,
2537 "ERROR %s(): exit: returnErr: %d, p_ctx->status: %d\n", __func__,
2543static int64_t guess_correct_pts(
ni_session_context_t* p_ctx, int64_t reordered_pts, int64_t dts)
2551 "%s: pts_correction_last_dts %" PRId64
" "
2552 "pts_correction_num_faulty_dts %d\n",
2567 "%s: pts_correction_last_pts %" PRId64
" "
2568 "pts_correction_num_faulty_pts %d\n",
2581 pts = reordered_pts;
2593 pts = reordered_pts;
2601static int rotated_array_binary_search(uint64_t *lefts, uint64_t *rights,
2602 int32_t size, uint64_t target)
2608 int mid = lo + (hi - lo) / 2;
2609 if (lefts[mid] <= target && target < rights[mid])
2614 if (rights[mid] == 0)
2621 if (rights[lo] <= rights[mid])
2623 if (lefts[lo] <= target && target < lefts[mid])
2634 if (rights[mid] <= target && target < rights[hi])
2660 uint64_t frame_offset = 0;
2661 uint32_t frame_dropped = 0;
2662 uint8_t *p_data_buffer = NULL;
2668 uint32_t total_bytes_to_read = 0;
2669 uint32_t read_size_bytes = 0;
2674 int query_retry = 0;
2675 uint32_t ui32LBA = 0;
2676 unsigned int bytes_read_so_far = 0;
2678 int low_delay_notify = 0;
2679 uint32_t frames_dropped = 0;
2680 uint8_t get_first_metadata = 0;
2681 uint8_t sequence_change = 0;
2685 if ((!p_ctx) || (!p_frame))
2703 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
2708 p_frame->
data_len[2] + metadata_hdr_size;
2759 ni_log2(p_ctx,
NI_LOG_TRACE,
"Warning: dec read query fail rc %d retry %d max_retry_fail_count %d\n",
2762 if (query_retry >= 1000)
2765 low_delay_notify = 1;
2782 total_bytes_to_read = metadata_hdr_size;
2783 sequence_change = 1;
2806 "WARNING: Dec eos reached but also exceeded max dec read query "
2807 "retries. is_flushed=%u try=%d.\n",
2812 "Dec eos reached. is_flushed=%u try=%d.\n",
2816 low_delay_notify = 1;
2822 " retrying ..\n", query_retry);
2836 query_retry < 1000 / 2)
2843 low_delay_signal(p_ctx);
2851 "size %u >= required size %u !\n",
2868 low_delay_signal(p_ctx);
2871 "Warning: ceased using low delay decoding mode after "
2872 "excessively long decoder read query.\n");
2875 low_delay_signal(p_ctx);
2885 if(query_retry <= 2000)
2894 "Warning: decoder pkt_num %u frame_num %u "
2895 "timeout, increasing pkt_delay_cnt to %u\n",
2919 "At least %d packets should be sent before reading the "
2936 "%ux%u frame-rate %u is_flushed %u\n",
2970#ifdef XCODER_SELF_KILL_ERR
2975 kill(getpid(), SIGTERM);
2992 p_frame->
data_len[2] + metadata_hdr_size;
2993 p_data_buffer = (uint8_t*) p_frame->
p_buffer;
3005 "%u cb len %u hdr %d\n",
3008 p_frame->
data_len[2], metadata_hdr_size);
3014 "ERROR %s() avaliable size(%u)"
3015 "less than needed (%u)\n",
3027 void *p_metadata_buffer = NULL;
3033 "ERROR %d: %s() Cannot allocate metadata buffer.\n",
3038 p_data_buffer = (uint8_t *)p_metadata_buffer;
3039 get_first_metadata = 1;
3041 sequence_change = 0;
3062 p_data_buffer, read_size_bytes, ui32LBA);
3071 }
else if (get_first_metadata) {
3079 get_first_metadata = 0;
3093 low_delay_notify = 1;
3106 total_bytes_to_read = total_bytes_to_read + sei_size;
3108 "include sei %u sei_size %d\n",
3109 retval, total_bytes_to_read, sei_size);
3112 bytes_read_so_far = total_bytes_to_read ;
3119 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, &frame_dropped,
false);
3123 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
false);
3139 "is cancelled due to has_b_frames, frame_num %u\n",
3150 int64_t tmp_dts, prev_dts = INT64_MIN, ts_diff = 0;
3159 "### %s(): Warning: ui32FramesDropped %u should be %u + %u\n",
3176 "%s(): First frame : session_id 0x%x, pic_reorder_delay: %d "
3177 "total frames input:%u buffered: %u completed: %u output: %u "
3178 "dropped: %u (%u %u) error: %u\n",
3198 "decoder dts queue %d %ld failed !\n",
3199 __func__, i, tmp_dts);
3204 "decoder dts queue %d %ld success !\n",
3205 __func__, i, tmp_dts);
3206 if (prev_dts != INT64_MIN) {
3207 ts_diff += llabs(tmp_dts - prev_dts);
3215 ts_diff = ts_diff / nb_diff;
3219 "average diff: %ld\n", __func__, ts_diff);
3234 "decoder dts queue %d %ld failed !\n",
3235 __func__, i, tmp_dts);
3262 for (i = 0; (int)i < p_ctx->pic_reorder_delay; i++)
3269 if (p_frame->
pts >= p_frame->
dts &&
3270 p_frame->
pts - p_frame->
dts < 1000)
3286 "decoder dts queue %d %ld success !\n",
3287 __func__, i, p_frame->
dts);
3323 "%s: (found pts) dts %" PRId64
" pts "
3324 "%" PRId64
" frame_offset %" PRIu64
" j %d "
3325 "pkt_offsets_index_min %" PRIu64
" pkt_offsets_index "
3326 "%" PRIu64
" pkt_pos %" PRIu64
" \n",
3327 __func__, p_frame->
dts, p_frame->
pts, frame_offset, j,
3342 while (p_frame->
dts < p_frame->
pts &&
3343 llabs(p_frame->
pts - p_frame->
dts) > ts_diff)
3346 "dts %lld diff. %lld > ts_diff %lld\n",
3347 __func__, p_frame->
pts, p_frame->
dts,
3348 llabs(p_frame->
pts - p_frame->
dts), ts_diff);
3355 "pop decoder dts queue error.\n", __func__);
3378 "ERROR: Frame pts %" PRId64
" not found for offset "
3379 "%" PRIu64
"\n", p_frame->
pts, frame_offset);
3381 "%s: (not found use default) dts %" PRId64
" pts %" PRId64
3383 __func__, p_frame->
dts, p_frame->
pts);
3395 p_frame->
pts = guess_correct_pts(p_ctx, p_frame->
pts, p_frame->
dts);
3403 __func__, p_frame->
pts);
3413#ifdef MEASURE_LATENCY
3420#ifdef XCODER_DUMP_DATA
3421 char dump_file[256];
3422 snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-dec-fme/fme-%04ld.yuv",
3436 "%s(): p_frame->start_of_stream=%u, "
3437 "p_frame->end_of_stream=%u, p_frame->video_width=%u, "
3438 "p_frame->video_height=%u\n",
3447 "Decoder pts queue size = %u dts queue size = %u\n\n",
3454#ifdef MEASURE_LATENCY
3470 if (get_first_metadata && p_data_buffer)
3472 if (sequence_change && p_ctx->
frame_num)
3487 low_delay_signal(p_ctx);
3493 if (low_delay_notify)
3495 low_delay_signal(p_ctx);
3515 device_type, g_device_type_str[device_type]);
3538 switch (device_type)
3560 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s blk_dev %s blk_xcoder %s dev_xcoder %s current_load:%u model_load:%u fw_load:%u "
3561 "total_contexts:%u fw_video_mem_usage:%u "
3562 "fw_video_shared_mem_usage:%u fw_share_mem_usage:%u "
3563 "fw_p2p_mem_usage:%u active_hwuploaders:%u\n", __func__,
3579 "Overall load %u, model load %u, instance count %u\n",
3606 device_type, g_device_type_str[device_type]);
3637 void *p_buffer = NULL;
3639 uint32_t ui32LBA = 0;
3640 uint32_t max_cu_size;
3641 uint32_t block_size;
3642 int32_t width, height;
3643 int m_threshold = 0;
3644 char fmt_fw_api_ver1[5], fmt_fw_api_ver2[5];
3662 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() RGBA / BGRA / ARGB / AGBR resolution invalid, return\n",
3675#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
3684 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): not support enableCpuAffinity parameter, "
3685 "enable with [./build.sh -c] on linux\n", __func__);
3698 width = (width / 8) * 8;
3699 height = (height / 8) * 8;
3703 ((width + max_cu_size - 1) & (~(max_cu_size - 1))) *
3704 ((height + max_cu_size - 1) & (~(max_cu_size - 1))) /
3706 p_ctx->
roi_len = ((block_size + 63) & (~63));
3784 "ERROR %s(): p_ctx->device_handle=%" PRIx64
", "
3785 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
3796 uint64_t keep_alive_timeout =
3799 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
3801 keep_alive_timeout);
3812 "ERROR %s(): nvme write keep_alive_timeout command "
3813 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
3829 __func__, fmt_fw_api_ver1, fmt_fw_api_ver2);
3840 "ERROR %s(): nvme write sw_version command "
3841 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
3886 ni_log2(p_ctx,
NI_LOG_ERROR,
"The bit depth or resoultion is not supported on ai enhance mode\n");
3900 "ERROR %s(): p_ctx->device_handle=%" PRIx64
", "
3901 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
3938 if (m_threshold > 4 * 1024 * 1024 *
sizeof(
long))
3941 "DEFAULT_MMAP_THRESHOLD_MAX, use default value (%d)\n",
3942 m_threshold, 4 * 1024 * 1024 *
sizeof(
long));
3943 m_threshold = 4 * 1024 * 1024 *
sizeof(long);
3948#if defined(__linux__) && !defined(_ANDROID) && !defined(__OPENHARMONY__)
3952 if (mallopt(M_MMAP_THRESHOLD, m_threshold) == 0)
3965 if (mallopt(M_TRIM_THRESHOLD, 3 * m_threshold) == 0)
3974 "Warning: this platform does not support staticMmapThreshold\n");
3981 m_threshold = (int) (m_threshold * 1.25);
3982 void *temp_buf = malloc((
size_t) m_threshold);
3983 ni_log2(p_ctx,
NI_LOG_TRACE,
"trigger a pre-mature increase in mmap&trim threshold: 0x%p = malloc(%d)\n",
3984 temp_buf, m_threshold);
3991 bool device_in_ctxt =
true;
4007 for (uint8_t ui8Index = 0; ui8Index < 20; ui8Index++)
4030 "p_ctx->sender_handle=%" PRIx64
", p_ctx->hw_id=%d, p_ctx->session_id=%u\n",
4039 "p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, p_ctx->session_id=%u\n",
4045 if ((sender_vf_ns_id.
ns_id != curr_vf_ns_id.
ns_id) ||
4046 (sender_vf_ns_id.
vf_id != curr_vf_ns_id.
vf_id))
4063 "p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
4074 "ERROR: ni_ai_query_network_ready returned %d\n", retval);
4107 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() line-%d return %d\n", __func__, __LINE__, retval);
4123 "%s(): p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, "
4124 "p_ctx->session_id=%d\n",
4128#ifdef XCODER_DUMP_DATA
4129 char dir_name[256] = {0};
4130 snprintf(dir_name,
sizeof(dir_name),
"%ld-%u-enc-pkt", (
long)getpid(),
4132 DIR *dir = opendir(dir_name);
4135 mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
4143 snprintf(dir_name,
sizeof(dir_name),
"%ld-%u-enc-fme", (
long)getpid(),
4145 dir = opendir(dir_name);
4148 mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
4219 void* p_buffer = NULL;
4220 uint32_t ui32LBA = 0;
4245 "Encoder_complete_info:session_id 0x%x, total frames input:%u "
4246 "buffered: %u completed: %u output: %u dropped: %u error: %u\n",
4288 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
4289 "p_ctx->session_id=%d, close_mode=1\n",
4357 for (i = 0; i < 120 ; i++)
4371 low_delay_signal(p_ctx);
4382 int32_t width_stride[4] = {0};
4383 int32_t height_stride[4] = {0};
4398 width_stride, height_stride);
4401 for (
int i = 0; i < 120; i++)
4422 for (
int j = 0; j < source_height; j++)
4425 ni_frame->
p_data[0] + j * width_stride[0],
4428 for (
int j = 0; j < (source_height + 1) / 2; j++)
4431 ni_frame->
p_data[1] + j * width_stride[1],
4434 for (
int j = 0; j < (source_height + 1) / 2; j++)
4437 ni_frame->
p_data[2] + j * width_stride[2],
4453 for (
int j = 0; j < source_height; j++)
4456 ni_frame->
p_data[0] + j * width_stride[0],
4459 for (
int j = 0; j < (source_height + 1) / 2; j++)
4462 ni_frame->
p_data[1] + j * width_stride[1],
4465 for (
int j = 0; j < (source_height + 1) / 2; j++)
4468 ni_frame->
p_data[2] + j * width_stride[2],
4491 bool ishwframe =
false;
4493 uint32_t send_count = 0;
4495 uint32_t sent_size = 0;
4496 uint32_t frame_size_bytes = 0;
4501 if (!p_ctx || !p_frame)
4520 if (!((input_frame_idx > 0 &&
4526 __func__, input_frame_idx);
4545 low_delay_wait(p_ctx);
4547#ifdef MEASURE_LATENCY
4574 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: passed video_height and video_width are not valid!, return\n");
4586 "%s: data_len[0] %u data_len[1] %u "
4587 "data_len[2] %u extra_data_len %u frame_size_bytes %u\n",
4621 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() line-%d retrun %d\n", __func__, __LINE__, retval);
4628 "Enc write query retry %d. rc=%d. Available buf size %u < "
4629 "frame size %u\n", retval, send_count,
4633 int retval_backup = retval;
4646 "Enc write query buf info exceeded max retries: "
4647 "%d, rc=%d. Available buf size %u < frame size %u\n",
4661 "Info enc write query success, available buf "
4662 "size %u >= frame size %u !\n",
4671 if (separate_metadata)
4677 p_frame->
p_data[2 + ishwframe] +
4692 "use_cur_src_as_long_term_pic %d use_long_term_ref %d\n",
4707 "%s(): ctx->force_frame_type"
4708 " %d frame->force_key_frame %d force frame_num %" PRIu64
""
4755 "%s(): %d.%u p_ctx->frame_num=%" PRIu64
", "
4756 "p_frame->start_of_stream=%u, p_frame->end_of_stream=%u, "
4757 "p_frame->video_width=%u, p_frame->video_height=%u, pts=0x%08x 0x%08x, "
4758 "dts=0x%08x 0x%08x, sei_len=%u, roi size=%u avg_qp=%u reconf_len=%u "
4759 "force_pic_qp=%u use_cur_src_as_long_term_pic %u use_long_term_ref "
4760 "%u start_len [%u,%u,%u] inconsecutive_transfer %u "
4761 "get_recon_frame_mode %u\n",
4765 (uint32_t)(p_frame->
pts & 0xFFFFFFFF),
4766 (uint32_t)((p_frame->
dts >> 32) & 0xFFFFFFFF),
4813 "ni_timestamp_register() for dts returned: %d\n",
4817 if (separate_metadata)
4819 uint32_t ui32LBA_metadata =
4822 "%s: p_metadata_buffer = %p, metadata_buffer_size "
4823 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
4852 "%s: p_start_buffer = %p, p_frame->start_buffer_size "
4853 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
4881 "%s: p_data = %p, p_frame->buffer_size "
4882 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
4914 "%s: p_data = %p, p_frame->buffer_size "
4915 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
4919 sent_size = frame_size_bytes;
4920 if (separate_metadata)
4953 int ret =
hwdl_frame(p_ctx, &hwdl_session_data, p_frame,
4974 "%s(): session=0x%x ui16FrameIdx=%u\n",
4982 size = frame_size_bytes;
4985#ifdef XCODER_DUMP_DATA
4986 char dump_file[256];
4987 snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-enc-fme/fme-%04ld.yuv",
5035 switch (video_codec_id)
5061 "Av_QP: f=%.6f FrameSize: i32=%d InitialQP: i32=%d max_QP: i32=%d MbQPs_1_: f=%.6f "
5062 "FrameType: i32=%d Sec_Codec: i32=%d Seq_Profile: i32=%d "
5063 "MbQPs_5_: f=%.6f MbQPs_6_: f=%.6f AnalyzedMBs: i32=%d "
5064 "MbTypes_5_: i32=%d MbTypes_6_: i32=%d MbTypes_0_: i32=%d MbTypes_1_: i32=%d "
5065 "quality_pixel_count: i32=%d\n",
5072 quality_pixel_count);
5079 uint32_t actual_read_size = 0;
5080 uint32_t to_read_size = 0;
5082 static long long encq_count = 0LL;
5084 int query_retry = 0;
5086 uint32_t ui32LBA = 0;
5091 int low_delay_notify = 0;
5094 if (!p_ctx || !p_packet || !p_packet->
p_data)
5114 ni_log2(p_ctx,
NI_LOG_DEBUG,
"frame_num=%" PRIu64
", pkt_num=%" PRIu64
", av1_pkt_num=%" PRIu64
"\n",
5127 low_delay_notify = 1;
5159 if(query_retry == 0)
5160 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: initial_frame_delay %d max_frame_delay %d ui8AdditionalFramesDelay %u current_frame_delay %d\n",
5174 "Info enc read query rc %d, available buf size %u, "
5175 "frame_num=%" PRIu64
", pkt_num=%" PRIu64
"\n",
5212 "%" PRIu64
" >= %" PRIu64
" pkt_num, keep querying p_ctx->status %d\n",
5220 low_delay_notify = 1;
5237 ni_log2(p_ctx,
NI_LOG_TRACE,
"%s: low delay mode 2, keep reading send frame %d receive pkt %d gop %d current_frame_delay %d\n",
5238 __FUNCTION__, p_ctx->
frame_num, pkt_num,
5256 ni_log2(p_ctx,
NI_LOG_TRACE,
"%s: constant delay mode 3, delay reading send frame %d receive pkt %d gop %d current_frame_delay %d\n",
5257 __FUNCTION__, p_ctx->
frame_num, pkt_num,
5284 actual_read_size = to_read_size;
5297 "ERROR %s(): packet buffer size %u allocation "
5299 __func__, actual_read_size);
5306 p_packet->
p_data, actual_read_size, ui32LBA);
5332 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s MetaDataSize %d FrameType %d AvgFrameQp %d ssim %d %d %d\n",
5350 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: current gop_size %u last_gop_size %d initial_frame_delay %d max_frame_delay %d current_frame_delay %d\n",
5374 ni_log2(p_ctx,
NI_LOG_DEBUG,
"pkt_num %d max_mv x[0] %d x[1] %d y[0] %d y[1] %d min_mv x[0] %d x[1] %d y[0] %d y[1] %d frame_size %u inter_total_count %u intra_total_count %u stillImage %d scenechange %d\n",
5391 if (p_meta->
ssimY != 0)
5399#ifdef NI_LOG_SSIM_AT_INFO
5404 "%s: pkt #%" PRId64
" pts %" PRId64
" ssim "
5405 "Y %.4f U %.4f V %.4f\n", __FUNCTION__, p_ctx->
pkt_num,
5406 p_packet->
pts, (
float)p_meta->
ssimY/10000,
5407 (
float)p_meta->
ssimU/10000, (
float)p_meta->
ssimV/10000);
5439 get_bitstream_features_from_cu_info(p_ctx, p_packet);
5447 ni_write_bitstream_features_internal(p_ctx, p_packet);
5481 low_delay_notify = 1;
5486#ifdef MEASURE_LATENCY
5493#ifdef XCODER_DUMP_DATA
5494 char dump_file[256];
5495 snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-enc-pkt/pkt-%04ld.bin",
5509 "%s(): %d.%u p_packet->start_of_stream=%u, "
5510 "p_packet->end_of_stream=%u, p_packet->video_width=%u, "
5511 "p_packet->video_height=%u, p_packet->dts=0x%08x 0x%08x, "
5512 "p_packet->pts=0x%08x 0x%08x, type=%u, avg_frame_qp=%u, show_frame=%d\n",
5515 (uint32_t)((p_packet->
dts >> 32) & 0xFFFFFFFF),
5516 (uint32_t)(p_packet->
dts & 0xFFFFFFFF),
5517 (uint32_t)((p_packet->
pts >> 32) & 0xFFFFFFFF),
5518 (uint32_t)(p_packet->
pts & 0xFFFFFFFF), p_packet->
frame_type,
5524 if (encq_count % 500 == 0)
5527 "Encoder pts queue size = %u dts queue size = %u\n\n",
5533#ifdef MEASURE_LATENCY
5553 if (low_delay_notify)
5555 low_delay_signal(p_ctx);
5579 p_ctx->
last_gop_size = g_map_preset_to_gopsize[lookAheadEnable][gop_preset_index + 1];
5591 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR %s(): config encoder sequence change command failed\n",
5616 void* p_buffer = NULL;
5617 uint32_t ui32LBA = 0;
5618 char fmt_fw_api_ver1[5], fmt_fw_api_ver2[5];
5633 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use stack filter on device with FW API version < 6.4\n");
5643 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use rotate filter on device with FW API version < 6.7\n");
5653 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use in-place overlay filter on device with FW API version < 6.L\n");
5663 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use ai align filter on device with FW API version < 6.sI\n");
5730 "ERROR %s(): p_ctx->device_handle=%" PRIx64
5731 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
5739 "%s(): p_ctx->device_handle=%" PRIx64
5740 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
5745 uint64_t keep_alive_timeout =
5748 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
5750 keep_alive_timeout);
5761 "ERROR %s(): nvme write keep_alive_timeout command "
5762 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
5778 __func__, fmt_fw_api_ver1, fmt_fw_api_ver2);
5789 "ERROR %s(): nvme write sw_version command "
5790 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
5806#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OPEN_HARMONY__) && !defined(_ANDROID)
5809 retval = p2p_fill_pcie_address(p_ctx);
5836 void * p_buffer = NULL;
5837 uint32_t ui32LBA = 0;
5871 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
5872 "p_ctx->session_id=%d, close_mode=1\n",
5924 void *p_scaler_config = NULL;
5928 uint32_t ui32LBA = 0;
5932 if (!p_ctx || !p_params)
5958 memset(p_scaler_config, 0, buffer_size);
5976 "on device with FW API version < 6rL\n", __func__);
5982 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
5983 "hw_id, %d, xcoder_inst_id: %d\n",
6010 "on device with FW API version < 6s1\n", __func__);
6016 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6017 "hw_id, %d, xcoder_inst_id: %d\n",
6030 "be in [0 , 5]. scaler_params_b is %lf, scaler_params_c is %lf\n",
6037 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6038 "hw_id, %d, xcoder_inst_id: %d\n",
6052 p_scaler_config, buffer_size, ui32LBA);
6053 if ((int32_t)retval < 0)
6056 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
6057 ", hw_id, %d, xcoder_inst_id: %d\n",
6064 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6065 "hw_id, %d, xcoder_inst_id: %d\n",
6110 int rectangle_width,
6111 int rectangle_height,
6120 uint32_t ui32LBA = 0;
6121 uint32_t query_retry = 0;
6126 dataLen = dataLen & 0xFFFFF000;
6143 if (rgba_color == 0)
6150 "WARNING: Allocate framepool size 0 for session 0x%x\n", p_ctx->
session_id);
6156 "ERROR: %s() try to free session 0x%x framepool while it's not allocated\n",
6167 "ERROR: %s() try to free session 0x%x framepool of type %u while "
6168 "passing type %u\n",
6183 "ERROR: allocate framepool multiple times for session 0x%x "
6184 "not supported in FW API version < 6r3\n",
6191 "Expand frame pool of scaler 0x%x with %u more frames\n",
6197 "ERROR: try to expand session 0x%x framepool with type %u "
6198 "while pool type is %u\n",
6213 memset(p_data, 0x00, dataLen);
6272 ni_log2(p_ctx,
NI_LOG_ERROR,
"Resolution %d x %d not supported for %d format!\n", width, height, format);
6277 "Session=0x%x: Dev alloc frame: FrameIndex=%d; W=%d; H=%d; C=%d; RW=%d; RH=%d; RX=%d; RY=%d\n",
6291 p_data, dataLen, ui32LBA);
6318 "ERROR: ni_nvme_send_admin_cmd failed: "
6319 "blk_io_handle: %" PRIx64
", hw_id, %u, xcoder_inst_id: %d\n",
6348 uint32_t ui32LBA = 0;
6353 dataLen = dataLen & 0xFFFFF000;
6355 if (!p_ctx || !p_cfg)
6374 memset(p_data, 0x00, dataLen);
6419 "Session=0x%x: Dev config frame: FrameIndex=%u; W=%d; H=%d; C=%d; RW=%d; RH=%d; RX=%d; RY=%d; O=%d\n",
6430 p_data, dataLen, ui32LBA);
6436 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
6437 ", hw_id, %u, xcoder_inst_id: %d\n",
6441 "ERROR ni_scaler_config(): nvme command failed!\n");
6472 uint32_t ui32LBA = 0;
6478 dataLen = dataLen & 0xFFFFF000;
6480 if (!p_ctx || (!p_cfg_in && numInCfgs))
6499 memset(p_data, 0x00, dataLen);
6501 p_data_orig = p_data;
6503 for (i = 0; i < numInCfgs; i++)
6520 "Session=0x%x: Dev in config frame %d: FrameIndex=%u; Session=0x%x; W=%d; H=%d; C=%d; RW=%d; RH=%d; RX=%d; RY=%d\n",
6545 "Session=0x%x: Dev out config frame: FrameIndex=%u; W=%d; H=%d; C=%d; RW=%d; RH=%d; RX=%d; RY=%d\n",
6563 p_data_orig, dataLen, ui32LBA);
6569 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
6570 ", hw_id, %u, xcoder_inst_id: %d\n",
6574 "ERROR ni_scaler_config(): nvme command failed!\n");
6596 void* p_buffer = NULL;
6598 uint32_t ui32LBA = 0;
6603 if ((!p_ctx) || (!p_gen_status))
6614 __func__, device_type);
6629 memset(p_buffer, 0, dataLen);
6664 void* p_buffer = NULL;
6666 uint32_t ui32LBA = 0;
6667 uint32_t dataLen = 0;
6668 uint32_t copyLen = 0;
6689 if ((!p_ctx) || (!p_detail_status))
6700 __func__, device_type);
6713 memset(p_buffer, 0, dataLen);
6723 memcpy(p_detail_status, p_buffer, copyLen);
6746 void* p_buffer = NULL;
6748 uint32_t ui32LBA = 0;
6753 if ((!p_ctx) || (!p_stream_info))
6765 __func__, device_type);
6787 memset(p_buffer, 0, dataLen);
6833 void* p_buffer = NULL;
6834 uint64_t session_timestamp;
6835 uint32_t ui32LBA = 0;
6844 if ((!p_ctx) || (!p_session_stats))
6855 __func__, device_type);
6877 memset(p_buffer, 0, dataLen);
6909 session_timestamp <<= 32;
6921 "query timestamp:%" PRIu64
"\n", p_ctx->
session_id,
6930 ni_log2(p_ctx,
NI_LOG_ERROR,
"%s(): session id %u ts %lu hw_id %d device_type %u codec_format %u frame_num %lu pkt_num %lu "
6931 "ready_to_close %u session_run_state %d active_video_width %u active_video_height %u\n",
6945#if __linux__ || __APPLE__
6946#if !defined(_ANDROID) && !defined(__OPENHARMONY__)
6947#ifndef DISABLE_BACKTRACE_PRINT
6948 ni_print_backtrace();
6962 "%s(): device 0x%" PRIx64
" last command Failed due to wrong "
6963 "session ID. Expected 0x%x, got 0x%x keep alive last access "
6964 "time %" PRIu64
", current %" PRIu64
"\n", __func__,
6967 if (dt > 1000000000)
6970 "%s():long delay between last command dt = %" PRId64
" ns, "
6971 "process was possibly blocked.\n", __func__, dt);
7005 void* p_buffer = NULL;
7007 uint32_t ui32LBA = 0;
7012 if (!p_ctx || !p_stream_complete)
7024 __func__, device_type);
7046 memset(p_buffer, 0, dataLen);
7068static const char* ni_get_device_type_str(
int type)
7072 return "Invalid device type";
7074 return g_device_type_str[type];
7082 memcpy((
void *)p_session_statistic, p_buffer,
7086 p_session_statistic->ui32RdBufAvailSize =
7087 ni_htonl(p_session_statistic->ui32RdBufAvailSize);
7088 p_session_statistic->ui32WrBufAvailSize =
7089 ni_htonl(p_session_statistic->ui32WrBufAvailSize);
7091 p_session_statistic->ui32FramesInput =
7092 ni_htonl(p_session_statistic->ui32FramesInput);
7093 p_session_statistic->ui32FramesBuffered =
7094 ni_htonl(p_session_statistic->ui32FramesBuffered);
7095 p_session_statistic->ui32FramesCompleted =
7096 ni_htonl(p_session_statistic->ui32FramesCompleted);
7097 p_session_statistic->ui32FramesOutput =
7098 ni_htonl(p_session_statistic->ui32FramesOutput);
7099 p_session_statistic->ui32FramesDropped =
7100 ni_htonl(p_session_statistic->ui32FramesDropped);
7101 p_session_statistic->ui32InstErrors =
7102 ni_htonl(p_session_statistic->ui32InstErrors);
7104 p_session_statistic->ui16SessionId =
7105 ni_htons(p_session_statistic->ui16SessionId);
7106 p_session_statistic->ui16ErrorCount =
7107 ni_htons(p_session_statistic->ui16ErrorCount);
7108 p_session_statistic->ui32LastTransactionId =
7109 ni_htonl(p_session_statistic->ui32LastTransactionId);
7110 p_session_statistic->ui32LastTransactionCompletionStatus =
7111 ni_htonl(p_session_statistic->ui32LastTransactionCompletionStatus);
7112 p_session_statistic->ui32LastErrorTransactionId =
7113 ni_htonl(p_session_statistic->ui32LastErrorTransactionId);
7114 p_session_statistic->ui32LastErrorStatus =
7115 ni_htonl(p_session_statistic->ui32LastErrorStatus);
7116 p_session_statistic->ui32Session_timestamp_high =
7117 ni_htonl(p_session_statistic->ui32Session_timestamp_high);
7118 p_session_statistic->ui32Session_timestamp_low =
7119 ni_htonl(p_session_statistic->ui32Session_timestamp_low);
7123 if (p_ctx->
session_id != p_session_statistic->ui16SessionId)
7128 "%s(): %s device 0x%" PRIx64
" last command Failed due to wrong "
7129 "session ID. Expected 0x%x, got 0x%x w_r <%u %u> keep alive "
7130 "last access time %" PRIu64
", current %" PRIu64
"\n", __func__,
7133 p_session_statistic->ui16SessionId,
7134 p_session_statistic->ui32WrBufAvailSize,
7137 if (dt > 1000000000)
7140 "%s():long delay between last command dt = %" PRId64
" ns, "
7141 "process was possibly blocked.\n", __func__, dt);
7143 p_session_statistic->ui32LastErrorStatus =
7153 __func__, p_session_statistic->ui16ErrorCount,
7154 p_session_statistic->ui32LastTransactionCompletionStatus,
7155 p_session_statistic->ui32LastErrorStatus);
7175 void *p_buffer = NULL;
7177 uint32_t ui32LBA = 0;
7183 if (!p_ctx || !p_session_statistic)
7186 "ERROR: %s() passed parameters are null!, return\n", __func__);
7194 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() not supported on device with FW api version < 6.5\n", __func__);
7203 __func__, device_type);
7225 memset(p_buffer, 0, dataLen);
7234 p_buffer, dataLen, ui32LBA) < 0)
7245 ni_parse_session_statistic_info(p_ctx, p_session_statistic, p_buffer);
7250 __func__, ni_get_device_type_str(p_ctx->
device_type));
7279 void* p_buffer = NULL;
7281 uint32_t ui32LBA = 0;
7289 if (!p_ctx || !p_inst_buf_info)
7303 __func__, device_type);
7370 memset(p_buffer, 0, dataLen);
7407 uint8_t enable, uint8_t hw_action,
7411 uint32_t ui32LBA = 0;
7412 void * p_buffer = NULL;
7413 uint32_t buffer_size = 0;
7442 memset(p_buffer, 0, buffer_size);
7501 uint32_t ui32LBA = 0;
7517 __func__, device_type);
7555 uint32_t ui32LBA = 0;
7571 __func__, device_type);
7610 uint32_t ui32LBA = 0;
7625 __func__, device_type);
7672 uint32_t ui32LBA = 0;
7673 void * p_buffer = NULL;
7674 uint32_t buffer_size = 0;
7690 __func__, device_type);
7711 memset(p_buffer, 0, buffer_size);
7712 memcpy(p_buffer, &len,
sizeof(len));
7742 uint32_t ui32LBA = 0;
7743 void * p_buffer = NULL;
7744 uint32_t buffer_size = 0;
7758 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Seq Change not supported for device type %d, return\n", device_type);
7779 memset(p_buffer, 0, buffer_size);
7807 void* p_encoder_config = NULL;
7808 void* p_encoder_roi_qp_map = NULL;
7810 uint32_t buffer_size = 0;
7812 uint32_t ui32LBA = 0;
7838 if (
ni_posix_memalign(&p_encoder_roi_qp_map, sysconf(_SC_PAGESIZE), buffer_size))
7845 memset(p_encoder_roi_qp_map, 0, buffer_size);
7849 p_encoder_roi_qp_map, buffer_size, ui32LBA);
7867 ni_log2(p_ctx,
NI_LOG_INFO,
"customizeQpMapFile is ignored since customizeQpLevel=0");
7881 memset(p_encoder_config, 0, buffer_size);
7942 p_encoder_config, buffer_size, ui32LBA);
7979 uint32_t ui32LBA = 0;
7983 if (!p_ctx || !p_params)
8017 buffer_size, ui32LBA) < 0)
8044 p_frame_offset, uint32_t* p_frame_dropped,
bool is_hw_frame)
8049 if (!p_frame || !p_frame_offset)
8056 *p_frame_offset = 0;
8057 if (p_frame_dropped)
8058 *p_frame_dropped = 0;
8062 unsigned int video_data_size = p_frame->
data_len[0] + p_frame->
data_len[1] +
8069 if (rx_size == metadata_size)
8071 video_data_size = 0;
8074 if (rx_size > video_data_size)
8081 rx_size -= metadata_size;
8092 "%s: [metadata] cropRight=%u, cropLeft=%u, "
8093 "cropBottom=%u, cropTop=%u, frame_offset=%" PRIu64
", pic=%ux%u, "
8094 "pict_type=%d, crop=%ux%u, sei header: 0x%0x number %u size %u num_frame_dropped %u\n",
8116 if (p_frame_dropped)
8124 ni_log(
NI_LOG_DEBUG,
"ui32SeiHeader 0x%x ui16SeiNumber %d ui16SeiSize %d SEI 0x%02x%02x\n",
8126 *((uint8_t*)p_meta + metadata_size),
8127 *((uint8_t*)p_meta + metadata_size+1));
8130 uint16_t ui16SeiProcessed = 0;
8132 uint32_t ui32Offset = 0;
8141 if (pEntryHeader->
status)
8143 ui32Size = pEntryHeader->
size;
8151 ui16SeiProcessed, pEntryHeader->
status,
8152 pEntryHeader->
size, pEntryHeader->
type, ui32Size,
8154 *((uint8_t *)p_meta + metadata_size + ui32Offset),
8155 *((uint8_t *)p_meta + metadata_size + ui32Offset + 1));
8162 switch(pEntryHeader->
type)
8167 uint8_t *ptr = (uint8_t*)p_meta + metadata_size + ui32Offset;
8174 video_data_size + metadata_size + ui32Offset;
8201 "%s: close caption size %u ,"
8202 "offset %u = video size %u meta size %d off "
8205 video_data_size, metadata_size, ui32Offset);
8210 "%s: unsupported T35; type %u size %u status %u "
8212 __func__, pEntryHeader->
type, pEntryHeader->
size,
8213 pEntryHeader->
status, ui32Offset);
8219 "Error %s: T35 SEI dropped due to %s; type %u size %u status %u offset %u\n",
8220 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8221 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8238 "Error %s: User Data Unreg dropped due to %s; type %u size %u status %u offset %u\n",
8239 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8240 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8249 video_data_size + metadata_size + ui32Offset;
8254 *)((uint8_t *)p_meta + metadata_size + ui32Offset);
8276 "Error %s: mastering display info dropped due to %s; type %u size %u status %u offset %u\n",
8277 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8278 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8287 video_data_size + metadata_size + ui32Offset;
8293 (uint8_t*)p_meta + metadata_size + ui32Offset);
8302 "Error %s: content light level info dropped due to %s; type %u size %u status %u offset %u\n",
8303 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8304 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8313 video_data_size + metadata_size + ui32Offset;
8322 "Warning %s: SEI message dropped (unsupported - check "
8323 "decoder SEI bitmap settings);"
8324 " type %u size %u status %u offset %u payload bytes %u\n",
8325 __func__, pEntryHeader->
type, pEntryHeader->
size,
8326 pEntryHeader->
status, ui32Offset, ui32Size);
8329 ui32Offset += ui32Size;
8330 pEntryHeader = (
ni_sei_header_t *)((uint8_t*)p_meta + metadata_size + ui32Offset);
8332 }
while (ui32Offset <= p_meta->sei_size && ui16SeiProcessed < p_meta->sei_number);
8338 "Error %s: number of SEI messages reported %u != processed %u\n",
8339 __func__, p_meta->
sei_number, ui16SeiProcessed);
8348 ni_sei_user_data_entry_t *pEntry;
8349 uint32_t ui32CCOffset = 0, ui32CCSize = 0;
8353 pEntry = (ni_sei_user_data_entry_t *)((uint8_t*)p_meta + metadata_size);
8356 &ui32CCOffset, &ui32CCSize))
8360 video_data_size + metadata_size + ui32CCOffset;
8373 &ui32CCOffset, &ui32CCSize))
8377 ptr = (uint8_t*)pEntry + ui32CCOffset;
8380 ui32CCSize = (ptr[8] & 0x1F) * 3;
8386 + ui32CCOffset + 10;
8391 "%s: close caption size %u ,"
8392 "offset %u = video size %u meta size %u off "
8395 video_data_size, metadata_size, ui32CCOffset);
8405 &ui32CCOffset, &ui32CCSize))
8409 video_data_size + metadata_size + ui32CCOffset;
8413 ni_dec_mastering_display_colour_volume_t* pColourVolume =
8414 (ni_dec_mastering_display_colour_volume_t*)((uint8_t*)pEntry + ui32CCOffset);
8417 pColourVolume->display_primaries_x[0],
8418 pColourVolume->display_primaries_y[0]);
8420 pColourVolume->display_primaries_x[1],
8421 pColourVolume->display_primaries_y[1]);
8423 pColourVolume->display_primaries_x[2],
8424 pColourVolume->display_primaries_y[2]);
8427 pColourVolume->white_point_x,
8428 pColourVolume->white_point_y);
8430 pColourVolume->max_display_mastering_luminance, pColourVolume->min_display_mastering_luminance);
8434 &ui32CCOffset, &ui32CCSize))
8438 video_data_size + metadata_size + ui32CCOffset;
8442 ni_content_light_level_info_t* pLightLevel =
8443 (ni_content_light_level_info_t*)((uint8_t*)pEntry + ui32CCOffset);
8445 pLightLevel->max_content_light_level, pLightLevel->max_pic_average_light_level);
8450 &ui32CCOffset, &ui32CCSize) ||
8453 &ui32CCOffset, &ui32CCSize))
8457 video_data_size + metadata_size + ui32CCOffset;
8499 ni_device_handle_t device_handle,
bool device_in_ctxt)
8501 int i, total_types = 0, total_modules = 0;
8509 if (!p_cap || !p_data)
8522 "ERROR: Previously in context device got an invalid vendor ID 0x%X SSVID 0x%X. Netint "
8523 "ID 0x%X. Retrying\n",
8527 (
int)
sizeof(p_id_data->
ai8Sn), p_id_data->
ai8Sn);
8529 (
int)
sizeof(p_id_data->
ai8Mn), p_id_data->
ai8Mn);
8531 (
int)
sizeof(p_id_data->
ai8Fr), p_id_data->
ai8Fr);
8535 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
8546 "ERROR: %s(): Retry got an invalid vendor ID too 0x%X SSVID "
8551 (
int)
sizeof(p_id_data->
ai8Sn), p_id_data->
ai8Sn);
8553 (
int)
sizeof(p_id_data->
ai8Mn), p_id_data->
ai8Mn);
8555 (
int)
sizeof(p_id_data->
ai8Fr), p_id_data->
ai8Fr);
8563 "Retry got valid a vendor ID 0x%X SSVID 0x%X. Netint ID 0x%X\n",
8606 "Error: mismatch; xcoder_num_elements: %d (calculated: %d) "
8607 "xcoder_num_devices: %d (calculated: %d)\n",
8664 "ERROR: Previously in context device is not a xcoder device "
8684 if (total_modules >= 1)
8699 if (total_modules >= 2)
8714 if (total_modules >= 3)
8729 if (total_modules >= 4)
8797static uint32_t presetGopSize[] = {
8817 int pos_byte = (pos/8);
8818 int pos_in_byte = pos%8;
8819 int remaining_bytes_in_current_byte = 8 - pos_in_byte;
8821 if (pos_in_byte == 0)
8823 vui[pos_byte] = (uint8_t)(value >> 24);
8824 vui[pos_byte+1] = (uint8_t)(value >> 16);
8825 vui[pos_byte+2] = (uint8_t)(value >> 8);
8826 vui[pos_byte+3] = (uint8_t)(value);
8830 vui[pos_byte] = vui[pos_byte] + (uint8_t)(value >> (32-remaining_bytes_in_current_byte));
8831 vui[pos_byte+1] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-8));
8832 vui[pos_byte+2] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-16));
8833 vui[pos_byte+3] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-24));
8834 vui[pos_byte+4] = vui[pos_byte+4] + ((uint8_t)(value << remaining_bytes_in_current_byte));
8849 uint32_t max_pkt_size)
8853 if ((!p_ctx) || (!p_cfg) || (!p_src))
8862 bool shift_params =
false;
8891 ni_log2(p_ctx,
NI_LOG_INFO,
"%s height %d width %d fps_number %d fps_denominator %d\n",
8901 shift_params =
true;
8902 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Output 2 used before output 1, Shifting output2 settings to output1 and disabling output 2\n");
8907 if (!shift_params || i == 0)
8913 j = (i == 1) ? 2 : 1;
8919 (uint16_t)((p_dec->
crop_whxy[j][0]) & 0xFFFE);
8921 (uint16_t)((p_dec->
crop_whxy[j][1]) & 0xFFFE);
8923 (uint16_t)((p_dec->
crop_whxy[j][2]) & 0xFFFE);
8925 (uint16_t)((p_dec->
crop_whxy[j][3]) & 0xFFFE);
8980 (int16_t)(p_dec->
scale_wh[j][0] & -2) : (int16_t)((p_dec->
scale_wh[j][0]+1) & 0xFFFE);
8982 (int16_t)(p_dec->
scale_wh[j][1] & -2) : (int16_t)((p_dec->
scale_wh[j][1]+1) & 0xFFFE);
8987 0 : (int16_t)((p_dec->
scale_wh[j][0]+1) & 0xFFFE);
8989 0 : (int16_t)((p_dec->
scale_wh[j][1]+1) & 0xFFFE);
9007 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): maxExtraHwFrameCnt is not support for FW < 6rB\n", __func__);
9015 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): (enableAdvancedEc == 2) is not support for FW < 6rO\n", __func__);
9022 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): (EcPolicy == limited_error) not supported for FW < 6ri\n", __func__);
9029 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): setting ecErrThreshold not supported for FW < 6ri\n", __func__);
9036 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): (EcPolicy == best_effort_out_dc) not supported for FW < 6s1\n", __func__);
9044 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): surviveStreamErr is not supported for FW < 6rl\n", __func__);
9053 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s():Not support to reduce dpb delay and reset.\n", __func__);
9112 if ((!p_ctx) || (!p_cfg) || (!p_src))
9167 ni_log2(p_ctx,
NI_LOG_DEBUG,
"force enable_mb_level_rc & enable_cu_level_rate_control to 0 because rate control is disabled\n");
9171 ni_log2(p_ctx,
NI_LOG_TRACE,
"### %s: b preset_index %d bitrate %d rcEnable %d %d EnableRdoQuant %d lookAheadDepth %d gop_preset_index %d rdoLevel %d vbv_buffer_size %d crf %d %f\n", __func__,
9183 if (p_enc->
crf != -1 || p_enc->
crfFloat != -1.0f) {
9186 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): CRF disabled due to preset enabled\n", __func__);
9225 ni_log2(p_ctx,
NI_LOG_DEBUG,
"### %s: Slow sequence happened retain last_bitrate %d. assigned bitrate %d\n",
9237 ni_log2(p_ctx,
NI_LOG_TRACE,
"### %s: a bitrate %d rcEnable %d %d EnableRdoQuant %d lookAheadDepth %d gop_preset_index %d rdoLevel %d vbv_buffer_size %d enable_cu_level_rate_control %d\n", __func__,
9291 ni_log2(p_ctx,
NI_LOG_DEBUG,
"### %s: Slow sequence happened retain last_framerate num %d den %d. assigned num %d den %d\n",
9308 uint32_t numUnitsInTick = 1000;
9393 "ERROR: %s() unknown value for p_t408->decoding_refresh_type: %d\n",
9417 ni_log2(p_ctx,
NI_LOG_DEBUG,
"force intraRefreshMode to 1 because quadra only supports intra refresh by rows\n");
9427 int mbRows = (p_cfg->
i32picHeight + mbHeight - 1) / mbHeight;
9462 "for profile 3 (extended) or 1 (baseline)\n");
9472 "force EnableRdoQuant 0 to accommodate HW limiation\n");
9592 if (p_enc->
crf != -1)
9740 "Turning off strongIntraSmoothing because hvsQPEnable=1 "
9741 "for better subjective VQ\n");
9753 "Turning off strongIntraSmoothing because hvsQPEnable=1 for "
9754 "better subjective VQ\n");
9788 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): spatialLayers is not supported for FW < 6rw\n", __func__);
9796 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): spatialLayers is not supported for FW < 6s0\n", __func__);
9814 ni_log(
NI_LOG_INFO,
"Warning h.265 psnr_y is only supported for YUV420P, YUV420P10LE, NV12, and P010LE\n");
9824 ni_log(
NI_LOG_INFO,
"Warning reconstructed frames only supported for YUV420P, NV12\n");
9830 ni_log(
NI_LOG_INFO,
"Warning reconstructed frames feature is not supported when cropWidth x cropHeight are set\n");
9840 ni_log(
NI_LOG_INFO,
"Warning get psnr feature only support YUV420P (except for h.265 psnr_y)\n");
9846 ni_log(
NI_LOG_INFO,
"Warning get psnr feature is not supported when cropWidth x cropHeight are set\n");
9883 int gopSize = g_map_preset_to_gopsize[lookAheadEnable][p_t408->
gop_preset_index + 1];
9889 if (lookAheadEnable)
9891 int firstGopEnd = gopSize + 1 + mulitcoreDelay;
9892 int lookaheadGopEnd = mulitcoreDelay ?
9895 int initialDelayNum = (firstGopEnd > lookaheadGopEnd) ? firstGopEnd : lookaheadGopEnd;
9897 int maxLookaheadQueue = initialDelayNum + (gopSize - 1) + mulitcoreDelay;
9900 p_ctx->
max_frame_delay = ((maxDelayNum > maxLookaheadQueue) ? maxDelayNum : maxLookaheadQueue) + (mulitcoreDelay ? 4 : 0);
9923 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: firstGopEnd %d lookaheadGopEnd %d initialDelayNum %d maxDelayNum %d maxLookaheadQueue %d\n",
9924 __FUNCTION__, firstGopEnd, lookaheadGopEnd, initialDelayNum, maxDelayNum, maxLookaheadQueue);
9932 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: preset %d lookAheadDepth %d gopSize %d mulitcoreDelay %d "
9933 "last_gop_size %d linitial_frame_delay %d current_frame_delay %d max_frame_delay %d\n",
9950 if (p_enc->
qcomp != (
float)0.6)
9970 if (p_enc->
ipRatio != (
float)1.4)
9975 if (p_enc->
pbRatio != (
float)1.3)
10000 if (p_enc->
crfFloat != (
float)-1.0)
10213 for (i = 0; i < 8; i++)
10461 if( (!p_ctx) || (!p_config) )
10733 p_config->
i8crf = -1;
10792 p_config->
i8crfMax = (int8_t)(-1) + 1;
10793 p_config->
i32qcomp = (int32_t)(0.6 * 1000) + 1000;
10797 p_config->
i32ipRatio = (int32_t)(1.4 * 1000) + 1000;
10798 p_config->
i32pbRatio = (int32_t)(1.3 * 1000) + 1000;
10799 p_config->
i32cplxDecay = (int32_t)(0.5 * 1000) + 1000;
10803 p_config->
i8pass1Qp = (int8_t)(-1) + 1;
10860 uint32_t max_err_len)
10866 char *p_param_warn = NULL;
10869 if (!p_ctx || !p_cfg || !p_param_err)
10887 memset(p_param_err, 0, max_err_len);
10888 memset(p_param_warn, 0, max_err_len);
10901 ni_strncpy(p_param_err, max_err_len,
"Incompatible output format: hw frame must be used if out1 or out2 used", max_err_len - 1);
10911 ni_strncpy(p_param_err, max_err_len,
"ddr_priority_mode not supported on device with FW api version < 6.e",
10920 ni_strncpy(p_param_err, max_err_len,
"LowDelay is not supported on jpeg/vp9 decoder",
10934 ni_strncpy(p_param_err, max_err_len,
"Invalid crop offset: extends past 48x48 minimum window", max_err_len - 1);
10941 ni_strncpy(p_param_err, max_err_len,
"Invalid crop w or h: must be at least 48x48 minimum window", max_err_len - 1);
10948 ni_strncpy(p_param_err, max_err_len,
"Invalid crop w or h: must be smaller than input", max_err_len - 1);
10955 ni_strncpy(p_param_err, max_err_len,
"Invalid crop rect: must fit in input", max_err_len - 1);
10964 ni_strncpy(p_param_err, max_err_len,
"Invalid crop value: even values only", max_err_len - 1);
10970 ni_strncpy(p_param_warn, max_err_len,
"crop param used but output not enabled!", max_err_len - 1);
10985 ni_strncpy(p_param_err, max_err_len,
"Invalid scale dimensions: zero", max_err_len - 1);
10993 ni_strncpy(p_param_err, max_err_len,
"Invalid scale value: even values only", max_err_len - 1);
11003 ni_strncpy(p_param_err, max_err_len,
"Invalid scale value: downscale only", max_err_len - 1);
11015 ni_strncpy(p_param_err, max_err_len,
"Invalid scale dimensions: downscale only after cropping", max_err_len - 1);
11022 ni_strncpy(p_param_warn, max_err_len,
"scale param used but output not enabled!", max_err_len - 1);
11030 ni_strncpy(p_param_warn, max_err_len,
"force8bit or semiPlanar used but output not enabled!", max_err_len - 1);
11045 "Invalid pairing: out=HW must be set with tiled format",
11052 ni_strncpy(p_param_err, max_err_len,
"Invalid pairing: VP9 not compatible with tiled format",
11064 "Invalid scale height: mult of 4 only, >= 128",
11074 "Invalid scale width: mult of 128 only, >= 144",
11086 "Invalid crop height: mult of 4 only, >= 128",
11096 "Invalid crop width: mult of 128 only, >= 144",
11104 ni_strncpy(p_param_err, max_err_len,
"Force 8 bit: not supported with tiled format\n", max_err_len - 1);
11114 ni_strncpy(p_param_err, max_err_len, p_param_warn, max_err_len - 1);
11119 free(p_param_warn);
11124static ni_retcode_t ni_check_level(
int level,
int codec_id,
int *level_index)
11126 const int l_levels_264[] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32,
11127 40, 41, 42, 50, 51, 52, 60, 61, 62, 0};
11128 const int l_levels_265[] = {10, 20, 21, 30, 31, 40, 41,
11129 50, 51, 52, 60, 61, 62, 0};
11130 const int l_levels_av1[] = {20, 21, 30, 31, 40, 41, 50, 51, 52, 53, 60, 61, 62, 63, 0};
11131 const int *l_levels = l_levels_264;
11143 l_levels = l_levels_265;
11146 l_levels = l_levels_av1;
11149 while (*l_levels != 0)
11151 if (*l_levels == level)
11153 *level_index = index;
11163static uint32_t get_max_pic_size(
ni_codec_format_t codecFormat , int32_t levelIdx )
11165 assert( levelIdx >= 0);
11166 int32_t level =
MAX(0, levelIdx);
11167 uint32_t maxPicSize = 0;
11169 switch( codecFormat )
11174 maxPicSize = max_pic_size_h265[ level ];
11180 maxPicSize = max_pic_size_h264[ level ];
11185 maxPicSize = max_pic_size_av1[ level ];
11195static uint64_t get_max_sample_rate_second(
ni_codec_format_t codecFormat , int32_t levelIdx )
11197 assert( levelIdx >= 0);
11198 int32_t level =
MAX(0, levelIdx);
11199 uint64_t maxSBPS = 0;
11201 switch( codecFormat )
11206 maxSBPS = max_sample_rate_second_h265[ level ];
11212 maxSBPS = max_sample_rate_second_h264[ level ];
11217 maxSBPS = max_sample_rate_second_av1[ level ];
11228static uint32_t get_max_cpb_bitrate(
ni_codec_format_t codecFormat , int32_t levelIdx, int32_t profile, int32_t tier, int32_t type )
11230 assert( levelIdx >= 0);
11231 int32_t level =
MAX(0, levelIdx);
11232 uint32_t maxBR = 0;
11234 switch( codecFormat )
11239 maxBR = (tier ==
HIGH_TIER) ? max_cpb_hightier_second_h265[ level ] : max_cpb_second_h265[ level ];
11245 float h264_high10_factor = 1;
11247 h264_high10_factor = 1.25;
11248 else if(profile == 5)
11249 h264_high10_factor = 3.0;
11251 maxBR = (uint32_t)(max_bitrate_h264[ level ] * h264_high10_factor);
11253 maxBR = (uint32_t)(max_cpb_second_h264[ level ] * h264_high10_factor);
11258 maxBR = ((level > 7) && (tier ==
HIGH_TIER)) ? max_cpb_hightier_second_av1[ level ] : max_cpb_second_av1[ level ];
11269static ni_retcode_t ni_check_level_tier_compliance(
int level,
11274 char* p_param_warn,
11275 uint32_t max_err_len,
11279 if( (!p_ctx) || (!p_cfg) || (!p_src) || (!p_param_err) || (!p_param_warn) || (!warning) )
11288 uint32_t max_pic_size = get_max_pic_size(p_ctx->
codec_format, level_index);
11289 uint64_t max_sample_rate_second = get_max_sample_rate_second(p_ctx->
codec_format, level_index);
11293 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): sample_per_picture %u sample_per_second %" PRIu64
" fr num %d den %d level_index %d\n",
11296 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): max_pic_size %d max_sample_rate_second %" PRIu64
" max_bitrate %u\n",
11297 __func__, max_pic_size, max_sample_rate_second, max_bitrate);
11299 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): i8crf %d i32bitRate %d ui32vbvMaxRate %u i32vbvBufferSize %d\n",
11302 if (p_cfg->
i8crf != -1)
11306 snprintf(p_param_warn, max_err_len,
"Level (%.1f): Switched crf to capped crf to be compliant with the level",
11315 ni_strncpy(p_param_warn, max_err_len,
"Enabled rate control because level parameter is used", max_err_len - 1);
11321 if(sample_per_picture > max_pic_size)
11323 snprintf(p_param_err, max_err_len,
"Invalid Encoder Level (%.1f): picture size %u exceeds supported limits %u",
11324 (
float) level/10, sample_per_picture, max_pic_size);
11328 if(sample_per_second > max_sample_rate_second)
11330 snprintf(p_param_err, max_err_len,
"Invalid Encoder Level (%.1f): picture sample rate %" PRIu64
" exceeds supported limits %" PRIu64
"",
11331 (
float) level/10, sample_per_second, max_sample_rate_second);
11335 if(p_cfg->
i32bitRate > (int32_t)max_bitrate)
11337 snprintf(p_param_warn, max_err_len,
"Level (%.1f): bitrate %d exceeds supported limit. Changed it to maximum %u",
11338 (
float) level/10, p_cfg->
i32bitRate, max_bitrate);
11345 snprintf(p_param_warn, max_err_len,
"Level (%.1f): vbvMaxRate %u exceeds supported limit. Changed it to maximum %u",
11365 uint32_t max_err_len)
11372 int level_index = 0;
11374 if( (!p_ctx) || (!p_cfg) || (!p_src) || (!p_param_err) )
11384 memset(p_param_err, 0, max_err_len);
11385 memset(p_param_warn, 0, max_err_len);
11389 ni_strncpy(p_param_err, max_err_len,
"Invalid frame_rate of 0 value", max_err_len - 1);
11397 ni_strncpy(p_param_err, max_err_len,
"Invalid i32frameRateInfo: too big", max_err_len - 1);
11405 ni_strncpy(p_param_err, max_err_len,
"Invalid i32bitRate: smaller than or equal to frame rate", max_err_len - 1);
11412 ni_strncpy(p_param_err, max_err_len,
"Invalid i32bitRate: too big", max_err_len - 1);
11419 ni_strncpy(p_param_err, max_err_len,
"Invalid i32bitRate: too low", max_err_len - 1);
11426 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Width: too small", max_err_len - 1);
11433 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Width: too big", max_err_len - 1);
11440 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Height: too small", max_err_len - 1);
11447 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Height: too big", max_err_len - 1);
11457 snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height (%u x %u): both need to be specified",
11465 snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height (%u x %uu): must be even",
11473 snprintf(p_param_err, max_err_len,
"Invalid Crop Width: less than %d",
11480 snprintf(p_param_err, max_err_len,
"Invalid Crop Height: less than %d",
11487 snprintf(p_param_err, max_err_len,
"Invalid Crop Width: exceeds %d",
11494 snprintf(p_param_err, max_err_len,
"Invalid Crop Height: exceeds %d",
11501 snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height: exceeds %d",
11511 snprintf(p_param_err, max_err_len,
"Invalid Crop Width: exceeds %d",
11518 snprintf(p_param_err, max_err_len,
"Invalid Crop Height: exceeds %d",
11525 snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height: exceeds %d",
11535 snprintf(p_param_err, max_err_len,
"Invalid Crop horOffset %u and/or verOffset %u: must be even",
11543 snprintf(p_param_err, max_err_len,
"Invalid Crop Width: offset %u + crop width %u too big > %d",
11550 snprintf(p_param_err, max_err_len,
"Invalid Crop Height: offset %u + crop height %u too big > %d",
11557 snprintf(p_param_err, max_err_len,
"roiEnable must disabled when Crop Width > 0 || Crop Height > 0");
11568 snprintf(p_param_err, max_err_len,
"Invalid Picture Width: exceeds %d",
11575 snprintf(p_param_err, max_err_len,
"Invalid Picture Height: exceeds %d",
11582 snprintf(p_param_err, max_err_len,
"Invalid Picture Width x Height: exceeds %d",
11592 ni_strncpy(p_param_err, max_err_len,
"Invalid input planar format: out of range", max_err_len - 1);
11601 ni_strncpy(p_param_err, max_err_len,
"Invalid input planar format for device with FW api version < 6.8",
11608 ni_strncpy(p_param_err, max_err_len,
"Invalid Encoder Selected: Tiled format must be on same device",
11616 "Invalid Picture Height: tiled format only supports "
11625 "Invalid Picture Width: tiled format only supports "
11640 ni_strncpy(p_param_err, max_err_len,
"zeroCopyMode must not be disabled for RGBA / BGRA / ABGR / ARGB pixel formats", max_err_len - 1);
11650 ni_strncpy(p_param_err, max_err_len,
"RGBA / BGRA pixel formats not supported on device with FW api version < 6.Y",
11664 snprintf(p_param_err, max_err_len,
"Unsupported pixel format %d in encoder", p_cfg->
ui8PixelFormat);
11674 ni_strncpy(p_param_err, max_err_len,
"ddr_priority_mode not supported on device with FW api version < 6.e",
11686 ni_strncpy(p_param_err, max_err_len,
"Invalid Encoder Level: out of range", max_err_len - 1);
11691 param_ret = ni_check_level_tier_compliance(
11692 p_src->
cfg_enc_params.
level_idc, p_ctx, p_cfg, p_src, p_param_err, p_param_warn, max_err_len, &warning, level_index);
11704 ni_strncpy(p_param_err, max_err_len,
"Invalid intra_mb_refresh_mode: out of range",
11716 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too small", max_err_len - 1);
11723 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too big", max_err_len - 1);
11736 "Invalid custom GOP paramaters: custom gop size must > 0",
11748 "Invalid custom GOP paramaters: selected gopPresetIdx is "
11749 "not compatible with custom gop",
11756 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too small", max_err_len - 1);
11763 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too big", max_err_len - 1);
11773 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: poc_offset larger"
11774 " than GOP size", max_err_len - 1);
11786 ni_strncpy(p_param_warn, max_err_len,
"useLowDelayPocType is only supported for H.264. Change useLowDelayPocType to 0", max_err_len - 1);
11795 "entropyCodingMode is only supported for H.264.",
11806 "av1ErrorResilientMode is only supported for AV1.",
11816 snprintf(p_param_err, max_err_len,
"%s is not supported for JPEG.",
11826 ni_strncpy(p_param_err, max_err_len,
"qLevel is only supported for JPEG.",
11839 ni_strncpy(p_param_warn, max_err_len,
"enableSSIM only supported on device with FW api version < 6.2 "
11840 "and the encoder is not av1_ni_quadra_enc. Reported ssim will be 0.", max_err_len - 1);
11849 ni_strncpy(p_param_err, max_err_len,
"sliceMode/sliceArg is only supported for H.264 or H.265.",
11858 int max_num_ctu_mb_row = (p_src->
source_height + ctu_mb_size - 1) / ctu_mb_size;
11862 snprintf(p_param_err, max_err_len,
"Invalid number of rows per slice: should be between 1 and %d",
11873 ni_strncpy(p_param_err, max_err_len,
"useLowDelayPocType is only supported for H.264.",
11886 ni_strncpy(p_param_warn, max_err_len,
"ui8enableCompensateQp only supported when device with FW api version < 6rt "
11887 "and the encoder is not av1_ni_quadra_enc and ui16maxFrameSize > 0. Reported enableCompensateQp will be 0.", max_err_len - 1);
11899 ni_strncpy(p_param_warn, max_err_len,
"enableTimecode does not need to be set for H.265. Use ni_enc_insert_timecode API"
11900 "from libxcoder directly to insert time code SEI", max_err_len - 1);
11904 ni_strncpy(p_param_warn, max_err_len,
"enableTimecode not supported for the codec used. Forcing value to 0.", max_err_len - 1);
11922 "this gopPreset is not supported for lookahead and/or CRF",
11930 bool bIsgopLowdelay =
true;
11938 bIsgopLowdelay =
false;
11944 bIsgopLowdelay =
false;
11948 if (bIsgopLowdelay)
11950 ni_strncpy(p_param_err, max_err_len,
"B-frames low delay custom gop is not supported for "
11951 "lookahead and/or CRF", max_err_len - 1);
11960 "bitrateMode is invalid when lookahead is enabled (or in CRF mode)",
11972 "totalCuTreeDepth is invalid without lookahead",
11980 ni_strncpy(p_param_warn, max_err_len,
"totalCuTreeDepth does not take effects when its value <= lookahead depth", max_err_len - 1);
11989 "totalCuTreeDepth is not supported in multicoreJointMode",
12002 "qpScaleEnable is invalid without lookahead",
12008 if (p_cfg->
i8crf < 0)
12011 "qpScaleEnable is only supported in CRF or Capped CRF modes",
12020 "adaptiveCrfMode is invalid when qpScaleEnable",
12043 "gopPresetIdx 2 is obsolete, suggest to use gopPresetIdx 9 "
12067 "gopPresetIdx 6 is obsolete, suggest to use gopPresetIdx 7 "
12105 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Force newRcEnable to 0 in 2-pass encode or in 1-pass average bitrate mode, with ipRatio, VbvMaxRate, or VbvMinRate\n");
12117 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Set newRcEnable to 0 in spatial layer separated rate control mode\n");
12130 ni_strncpy(p_param_warn, max_err_len,
"StillImageDetect or SceneChangeDetect only support gopPresetIdx=9 with FW > 6rm\n", max_err_len - 1);
12141 "currently do not support gop preset in multi spatial layers encode or spatial layer separated rate control mode",
12155 "higher spatial layers referencing base layer is only supported in multi spatial layers encode",
12173 ni_strncpy(p_param_err, max_err_len,
"number of values specified in spatialLayerBitrate must match the total number of spatial layers", max_err_len - 1);
12183 ni_strncpy(p_param_err, max_err_len,
"spatialLayerBitrate is not supported in multicoreJointMode for FW api version < 6sD", max_err_len - 1);
12201 ni_strncpy(p_param_err, max_err_len,
"Invalid av1OpLevel: out of range", max_err_len - 1);
12206 param_ret = ni_check_level_tier_compliance(
12207 p_cfg->
ui8av1OpLevel[i], p_ctx, p_cfg, p_src, p_param_err, p_param_warn, max_err_len, &warning, level_index);
12218 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel and level cannot be both specified", max_err_len - 1);
12225 ni_strncpy(p_param_err, max_err_len,
"number of values specified in av1OpLevel must match the total number of spatial layers", max_err_len - 1);
12236 "crfMaxIframeEnable is only supported in Capped CRF mode with lookahead enabled",
12252 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 5 (high10)",
12262 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (baseline), 2 (main),"
12263 " 3 (extended), 4 (high), or 5 (high10)", max_err_len - 1);
12274 ni_strncpy(p_param_err, max_err_len,
"Invalid gopPresetIdx for H.264 baseline profile:"
12275 " must be 1, 2, 6 or 0 (custom with no B frames)", max_err_len - 1);
12287 ni_strncpy(p_param_err, max_err_len,
"H.264 baseline profile: custom GOP can not "
12288 "have B frames", max_err_len - 1);
12299 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (baseline), 2 (main),"
12300 " 4 (high), or 5 (high10)", max_err_len - 1);
12306 ni_strncpy(p_param_warn, max_err_len,
"AVC Baseline/Main/High Profile do not support 10-bit, auto convert to 8-bit", max_err_len - 1);
12317 ni_strncpy(p_param_err, max_err_len,
"H.264 baseline profile: custom GOP can not "
12318 "have B frames", max_err_len - 1);
12333 "Must use gopPresetIdx 1,9,10 (no "
12334 "B frames) for profile 1",
12344 ni_strncpy(p_param_err, max_err_len,
"Tier is not supported for H.264", max_err_len - 1);
12351 "spatialLayers is not supported for h.264 encode",
12358 ni_strncpy(p_param_err, max_err_len,
"disableAv1TimingInfo is not supported for h.264",
12365 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel is not supported for h.264",
12380 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 2 (main10)",
12390 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (main) or 2 (main10)",
12401 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (main) or 2 (main10)",
12408 ni_strncpy(p_param_warn, max_err_len,
"HEVC Main Profile does not support 10-bit, auto convert to 8-bit", max_err_len - 1);
12414 "spatialLayers is not supported for h.265 encode",
12421 ni_strncpy(p_param_err, max_err_len,
"disableAv1TimingInfo is not supported for h.265",
12428 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel is not supported for h.265",
12435 ni_strncpy(p_param_err, max_err_len,
"getBitstreamFeatures is not supported for h.265 encoder",
12445 ni_strncpy(p_param_err, max_err_len,
"TuneBframeVisual MEDIUM is not supported for AV1", max_err_len - 1);
12451 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (main)",
12462 "AV1 level < 2.0 is not supported, change to level 2.0",
12469 "AV1 level > 6.3 is not supported, change to level 6.3",
12479 ni_strncpy(p_param_warn, max_err_len,
"confWinTop is not supported in AV1",
12487 ni_strncpy(p_param_warn, max_err_len,
"confWinBottom is not supported in AV1",
12495 ni_strncpy(p_param_warn, max_err_len,
"confWinLeft is not supported in AV1",
12503 ni_strncpy(p_param_warn, max_err_len,
"confWinRight is not supported in AV1",
12510 "masterDisplay not supported for AV1",
12516 ni_strncpy(p_param_err, max_err_len,
"hrdEnable is not supported on av1 encoder",
12523 ni_strncpy(p_param_err, max_err_len,
"enableAUD is not supported on av1 encoder",
12530 ni_strncpy(p_param_err, max_err_len,
"maxCLL is not supported on av1 encoder",
12537 ni_strncpy(p_param_err, max_err_len,
"repeatHeaders is not supported on av1 encoder",
12543 ni_strncpy(p_param_err, max_err_len,
"enableSSIM is not supported on av1 encoder",
12550 ni_strncpy(p_param_err, max_err_len,
"EnableRdoQuant is not supported on av1 encoder",
12557 ni_strncpy(p_param_err, max_err_len,
"fillerEnable is not supported on av1 encoder",
12564 ni_strncpy(p_param_err, max_err_len,
"ppsInitQp is not supported for av1 encoder",
12571 ni_strncpy(p_param_err, max_err_len,
"vbvBufferReencode is not supported for av1 multicoreJointMode", max_err_len - 1);
12577 ni_strncpy(p_param_err, max_err_len,
"getBitstreamFeatures is not supported for av1 encoder",
12586 ni_strncpy(p_param_err, max_err_len,
"crop Parameters not supported for JPEG", max_err_len - 1);
12592 ni_strncpy(p_param_err, max_err_len,
"Tier is not supported for JPEG", max_err_len - 1);
12598 ni_strncpy(p_param_err, max_err_len,
"TuneBframeVisual is not supported for JPEG", max_err_len - 1);
12605 "masterDisplay not supported for jpeg",
12611 ni_strncpy(p_param_err, max_err_len,
"confWinTop is not supported in jpeg",
12618 ni_strncpy(p_param_err, max_err_len,
"confWinBottom is not supported in jpeg",
12625 ni_strncpy(p_param_err, max_err_len,
"confWinLeft is not supported in jpeg",
12632 ni_strncpy(p_param_err, max_err_len,
"confWinRight is not supported in jpeg",
12639 ni_strncpy(p_param_err, max_err_len,
"hrdEnable is not supported on jpeg encoder",
12646 ni_strncpy(p_param_err, max_err_len,
"enableAUD is not supported on jpeg encoder",
12653 ni_strncpy(p_param_err, max_err_len,
"repeatHeaders is not supported on jpeg encoder",
12660 ni_strncpy(p_param_err, max_err_len,
"prefTRC is not supported on jpeg encoder",
12667 ni_strncpy(p_param_err, max_err_len,
"maxCLL is not supported on jpeg encoder",
12674 ni_strncpy(p_param_err, max_err_len,
"colorPri is not supported on jpeg encoder",
12681 ni_strncpy(p_param_err, max_err_len,
"colorTrc is not supported on jpeg encoder",
12688 ni_strncpy(p_param_err, max_err_len,
"colorSpc is not supported on jpeg encoder",
12695 ni_strncpy(p_param_err, max_err_len,
"sarNum is not supported on jpeg encoder",
12702 ni_strncpy(p_param_err, max_err_len,
"sarDenom is not supported on jpeg encoder",
12710 "videoFullRangeFlag is not supported on jpeg encoder",
12718 "temporalLayersEnable is not supported on jpeg encoder",
12726 "spatialLayers is not supported for jpeg encode",
12733 ni_strncpy(p_param_err, max_err_len,
"LowDelay is not supported on jpeg encoder",
12740 ni_strncpy(p_param_err, max_err_len,
"rdoLevel is not supported on jpeg encoder",
12747 ni_strncpy(p_param_err, max_err_len,
"EnableRdoQuant is not supported on jpeg encoder",
12755 "enable2PassGop is not supported on jpeg encoder",
12763 "lookAheadDepth is not supported on jpeg encoder",
12771 "gopPresetIdx is not supported on jpeg encoder",
12778 ni_strncpy(p_param_err, max_err_len,
"roiEnable is not supported on jpeg encoder",
12786 "RoiDemoMode is not supported on jpeg encoder",
12793 ni_strncpy(p_param_err, max_err_len,
"cacheRoi is not supported on jpeg encoder",
12801 "ReconfDemoMode is not supported on jpeg encoder",
12809 "intraRefreshMode is not supported on jpeg encoder",
12817 "intraRefreshArg is not supported on jpeg encoder",
12825 "intraPeriod is not supported on jpeg encoder",
12833 p_param_err, max_err_len,
12834 "IntraRefreshResetOnForceIDR is not supported on jpeg encoder",
12842 "longTermReferenceEnable is not supported on jpeg encoder",
12850 "longTermReferenceInterval is not supported on jpeg encoder",
12858 "longTermReferenceCount is not supported on jpeg encoder",
12866 "multicoreJointMode is not supported on jpeg encoder",
12873 ni_strncpy(p_param_err, max_err_len,
"enableSSIM is not supported on jpeg encoder",
12881 "vbvBufferSize is not supported on jpeg encoder",
12889 "fillerEnable is not supported on jpeg encoder",
12896 ni_strncpy(p_param_err, max_err_len,
"picSkip is not supported on jpeg encoder",
12903 ni_strncpy(p_param_err, max_err_len,
"maxFrameSize is not supported on jpeg encoder",
12911 "cuLevelRCEnable is not supported on jpeg encoder",
12918 ni_strncpy(p_param_err, max_err_len,
"hvsQPEnable is not supported on jpeg encoder",
12925 ni_strncpy(p_param_err, max_err_len,
"profile is not supported on jpeg encoder",
12932 ni_strncpy(p_param_err, max_err_len,
"intraRefreshMode or intraRefreshArg is not supported on jpeg encoder",
12937 if (p_cfg->
i8crf != -1)
12939 ni_strncpy(p_param_err, max_err_len,
"crf is not supported on jpeg encoder",
12946 ni_strncpy(p_param_err, max_err_len,
"tolCtbRcInter is not supported on jpeg encoder",
12953 ni_strncpy(p_param_err, max_err_len,
"tolCtbRcIntra is not supported on jpeg encoder",
12961 "rcQpDeltaRange is not supported on jpeg encoder",
12968 ni_strncpy(p_param_err, max_err_len,
"bitrateWindow is not supported on jpeg encoder",
12975 ni_strncpy(p_param_err, max_err_len,
"ctbRowQpStep is not supported on jpeg encoder",
12983 "enableAIEnhance is not supported on jpeg encoder",
12990 ni_strncpy(p_param_err, max_err_len,
"ppsInitQp is not supported for jpeg encoder",
12997 ni_strncpy(p_param_err, max_err_len,
"pass1Qp is not supported for jpeg encoder",
13004 ni_strncpy(p_param_err, max_err_len,
"bitrateMode is not supported for jpeg encoder",
13012 "vbvBufferReencode is not supported on jpeg encoder",
13020 "getPsnrMode or getReconstructedMode is not supported on jpeg encoder",
13028 "spatialLayers is not supported for Jpeg encode",
13035 ni_strncpy(p_param_err, max_err_len,
"disableAv1TimingInfo is not supported for Jpeg",
13042 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel is not supported for Jpeg",
13050 "getBitstreamFeatures is not supported for jpeg encoder",
13059 ni_strncpy(p_param_err, max_err_len,
"Invalid forceFrameType: out of range",
13067 ni_strncpy(p_param_err, max_err_len,
"Invalid forcedHeaderEnable: out of range",
13076 ni_strncpy(p_param_err, max_err_len,
"Invalid decoding_refresh_type: out of range", max_err_len - 1);
13086 ni_strcpy(p_param_err, max_err_len,
"Invalid gop_preset_index: out of range");
13099 ni_strcpy(p_param_err, max_err_len,
"GOP size must be 1 when lowDelay is enabled");
13108 ni_strncpy(p_param_err, max_err_len,
"Invalid gopSize out of range", max_err_len - 1);
13116 ni_strncpy(p_param_err, max_err_len,
"GOP size must be <= 4 for low delay GOP", max_err_len - 1);
13125 ni_strncpy(p_param_err, max_err_len,
"Invalid LookAheadDepth: out of range. <[4-40]>", max_err_len - 1);
13131 ni_strncpy(p_param_err, max_err_len,
"2-pass encode does not support low delay GOP", max_err_len - 1);
13137 ni_strncpy(p_param_err, max_err_len,
"2-pass encode does not support tile4x4 format",
13144 ni_strncpy(p_param_err, max_err_len,
"currently do not support lookahead encode with multi spatial layers", max_err_len - 1);
13159 ni_strncpy(p_param_err, max_err_len,
"Custom GOP must not include backward prediction when lowDelay is enabled", max_err_len - 1);
13161 ni_strncpy(p_param_err, max_err_len,
"Custom GOP must not include backward prediction when picSkip is enabled", max_err_len - 1);
13174 ni_strncpy(p_param_err, max_err_len,
"Must use low delay GOP (gopPresetIdx 1,3,7,9,10) when lowDelay is enabled", max_err_len - 1);
13181 ni_strncpy(p_param_err, max_err_len,
"Must use low delay GOP (gopPresetIdx 1,3,7,9,10) when picSkip is enabled", max_err_len - 1);
13188 ni_strncpy(p_param_err, max_err_len,
"lookAheadDepth must be 0 when lowDelay is enabled", max_err_len - 1);
13190 ni_strncpy(p_param_err, max_err_len,
"lookAheadDepth must be 0 when picSkip is enabled", max_err_len - 1);
13199 "Cannot use multicoreJointMode when lowDelay is enabled",
13203 "Cannot use multicoreJointMode when picSkip is enabled",
13213 "Cannot enable minFramesDelay when lowDelay is enabled",
13217 "Cannot enable minFramesDelay when picSkip is enabled",
13234 ni_strncpy(p_param_err, max_err_len,
"Custom GOP size must be 1 when useLowDelayPocType is enabled", max_err_len - 1);
13240 ni_strncpy(p_param_err, max_err_len,
"Must use GOP with all frames as reference frames (gopPresetIdx 1,3,7,9) when useLowDelayPocType is enabled", max_err_len - 1);
13263 "minimum frame size %d bytes in low delay mode\n", __func__,
13269 "mode. Set it to half of the maximum frame size %d bytes\n",
13276 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: maxFrameSize %u is too small. Changed to minimum value (bitrate/framerate in byte): %u\n",
13285 ni_strncpy(p_param_err, max_err_len,
"maxFrameSize can only be used when lowDelay is enabled", max_err_len - 1);
13302 ni_strncpy(p_param_err, max_err_len,
"Custom GOP can not have B frames for intra refresh", max_err_len - 1);
13313 "Must use gopPresetIdx 9 (consecutive P frame) for intra refresh",
13318 ni_strncpy(p_param_warn, max_err_len,
"GOP size forced to 1 and low delay GOP force disabled (no B frames) for intra refresh", max_err_len - 1);
13326 "intra refresh cycle (height / intraRefreshArg MB or CTU) must > 1",
13333 ni_strncpy(p_param_err, max_err_len,
"lookaheadDepth must be 0 for intra refresh", max_err_len - 1);
13342 ni_strncpy(p_param_warn, max_err_len,
"intraPeriod forced to match intra refersh cycle (intraPeriod must >= intra refersh cycle)", max_err_len - 1);
13351 ni_strncpy(p_param_warn, max_err_len,
"intraPeriod forced to match intra refersh cycle (intraPeriod must >= intra refersh cycle)", max_err_len - 1);
13362 ni_strncpy(p_param_warn, max_err_len,
"HRD conformance is not guaranteed in multicoreJointMode", max_err_len - 1);
13371 snprintf(p_param_err, max_err_len,
"HRD conformance with multiple temporal layers is currently not supported");
13397 snprintf(p_param_err, max_err_len,
"vbvMaxRate %u cannot be smaller than bitrate %d",
13409 snprintf(p_param_err, max_err_len,
"vbvMinRate %u cannot be larger than bitrate %d",
13424 snprintf(p_param_err, max_err_len,
"vbvBufferSize must be greater than the average frame size. Minimum is %d msec for framerate %d fps",
13436 snprintf(p_param_warn, max_err_len,
"vbvBufferSize cannot be smaller than one frame size based on vbvMaxRate, force vbvBufferSize to %d msec for bitrate %d vbvMaxRate %u and framerate %d fps",
13448 snprintf(p_param_warn, max_err_len,
"vbvBufferSize cannot be smaller than one frame size based on vbvMinRate, force vbvBufferSize to %d msec for bitrate %d vbvMinRate %u and framerate %d fps",
13460 snprintf(p_param_warn, max_err_len,
"vbvMaxRate %u vbvMinRate %u does not take effect when vbvBufferSize is 0, force vbvMaxRate vbvMinRate to 0",
13473 "Can't enable ltrRefInterval and longTermReferenceEnable "
13484 ni_strncpy(p_param_err, max_err_len,
"Custom GOP size can not be > 1 for long term reference", max_err_len - 1);
13494 "Must use low delay GOP (gopPresetIdx 1,3,7,9) for long term reference",
13499 ni_strncpy(p_param_warn, max_err_len,
"GOP size forced to 1 for long term reference", max_err_len - 1);
13506 ni_strncpy(p_param_err, max_err_len,
"lookaheadDepth must be 0 for long term reference", max_err_len - 1);
13510 if (p_cfg->
i8crf >= 0)
13512 ni_strncpy(p_param_err, max_err_len,
"crf must < 0 for long term reference", max_err_len - 1);
13521 p_param_err, max_err_len,
13522 "Must set longTermReferenceEnable for longTermReferenceInterval",
13532 ni_strncpy(p_param_warn, max_err_len,
"AV1 err resilient mode forced to 0 when using other codecs", max_err_len - 1);
13542 ni_strncpy(p_param_warn, max_err_len,
"Motion Constrained mode force disabled for codecs other than HEVC", max_err_len - 1);
13551 p_param_err, max_err_len,
13552 "rdoLevel must be 1 for Motion Constrained mode 1 or 2",
13563 p_param_err, max_err_len,
13564 "multicoreJointMode must be 0 for Motion Constrained mode 2",
13575 p_param_err, max_err_len,
13576 "input resolution (or cropping window) must be 64x64 aligned for Motion Constrained mode 2",
13590 ni_strncpy(p_param_warn, max_err_len,
"AVCC HVCC forced to 0 for codecs other than AVC HEVC", max_err_len - 1);
13604 "getBitstreamFeatures is only supported for gopPresetIndex 1, 3, 7, 9",
13613 "getBitstreamFeatures is not supported when Crop Width > 0 || Crop Height > 0",
13624 "getBitstreamFeatures is not supported in FW API version < 6sM\n",
13635 ni_strncpy(p_param_err, max_err_len,
"Invalid cu_size_mode: out of range", max_err_len - 1);
13645 ni_strncpy(p_param_err, max_err_len,
"Invalid use_recommend_enc_params: out of range", max_err_len - 1);
13663 ni_strncpy(p_param_err, max_err_len,
"Invalid max_num_merge: out of range", max_err_len - 1);
13677 ni_strncpy(p_param_err, max_err_len,
"Invalid intra_qp: out of range", max_err_len - 1);
13684 if (p_cfg->
i8crf >= 0 && p_cfg->
i8crf <= 51)
13691 ni_strncpy(p_param_err, max_err_len,
"CRF requres LookAheadDepth <[4-40]>", max_err_len - 1);
13699 ni_strncpy(p_param_warn, max_err_len,
"enable lookahead of current frame", max_err_len - 1);
13706 ni_strncpy(p_param_err, max_err_len,
"CRF requires RcEnable 0", max_err_len - 1);
13713 ni_strncpy(p_param_warn,
sizeof(p_param_warn),
"Lookahead with cuLevelRCEnable or hvsQPEnable may degrade quality", max_err_len - 1);
13724 ni_strncpy(p_param_err, max_err_len,
"tuneBframeVisual level 1 (medium) requires lookahead or crf encode", max_err_len - 1);
13734 ni_strncpy(p_param_err, max_err_len,
"Invalid enable_mb_level_rc: out of range", max_err_len - 1);
13743 ni_strncpy(p_param_err, max_err_len,
"Invalid min_qp: out of range", max_err_len - 1);
13751 ni_strncpy(p_param_err, max_err_len,
"Invalid max_qp: out of range", max_err_len - 1);
13759 ni_strncpy(p_param_err, max_err_len,
"Invalid enable_cu_level_rate_control: out of range", max_err_len - 1);
13769 ni_strncpy(p_param_err, max_err_len,
"Invalid enable_hvs_qp: out of range", max_err_len - 1);
13779 ni_strncpy(p_param_err, max_err_len,
"Invalid max_delta_qp: out of range", max_err_len - 1);
13788 ni_strncpy(p_param_err, max_err_len,
"Invalid i32vbvBufferSize: out of range", max_err_len - 1);
13811 ni_strncpy(p_param_err, max_err_len, p_param_warn, max_err_len - 1);
13815 free(p_param_warn);
13821 char *p_param_err, uint32_t max_err_len)
13824 int32_t low_delay = 0;
13825 int32_t intra_period_gop_step_size;
13828 if (!p_param || !p_src || !p_param_err)
13837 memset(p_param_err, 0, max_err_len - 1);
13871 intra_period_gop_step_size = 1;
13888 ni_strncpy(p_param_err, max_err_len,
"Invalid intra_period and gop_preset_index: gop structure is larger than intra period", max_err_len - 1);
13893 if (((!low_delay) && (p_param->
intra_period != 0) && ((p_param->
intra_period % intra_period_gop_step_size) != 0)) ||
13896 ni_strncpy(p_param_err, max_err_len,
"Invalid intra_period and gop_preset_index: intra period is not a multiple of gop structure size", max_err_len - 1);
13909 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id larger than 7", max_err_len - 1);
13916 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id is zero or negative", max_err_len - 1);
13921 if (min_poc > temp_poc[i])
13923 min_poc = temp_poc[i];
13931 if (temp_poc[j] == min_poc)
13940 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: poc_offset is invalid", max_err_len - 1);
13956 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id larger than 7", max_err_len - 1);
13963 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id is negative", max_err_len - 1);
13972 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: ref pic delta cannot be 0", max_err_len - 1);
13983 ni_log(
NI_LOG_ERROR,
"g%drefPic%d specified without g%drefPic%dUsed specified!\n", i, j, i, j);
13990 if (min_poc > temp_poc[i])
13992 min_poc = temp_poc[i];
14000 if (temp_poc[j] == min_poc)
14009 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: poc_offset is invalid", max_err_len - 1);
14027 if (((p_param->
cu_size_mode & 0x1) == 0) && ((align_8_width_flag != 0) || (align_8_height_flag != 0)))
14029 ni_strncpy(p_param_err, max_err_len,
"Invalid use_recommend_enc_params and cu_size_mode: picture width and height must be aligned with 8 pixels when enable CU8x8 of cu_size_mode. Recommend to set cu_size_mode |= 0x1 (CU8x8)", max_err_len - 1);
14033 else if (((p_param->
cu_size_mode & 0x1) == 0) && ((p_param->
cu_size_mode & 0x2) == 0) && ((align_16_width_flag != 0) || (align_16_height_flag != 0)))
14035 ni_strncpy(p_param_err, max_err_len,
"Invalid use_recommend_enc_params and cu_size_mode: picture width and height must be aligned with 16 pixels when enable CU16x16 of cu_size_mode. Recommend to set cu_size_mode |= 0x2 (CU16x16)", max_err_len - 1);
14039 else if (((p_param->
cu_size_mode & 0x1) == 0) && ((p_param->
cu_size_mode & 0x2) == 0) && ((p_param->
cu_size_mode & 0x4) == 0) && ((align_32_width_flag != 0) || (align_32_height_flag != 0)))
14041 ni_strncpy(p_param_err, max_err_len,
"Invalid use_recommend_enc_params and cu_size_mode: picture width and height must be aligned with 32 pixels when enable CU32x32 of cu_size_mode. Recommend to set cu_size_mode |= 0x4 (CU32x32)", max_err_len - 1);
14050 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_top: out of range", max_err_len - 1);
14056 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_top: not multiple of 2", max_err_len - 1);
14063 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_bottom: out of range", max_err_len - 1);
14069 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_bottom: not multiple of 2", max_err_len - 1);
14076 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_left: out of range", max_err_len - 1);
14082 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_left: not multiple of 2", max_err_len - 1);
14089 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_right: out of range", max_err_len - 1);
14095 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_right: not multiple of 2", max_err_len - 1);
14109 if( (!p_cfg) || (!p_param_err) )
14119 memset(p_param_err, 0, max_err_len - 1);
14123 ni_strncpy(p_param_err, max_err_len,
"Invalid roiEnable: out of range", max_err_len - 1);
14130 ni_strncpy(p_param_err, max_err_len,
"hvsQPEnable and roiEnable: not mutually exclusive", max_err_len - 1);
14139 ni_strncpy(p_param_err, max_err_len,
"Invalid min_qp(P/B) and max_qp(P/B): min_qp cannot be larger than max_qp", max_err_len - 1);
14160 if (!p_encoder_params)
14289 ni_pthread_mutex_t *p_mutex;
14294 struct sched_param sched_param;
14300 sigfillset(&signal);
14311 if (((sched_param.sched_priority = sched_get_priority_max(SCHED_RR)) ==
14313 sched_setscheduler(syscall(SYS_gettid), SCHED_RR, &sched_param) < 0)
14319 if (setpriority(PRIO_PROCESS, 0, -20) != 0)
14327#elif defined(_WIN32)
14332 if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL) ==
14343 char name[16] = {0};
14344 snprintf(name,
sizeof(name),
"%s%.2x%.4x",
"KAT", args->
hw_id, args->
session_id);
14346 prctl(PR_SET_NAME, name);
14348 pthread_setname_np(name);
14372 "%s creation timeout. session_id=0x%X requested timeout: %" PRIu64
14373 "ns, ping time delta: %" PRIu64
"ns\n ",
14403 session_ctx->
hw_id,
14422 session_ctx->
hw_id,
14427 "Persistent failures detected, %s() line-%d: session_no 0x%x sess_err_no %u "
14428 "inst_err_no %u\n",
14441 "%s was possibly blocked. session_id=0x%X requested timeout: %" PRIu64
14442 "ns, ping time delta: %" PRIu64
"ns\n ",
14463 endtime += interval;
14508 void * p_buffer = NULL;
14509 uint32_t ui32LBA = 0;
14510 uint32_t modelled_load;
14584 "ERROR %s(): p_ctx->device_handle=%" PRIx64
14585 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
14593 "Uploader open session ID:0x%x,timestamp:%" PRIu64
"\n",
14597 uint64_t keep_alive_timeout =
14600 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
14602 keep_alive_timeout);
14613 "ERROR %s(): nvme write keep_alive_timeout command "
14614 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
14638 modelled_load >>= 10;
14643 memcpy(p_buffer, &modelled_load, 4);
14674 "%s(): p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, "
14675 "p_ctx->session_id=%d\n",
14680#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OPEN_HARMONY__) && !defined(_ANDROID)
14684 retval = p2p_fill_pcie_address(p_ctx);
14708 if (!src_p_ctx || !dst_p_ctx)
14710 ni_log(
NI_LOG_ERROR,
"ERROR %s(): passed parameters are null!, return\n", __func__);
14721 if (src_p_ctx->
isP2P)
14726 dst_p_ctx->
bus = src_p_ctx->
bus;
14727 dst_p_ctx->
dev = src_p_ctx->
dev;
14728 dst_p_ctx->
fn = src_p_ctx->
fn;
14751 int query_retry = 0;
14763 "Session=0x%x: %s buffered_frame_index=%d return %d\n",
14773 query_sleep(p_ctx);
14774 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: query by ni_query_instance_buf_info INST_BUF_INFO_RW_UPLOAD\n", __func__);
14785 if (query_retry >=500)
14788 "scaler write exceeded max query retries. rc=%d try=%d\n",
14789 retval, query_retry);
14811 "Session=0x%x: %s got FrameIndex=%u buffered_frame_index=%d\n",
14821 "%s Warning scalar read hwdesc fail rc %d or ind !\n",
14843 uint32_t frame_size_bytes = 0;
14844 uint32_t retry_count = 0;
14863 abs_time_ns, p_frame->pts);
14874 query_sleep(p_ctx);
14883 if (retry_count >= 500)
14886 "hwupload write exceeded max query retries. rc=%d try=%d"
14888 retval, retry_count);
14912 "size %u >= frame size %u , retry %u\n",
14951 uint32_t sent_size = 0;
14952 uint32_t frame_size_bytes = 0;
14953 uint32_t retry_count = 0;
14962 if (!p_ctx || !p_frame)
14981#ifdef MEASURE_LATENCY
14986 abs_time_ns, p_frame->
pts);
15010 query_sleep(p_ctx);
15019 if (retry_count >= 500)
15022 "hwupload write exceeded max query retries. rc=%d try=%d"
15024 retval, retry_count);
15045 "size %u >= frame size %u , retry %u\n",
15050#ifdef XCODER_TIMESTAMP_DTS_ENABLED
15056 "ERROR %s(): ni_timestamp_register() for dts "
15069 if (separate_metadata)
15074 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR %s(): uploader separated metadata not supported on device with FW api version < 6.S\n",
15082 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR %s(): p_metadata_buffer is NULL, allocation failed?\n",
15092 if (separate_start)
15105 "%s(): %d.%u p_ctx->frame_num=%" PRIu64
", "
15106 "p_frame->video_width=%u, p_frame->video_height=%u, "
15107 "start_len [%u,%u,%u] inconsecutive_transfer %u\n",
15113 uint32_t ui32LBA_metadata =
15116 "%s: p_metadata_buffer = %p, metadata_buffer_size "
15117 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15141 if (separate_start)
15154 "%s: p_start_buffer = %p, p_frame->start_buffer_size "
15155 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15183 "%s: p_data = %p, p_frame->buffer_size "
15184 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15191 if (separate_start)
15216 "%s: p_data = %p, p_frame->buffer_size = %u, "
15217 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15221 sent_size = frame_size_bytes;
15222 if (separate_start)
15250 size = frame_size_bytes;
15252#ifdef XCODER_DUMP_DATA
15253 char dump_file[256];
15254 snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-hwup-fme/fme-%04ld.yuv",
15267#ifdef MEASURE_LATENCY
15306 int query_retry = 0;
15310 if (!p_ctx || !hwdesc)
15328 query_sleep(p_ctx);
15347 if (query_retry >= 1000)
15389 void* p_buffer = NULL;
15391 uint32_t ui32LBA = 0;
15416 NI_INVALID_DEVICE_HANDLE, p_buffer,
15445 uint64_t frame_offset = 0;
15446 uint32_t frame_dropped = 0;
15447 uint8_t *p_data_buffer = NULL;
15453 uint32_t total_bytes_to_read = 0;
15454 uint32_t total_yuv_met_size = 0;
15455 uint32_t read_size_bytes = 0;
15457 int query_retry = 0;
15458 uint32_t ui32LBA = 0;
15459 unsigned int bytes_read_so_far = 0;
15461 int low_delay_notify = 0;
15463 uint32_t frames_dropped = 0;
15465 uint8_t get_first_metadata = 0;
15466 uint8_t sequence_change = 0;
15470 if (!p_ctx || !p_frame)
15489 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
15494 total_bytes_to_read = p_frame->
data_len[3] + metadata_hdr_size;
15497 "Total bytes to read %u total_yuv_met_size %u, low_delay %u\n",
15518 query_sleep(p_ctx);
15527 &sessionStatistic);
15551 if (query_retry >= 1000)
15554 "\n", query_retry, retval);
15556 low_delay_notify = 1;
15571 "Dec read desc only hdr metadata is available. Seq change may "
15572 "have occured.\n");
15573 total_bytes_to_read = metadata_hdr_size;
15574 sequence_change = 1;
15578 ni_log2(p_ctx,
NI_LOG_TRACE,
"Dec read desc buf_size < frame_size. Retry %d\n", query_retry);
15584 "Dec read desc query, ready_to_close %u, query eos\n",
15599 "WARNING: Dec read desc query eos reached but exceeded max "
15600 "retries. is_flushed=%u try=%d.\n",
15605 "Dec read desc query eos reached. is_flushed=%u try=%d"
15610 low_delay_notify = 1;
15617 "Dec read desc available buf size == %d, query try %d, "
15631 query_retry < 1000 / 2)
15638 low_delay_signal(p_ctx);
15646 "size %u >= required size %u !\n",
15664 low_delay_signal(p_ctx);
15667 "input (B frames)? Just cancel the low delay mode then\n");
15670 low_delay_signal(p_ctx);
15680 if(query_retry <= 2000)
15689 "Warning: decoder pkt_num %u frame_num %u "
15690 "timeout, increasing pkt_delay_cnt to %u\n",
15697 "\n", query_retry, retval);
15713 "At least %d packets should be sent before reading the "
15730 "%ux%u frame-rate %u is_flushed %u\n",
15758 total_bytes_to_read = p_frame->
data_len[3] + metadata_hdr_size;
15759 p_data_buffer = (uint8_t*)p_frame->
p_buffer;
15769 ni_log2(p_ctx,
NI_LOG_DEBUG,
"total_bytes_to_read %u max_nvme_io_size %u ylen %u cr len "
15770 "%u cb len %u hdr %d\n",
15773 p_frame->
data_len[2], metadata_hdr_size);
15781 "ERROR %s() avaliable size(%u) less than "
15785 }
else if (total_bytes_to_read == metadata_hdr_size && !p_ctx->
frame_num)
15792 void *p_metadata_buffer = NULL;
15802 p_data_buffer = (uint8_t *)p_metadata_buffer;
15803 get_first_metadata = 1;
15804 sequence_change = 0;
15815 read_size_bytes = total_bytes_to_read;
15823 p_data_buffer, read_size_bytes, ui32LBA);
15832 }
else if (get_first_metadata) {
15840 get_first_metadata = 0;
15856 low_delay_notify = 1;
15859 p_data_buffer = (uint8_t *)p_frame->
p_buffer +
15861 memcpy(p_meta, p_data_buffer, metadata_hdr_size);
15866 metadata_hdr_size);
15898 "p_data3_1:sei_size=%d device_handle=%d == hw_id=%d ses_id=%d\n",
15902 "p_data3_1: ui16FrameIdx=%d NodeAddre=0x%x planar=%d bd=%d\n",
15907 "p_data3_2:sei_size=%d device_handle=%d == hw_id=%d ses_id=%d\n",
15911 "p_data3_2: ui16FrameIdx=%d NodeAddre=0x%x planar=%d bd=%d\n",
15916 "%s:sei_size=%d device_handle=%d == hw_id=%d "
15921 "%s: session=0x%x ui16FrameIdx=%u NodeAddress=0x%x, "
15922 "planar=%d bd=%d\n",
15937 total_bytes_to_read = total_bytes_to_read + sei_size;
15939 "%s decoder read desc success, retval %d "
15940 "total_bytes_to_read include sei %u sei_size %d\n",
15941 __func__, retval, total_bytes_to_read, sei_size);
15955 bytes_read_so_far = total_bytes_to_read;
15960 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, &frame_dropped,
true);
15964 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
true);
15980 "is cancelled due to has_b_frames, frame_num %u\n",
15991 int64_t tmp_dts, prev_dts = INT64_MIN, ts_diff = 0;
16000 "### %s(): Warning: ui32FramesDropped %u should be %u + %u\n",
16013 "%s(): First frame : session_id 0x%x, pic_reorder_delay: %d "
16014 "total frames input:%u buffered: %u completed: %u output: %u "
16015 "dropped: %u (%u %u) error: %u\n",
16035 "decoder dts queue %d %ld failed !\n",
16036 __func__, i, tmp_dts);
16041 "decoder dts queue %d %ld success !\n",
16042 __func__, i, tmp_dts);
16043 if (prev_dts != INT64_MIN) {
16044 ts_diff += llabs(tmp_dts - prev_dts);
16047 prev_dts = tmp_dts;
16052 ts_diff = ts_diff / nb_diff;
16056 "average diff: %ld\n", __func__, ts_diff);
16071 "decoder dts queue %d %ld failed !\n",
16072 __func__, i, tmp_dts);
16099 for (i = 0; (int)i < p_ctx->pic_reorder_delay; i++)
16106 if (p_frame->
pts >= p_frame->
dts &&
16107 p_frame->
pts - p_frame->
dts < 1000)
16123 "decoder dts queue %d %ld success !\n",
16124 __func__, i, p_frame->
dts);
16160 "%s: (found pts) dts %" PRId64
" pts "
16161 "%" PRId64
" frame_offset %" PRIu64
" j %d "
16162 "pkt_offsets_index_min %" PRIu64
" "
16163 "pkt_offsets_index %" PRIu64
" pkt_pos %" PRIu64
"\n",
16164 __func__, p_frame->
dts, p_frame->
pts, frame_offset, j,
16179 while (p_frame->
dts < p_frame->
pts &&
16180 llabs(p_frame->
pts - p_frame->
dts) > ts_diff)
16183 "dts %ld diff. %ld > ts_diff %ld\n",
16184 __func__, p_frame->
pts, p_frame->
dts,
16185 llabs(p_frame->
pts - p_frame->
dts), ts_diff);
16192 "pop decoder dts queue error.\n", __func__);
16215 "ERROR: Frame pts %" PRId64
" not found for offset "
16216 "%" PRIu64
"\n", p_frame->
pts, frame_offset);
16218 "%s: (not found use default) dts %" PRId64
" pts %" PRId64
16220 __func__, p_frame->
dts, p_frame->
pts);
16233 p_frame->
pts = guess_correct_pts(p_ctx, p_frame->
pts, p_frame->
dts);
16241 __func__, p_frame->
pts);
16254 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: ppu reconfig done. ppu_reconfig_pkt_pos = %u, frame_num = %u droped = %u\n",
16258#ifdef MEASURE_LATENCY
16269 "%s(): p_frame->start_of_stream=%u, "
16270 "p_frame->end_of_stream=%u, p_frame->video_width=%u, "
16271 "p_frame->video_height=%u\n",
16280 "Decoder pts queue size = %d dts queue size = %d\n\n",
16287#ifdef MEASURE_LATENCY
16292 ni_log2(p_ctx,
NI_LOG_INFO,
"DTS:%" PRId64
",DELTA:%" PRId64
",dLAT:%" PRIu64
";\n",
16303 if (get_first_metadata && p_data_buffer)
16305 if (sequence_change && p_ctx->
frame_num)
16319 low_delay_signal(p_ctx);
16326 if (low_delay_notify)
16328 low_delay_signal(p_ctx);
16346 uint64_t frame_offset = 0;
16347 uint8_t *p_data_buffer;
16350 uint32_t total_bytes_to_read = 0;
16351 uint32_t read_size_bytes = 0;
16352 uint32_t ui32LBA = 0;
16361 if ((!p_ctx) || (!p_frame))
16376 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
16378 if (!p_frame->
p_data[0] || !p_data_buffer)
16400 "ERROR %s(): NI_PIXEL_PLANAR_FORMAT_TILED4X4 not supported in download.\n",
16407 unsigned int bytes_read_so_far = 0;
16410 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Total bytes to download %u, start offset = %u, chunkOffset "
16411 "%u, minorOffset %u\n",
16413 output_chunk_offset, output_minor_offset);
16415 ni_log2(p_ctx,
NI_LOG_DEBUG,
"total_bytes_to_read %u max_nvme_io_size %u ylen %u cr len "
16416 "%u cb len %u hdr %d\n",
16419 p_frame->
data_len[2], metadata_hdr_size);
16438 "Config HW download read desc success, retval %d total_bytes_to_read %u\n",
16439 retval, total_bytes_to_read);
16442 read_size_bytes = total_bytes_to_read;
16444 ui32LBA += output_chunk_offset;
16452 NI_INVALID_DEVICE_HANDLE, p_data_buffer, read_size_bytes, ui32LBA);
16464 "HW download read desc success, retval %d total_bytes_to_read %u\n",
16465 retval, total_bytes_to_read);
16482 "Unconfig HW download read desc success, retval %d total_bytes_to_read %u\n",
16483 retval, total_bytes_to_read);
16486 bytes_read_so_far = total_bytes_to_read;
16491 rx_size = (int)bytes_read_so_far;
16495 ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
false);
16500 __func__, rx_size);
16502 "%s(): p_frame->start_of_stream=%u, "
16503 "p_frame->end_of_stream=%u, p_frame->video_width=%u, "
16504 "p_frame->video_height=%u\n",
16508 "%s(): p_ctx->frame_num %" PRIu64
", "
16509 "p_frame->data_len[0/1/2]=%u/%u/%u\n",
16538 uint64_t frame_offset = 0;
16539 uint8_t *p_data_buffer;
16542 uint32_t total_bytes_to_read = 0;
16543 uint32_t read_size_bytes = 0;
16544 uint32_t ui32LBA = 0;
16546 const char *error_flag =
"NetintQuadraErr";
16550 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
16552 if (!p_frame->
p_data[0] || !p_data_buffer || 0 == p_frame->
data_len[0])
16554 ni_log(
NI_LOG_ERROR,
"ERROR %s(): passed parameters are null or p_frame->data_len is 0.\n",
16566 "ERROR %s(): Unsupported format %d for hw download.\n",
16573 unsigned int bytes_read_so_far = 0;
16578 "%u cb len %u hdr %d\n",
16579 total_bytes_to_read,
16581 p_frame->
data_len[2], metadata_hdr_size);
16586 memcpy(global_state->
error_flag, error_flag, strlen(error_flag)+1);
16590 read_size_bytes = total_bytes_to_read;
16592 ui32LBA += output_chunk_offset;
16598 "%u, minorOffset %u hwdesc->ui16FrameIdx %d ui32LBA 0x%x\n",
16600 output_chunk_offset, output_minor_offset, hwdesc->
ui16FrameIdx, ui32LBA);
16604 NI_INVALID_DEVICE_HANDLE, p_data_buffer, read_size_bytes, ui32LBA);
16613 if (!strcmp(global_state->
error_flag, error_flag) &&
16617 "size %u + offset %u out of range\n",
16618 __func__, hwdesc->
ui16FrameIdx, read_size_bytes, output_chunk_offset);
16623 bytes_read_so_far = total_bytes_to_read;
16628 rx_size = (int)bytes_read_so_far;
16632 ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
false);
16636 "HW download read desc success, retval %d total_bytes_to_read %u\n",
16637 retval, total_bytes_to_read);
16656 uint8_t *p_data = NULL;
16658 uint32_t ui32LBA = 0;
16679 memset(p_data, 0, dataLen);
16681 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): ui16DstIdx %u, ui16SrcIdx %u, size %u, offset %u\n", __func__,
16687 p_data, dataLen, ui32LBA);
16744 uint32_t pool_size,
16747 void* p_uploader_config = NULL;
16751 uint32_t ui32LBA = 0;
16779 memset(p_uploader_config, 0, buffer_size);
16801 ni_log2(p_ctx,
NI_LOG_DEBUG,
"ni_config_instance_set_uploader_params():%d x %d x Format %d with %d framepool\n",
16809 p_uploader_config, buffer_size, ui32LBA);
16848 void* p_decoder_config = NULL;
16851 uint32_t ui32LBA = 0;
16872 ni_log2(p_ctx,
NI_LOG_INFO,
"%s() FW rev %s < 6rT-- load balancing might be affected\n", __func__,
16884 memset(p_decoder_config, 0, buffer_size);
16937 p_decoder_config, buffer_size, ui32LBA);
16970 void *p_dec_ppu_config,
int buffer_size)
16972 void* p_ppu_config = NULL;
16974 uint32_t tmp_buffer_size = buffer_size;
16976 uint32_t ui32LBA = 0;
16980 if (!p_ctx || !p_dec_ppu_config)
17000 ni_log2(p_ctx,
NI_LOG_INFO,
"%s() FW rev %s < 6rT-- load balancing might be affected\n", __func__,
17012 memset(p_ppu_config, 0, tmp_buffer_size);
17014 memcpy(p_ppu_config, p_dec_ppu_config, buffer_size);
17019 p_ppu_config, tmp_buffer_size, ui32LBA);
17064 int query_retry = 0;
17066 if (!p_ctx || !p_frame || !p_frame->
p_data[3])
17100 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: query by ni_query_instance_buf_info INST_BUF_INFO_RW_UPLOAD\n",
17111 if (query_retry >= 1000)
17134 if (query_retry >= 1000)
17145 "Session=0x%x: %s got FrameIndex=%u\n",
17161 "%s Warning scalar read hwdesc fail rc %d or ind !\n",
17243 uint32_t *p_offset)
17255 "FrameIdx %d OOR (%d,%d]. DDR config %d \n", __func__, hwdesc->
ui16FrameIdx,
17270 void *nb_data, uint32_t nb_size)
17272 void *p_ai_config = NULL;
17273 void *p_nb_data = NULL;
17274 uint32_t buffer_size;
17278 uint32_t ui32LBA = 0;
17279 uint32_t config_size;
17280 void *p_buffer = NULL;
17283 int retry_count = 0;
17294 if (!nb_data || nb_size == 0) {
17296 __func__, nb_data, nb_size);
17319 ((
ni_ai_config_t *)p_ai_config)->ui32NetworkBinarySize = nb_size;
17332 memcpy(p_nb_data, nb_data, nb_size);
17340 p_ai_config, config_size, ui32LBA);
17346 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17347 ", hw_id, %u, xcoder_inst_id: %d\n",
17354 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17355 ", hw_id, %u, xcoder_inst_id: %d\n",
17376 memset(p_buffer, 0, dataLen);
17389 p_buffer, dataLen, ui32LBA);
17421 "AI write query failed or buf_size %u < "
17427 "Info ai write query success, available buf "
17428 "size %u >= frame size %u !\n",
17452 p_nb_data, buffer_size, ui32LBA);
17459 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17460 ", hw_id, %u, xcoder_inst_id: %d\n",
17467 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17468 ", hw_id, %u, xcoder_inst_id: %d\n",
17480 for (transferred = 0; transferred < buffer_size; transferred += this_size)
17484 (buffer_size - transferred);
17486 if (this_size & (4096 - 1))
17488 this_size = (this_size + (4096 - 1)) & ~(4096 - 1);
17492 (transferred >> 12);
17494 "%s(): write nb LBA 0x%x, this_size %u, page_offset %u\n",
17495 __func__, ui32LBA, this_size, (transferred >> 12));
17496 p_data = (uint8_t *)p_nb_data + transferred;
17499 (uint8_t *)p_nb_data + transferred, this_size, ui32LBA);
17507 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17508 ", hw_id, %u, xcoder_inst_id: %d\n",
17516 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17517 ", hw_id, %u, xcoder_inst_id: %d\n",
17543 void *p_stream_info = NULL;
17544 void *p_ai_config = NULL;
17545 void *p_nb_data = NULL;
17547 uint32_t ui32LBA = 0;
17548 uint32_t config_size;
17596 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: USM filter not support for FW version lower than 6sW\n");
17605 "### %s: width %d %d height %d model type %d level %d pix_format %d\n", __func__,
17616 p_stream_info, config_size, ui32LBA);
17622 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17623 ", hw_id, %u, xcoder_inst_id: %d\n",
17630 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17631 ", hw_id, %u, xcoder_inst_id: %d\n",
17655 void *p_buffer = NULL;
17656 uint32_t ui32LBA = 0;
17657 int retry_count = 0;
17668 memset(p_buffer, 0, dataLen);
17673 p_buffer, dataLen, ui32LBA);
17711 uint32_t ui32LBA = 0;
17713 uint32_t frame_size_bytes;
17714 uint32_t sent_size = 0;
17715 int32_t query_retry = 0;
17721 if (!p_ctx || !p_frame)
17748 frame_size_bytes = p_frame->
data_len[0];
17759 "Info ai write query success, available buf "
17760 "size %u >= frame size %u !\n",
17787 "AI write query failed or buf_size < frame_size. Retry %d\n",
17793 "AI write query exceeded max retries: %d\n",
17810 if (!p_frame->
iovec) {
17827 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Ai session write: p_data = %p, p_frame->buffer_size = %u, "
17828 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
17832 sent_size = frame_size_bytes;
17840 p_data, sent_size, ui32LBA);
17869 uint32_t rel_offset = 0;
17870 int32_t iovec_index = 0;
17871 int32_t iovec_left;
17873 if (!p_frame->
iovec) {
17879 for (i = 0; i < p_frame->
iovec_num; i++) {
17883 this_iovec->
ptr, this_iovec->
size);
17884 if ((this_iovec->
ptr == NULL) || (this_iovec->
size == 0) ||
17887 (int64_t)this_iovec->
ptr, this_iovec->
size);
17902 memset(buffer_info, 0x00, dataLen);
17908 uint32_t rel_lba = 0;
17913 for (i = 0; (int)i < iovec_batch; i++) {
17919 rel_offset += iovec->
size;
17929 buffer_info, dataLen, ui32LBA);
17937 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17938 ", hw_id, %u, xcoder_inst_id: %d\n",
17947 for (i = 0; (int)i < iovec_batch; i++) {
17952 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
17965 for (i = 0; (int)i < iovec_batch; i++) {
17969 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
17976 iovec->
ptr, sent_size, ui32LBA);
17985 iovec_index += iovec_batch;
17986 iovec_left -= iovec_batch;
17987 }
while (iovec_left);
18018 retval = frame_size_bytes;
18034 uint32_t actual_read_size = 0;
18036 uint32_t ui32LBA = 0;
18041 if (!p_ctx || !p_packet || !p_packet->
p_data)
18066 "Info ai read query success, available buf "
18067 "size %u >= frame size %u !\n",
18090 "Info ai read query rc %d, available buf size %u, "
18091 "frame_num=%" PRIu64
", pkt_num=%" PRIu64
"\n",
18112 actual_read_size = p_packet->
data_len;
18120 p_packet->
p_data, actual_read_size, ui32LBA);
18170 void *p_buffer = NULL;
18171 void *p_info = NULL;
18173 uint32_t ui32LBA = 0;
18175 int32_t query_retry = 0;
18178 uint32_t buffer_size;
18179 uint32_t this_size;
18181 uint32_t total_io_num;
18185 if (!p_ctx || !p_network)
18197 "ERROR: %s(): network parameters data is already initialized\n",
18223 memset(p_buffer, 0, dataLen);
18239 p_buffer, dataLen, ui32LBA);
18255 if (query_retry > 50000)
18258 __func__, query_retry - 1);
18303 if (!network_data->
inset)
18326 memset(p_info, 0, dataLen);
18330 p_info, dataLen, ui32LBA);
18331 if ((int32_t)retval < 0)
18353 memset(p_info, 0, dataLen);
18357 p_info, dataLen, ui32LBA);
18358 if ((int32_t)retval < 0)
18368 for (l = 0, network_data->
input_num = 0; l < 4; l++)
18378 for (l = 0, network_data->
output_num = 0; l < 4; l++)
18389 for (l = 0, buffer_size = 0; l < network_data->
input_num; l++)
18396 buffer_size += this_size;
18400 "%s(): network input layer %d: dims %u, %u/%u/%u/%u, f %d, q %d\n",
18406 for (l = 0, buffer_size = 0; l < network_data->
output_num; l++)
18413 buffer_size += this_size;
18417 "%s(): network output layer %d: dims %u, %u/%u/%u/%u, f %d, q %d\n",
18432 ni_unreference_network_data(network_data);
18443 void *p_buffer = NULL;
18444 uint32_t ui32LBA = 0;
18524 "ERROR %s(): p_ctx->device_handle=%" PRIx64
18525 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
18542 "%s(): p_ctx->device_handle=%" PRIx64
18543 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
18548 uint64_t keep_alive_timeout =
18551 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
18553 keep_alive_timeout);
18565 "ERROR %s(): nvme write keep_alive_timeout command "
18566 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
18577 "ERROR %s(): Unable to allocate network_data memory\n");
18592 if (!p_ctx->
iocbs) {
18599 p_ctx->
iocbs[i] = (ni_iocb_t *)malloc(
sizeof(ni_iocb_t));
18600 if (!p_ctx->
iocbs[i]) {
18634 void *p_buffer = NULL;
18635 uint32_t ui32LBA = 0;
18671 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
18672 "p_ctx->session_id=%d, close_mode=1\n",
18717 if (p_ctx->
iocbs) {
18756 void *p_read_data = NULL;
18758 uint32_t ui32LBA = 0;
18775 int32_t query_retry = 0;
18783 "Info ai write query success, available buf "
18800 "AI write query failed or buf_size < frame_size. Retry %d\n",
18806 "AI write query exceeded max retries: %d\n",
18829 memset(p_data, 0x00, dataLen);
18835 for(
int i = 0; i < numInCfgs; i++){
18847 p_data, dataLen, ui32LBA);
18855 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
18856 ", hw_id, %u, xcoder_inst_id: %d\n",
18867 if (p_read_data != NULL)
18879 void *p_read_data = NULL;
18881 uint32_t ui32LBA = 0;
18902 "Error: %s function not supported on device with FW API version < 6rL\n",
18909 int query_retry = 0;
18920 memset(p_read_data, 0, dataLen);
18928 p_read_data, dataLen, ui32LBA);
18952 if (query_retry > 2000)
18955 __func__, query_retry - 1);
18973 if (p_read_data != NULL)
18981 int height,
int options,
int pool_size,
18986 void *p_read_data = NULL;
18988 uint32_t ui32LBA = 0;
19008 int query_retry = 0;
19019 memset(p_read_data, 0, dataLen);
19027 p_read_data, dataLen, ui32LBA);
19044 if (query_retry > 2000)
19047 __func__, query_retry - 1);
19065 int32_t query_retry = 0;
19073 "Info ai write query success, available buf "
19090 "AI write query failed or buf_size < frame_size. Retry %d\n",
19096 "AI write query exceeded max retries: %d\n",
19119 memset(p_data, 0x00, dataLen);
19134 p_data, dataLen, ui32LBA);
19142 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
19143 ", hw_id, %u, xcoder_inst_id: %d\n",
19155 if (p_read_data != NULL)
19178 int retry_count = 0;
19205 if (retry_count >= 500)
19231 if (retry_count >= 500)
19268 void *p_buffer = NULL;
19271 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
19277 if (NI_INVALID_DEVICE_HANDLE == device_handle)
19352 uint8_t ddr_priority_mode)
19354 void *p_buffer = NULL;
19363 ddr_priority_mode);
19365 if (NI_INVALID_DEVICE_HANDLE == device_handle)
19384 p_cfg->
ddr_mode = ddr_priority_mode;
19389 ddr_priority_mode);
19417 void *metadata_buffer = NULL;
19420 if ((!p_frame) || (extra_len <= 0))
19423 "ERROR: %s passed parameters are null or not supported, "
19424 "p_frame %p, extra_len %d",
19425 __func__, p_frame, extra_len);
19429 int buffer_size = extra_len;
19441 "%s: free current p_frame metadata buffer, "
19442 "p_frame->buffer_size=%u\n",
19455 "ERROR %d: %s() Cannot allocate metadata buffer.\n",
19462 memset(metadata_buffer, 0, buffer_size);
19473 "%s: success: p_frame->p_metadata_buffer %p "
19474 "p_frame->metadata_buffer_size=%u\n",
19503 void *start_buffer = NULL;
19509 "ERROR: %s passed parameters are null or not supported, "
19511 __func__, p_frame);
19522 "ERROR %d: %s() Cannot allocate start buffer.\n",
19540 "%s: success: p_frame->p_start_buffer %p "
19541 "p_frame->start_buffer_size=%u\n",
19558 void *p_buffer = NULL;
19560 uint32_t ui32LBA = 0;
19563 if (!p_ctx || !p_metrics)
19566 "ERROR: %s() passed parameters are null!, return\n", __func__);
19590 p_buffer, dataLen, ui32LBA);
19633 uint32_t *u32_buf = (uint32_t *)buf;
19635 u32_buf[1] = value;
19648 CoreName = (
char *)
"all";
19651 CoreName = (
char *)
"np";
19654 CoreName = (
char *)
"ep";
19657 CoreName = (
char *)
"dp";
19660 CoreName = (
char *)
"tp";
19663 CoreName = (
char *)
"fp";
19666 CoreName = (
char *)
"fl";
19669 CoreName = (
char *)
"Not Found";
19707static int ni_write_fl_log_decoded_file(
void *p_data, uint32_t buf_len, FILE *p_file)
19711 uint32_t log_lines;
19712 uint64_t payload_u;
19713 size_t payload_len;
19714 size_t max_payload;
19719 if (buf_len < 4 || !p_data || !p_file)
19722 memcpy(&flsign, p_data,
sizeof(flsign));
19727 memcpy(&fllen, (
const uint8_t *)p_data + 4,
sizeof(fllen));
19728 log_lines = fllen & 0xFFFFFFU;
19729 payload_u = (uint64_t)log_lines * 128ULL;
19730 max_payload = (size_t)buf_len - 4;
19731 payload_len = (payload_u > max_payload) ? max_payload : (size_t)payload_u;
19733 in = (
const uint8_t *)p_data + 8;
19734 out = (uint8_t *)malloc(payload_len ? payload_len : 1);
19738 for (i = 0, j = 0; i < payload_len; i++)
19742 if (j > 0 && fwrite(out, 1, j, p_file) != j) {
19755 char *core_name = NULL;
19756 FILE *p_file = NULL;
19759 if (!p_ctx || !p_data)
19762 __func__, __LINE__, p_ctx, p_data);
19775 *(uint8_t *)p_data = 0x55;
19781 __func__, __LINE__, core_id);
19792 __func__, __LINE__, rc, core_name);
19794 else if (gen_log_file)
19797 char filename[32] =
"raw_";
19801 bool pcie_id_name =
false;
19802 char devFilePath[1024] = {0};
19803 char devFDPath[1024] = {0};
19804 char pcie[64] = {0};
19805 char domain[5] = {0}, slot[3] = {0}, dev[3] = {0}, func[2] = {0};
19807 snprintf(devFDPath,
sizeof(devFDPath),
"/proc/self/fd/%d", p_ctx->
blk_io_handle);
19808 ssize_t len = readlink(devFDPath, devFilePath,
sizeof(devFilePath)-1);
19810 devFilePath[len] =
'\0';
19812 if (strstr(devFilePath,
"/dev/nvme") != NULL)
19815 if (strlen(pcie) > 0 && strlen(slot) > 0 && strlen(domain) > 0)
19820 pcie_id_name =
true;
19825 ni_log2(p_ctx,
NI_LOG_INFO,
"%s:():%d: For dev %d can't look up PCI domain and slot info. Defaulting to slot=hw_id and domain=0000\n",
19828 snprintf(num, 4,
"%d", p_ctx->
hw_id);
19837 snprintf(num, 4,
"%02x", p_ctx->
hw_id);
19844 ni_fopen(&p_file, filename,
"wb");
19850 int wrc = ni_write_fl_log_decoded_file(p_data, data_len, p_file);
19854 __func__, __LINE__);
19857 else if (wrc == -3)
19860 __func__, __LINE__);
19863 else if (wrc == -1)
19866 __func__, __LINE__);
19869 else if (wrc == -4)
19872 __func__, __LINE__);
19877 else if (fwrite((uint8_t *)p_data ,
19878 data_len, 1, p_file) != 1)
19881 __func__, __LINE__, data_len);
19885 if (fflush(p_file))
19896 __func__, __LINE__, filename);
19909 if (!p_ctx || !p_data)
19912 __func__, __LINE__, p_ctx, p_data);
19925 for (i =
NVME_CORE; i<= max_cores; i++)
19954 void *p_buffer = NULL;
19956 uint32_t ui32LBA = 0;
19981 p_data = (uint8_t *) p_buffer;
19985 memcpy(p_data + 8, &dmaAddrs->
ui32DMALen[0], 4);
19988 memcpy(p_data + 18, &ui16Direction, 2);
19993 uint32_t ui32NeedsSplit = 0;
19994 uint32_t ui32EntryIdx = 0;
19996 for (ui32EntryIdx = 0; ui32EntryIdx < dmaAddrs->
ui32NumEntries; ui32EntryIdx++)
20000 ui32NeedsSplit = 1;
20005 if (ui32NeedsSplit)
20008 uint32_t ui32SglIdx = 0;
20011 memset(&sSplitSgl, 0,
sizeof(sSplitSgl));
20012 for (ui32EntryIdx = 0;
20016 uint64_t ui64BaseAddr = dmaAddrs->
ui64DMAAddr[ui32EntryIdx];
20017 uint32_t ui32RemainingData = dmaAddrs->
ui32DMALen[ui32EntryIdx];
20018 uint32_t ui32Offset = 0;
20024 sSplitSgl.
ui64DMAAddr[ui32SglIdx] = ui64BaseAddr + ui32Offset;
20026 ui32Offset += ui32Seg;
20027 ui32RemainingData -= ui32Seg;
20031 if (ui32RemainingData > 0)
20034 "%s: SGL overflow: table full (%u slots) at entry"
20035 " %u/%u, %u bytes unprocessed\n",
20037 ui32EntryIdx, ui32OrigEntries, ui32RemainingData);
20043 if (ui32EntryIdx < ui32OrigEntries)
20046 "%s: SGL overflow: table full (%u slots), "
20047 "%u/%u entries not processed\n",
20049 ui32OrigEntries - ui32EntryIdx, ui32OrigEntries);
20057 "%s: SGL split: %u original entr%s -> %u chunks "
20058 "(max 0x%X bytes/chunk)\n", __func__,
20059 ui32OrigEntries, ui32OrigEntries == 1 ?
"y" :
"ies",
20065 memcpy(&p_data[24] + (i * 8), &sSplitSgl.
ui64DMAAddr[i], 8);
20078 memcpy(&p_data[24] + (i * 8), &dmaAddrs->
ui64DMAAddr[i], 8);
20102 if (p_buffer != NULL)
20112 void *p_buffer = NULL;
20114 uint32_t ui32LBA = 0;
20118 uint32_t ui32Dummy = 0;
20140 p_data = (uint8_t *) p_buffer;
20144 memcpy(p_data + 8, &ui32Dummy, 4);
20147 memcpy(p_data + 18, &ui16Direction, 2);
20152 memcpy(&p_data[24] + (i*8), &dmaAddrs->
ui64DMAAddr[i], 8);
20174 if (p_buffer != NULL)
20194#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
20196 if (numa_available() == -1) {
20214#if defined(LIBNUMA_API_VERSION) && (LIBNUMA_API_VERSION == 2)
20215 struct bitmask *node_mask = numa_allocate_nodemask();
20222 numa_bitmask_setbit(node_mask, numa_node);
20223 numa_bind(node_mask);
20224 numa_bitmask_free(node_mask);
20226 nodemask_t node_mask;
20227 nodemask_zero(&node_mask);
20228 nodemask_set(&node_mask, numa_node);
20229 numa_bind(&node_mask);
20237#ifdef PRINT_FW_LOGS
20243static inline bool is_log_start_marker(
const uint8_t* data) {
20252static inline bool is_log_end_marker(
const uint8_t* data) {
20261static inline uint64_t extract_timestamp(uint8_t* timestamp_bytes) {
20262 uint64_t timestamp = 0;
20264 for (
int i = 0; i < 8; i++) {
20265 timestamp |= ((uint64_t)timestamp_bytes[i] << (i * 8));
20277static void ni_find_latest_complete_log(
const uint8_t* data,
size_t data_size,
20280 uint64_t timestamp = 0, max_timestamp = 0;
20282 uint64_t data_start;
20284 const uint8_t* end_ptr;
20290 latest_entry->
end_ptr = NULL;
20294 if (!is_log_start_marker(data + index)) {
20305 timestamp = extract_timestamp(header->
timestamp);
20308 if (timestamp == 0) {
20319 if (is_log_end_marker(data + j)) {
20326 if (found_end && end_ptr != NULL) {
20328 if (timestamp > max_timestamp) {
20329 max_timestamp = timestamp;
20330 latest_entry->
start_ptr = data + index;
20331 latest_entry->
end_ptr = end_ptr;
20341 index = end_ptr - data;
20360static void ni_extract_64k_from_end_marker(
const uint8_t* data,
size_t data_size,
20361 const uint8_t* end_marker_ptr,
20362 uint8_t* output,
bool wrap_around) {
20363 uint64_t end_marker_offset = end_marker_ptr - data;
20364 uint64_t extract_start;
20372 }
else if (wrap_around) {
20375 uint64_t second_part_size = end_marker_offset;
20377 memcpy(output, data + data_size - first_part_size, first_part_size);
20379 if (second_part_size > 0) {
20380 memcpy(output + first_part_size, data, second_part_size);
20396ni_retcode_t ni_extract_64k_from_latest_log_end(
const uint8_t* data, uint8_t* output) {
20399 if (data == NULL || output == NULL) {
20408 " it is not expected, So will print the first 64K fw logs\n");
20414 ni_extract_64k_from_end_marker(
20428 const uint8_t *p_data, uint32_t core_id) {
20430 uint8_t *output = NULL;
20432 if (!p_ctx || !p_data) {
20434 __func__, __LINE__, p_ctx);
20443 if (output == NULL) {
20449 ret = ni_extract_64k_from_latest_log_end(p_data, output);
20453 uint8_t print_buffer[260];
20456 for (
int i = 0; i < chunks; i++) {
20457 uint8_t* ptr = print_buffer;
20464 memcpy(ptr, output + (i * 256), 256);
20472 for (
int j = 0; j <
sizeof(print_buffer); j++) {
20498 bool gen_log_file =
false;
20499 void *p_log_buffer = NULL;
20505 __func__, __LINE__, p_ctx);
20528 for (i =
NVME_CORE; i<= max_cores; i++)
20538 retval = ni_device_print_firmware_logs(p_ctx, p_log_buffer, i);
#define NI_XCODER_REVISION_API_MAJOR_VER_IDX
#define NI_MAX_NUM_SW_FRAME_DATA_POINTERS
#define NI_XCODER_REVISION
#define NI_GET_MIN_HWDESC_P2P_BUF_ID(x)
#define NI_GET_MAX_HWDESC_FRAME_INDEX(x)
struct _ni_session_statistic_t ni_session_statistic_t
#define CPU_FL_LOG_BUFFER_LEN
#define NI_MAX_CONTEXTS_PER_HW_INSTANCE
#define NI_MAX_DEVICES_PER_HW_INSTANCE
#define NI_MAX_NUM_OF_DECODER_OUTPUTS
@ NI_DEVICE_TYPE_XCODER_MAX
#define CPU_LOG_BUFFER_SIZE
#define NI_GET_MAX_HWDESC_P2P_BUF_ID(x)
#define CPU_FL_LOG_BUFFER_SIZE
#define NETINT_PCI_VENDOR_ID
#define ni_assert(expression)
@ NI_SCALER_OPCODE_IPOVLY
@ NI_SCALER_OPCODE_OVERLAY
@ NI_SCALER_OPCODE_WATERMARK
@ NI_SCALER_OPCODE_ROTATE
@ NI_SCALER_OPCODE_AI_ALIGN
#define PRINT_FW_LOG_SIZE
#define NI_MEM_PAGE_ALIGNMENT
#define NI_FW_META_DATA_SZ
@ NI_RETCODE_PARAM_ERROR_INTRA_PERIOD
@ NI_RETCODE_PARAM_ERROR_HEIGHT_TOO_BIG
@ NI_RETCODE_PARAM_ERROR_BRATE
@ NI_RETCODE_PARAM_ERROR_HVS_QP_EN
@ NI_RETCODE_PARAM_ERROR_VBV_BUFFER_SIZE
@ NI_RETCODE_PARAM_ERROR_CUSIZE_MODE_8X8_EN
@ NI_RETCODE_PARAM_ERROR_CUSIZE_MODE_32X32_EN
@ NI_RETCODE_PARAM_ERROR_RCENABLE
@ NI_RETCODE_PARAM_ERROR_MX_DELTA_QP
@ NI_RETCODE_PARAM_ERROR_LOOK_AHEAD_DEPTH
@ NI_RETCODE_PARAM_ERROR_CONF_WIN_R
@ NI_RETCODE_ERROR_INVALID_SESSION
@ NI_RETCODE_PARAM_ERROR_CU_SIZE_MODE
@ NI_RETCODE_PARAM_ERROR_CONF_WIN_BOT
@ NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
@ NI_RETCODE_PARAM_ERROR_MN_QP
@ NI_RETCODE_NVME_SC_INVALID_PARAMETER
@ NI_RETCODE_PARAM_ERROR_PIC_WIDTH
@ NI_RETCODE_PARAM_ERROR_CONF_WIN_TOP
@ NI_RETCODE_PARAM_ERROR_CONF_WIN_L
@ NI_RETCODE_PARAM_ERROR_DECODING_REFRESH_TYPE
@ NI_RETCODE_PARAM_ERROR_AREA_TOO_BIG
@ NI_RETCODE_PARAM_ERROR_FRATE
@ NI_RETCODE_NVME_SC_WRITE_BUFFER_FULL
@ NI_RETCODE_NVME_SC_VPU_RECOVERY
@ NI_RETCODE_PARAM_ERROR_HEIGHT_TOO_SMALL
@ NI_RETCODE_ERROR_INVALID_HANDLE
@ NI_RETCODE_PARAM_INVALID_VALUE
@ NI_RETCODE_ERROR_RESOURCE_UNAVAILABLE
@ NI_RETCODE_PARAM_ERROR_CU_LVL_RC_EN
@ NI_RETCODE_PARAM_ERROR_INTRA_QP
@ NI_RETCODE_PARAM_ERROR_MAXNUMMERGE
@ NI_RETCODE_NVME_SC_RESOURCE_UNAVAILABLE
@ NI_RETCODE_PARAM_ERROR_GOP_PRESET
@ NI_RETCODE_PARAM_ERROR_WIDTH_TOO_BIG
@ NI_RETCODE_ERROR_NVME_CMD_FAILED
@ NI_RETCODE_PARAM_ERROR_USR_RMD_ENC_PARAM
@ NI_RETCODE_PARAM_ERROR_PIC_HEIGHT
@ NI_RETCODE_NVME_SC_VPU_RSRC_INSUFFICIENT
@ NI_RETCODE_ERROR_MEM_ALOC
@ NI_RETCODE_ERROR_UNSUPPORTED_FEATURE
@ NI_RETCODE_PARAM_ERROR_OOR
@ NI_RETCODE_PARAM_ERROR_CUSIZE_MODE_16X16_EN
@ NI_RETCODE_ERROR_VPU_RECOVERY
@ NI_RETCODE_PARAM_ERROR_WIDTH_TOO_SMALL
@ NI_RETCODE_PARAM_ERROR_CUSTOM_GOP
@ NI_RETCODE_INVALID_PARAM
@ NI_RETCODE_PARAM_ERROR_TOO_SMALL
@ NI_RETCODE_PARAM_ERROR_MX_QP
#define IS_XCODER_DEVICE_TYPE(t)
#define NI_MAX_4K_FPS_QUADRA
#define NI_MAX_P2P_SGL_ENTRY
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_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...
void ni_device_session_context_free(ni_session_context_t *p_ctx)
Free previously allocated session context.
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.
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...
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...
ni_session_context_t * ni_device_session_context_alloc_init(void)
Allocate and initialize a new ni_session_context_t struct.
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_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...
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.
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,...
Public definitions for operating NETINT video processing devices for video processing.
@ SESSION_RUN_STATE_NORMAL
@ SESSION_RUN_STATE_SEQ_CHANGE_DRAINING
#define NI_PARAM_MAX_HEIGHT
#define AV_CODEC_DEFAULT_BITRATE
#define NI_MAX_ENCODER_QUERY_RETRIES
#define NI_CC_SEI_TRAILER_LEN
#define NI_NUM_OF_PIXELS_1440P
@ NI_QUADRA_PREDICTED_FRAME
@ NI_QUADRA_BIDIR_PREDICTED_FRAME
#define NI_AV1_INVALID_BUFFER_INDEX
#define NI_HDR10P_SEI_BYTE2
struct _niFrameSurface1 niFrameSurface1_t
@ NI_PIXEL_PLANAR_FORMAT_SEMIPLANAR
@ NI_PIXEL_PLANAR_FORMAT_TILED4X4
@ NI_PIXEL_PLANAR_FORMAT_PLANAR
#define NI_ENC_REPEAT_HEADERS_ALL_I_FRAMES
struct _ni_network_layer_params_t ni_network_layer_params_t
#define NI_PARAM_AV1_MAX_HEIGHT
#define NI_SCALER_FLAG_PC
#define NI_MIN_RESOLUTION_HEIGHT_SCALER
#define NI_MAX_RESOLUTION_RGBA_WIDTH
#define NI_CC_SEI_HDR_H264_LEN
#define NI_HDR10P_SEI_BYTE0
#define NI_ENC_MIN_RESOLUTION_HEIGHT
struct _ni_instance_mgr_detail_status_v1 ni_instance_mgr_detail_status_v1_t
#define NI_CUSTOMIZE_ROI_QP_NUM
Max number of entries per line supported for the qp number.
#define NI_MAX_FRAME_SIZE
@ NI_DEC_CROP_MODE_MANUAL
#define PRESET_DEFAULT_BITRATE
#define NI_PARAM_AV1_MAX_WIDTH
#define NI_EC_POLICY_LIMITED_ERROR
#define NI_MIN_RESOLUTION_WIDTH
#define NI_MAX_RESOLUTION_WIDTH
#define NI_MAX_SLICE_SIZE
@ NI_H265_USERDATA_FLAG_UNREGISTERED_PRE
@ NI_H265_USERDATA_FLAG_MASTERING_COLOR_VOL
@ NI_H265_USER_DATA_FLAG_CONTENT_LIGHT_LEVEL_INFO
@ NI_H265_USERDATA_FLAG_UNREGISTERED_SUF
#define NI_EC_ERR_THRESHOLD_DEFAULT
#define NI_ENC_MIN_RESOLUTION_WIDTH
struct _ni_network_perf_metrics ni_network_perf_metrics_t
#define NI_HDR10P_SEI_HDR_H264_LEN
@ H264_CODEC_PROFILE_EXTENDED
@ H264_CODEC_PROFILE_HIGH
@ H264_CODEC_PROFILE_BASELINE
@ H264_CODEC_PROFILE_MAIN
#define NI_PARAM_AV1_MAX_AREA
#define NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL
Max number of lines supported for qpoffset level.
#define NI_INVALID_SESSION_ID
@ HEVC_CODEC_PROFILE_MAIN10
@ HEVC_CODEC_PROFILE_MAIN
#define NI_MAX_RESOLUTION_AREA
#define NI_HDR10P_SEI_BYTE1
#define NI_SCALER_FLAG_P2
enum _ni_codec_format ni_codec_format_t
This is an enumeration for supported codec formats.
struct _ni_scaler_params_t ni_scaler_params_t
#define NI_MAX_RESOLUTION_RGBA_HEIGHT
#define MOTION_CONSTRAINED_QUALITY_MODE
#define NI_NUM_OF_PIXELS_1080P
@ NI_QUADRA_AV1_PROFILE_MAIN
#define NI_MIN_RESOLUTION_HEIGHT
#define NI_MAX_TX_RETRIES
#define NI_EC_POLICY_BEST_EFFORT_OUT_DC
#define NI_MIN_RESOLUTION_WIDTH_SCALER
#define NI_MAX_SPATIAL_LAYERS
#define NI_HDR10P_SEI_HDR_HEVC_LEN
@ NI_CODEC_HW_PAYLOAD_OFFSET
#define NI_HDR10P_SEI_BYTE5
#define NI_PARAM_MAX_WIDTH
struct _ni_network_layer_info ni_network_layer_info_t
struct _ni_sei_header ni_sei_header_t
#define NI_HDR10P_SEI_BYTE3
#define NI_SCALER_FLAG_IO
#define NI_EC_POLICY_DEFAULT
#define NI_MAX_RESOLUTION_HEIGHT
@ NI_QUADRA_HEVC_PROFILE_MAIN
@ NI_QUADRA_HEVC_PROFILE_MAIN10
@ NI_QUADRA_H264_PROFILE_BASELINE
@ NI_QUADRA_H264_PROFILE_HIGH
@ NI_QUADRA_H264_PROFILE_MAIN
@ NI_QUADRA_H264_PROFILE_EXTENDED
struct _ni_instance_mgr_detail_status ni_instance_mgr_detail_status_t
#define NI_HDR10P_SEI_BYTE4
#define NI_CC_SEI_HDR_HEVC_LEN
struct _ni_frameclone_desc ni_frameclone_desc_t
ni_retcode_t ni_encoder_session_open(ni_session_context_t *p_ctx)
Open a xcoder encoder instance.
void SwapSWBytes(uint8_t *buf, uint32_t bytes)
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)
ni_retcode_t ni_config_instance_set_decoder_ppu_params(ni_session_context_t *p_ctx, void *p_dec_ppu_config, int buffer_size)
Send a p_config command to configure decoding parameters.
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.
enum _ni_t35_sei_mesg_type ni_t35_sei_mesg_type_t
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_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
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.
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.
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.
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_config_instance_set_encoder_frame_params(ni_session_context_t *p_ctx, ni_encoder_frame_params_t *p_params)
Send a p_config command to configure encoding p_frame parameters.
ni_retcode_t ni_decoder_session_close(ni_session_context_t *p_ctx, int eos_recieved)
Close a xcoder decoder instance.
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.
ni_retcode_t ni_config_instance_set_write_len(ni_session_context_t *p_ctx, ni_device_type_t device_type, uint32_t len)
Send a p_config command to set the length for the incoming write packet.
ni_retcode_t ni_config_instance_set_sequence_change(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_resolution_t *p_resolution)
Send a p_config command to inform encoder sequence change.
ni_retcode_t ni_hwupload_session_query_buffer_avail(ni_session_context_t *p_ctx)
Query and acquire buffer from xcoder upload instance.
ni_retcode_t ni_scaler_session_close(ni_session_context_t *p_ctx, int eos_received)
close a scaler session
ni_retcode_t ni_ai_session_write(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
ni_retcode_t ni_config_instance_hvsplus(ni_session_context_t *p_ctx)
ni_retcode_t ni_scaler_session_query_buffer_avail(ni_session_context_t *p_ctx)
Query and acquire buffer from xcoder scaler instance.
ni_retcode_t ni_set_cpu_affinity(ni_session_context_t *p_ctx)
set cpu affinity based on numa node
ni_retcode_t ni_config_instance_sos(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a p_config command for Start Of Stream.
ni_retcode_t ni_encoder_session_close(ni_session_context_t *p_ctx, int eos_recieved)
Close a xcoder encoder instance.
ni_retcode_t ni_ai_session_query_metrics(ni_session_context_t *p_ctx, ni_network_perf_metrics_t *p_metrics)
ni_retcode_t ni_dump_log_single_core(ni_session_context_t *p_ctx, void *p_data, uint32_t core_id, bool gen_log_file)
ni_retcode_t ni_encoder_session_send_eos(ni_session_context_t *p_ctx)
Flush encoder output.
ni_retcode_t ni_config_read_inout_layers(ni_session_context_t *p_ctx, ni_network_data_t *p_network)
int ni_decoder_session_read(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Retrieve a YUV p_frame from decoder.
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.
void ni_set_custom_dec_template(ni_session_context_t *p_ctx, ni_decoder_config_t *p_cfg, ni_xcoder_params_t *p_src, uint32_t max_pkt_size)
Setup all xcoder configurations with custom parameters (Rev. B)
ni_retcode_t ni_ai_session_read(ni_session_context_t *p_ctx, ni_packet_t *p_packet)
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_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.
ni_retcode_t ni_ai_alloc_dst_frame(ni_session_context_t *p_ctx, niFrameSurface1_t *p_out_surface)
ni_retcode_t ni_send_to_target_v2(ni_session_context_t *p_ctx, ni_frame_t *pSrcFrame, const ni_p2p_sgl_t *dmaAddrs)
Generates and writes a nvme command with sgl list.
uint32_t ni_get_log_lba(ni_core_type_t eCoreType)
#define NI_XCODER_FAILURES_MAX
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.
ni_retcode_t ni_decoder_session_open(ni_session_context_t *p_ctx)
Open a xcoder decoder instance.
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.
ni_retcode_t ni_scaler_session_read_hwdesc(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
read a hardware descriptor from a scaler session
ni_retcode_t ni_uploader_session_close(ni_session_context_t *p_ctx)
Close an xcoder upload instance.
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
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.
void * ni_session_keep_alive_thread(void *arguments)
decoder keep alive thread function triggers every 1 second
@ NI_T35_SEI_CLOSED_CAPTION
void SwapSW32(uint32_t *buf, uint32_t bytes)
ni_retcode_t ni_check_common_params(ni_t408_config_t *p_param, ni_xcoder_params_t *p_src, char *p_param_err, uint32_t max_err_len)
ni_retcode_t ni_recv_from_target(ni_session_context_t *p_ctx, const ni_p2p_sgl_t *dmaAddrs, ni_frame_t *pDstFrame)
void enqueue_ni_frame(ni_session_context_t *p_ctx, ni_frame_t *ni_frame, int32_t source_width, int32_t source_height)
char * ni_get_core_name(ni_core_type_t eCoreType)
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.
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_query_instance_buf_info(ni_session_context_t *p_ctx, ni_instance_buf_info_rw_type_t rw_type, ni_device_type_t device_type, ni_instance_buf_info_t *p_inst_buf_info)
Query a particular xcoder instance to get buffer/data Info data.
int ni_query_detail_status(ni_session_context_t *p_ctx, ni_device_type_t device_type, void *p_detail_status, int ver)
Query a particular xcoder instance to get DetailStatus data.
int ni_get_planar_from_pixfmt(int pix_fmt)
Grab planar info from NI_PIX_FMT.
void calculate_psnr(ni_session_context_t *p_ctx, ni_packet_t *p_packet)
ni_retcode_t ni_query_stream_info(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_stream_info_t *p_stream_info)
Query a particular xcoder instance to get Stream Info data.
ni_retcode_t ni_device_set_ddr_configuration(ni_session_context_t *p_ctx, uint8_t ddr_priority_mode)
Set DDR configuration of Quadra device.
int ni_hwupload_session_read_hwdesc(ni_session_context_t *p_ctx, niFrameSurface1_t *hwdesc)
Retrieve a HW descriptor of uploaded frame.
void ni_set_custom_template(ni_session_context_t *p_ctx, ni_encoder_config_t *p_cfg, ni_xcoder_params_t *p_src)
Setup all xcoder configurations with custom parameters (Rev. B)
ni_retcode_t ni_send_session_keep_alive(uint32_t session_id, ni_device_handle_t device_handle, ni_event_handle_t event_handle, void *p_data)
send a keep alive message to firmware
ni_retcode_t ni_validate_custom_template(ni_session_context_t *p_ctx, ni_encoder_config_t *p_cfg, ni_xcoder_params_t *p_src, char *p_param_err, uint32_t max_err_len)
Perform validation on custom parameters (Rev. B)
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_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_device_get_ddr_configuration(ni_session_context_t *p_ctx)
Get DDR configuration of Quadra device.
int ni_create_frame(ni_frame_t *p_frame, uint32_t read_length, uint64_t *p_frame_offset, uint32_t *p_frame_dropped, bool is_hw_frame)
Get info from received p_frame.
ni_retcode_t ni_config_instance_eos(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a p_config command for End Of Stream.
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
ni_retcode_t ni_ai_query_network_ready(ni_session_context_t *p_ctx)
int ni_query_general_status(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_general_status_t *p_gen_status)
Query a particular xcoder instance to get GeneralStatus data.
ni_retcode_t ni_check_ratecontrol_params(ni_encoder_config_t *p_cfg, char *p_param_err, uint32_t max_err_len)
int ni_query_eos(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_stream_complete_t *p_stream_complete)
Query a particular xcoder instance to get End of Output data.
#define READ_U32_FROM_BUF_2BYTES(buf, byte_offset)
ni_retcode_t ni_config_instance_flush(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a p_config command to flush the stream.
#define CHECK_VPU_RECOVERY(ret)
void SwapSW16(uint16_t *buf, uint32_t bytes)
#define READ_U32_FROM_BUF(buf, byte_offset)
ni_retcode_t ni_config_session_rw(ni_session_context_t *p_ctx, ni_session_config_rw_type_t rw_type, uint8_t enable, uint8_t hw_action, uint16_t frame_id)
Configure the read/write pipe for a session to control its behavior.
ni_retcode_t ni_decoder_session_send_eos(ni_session_context_t *p_ctx)
Send end of stream signal to the decoder.
ni_retcode_t ni_config_instance_set_decoder_params(ni_session_context_t *p_ctx, uint32_t max_pkt_size)
Send a p_config command to configure decoding parameters.
int ni_encoder_session_read(ni_session_context_t *p_ctx, ni_packet_t *p_packet)
ni_retcode_t ni_validate_custom_dec_template(ni_xcoder_params_t *p_src, ni_session_context_t *p_ctx, ni_decoder_config_t *p_cfg, char *p_param_err, uint32_t max_err_len)
Perform validation on custom dec parameters (Rev. B)
ni_retcode_t ni_uploader_session_open(ni_session_context_t *p_ctx)
Open a xcoder upload instance.
#define CHECK_ERR_RC(ctx, rc, info, opcode, type, hw_id, inst_id, opt)
ni_retcode_t ni_ai_session_open(ni_session_context_t *p_ctx)
ni_retcode_t ni_config_instance_set_encoder_params(ni_session_context_t *p_ctx)
Send a p_config command to configure encoding parameters.
ni_retcode_t ni_clear_instance_buf(niFrameSurface1_t *surface)
clear a particular xcoder instance buffer/data
ni_retcode_t ni_query_session_statistic_info(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_session_statistic_t *p_session_statistic)
Query a particular xcoder session to get session statistics.
void ni_params_print(ni_xcoder_params_t *const p_encoder_params)
Print xcoder user configurations.
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)
ni_retcode_t ni_ai_session_close(ni_session_context_t *p_ctx, int eos_recieved)
void ni_set_default_template(ni_session_context_t *p_ctx, ni_encoder_config_t *p_config)
Setup and initialize all xcoder configuration to default (Rev. B)
int lower_pixel_rate(const ni_load_query_t *pQuery, uint32_t ui32CurrentLowest)
void SwapSW64(uint64_t *buf, uint64_t bytes)
void ni_fix_VUI(uint8_t *vui, int pos, int value)
insert the 32 bits of integer value at bit position pos
int ni_get_bitdepth_factor_from_pixfmt(int pix_fmt)
Grab bitdepth factor from NI_PIX_FMT.
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.
#define AI_MODEL_TYPE_USM_FILTER
ni_retcode_t ni_decoder_session_flush(ni_session_context_t *p_ctx)
Flush decoder output.
ni_retcode_t ni_query_session_stats(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_session_stats_t *p_session_stats, int rc, int opcode)
Query a particular session to get the stats info.
ni_retcode_t ni_dump_log_all_cores(ni_session_context_t *p_ctx, void *p_data, bool gen_log_file)
int ni_scaler_session_open(ni_session_context_t *p_ctx)
Open a xcoder scaler instance.
int ni_encoder_session_write(ni_session_context_t *p_ctx, ni_frame_t *p_frame)
Send a YUV p_frame to encoder.
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 AI_MODEL_TYPE_HVSPLUS_FILTER
Private definitions used by ni_device_api.c for video processing tasks.
#define CU_SIZE_BIT_POSITION
#define NI_FW_ENC_BITSTREAM_META_DATA_SIZE_UNDER_MAJOR_6_MINOR_rc
#define AVC_MB_MODE_BYTE_OFFSET
struct _ni_instance_mgr_stream_complete ni_instance_mgr_stream_complete_t
#define NI_SESSION_CLOSE_RETRY_MAX
#define AVC_MB_MODE_BIT_POSITION
@ GOP_PRESET_IDX_HIERARCHICAL_IPPPP
#define AVC_RDCOST_BIT_POSITION
struct _ni_network_buffer_info ni_network_buffer_info_t
#define INTERCOST_BIT_POSITION
#define INTRA_PART_MODE_BYTE_OFFSET
#define CU_INFO_OUTPUT_SIZE_V1
#define RDCOST_OTHER_BYTE_OFFSET
#define RDCOST_OTHER_BITS
#define NI_FW_ENC_BITSTREAM_META_DATA_SIZE_UNDER_MAJOR_6_MINOR_sM
#define FW_LOG_END_DELIMITER_1
ni_session_config_rw_type_t
struct _ni_session_config_rw ni_session_config_rw_t
struct _ni_ai_config_t ni_ai_config_t
struct _ni_decoder_config_t ni_decoder_config_t
struct _ni_instance_mgr_stream_info ni_instance_mgr_stream_info_t
struct _ni_instance_buf_info ni_instance_buf_info_t
#define AVC_INTRA_PART_MODE_BIT_POSITION
#define RDCOST_BIT_POSITION
#define NI_RETRY_INTERVAL_100US
#define INTER_PRED_IDC_BYTE_OFFSET
#define INTER_PRED_IDC_BITS
#define FW_LOG_END_DELIMITER_0
#define CU_MODE_BIT_POSITION
struct _ni_session_stats ni_session_stats_t
#define NI_RETRY_INTERVAL_200US
#define INTRA_PART_MODE_BIT_POSITION
#define NI_QUADRA_MEMORY_CONFIG_SR_4G
#define RDCOST_BYTE_OFFSET
#define INTRA_PART_MODE_BITS
#define INTRACOST_BIT_POSITION
@ ni_xcoder_resource_recovery
#define AVC_INTRA_PART_MODE_BYTE_OFFSET
#define NI_DMA_SGL_MAX_XFER_SIZE
#define RDCOST_OTHER_BIT_POSITION
#define INTER_PRED_IDC_BIT_POSITION
struct _ni_encoder_config_t ni_encoder_config_t
#define AVC_INTRA_PART_MODE_BITS
#define AVC_RDCOST_BYTE_OFFSET
#define CU_SIZE_BYTE_OFFSET
struct _ni_metadata_enc_bstream ni_metadata_enc_bstream_t
#define AVC_INTER_PRED_IDC_BITS
#define AVC_INTER_PRED_IDC_BIT_POSITION
struct _ni_instance_mgr_allocation_info ni_instance_mgr_allocation_info_t
#define FW_LOG_START_DELIMITER_1
#define FW_LOG_START_DELIMITER_0
#define NI_QUADRA_MEMORY_CONFIG_SR
#define NI_MAX_AI_NETWORK_BINARY_BUFFER_QUERY_RETRIES
struct _ni_encoder_frame_params ni_encoder_frame_params_t
#define NI_MAX_P2P_SGL_ENTRIES
#define NI_MAX_DEC_SESSION_READ_QUERY_EOS_RETRIES
#define INTRACOST_BYTE_OFFSET
struct _ni_instance_mgr_general_status ni_instance_mgr_general_status_t
#define TUNE_BFRAME_VISUAL_MEDIUM
struct _ni_resolution ni_resolution_t
#define CU_MODE_BYTE_OFFSET
#define NI_HWDESC_UNIFIED_MEMBIN_SIZE
#define NI_FW_ENC_BITSTREAM_META_DATA_SIZE
#define FRAME_CHUNK_INDEX_SIZE
ni_instance_buf_info_rw_type_t
@ INST_BUF_INFO_R_ACQUIRE
@ INST_BUF_INFO_RW_WRITE_BUSY
@ INST_BUF_INFO_RW_UPLOAD
@ INST_BUF_INFO_RW_WRITE_BY_EP
@ INST_BUF_INFO_RW_READ_BY_AI
@ INST_BUF_INFO_RW_READ_BUSY
#define AVC_INTER_PRED_IDC_BYTE_OFFSET
#define NI_MAX_SEGMENT_NUM
#define INTERCOST_BYTE_OFFSET
#define NI_QUADRA_MEMORY_CONFIG_DR
#define NI_AI_HW_ALIGN_SIZE
#define NI_FW_ENC_BITSTREAM_META_DATA_SIZE_UNDER_MAJOR_6_MINOR_o
#define NI_MINIMUM_CROPPED_LENGTH
int hwdl_frame(ni_session_context_t *p_ctx, ni_session_data_io_t *p_session_data, ni_frame_t *p_src_frame, int output_format)
Download hw frames by HwDesc.
void * ni_lat_meas_q_add_entry(ni_lat_meas_q_t *frame_time_q, uint64_t abs_time, int64_t ts_time)
Add a new entry to latency queue.
uint64_t ni_lat_meas_q_check_latency(ni_lat_meas_q_t *frame_time_q, uint64_t abs_time, int64_t ts_time)
Check latency of a frame referenced by its timestamp.
Utility definitions for measuring frame/packet processing time in NETINT video processing devices.
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,
uint64_t ni_log_get_utime()
Get time for logs with microsecond timestamps.
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
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.
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.
ni_retcode_t ni_nvme_check_error_code(int rc, int opcode, uint32_t xcoder_type, uint32_t hw_id, uint32_t *p_instance_id)
Check f/w error return code, and if it's a fatal one, terminate application's decoding/encoding proce...
Private definitions for interfacing with NETINT video processing devices over NVMe.
#define CONFIG_INSTANCE_UploadModel_W(sid, instance)
#define CONFIG_INSTANCE_SetAiHVSPlus_W(sid, instance)
#define QUERY_INSTANCE_UPLOAD_ID_R(sid, instance)
#define CONFIG_INSTANCE_SetScalerPara_W(sid, instance)
#define CONFIG_INSTANCE_SetSOS_W(sid, instance)
#define CONFIG_INSTANCE_SetP2P_W(sid, instance)
#define WRITE_METADATA_W(sid, instance)
#define CONFIG_SESSION_FRAME_COPY_W(sid)
#define FL_LOG_OFFSET_IN_4K
@ nvme_admin_cmd_xcoder_config
@ nvme_admin_cmd_xcoder_open
@ nvme_admin_cmd_xcoder_query
#define QUERY_INSTANCE_STREAM_INFO_R(sid, instance)
#define QUERY_INSTANCE_NL_V2_R(sid, instance)
#define WRITE_INSTANCE_W(sid, instance)
#define QUERY_INSTANCE_ACQUIRE_BUF(sid, instance)
#define QUERY_INSTANCE_NL_R(sid, instance)
#define QUERY_INSTANCE_RBUFF_SIZE_BUSY_R(sid, instance)
#define CONFIG_INSTANCE_SetEOS_W(sid, instance)
#define CONFIG_SESSION_DDR_PRIORITY_W(sid)
#define DOWNLOAD_FRAMEIDX_R(frame_id)
#define CONFIG_INSTANCE_SetScalerAlloc_W(sid, instance)
#define FP_LOG_OFFSET_IN_4K
#define QUERY_INSTANCE_HW_OUT_SIZE_R(sid, instance)
#define CONFIG_INSTANCE_Flush_W(sid, instance)
#define CONFIG_INSTANCE_SetPktSize_W(sid, instance)
#define NVME_LOG_OFFSET_IN_4K
#define CONFIG_INSTANCE_SetDecPpuPara_W(sid, instance)
#define CLOSE_SESSION_R(sid, instance)
#define QUERY_INSTANCE_RBUFF_SIZE_R(sid, instance)
#define CONFIG_INSTANCE_SetAiFrm_W(sid, instance)
#define QUERY_GENERAL_GET_STATUS_R(instance)
#define QUERY_SESSION_STATS_R(sid, instance)
#define EP_LOG_OFFSET_IN_4K
#define CONFIG_SESSION_Read_W(sid)
#define IDENTIFY_DEVICE_R
#define QUERY_INSTANCE_WBUFF_SIZE_R_BY_EP(sid, instance)
#define NI_DATA_BUFFER_LEN
#define QUERY_INSTANCE_EOS_R(sid, instance)
#define TP_LOG_OFFSET_IN_4K
#define QUERY_DETAIL_GET_STATUS_R(instance)
#define QUERY_INSTANCE_AI_INFO_R(sid, instance)
#define CONFIG_SESSION_KeepAlive_W(sid)
#define CONFIG_INSTANCE_SetEncRoiQpMap_W(sid, instance)
#define QUERY_INSTANCE_METRICS_R(sid, instance)
#define CONFIG_INSTANCE_SetEncFramePara_W(sid, instance)
#define QUERY_INSTANCE_CUR_STATUS_INFO_R(sid, instance)
#define QUERY_INSTANCE_NL_SIZE_R(sid, instance)
#define CLEAR_INSTANCE_BUF_W(frame_id)
#define CONFIG_INSTANCE_SetAiPara_W(sid, instance)
#define QUERY_INSTANCE_WBUFF_SIZE_BUSY_R(sid, instance)
#define CONFIG_INSTANCE_SetSeqChange_W(sid, instance)
#define OPEN_ADD_CODEC(instance, codec, param)
#define NI_NVME_IDENTITY_CMD_DATA_SZ
#define CONFIG_SESSION_KeepAliveTimeout_W(sid)
#define CONFIG_INSTANCE_SetEncPara_W(sid, instance)
#define READ_INSTANCE_R(sid, instance)
#define QUERY_INSTANCE_WBUFF_SIZE_R(sid, instance)
#define QUERY_INSTANCE_NL_SIZE_V2_R(sid, instance)
#define QUERY_DETAIL_GET_STATUS_V1_R(instance)
@ nvme_config_xcoder_config_set_write_legth
@ nvme_config_xcoder_config_set_sequence_change
#define CONFIG_SESSION_SWVersion_W(sid)
#define CONFIG_SESSION_Write_W(sid)
#define OPEN_SESSION_CODEC(instance, codec, param)
#define CONFIG_INSTANCE_SetDecPara_W(sid, instance)
#define DP_LOG_OFFSET_IN_4K
#define CONFIG_GLOBAL_NAMESPACE_NUM
Definitions related to NETINT P2P kernel driver interface.
struct timeval current_time
int ni_rsrc_get_numa_node(char *device_name)
get linux numa_node
void ni_rsrc_free_device_context(ni_device_context_t *p_device_context)
Free previously allocated device context.
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....
Private definitions used by ni_rsrc_api.cpp for management of NETINT video processing devices.
void get_dev_pcie_addr(char *device_name, char *pcie, char *domain, char *slot, char *dev, char *func)
ni_retcode_t ni_timestamp_register(ni_queue_buffer_pool_t *p_buffer_pool, ni_timestamp_table_t *p_table, int64_t timestamp, uint64_t data_info)
Register timestamp in timestamp/frameoffset table.
int ni_pthread_mutex_lock(ni_pthread_mutex_t *mutex)
thread mutex lock
void ni_buffer_pool_free(ni_queue_buffer_pool_t *p_buffer_pool)
void ni_dec_fme_buffer_pool_free(ni_buf_pool_t *p_buffer_pool)
ni_retcode_t ni_strncpy(char *dest, size_t dmax, const char *src, size_t slen)
int ni_pthread_cond_signal(ni_pthread_cond_t *cond)
signal a condition
int ni_posix_memalign(void **memptr, size_t alignment, size_t size)
Allocate aligned memory.
void ni_fmt_fw_api_ver_str(const char ver_str[], char fmt_str[])
Get formatted FW API version string from unformatted FW API version string.
ni_retcode_t ni_strerror(char *dest, size_t dmax, int errnum)
void ni_calculate_sha256(const uint8_t aui8Data[], size_t ui32DataLength, uint8_t aui8Hash[])
int32_t ni_dec_fme_buffer_pool_initialize(ni_session_context_t *p_ctx, int32_t number_of_buffers, int width, int height, int height_align, int factor)
ni_retcode_t ni_timestamp_get_with_threshold(ni_timestamp_table_t *p_table, uint64_t frame_info, int64_t *p_timestamp, int32_t threshold, int32_t print, ni_queue_buffer_pool_t *p_buffer_pool)
ni_retcode_t ni_strcat(char *dest, size_t dmax, const char *src)
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....
ni_retcode_t ni_fopen(FILE **fp, const char *filename, const char *mode)
int ni_pthread_sigmask(int how, const ni_sigset_t *set, ni_sigset_t *oldset)
examine and change mask of blocked signals
ni_retcode_t ni_strcpy(char *dest, size_t dmax, const char *src)
uint32_t ni_ai_network_layer_size(ni_network_layer_params_t *p_param)
int ni_pthread_cond_timedwait(ni_pthread_cond_t *cond, ni_pthread_mutex_t *mutex, const struct timespec *abstime)
wait on a condition
ni_retcode_t ni_timestamp_init(ni_session_context_t *p_ctx, ni_timestamp_table_t **pp_table, const char *name)
Initialize timestamp handling.
void ni_usleep(int64_t usec)
ni_retcode_t ni_queue_free(ni_queue_t *p_queue, ni_queue_buffer_pool_t *p_buffer_pool)
Free xcoder queue.
uint64_t ni_gettime_ns(void)
void ni_timestamp_scan_cleanup(ni_timestamp_table_t *pts_list, ni_timestamp_table_t *dts_list, ni_queue_buffer_pool_t *p_buffer_pool)
int ni_pthread_mutex_unlock(ni_pthread_mutex_t *mutex)
thread mutex unlock
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...
#define XCODER_MAX_ENC_PIC_HEIGHT
#define NI_DEC_FRAME_BUF_POOL_SIZE_INIT
#define XCODER_MIN_ENC_PIC_WIDTH
#define COMPILE_ASSERT(condition)
#define XCODER_MAX_NUM_TEMPORAL_LAYER
#define ni_aligned_free(p_memptr)
#define XCODER_MIN_ENC_PIC_HEIGHT
#define XCODER_MAX_ENC_PIC_WIDTH
#define XCODER_FRAME_OFFSET_DIFF_THRES
#define ni_memfree(p_memptr)
float avg_forward_pred_block_qp
int num_forward_pred_blocks
int num_intra_block_blocks
int num_intra_plane_blocks
payload format of HDR SEI content light level info
uint16_t max_content_light_level
uint16_t max_pic_average_light_level
ni_gop_params_t pic_param[NI_MAX_GOP_NUM]
decoded payload format of HDR SEI mastering display colour volume
uint32_t min_display_mastering_luminance
uint32_t max_display_mastering_luminance
uint16_t display_primaries[3][2]
uint8_t ui8EnableAdvancedEc
uint8_t ui8ReduceDpbDelay
uint8_t ui8MaxExtraHwFrameCnt
uint16_t ui16MaxSeiDataSize
ni_decoder_output_config_t asOutputConfig[NI_MAX_NUM_OF_DECODER_OUTPUTS]
uint32_t ui32ErrRatioThreshold
uint8_t ui8DisableAdaptiveBuffers
uint8_t ui8DisablePictureReordering
uint8_t ui8EnablelowDelayCheck
uint8_t ui8SurviveStreamErr
uint32_t ui32SourceHeight
uint8_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
uint8_t fw_commit_time[26]
uint8_t serial_number[20]
uint8_t fw_commit_hash[41]
ni_hw_capability_t xcoder_devices[NI_MAX_DEVICES_PER_HW_INSTANCE]
uint8_t fw_branch_name[256]
uint8_t fw_build_time[26]
uint8_t xcoder_devices_cnt
int enable_dynamic_16x16_merge
int scene_change_detect_level
int linkFrameMaxIntraRatio
int intra_mb_refresh_mode
int preferred_transfer_characteristics
int motionConstrainedMode
int decoding_refresh_type
int enable_dynamic_32x32_merge
ni_custom_gop_params_t custom_gop_params
struct _ni_encoder_cfg_params::@16 rc
int enable_dynamic_8x8_merge
int av1_error_resilient_mode
int spatialLayerBitrate[NI_MAX_SPATIAL_LAYERS]
int crf_max_iframe_enable
float forceBframeQpfactor
int temporal_layers_enable
int pastFrameMaxIntraRatio
int av1OpLevel[NI_MAX_SPATIAL_LAYERS]
int spatial_layers_ref_base_layer
int long_term_ref_interval
int still_image_detect_level
int statistic_output_level
int enable_cu_level_rate_control
int max_consecutive_skip_num
int use_recommend_enc_params
int customize_roi_qp_level
uint8_t ui8av1ErrResilientMode
uint8_t ui8customMinCoeffDiv
uint8_t ui8vbvBufferReencode
uint32_t ui32ltrRefInterval
uint8_t ui8crfMaxIframeEnable
uint8_t ui8mallocStrategy
uint8_t ui8av1OpLevel[NI_MAX_SPATIAL_LAYERS]
int32_t i32forceBframeQpFactor
int32_t i32userMinDeltaQp
int8_t i8statisticOutputLevel
int32_t i32userMaxDeltaQp
uint8_t ui8fixedframerate
uint8_t u8customizeRoiQpLevel
uint8_t ui8adaptiveLamdaMode
uint8_t ui8rcQpDeltaRange
uint8_t ui8totalCuTreeDepth
uint8_t ui8lowLatencyMode
uint16_t ui16iFrameSizeRatio
uint8_t ui8intraCompensateMode
uint16_t ui16aspectRatioHeight
uint8_t ui8EnableRdoQuant
uint8_t ui8pastFrameMaxIntraRatio
uint16_t ui16HDR10MaxLight
uint8_t ui8videoFullRange
uint32_t ui32hdr10_minluma
uint8_t ui8noHWMultiPassSupport
uint32_t ui32lumaLinesize
uint8_t ui8preIntraHandling
uint8_t ui8setLongTermCount
int32_t i32ltrRefQpOffset
uint8_t ui8useLowDelayPocType
uint8_t ui8EnableAcqLimit
uint8_t ui8multicoreJointMode
uint8_t ui8adaptiveCuTree
uint8_t ui8LookAheadDepth
uint8_t ui8HDR10CLLEnable
uint32_t ui32VuiDataSizeBytes
uint8_t ui8enableSmoothCrf
int32_t i32spatialLayerBitrate[NI_MAX_SPATIAL_LAYERS]
uint8_t ui8linkFrameMaxIntraRatio
uint8_t ui8enableTimecode
uint32_t ui32chromaLinesize
uint32_t ui32VuiDataSizeBits
uint8_t ui8enableCompensateQp
uint8_t ui8disableBframeRDOQ
uint8_t ui8sceneChangeDetectLevel
uint8_t ui8colorPrimaries
uint32_t ui32sourceEndian
uint8_t ui8disableAv1TimingInfo
uint8_t ui8enable2PassGopPatern
uint8_t ui8temporalLayersEnable
uint8_t u8skipFrameInterval
int8_t i8hvsBaseMbComplexity
uint8_t ui8colorDescPresent
uint8_t ui8intraResetRefresh
uint8_t ui8AiEnhanceLevel
uint16_t ui16maxFrameSize
uint32_t ui32hdr10_maxluma
uint8_t ui8tuneBframeVisual
int8_t i8maxConsecutiveSkipFrameNum
uint32_t ui32setLongTermInterval
uint8_t ui8cutreeFlushIframe
uint16_t ui16HDR10AveLight
uint32_t ui32ltrNextInterval
uint8_t ui8adaptiveCrfMode
ni_t408_config_t niParamT408
uint8_t ui8spatialLayersRefBaseLayer
uint8_t ui8motionConstrainedMode
int32_t i32frameRateDenominator
uint8_t ui8stillImageDetectLevel
uint16_t ui16aspectRatioWidth
uint8_t ui8spatialLayersMinusOne
uint8_t ui8bitstreamFormat
uint16_t force_picture_type
uint16_t rectangle_height
uint8_t inconsecutive_transfer
uint32_t data_len[NI_MAX_NUM_DATA_POINTERS]
unsigned int sei_hdr_mastering_display_color_vol_offset
unsigned int sei_hdr_content_light_level_info_offset
uint32_t start_len[NI_MAX_NUM_DATA_POINTERS]
uint32_t start_buffer_size
uint8_t separate_metadata
unsigned int sei_hdr_plus_len
uint32_t metadata_buffer_size
unsigned int sei_hdr_plus_offset
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
unsigned int extra_data_len
unsigned int sei_total_len
unsigned int sei_cc_offset
unsigned int sei_user_data_unreg_len
ni_pic_type_t ni_pict_type
uint8_t use_cur_src_as_long_term_pic
ni_custom_sei_set_t * p_custom_sei_set
uint16_t hor_adjust_offset
unsigned int sei_hdr_content_light_level_info_len
uint8_t * p_metadata_buffer
unsigned int sei_hdr_mastering_display_color_vol_len
unsigned int sei_user_data_unreg_offset
uint8_t use_long_term_ref
ni_gop_rps_t rps[NI_MAX_REF_PIC]
uint16_t min_video_height
uint16_t max_video_height
uint8_t max_number_of_contexts
ni_instance_upload_ret_hwdesc_t hw_inst_ind
uint16_t rectangle_height
uint32_t fw_model_load_overall
uint8_t active_sub_instances_cnt
uint8_t process_load_percent_upper
uint8_t process_load_percent
uint8_t active_hwupload_sub_inst_cnt
uint8_t fw_video_shared_mem_usage
uint8_t process_load_percent_overall
uint8_t fw_video_mem_usage
uint8_t active_sub_instances_cnt_overall
uint8_t fw_share_mem_usage
uint16_t transfer_frame_height
uint16_t transfer_frame_stride
uint64_t last_benchmark_time
uint32_t fw_share_mem_usage
uint32_t total_pixel_load
uint32_t fw_p2p_mem_usage
uint32_t fw_video_shared_mem_usage
uint32_t active_hwuploaders
uint32_t fw_video_mem_usage
ni_segment_t segment[NI_MAX_SEGMENT_NUM]
ni_network_layer_offset_t * inset
ni_network_layer_info_t linfo
ni_network_layer_offset_t * outset
ni_network_layer_params_t * in_param
ni_network_layer_params_t * out_param
uint32_t total_idle_cycles
uint8_t hw_max_number_of_contexts
uint8_t hw2_video_profile
uint8_t xcoder_num_h264_decoder_hw
uint8_t xcoder_num_h264_encoder_hw
ni_nvme_identity_xcoder_hw_t xcoder_devices[NI_MAX_DEVICES_PER_HW_INSTANCE]
uint8_t fw_commit_time[26]
uint8_t xcoder_num_h265_decoder_hw
uint8_t fw_commit_hash[41]
uint8_t xcoder_num_elements
uint8_t xcoder_num_devices
uint8_t fw_branch_name[256]
uint8_t fw_build_time[26]
uint8_t hw0_video_profile
uint8_t hw3_video_profile
uint8_t xcoder_num_h265_encoder_hw
uint8_t hw1_video_profile
uint32_t overall_fw_model_load
uint32_t overall_current_load
uint32_t overall_instance_count
uint64_t ui64DMAAddr[NI_MAX_P2P_SGL_ENTRY]
uint32_t ui32DMALen[NI_MAX_P2P_SGL_ENTRY]
uint8_t scene_change_detected
uint8_t still_image_detected
ni_bitstream_features_t bitstream_features
ni_custom_sei_set_t * p_custom_sei_set
bool enable_scaler_params
union _ni_session_config_rw::@20 uHWAccessField
uint16_t ui16WriteFrameId
uint64_t pkt_offsets_index_min[NI_FIFO_SZ]
char blk_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
uint8_t itu_t_t35_hdr10p_sei_hdr_hevc[NI_HDR10P_SEI_HDR_HEVC_LEN]
int enable_user_data_sei_passthru
int max_retry_fail_count[2]
ni_pthread_cond_t low_delay_sync_cond
ni_queue_buffer_pool_t * buffer_pool
uint64_t ppu_reconfig_pkt_pos
int is_dec_pkt_512_aligned
uint32_t keep_alive_timeout
ni_session_statistic_t session_statistic
char blk_dev_name[NI_MAX_DEVICE_NAME_LEN]
ni_device_handle_t sender_handle
ni_device_handle_t device_handle
int flags_array[NI_FIFO_SZ]
ni_load_query_t load_query
int64_t last_pts_interval
ni_pthread_mutex_t * pext_mutex
uint64_t last_frame_offset
ni_custom_sei_set_t * pkt_custom_sei_set[NI_FIFO_SZ]
int pts_correction_num_faulty_dts
ni_device_handle_t auto_dl_handle
uint32_t actual_video_width
uint8_t sei_trailer[NI_CC_SEI_TRAILER_LEN]
uint32_t force_low_delay_cnt
ni_aio_context_t aio_context
ni_network_data_t * network_data
uint64_t pkt_offsets_index[NI_FIFO_SZ]
uint8_t itu_t_t35_cc_sei_hdr_hevc[NI_CC_SEI_HDR_HEVC_LEN]
volatile uint64_t last_access_time
char dev_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
uint8_t itu_t_t35_cc_sei_hdr_h264[NI_CC_SEI_HDR_H264_LEN]
ni_event_handle_t event_handle
ni_input_frame input_frame_fifo[120]
encoder:calculate PSNR start
uint32_t last_frame_dropped
ni_framerate_t last_framerate
uint32_t meta_size
Params used in VFR mode Done///.
uint8_t pending_bitstream_buffer_realloc
ni_device_handle_t blk_io_handle
uint32_t biggest_bitstream_buffer_allocated
int64_t pts_correction_last_dts
int hvsplus_level
encoder:calculate PSNR end
char stream_dir_name[256]
uint32_t scaler_operation
uint32_t max_nvme_io_size
uint64_t frame_pkt_offset
ni_overall_load_query_t overall_load_query
uint64_t pkt_pos[NI_FIFO_SZ]
int enable_low_delay_check
int64_t pts_correction_last_pts
ni_timestamp_table_t * pts_table
ni_session_run_state_t session_run_state
ni_pthread_mutex_t low_delay_sync_mutex
uint64_t session_timestamp
uint8_t itu_t_t35_hdr10p_sei_hdr_h264[NI_HDR10P_SEI_HDR_H264_LEN]
int64_t last_dts_interval
int16_t buffered_frame_index
int64_t pts_offsets[NI_FIFO_SZ]
ni_timestamp_table_t * dts_queue
uint32_t active_video_width
uint32_t active_video_height
uint32_t decoder_last_drop_frame_num
int pts_correction_num_faulty_pts
ni_frame_pool_type_t pool_type
uint32_t required_buf_size
ni_buf_pool_t * dec_fme_buf_pool
union _ni_session_data_io::@19 data
uint32_t ui32FramesBuffered
uint32_t ui32FramesDropped
uint8_t ui8AdditionalFramesDelay
uint32_t ui32LastTransactionCompletionStatus
uint32_t ui32FramesCorrupted
uint32_t ui32LastErrorStatus
uint32_t ui32RdBufAvailSize
uint32_t ui32WrBufAvailSize
uint32_t ui32LastErrorTransactionId
uint32_t ui32FramesCompleted
uint32_t ui32FramesOutput
uint32_t ui32FramesErrorRatio
uint32_t ui32LastTransactionId
uint32_t ui32Session_timestamp_high
uint32_t ui32LastTransactionCompletionStatus
uint32_t ui32LastErrorStatus
uint32_t ui32Session_timestamp_low
uint32_t ui32LastErrorTransactionId
int32_t lambdaScalingEnable
int32_t constIntraPredFlag
int32_t pu08IntraAngleDeltaRate
uint32_t strongIntraSmoothEnable
int32_t cu16InterDeltaRate
int32_t pu16IntraDcDeltaRate
int32_t enable_cu_level_rate_control
int32_t intra_mb_refresh_arg
int32_t cu08MergeDeltaRate
int32_t intra_mb_refresh_mode
int32_t independSliceMode
int32_t fixedBitRatio[NI_MAX_GOP_NUM]
int32_t dependSliceModeArg
int32_t use_recommend_enc_params
ni_custom_gop_params_t custom_gop_params
int32_t pu08IntraDcDeltaRate
int32_t decoding_refresh_type
int32_t independSliceModeArg
int32_t enable_mb_level_rc
uint32_t monochromeEnable
int32_t lfCrossSliceBoundaryEnable
uint32_t forcedHeaderEnable
uint32_t customLambdaEnable
int32_t pu04IntraDcDeltaRate
int32_t pu04IntraAngleDeltaRate
int32_t cu32InterDeltaRate
int32_t pu16IntraAngleDeltaRate
int32_t pu08IntraPlanarDeltaRate
uint32_t nrNoiseEstEnable
int32_t scalingListEnable
int32_t pu16IntraPlanarDeltaRate
uint32_t numTicksPocDiffOne
int32_t pu04IntraPlanarDeltaRate
int32_t enable_transform_8x8
int32_t entropy_coding_mode
int32_t cu32MergeDeltaRate
int32_t cu16MergeDeltaRate
uint32_t weightPredEnable
int32_t pu32IntraAngleDeltaRate
int32_t cu16IntraDeltaRate
int32_t cu08IntraDeltaRate
int32_t cu08InterDeltaRate
int32_t cu32IntraDeltaRate
int32_t pu32IntraDcDeltaRate
int32_t pu32IntraPlanarDeltaRate
ni_event_handle_t thread_event_handle
ni_pthread_mutex_t * p_mutex
uint32_t keep_alive_timeout
ni_device_handle_t device_handle
uint64_t session_timestamp
volatile uint64_t * plast_access_time
uint32_t ui32lumaLinesize
uint32_t ui32chromaLinesize
ni_encoder_cfg_params_t cfg_enc_params
int8_t customize_roi_qp_map[NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL][NI_CUSTOMIZE_ROI_QP_NUM]
ni_ddr_priority_mode_t ddr_priority_mode
ni_decoder_input_params_t dec_input_params
int use_low_delay_poc_type
int video_full_range_flag
int enableCuLevelRateControl
Log entry information structure.
const uint8_t * start_ptr
Log entry trailer structure.
uint8_t ui8EnablePpuScaleLimit
ni_decoder_output_picture_size sOutputPictureSize
uint8_t ui8SemiPlanarEnabled
uint8_t ui8EnablePpuScaleAdapt
ni_decode_cropping_rectangle sCroppingRectable