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__)
80#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
89static 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},
90 {8, 0, -1, -1, -1, 2, 4, -1, -1, 8, 1, -1, -1, -1, -1, -1, -1}};
91#define MIN(x,y) (((x)>(y))?(y):(x))
92#define MAX(x,y) (((x)<(y))?(y):(x))
93#define HEVC_LEVEL_NUM 13
94#define H264_LEVEL_NUM 20
95#define AV1_LEVEL_NUM 14
97static const uint64_t max_sample_rate_second_h265[
HEVC_LEVEL_NUM ] =
99 552960, 3686400, 7372800, 16588800, 33177600, 66846720, 133693440, 267386880,
100 534773760, 1069547520, 1069547520, 2139095040, 4278190080
102static const uint64_t max_sample_rate_second_h264[
H264_LEVEL_NUM ] =
104 (uint64_t)1485*256, (uint64_t)1485*256, (uint64_t)3000*256, (uint64_t)6000*256, (uint64_t)11880*256, (uint64_t)11880*256, (uint64_t)19800*256, (uint64_t)20250*256,
105 (uint64_t)40500*256, (uint64_t)108000*256, (uint64_t)216000*256, (uint64_t)245760*256, (uint64_t)245760*256,
106 (uint64_t)522240*256, (uint64_t)589824*256, (uint64_t)983040*256, (uint64_t)2073600*256,
107 (uint64_t)4177920*256, (uint64_t)8355840*256, (uint64_t)16711680*256
109static const uint64_t max_sample_rate_second_av1[
AV1_LEVEL_NUM ] =
111 5529600, 10454400, 24969600, 39938400, 77856768, 155713536,
112 273715200, 547430400, 1094860800, 1176502272, 1176502272, 2189721600, 4379443200, 4706009088
117 36864, 122880, 245760, 552960, 983040, 2228224, 2228224, 8912896,
118 8912896, 8912896, 35651584, 35651584, 35651584
122 99*256, 99*256, 396*256, 396*256, 396*256, 396*256, 792*256, 1620*256,
123 1620*256, 3600*256, 5120*256, 8192*256, 8192*256,
124 8704*256, 22080*256, 36864*256, 36864*256,
125 139264*256, 139264*256, 139264*256
129 147456, 278784, 665856, 1065024, 2359296, 2359296,
130 8912896, 8912896, 8912896, 8912896, 35651584, 35651584, 35651584, 35651584
135 350000, 1500000, 3000000, 6000000, 10000000, 12000000, 20000000,
136 25000000, 40000000, 60000000, 60000000, 120000000, 240000000
138static const uint32_t max_cpb_hightier_second_h265[
HEVC_LEVEL_NUM ] =
140 350000, 1500000, 3000000, 6000000, 10000000, 30000000, 50000000,
141 100000000, 160000000, 240000000, 240000000, 480000000, 800000000
145 175000, 350000, 500000, 1000000, 2000000, 2000000, 4000000, 4000000,
146 10000000, 14000000, 20000000, 25000000, 62500000,
147 62500000, 135000000, 240000000, 240000000,
148 240000000, 480000000, 800000000
152 1500000, 3000000, 6000000, 10000000, 12000000, 20000000,
153 30000000, 40000000, 60000000, 60000000, 60000000, 100000000, 160000000, 160000000
155static const uint32_t max_cpb_hightier_second_av1[
AV1_LEVEL_NUM ] =
157 0, 0, 0, 0, 30000000, 50000000,
158 100000000, 160000000, 240000000, 240000000, 240000000, 480000000, 800000000, 800000000
162 64000, 128000, 192000, 384000, 768000, 2000000, 4000000, 4000000,
163 10000000, 14000000, 20000000, 20000000, 50000000,
164 50000000, 135000000, 240000000, 240000000,
165 240000000, 480000000, 800000000
168#define MAGIC_P2P_VALUE "p2p"
169#define AI_MODEL_TYPE_HVSPLUS_FILTER 3
170#define AI_MODEL_TYPE_USM_FILTER 4
207 0x00, 0x00, 0x00, 0x01,
225 0x00, 0x00, 0x00, 0x01,
241 0x00, 0x00, 0x00, 0x01,
257 0x00, 0x00, 0x00, 0x01,
298#define NI_XCODER_FAILURES_MAX 25
299#define DP_IPC_PASSTHRU 0xFFFFFFFF
302#ifdef XCODER_SELF_KILL_ERR
303#undef XCODER_SELF_KILL_ERR
314 for (i = 0; i < bytes; i += 2)
316 uint8_t val = buf[i];
324 uint32_t i, words = (bytes + 1) / 2;
326 for (i = 0; i < words; i += 2)
328 uint16_t val = buf[i];
336 uint32_t i, words = (bytes + 3) / 4;
337 for (i = 0; i < words; i += 2)
339 uint32_t val = buf[i];
347 uint64_t i, words = (bytes + 7) / 8;
348 for (i = 0; i < words; i += 2)
350 uint64_t val = buf[i];
356static void memcpyToPelByBits (uint8_t *dst_u8, uint8_t *src,
int width,
int height,
int dst_stride,
int src_stride,
int srcValidBitsDepth)
359 uint8_t bitsDepth = srcValidBitsDepth;
360 uint32_t mask = (1<<bitsDepth)-1;
361 uint16_t *dst = (uint16_t *)dst_u8;
366 for (j = 0; j < height; j ++)
368 for (i = 0; i< width; i ++)
369 dst_u8[i] = src[i] & 0xff;
372 dst_u8 += dst_stride;
378 for (j = 0; j < height; j ++)
380 uint8_t *src_line = src;
381 uint32_t cache = 0, cache_bits = 0;
382 for (i = 0; i< width; i ++)
384 while(cache_bits < bitsDepth)
386 cache |= ((*src_line++) << cache_bits);
390 if (cache_bits >= bitsDepth)
392 dst[i] = cache & mask;
394 cache_bits -= bitsDepth;
419static void trace_recon_tile2raster_y(FILE *fRecon, uint8_t *mem,
int width,
int height,
420 int leftOffset,
int topOffset,
421 int src_stride,
int pixDepth, uint8_t *luma_mem_temp)
425 int write_data_len = 0;
426 int bytesPerPix = (pixDepth == 8 ? 1 : 2);
427 uint8_t *tmp_mem = (uint8_t *)malloc((
size_t)bytesPerPix*src_stride);
428 int num_tiles = (leftOffset + width + 3) / 4 - leftOffset/4;
431 mem += topOffset/4*4*src_stride + leftOffset/4*16*pixDepth/8;
432 for(i = topOffset/4*4; i < topOffset + height; i += 4) {
433 memcpyToPelByBits(tmp_mem, mem, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
434 if(i >= topOffset && i < topOffset + height){
436 memcpy(luma_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
437 write_data_len += width * bytesPerPix;
439 memcpyToPelByBits(tmp_mem, mem+4*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
440 if(i+1 >= topOffset && i+1 < topOffset + height)
443 memcpy(luma_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
444 write_data_len += width * bytesPerPix;
446 memcpyToPelByBits(tmp_mem, mem+8*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
447 if(i+2 >= topOffset && i+2 < topOffset + height)
450 memcpy(luma_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
451 write_data_len += width * bytesPerPix;
453 memcpyToPelByBits(tmp_mem, mem+12*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
454 if(i+3 >= topOffset && i+3 < topOffset + height)
457 memcpy(luma_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
458 write_data_len += width * bytesPerPix;
460 mem += (ptrdiff_t)4*src_stride;
465static void trace_recon_tile2raster_uv(FILE *fRecon, uint8_t *mem_uv,
int width,
int height,
466 int leftOffset,
int topOffset,
467 int src_stride,
int pixDepth, uint8_t *ch_mem_temp)
471 int bytesPerPix = (pixDepth == 8 ? 1 : 2);
472 uint8_t *tmp_mem = (uint8_t *)malloc((
size_t)bytesPerPix*src_stride*2);
473 int num_tiles = 2*((leftOffset + width + 3) / 4 - leftOffset/4);
478 int write_data_len = 0;
479 memset(tmp_mem, 0x00, (
size_t)bytesPerPix * src_stride * 2);
480 for(uv = 0; uv <= 1; uv ++) {
481 mem = mem_uv + (ptrdiff_t)(topOffset/4)*8*src_stride + (ptrdiff_t)(leftOffset/4)*32*pixDepth/8;
482 for(i = topOffset/4*4; i < topOffset + height; i += 4) {
483 if(i >= topOffset && i < topOffset + height) {
484 memcpyToPelByBits(tmp_mem, mem, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
485 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
487 tmp_mem[k] = tmp_mem[j];
489 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
492 memcpy(ch_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
493 write_data_len += width * bytesPerPix;
495 if(i+1 >= topOffset && i+1 < topOffset + height) {
496 memcpyToPelByBits(tmp_mem, mem+4*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
497 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
499 tmp_mem[k] = tmp_mem[j];
501 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
504 memcpy(ch_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
505 write_data_len += width * bytesPerPix;
507 if(i+2 >= topOffset && i+2 < topOffset + height) {
508 memcpyToPelByBits(tmp_mem, mem+8*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
509 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
511 tmp_mem[k] = tmp_mem[j];
513 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
516 memcpy(ch_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
517 write_data_len += width * bytesPerPix;
519 memcpyToPelByBits(tmp_mem, mem+12*pixDepth/8, 4, num_tiles, 4, 16*pixDepth/8, pixDepth);
520 if(i+3 >= topOffset && i+3 < topOffset + height) {
521 for(j = uv, k = 0; j < 4 * num_tiles; j += 2, k++) {
523 tmp_mem[k] = tmp_mem[j];
525 ((uint16_t*)tmp_mem)[k] = ((uint16_t*)tmp_mem)[j];
528 memcpy(ch_mem_temp + write_data_len, tmp_mem + (ptrdiff_t)(leftOffset & 3) * bytesPerPix, (
size_t)width * bytesPerPix);
529 write_data_len += width * bytesPerPix;
531 mem += (ptrdiff_t)8*src_stride;
537static double calc_noise(uint8_t *p1, uint8_t *p2,
int size)
544 for (i = 0; i < size; i++)
546 diff = p1[i] - p2[i];
591 FILE *fout_raster = NULL;
609 uint8_t *luma_mem_temp = NULL;
610 uint8_t *ch_mem_temp = NULL;
623 luma_mem_temp = (uint8_t *)malloc(luma_size);
624 memset(luma_mem_temp, 0x00, luma_size);
629 ch_mem_temp = (uint8_t *)malloc(ch_size);
630 memset(ch_mem_temp, 0x00, ch_size);
638 SwapSW16((uint16_t *)luma_mem, lum_sz);
639 SwapSW32((uint32_t *)luma_mem, lum_sz);
640 SwapSW64((uint64_t *)luma_mem, lum_sz);
641 trace_recon_tile2raster_y (fout_raster, luma_mem, width, height,
652 SwapSW16((uint16_t *)ch_mem, chr_sz);
653 SwapSW32((uint32_t *)ch_mem, chr_sz);
654 SwapSW64((uint64_t *)ch_mem, chr_sz);
655 trace_recon_tile2raster_uv(fout_raster, ch_mem, width / 2, height / 2,
674 double noise_y = 0.0, noise_u = 0.0, noise_v = 0.0, noise_yuv = 0.0;
675 double power_y = 0.0, power_u = 0.0, power_v = 0.0, power_yuv = 0.0;
676 double psnr_y = 0.0, psnr_u = 0.0, psnr_v = 0.0, psnr_yuv = 0.0;
686 power_y = 1.0 * max * max * width * height;
687 power_u = power_y / 4.0;
688 power_v = power_y / 4.0;
689 power_yuv = power_y * 3.0 / 2.0;
691 uint8_t *p_y_src_buf = NULL;
692 uint8_t *p_u_src_buf = NULL;
693 uint8_t *p_v_src_buf = NULL;
694 for (
int i = 0; i < 120; i++)
709 if (p_y_src_buf != NULL)
713 noise_y = calc_noise(p_y_src_buf, luma_mem_temp, width * height);
717 noise_y = power_y / pow(10, p_ctx->
psnr_y / 10);
722 noise_u = calc_noise(p_u_src_buf, ch_mem_temp, (width / 2) * (height / 2));
723 noise_v = calc_noise(p_v_src_buf, ch_mem_temp + (ptrdiff_t)(width / 2) * (height / 2), (width / 2) * (height / 2));
725 noise_yuv = noise_y + noise_u + noise_v;
729 noise_y = noise_y < 1 ? 1 : noise_y;
730 noise_u = noise_u < 1 ? 1 : noise_u;
731 noise_v = noise_v < 1 ? 1 : noise_v;
732 noise_yuv = noise_yuv < 1 ? 1 : noise_yuv;
736 psnr_y = 10 * log10(power_y / noise_y);
745 psnr_u = 10 * log10(power_u / noise_u);
746 psnr_v = 10 * log10(power_v / noise_v);
748 psnr_yuv = 10 * log10(power_yuv / noise_yuv);
776 luma_mem_temp = NULL;
802 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",
809#define READ_U32_FROM_BUF_2BYTES(buf, byte_offset) \
810 ((uint32_t)(buf)[(byte_offset)] | \
811 ((uint32_t)(buf)[(byte_offset)+1] << 8))
814#define READ_U32_FROM_BUF(buf, byte_offset) \
815 ((uint32_t)(buf)[(byte_offset)] | \
816 ((uint32_t)(buf)[(byte_offset)+1] << 8) | \
817 ((uint32_t)(buf)[(byte_offset)+2] << 16) | \
818 ((uint32_t)(buf)[(byte_offset)+3] << 24))
824 if (!p_ctx || !cuInfoBuf || !pEncCuInfo)
838 if (pEncCuInfo->
cuMode == 1)
847 pEncCuInfo->
cuSize = 8 * (1 << (cuSizeId + 3));
851 if (pEncCuInfo->
cuMode == 1)
871 if (!p_ctx || !p_packet)
879 if (p_meta->cuInfoSize != 0)
883 int total_cu_count = 0;
884 int analyzed_mbs = 0;
885 int num_intra_block_blocks = 0;
886 int num_intra_plane_blocks = 0;
888 uint64_t inter_pred_L0_qp_sum = 0;
889 uint64_t intra_plane_qp_sum = 0;
890 uint64_t intra_block_qp_sum = 0;
891 int inter_pred_L0_count = 0;
898 uint8_t *ctuOffset = (uint8_t *)p_packet->
p_data + p_packet->
data_len - p_meta->cuInfoSize;
899 uint8_t *cuData = ctuOffset + p_meta->cuInfoTableSize + p_meta->aqInfoSize;
900 uint32_t *ctuTable = (uint32_t *)ctuOffset;
906 int iCtuX, iCtuY, nCu, iCu;
912 ctu_per_row = (width + 16 - 1) / 16;
913 ctu_per_column = (height + 16 - 1) / 16;
918 ctu_per_row = (width + 64 - 1) / 64;
919 ctu_per_column = (height + 64 - 1) / 64;
923 for (iCtuY = 0; iCtuY < ctu_per_column; iCtuY++)
925 for (iCtuX = 0; iCtuX < ctu_per_row; iCtuX++)
936 nCu = (int)ctuTable[iCtu];
938 nCu -= (int)ctuTable[iCtu - 1];
944 for (iCu = 0; iCu < nCu; iCu++)
946 parse_cu_info(p_ctx, cuInfoBuf, &cuInfo);
950 max_qp = cuInfo.qp > max_qp ? cuInfo.qp : max_qp;
953 if (cuInfo.cuMode == 1)
955 if (cuInfo.intraPartMode == 0)
958 num_intra_plane_blocks += (cuInfo.cuSize / 4) * (cuInfo.cuSize / 4);
959 intra_plane_qp_sum += 16ULL * cuInfo.qp;
964 num_intra_block_blocks += (cuInfo.cuSize / 4) * (cuInfo.cuSize / 4);
965 intra_block_qp_sum += 16ULL * cuInfo.qp;
973 if (cuInfo.interPredIdc == 0)
975 inter_pred_L0_count += 16;
976 inter_pred_L0_qp_sum += 16ULL * cuInfo.qp;
978 else if (cuInfo.interPredIdc == 1)
990 int32_t gop_preset_index = api_param->cfg_enc_params.gop_preset_index;
992 if (gop_preset_index == 3 || gop_preset_index == 7)
994 inter_pred_L0_count += 16;
995 inter_pred_L0_qp_sum += 16ULL * cuInfo.qp;
1013 bitstream_features->average_qp = (float)qp_sum / (
float)total_cu_count;
1014 bitstream_features->initial_qp = p_meta->ppsInitQp;
1015 bitstream_features->max_qp = max_qp;
1016 bitstream_features->avg_forward_pred_block_qp = inter_pred_L0_count > 0 ? (float)inter_pred_L0_qp_sum / (
float)inter_pred_L0_count : (float)max_qp;
1017 bitstream_features->analyzed_mbs = analyzed_mbs;
1018 bitstream_features->avg_intra_block_qp = num_intra_block_blocks > 0 ? (float)intra_block_qp_sum / (
float)num_intra_block_blocks : (float)max_qp;
1019 bitstream_features->avg_intra_plane_qp = num_intra_plane_blocks > 0 ? (float)intra_plane_qp_sum / (
float)num_intra_plane_blocks : (float)max_qp;
1020 bitstream_features->num_intra_block_blocks = num_intra_block_blocks;
1021 bitstream_features->num_intra_plane_blocks = num_intra_plane_blocks;
1022 bitstream_features->num_skip_blocks = (int)(p_meta->skipCu8Num * 4);
1023 bitstream_features->num_forward_pred_blocks = inter_pred_L0_count - bitstream_features->num_skip_blocks;
1036 uint16_t ui16ErrorCount = 0;
1037 uint32_t ui32LastErrorStatus = 0;
1050 ni_device_get_and_print_firmware_logs(ctx);
1062 else if(opt ==
OPT_2){
1064 ni_log2(ctx,
NI_LOG_ERROR,
"ERROR %s(): passed parameters are null!, return\n", __func__);
1066 ni_device_get_and_print_firmware_logs(ctx);
1075 ui16ErrorCount > 0 && !retval &&
1081 else if(opt ==
OPT_3)
1090 "Persistent failures detected, %s() line-%d: session_no 0x%x "
1091 "sess_err_count %u inst_err_no %u\n",
1092 func, line, *(inst_id), ui16ErrorCount,
1093 ui32LastErrorStatus);
1095 ni_device_get_and_print_firmware_logs(ctx);
1097#ifdef XCODER_SELF_KILL_ERR
1100 kill(getpid(), SIGTERM);
1112#define CHECK_ERR_RC(ctx, rc, info, opcode, type, hw_id, inst_id, opt) \
1114 (rc) = check_err_rc(ctx, rc, info, opcode, type, hw_id, inst_id, opt, __func__, __LINE__); \
1115 if((rc) && ((opt) != OPT_3)) LRETURN; \
1118#define CHECK_VPU_RECOVERY(ret) \
1120 if (NI_RETCODE_NVME_SC_VPU_RECOVERY == (ret)) \
1122 ni_log(NI_LOG_ERROR, "Error, vpu reset.\n"); \
1123 (ret) = NI_RETCODE_ERROR_VPU_RECOVERY; \
1133 "decoder" :
"encoder";
1137 uint64_t abs_time_ns;
1144 ts.tv_sec = (time_t)(abs_time_ns / 1000000000LL);
1145 ts.tv_nsec = (long)(abs_time_ns % 1000000000LL);
1155 if (ret == ETIMEDOUT)
1167 "decoder" :
"encoder";
1197#elif __linux__ || __APPLE__
1199 char dir_name[128] = {0};
1200 char file_name[512] = {0};
1203 struct dirent *stream_folder;
1204 int curr_stream_idx = 0;
1205 int earliest_stream_idx = 0;
1206 int max_exist_idx = 0;
1208 time_t earliest_time = 0;
1209 struct stat file_stat;
1213 if (!p_device_context)
1220 flock(p_device_context->
lock, LOCK_EX);
1223 if (0 != access(dir_name, F_OK))
1225 if (0 != mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO))
1235 dir = opendir(dir_name);
1245 while ((stream_folder = readdir(dir)))
1247 if (!strncmp(stream_folder->d_name,
"stream", strlen(
"stream")))
1249 if (
ni_strtoi(&(stream_folder->d_name[strlen(
"stream")]),
1253 "ERROR: %s(): invalid stream index '%s'\n",
1254 __func__, stream_folder->d_name);
1257 curr_stream_idx = (int)tmp_val;
1258 if (curr_stream_idx > 0)
1260 if (curr_stream_idx > max_exist_idx)
1262 max_exist_idx = curr_stream_idx;
1277 curr_stream_idx = max_exist_idx + 1;
1281 while ((stream_folder = readdir(dir)))
1285 if (!strncmp(stream_folder->d_name,
"stream", strlen(
"stream")))
1287 (void)snprintf(file_name,
sizeof(file_name),
"%s/%s/pkt-0001.bin",
1288 dir_name, stream_folder->d_name);
1290 if (
ni_strtoi(&(stream_folder->d_name[strlen(
"stream")]),
1294 "ERROR: %s(): invalid stream index '%s'\n",
1295 __func__, stream_folder->d_name);
1298 curr_stream_idx = (int)tmp_val;
1300 if (curr_stream_idx > 0 && 0 == access(file_name, F_OK))
1303 if (stat(file_name, &file_stat))
1310 if (0 == earliest_stream_idx ||
1311 file_stat.st_mtime < earliest_time)
1313 earliest_stream_idx = curr_stream_idx;
1314 earliest_time = file_stat.st_mtime;
1321 curr_stream_idx = earliest_stream_idx;
1325 (void)snprintf(file_name,
sizeof(file_name),
"%s/stream%03d/pkt-0001.bin",
1326 dir_name, curr_stream_idx);
1327 if (utime(file_name, NULL))
1336 "%s/stream%03d", dir_name, curr_stream_idx);
1355 flock(p_device_context->
lock, LOCK_UN);
1358 (void)snprintf(file_name,
sizeof(file_name),
"%s/process_session_id.txt",
1364 char number[64] = {
'\0'};
1366 (void)snprintf(number,
sizeof(number),
"proc id: %ld\nsession id: %u\n",
1368 (void)fwrite(number, strlen(number), 1, fp);
1377#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OPEN_HARMONY__) && !defined(_ANDROID)
1378#define MAX_BDF_LEN 16
1382static int find_pci_address(
const char *dev_name,
char *pci_addr) {
1383 char sys_block_path[256];
1385 (void)snprintf(sys_block_path,
sizeof(sys_block_path),
"/sys/class/block/%s/device", dev_name);
1387 char *real_sysfs_path = realpath(sys_block_path, NULL);
1388 if (!real_sysfs_path) {
1389 perror(
"realpath failed");
1394 char *p = real_sysfs_path + strlen(real_sysfs_path);
1396 while (p > real_sysfs_path) {
1397 p = strrchr(real_sysfs_path,
'/');
1404 unsigned domain, bus, dev, func;
1405 if (sscanf(segment,
"%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) {
1408 free(real_sysfs_path);
1415 free(real_sysfs_path);
1422#if defined(_WIN32) || defined(__APPLE__) || defined(__OPEN_HARMONY__)
1430 char *dom, *bus, *dev, *fnc;
1442 p_ctx->
netint_fd = open(
"/dev/netint", O_RDWR);
1450 if (stat(p_dev, &bstat) < 0)
1456 if ((bstat.st_mode & S_IFMT) != S_IFBLK)
1463 ret = snprintf(syspath,
sizeof(syspath) - 1,
1464 "/sys/block/%s/device/address",
1466 syspath[ret] =
'\0';
1476 if (fgets(pci_addr,
sizeof(pci_addr), fp) == NULL)
1485 ret = find_pci_address(p_dev + 5, pci_addr);
1496 p_ctx->
domain = strtoul(pci_addr, &dom, 16);
1504 p_ctx->
bus = strtoul(dom + 1, &bus, 16);
1512 p_ctx->
dev = strtoul(bus + 1, &dev, 16);
1521 p_ctx->
fn = strtoul(dev + 1, &fnc, 16);
1537#if __linux__ || __APPLE__
1538#if !defined(_ANDROID) && !defined(__OPENHARMONY__)
1539#ifndef DISABLE_BACKTRACE_PRINT
1540void ni_print_backtrace() {
1541 void* callstack[128];
1542 int frames = backtrace(callstack, 128);
1543 char** strs = backtrace_symbols(callstack, frames);
1546 for (
int i = 0; i < frames; ++i) {
1567 void* p_buffer = NULL;
1568 uint32_t ui32LBA = 0;
1569 char fmt_fw_api_ver1[5], fmt_fw_api_ver2[5];
1589#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
1598 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): not support enableCpuAffinity parameter, "
1599 "enable with [./build.sh -c] on linux\n", __func__);
1637 "ERROR %d: %s() alloc decoder all zero buffer failed\n",
1678 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n", __func__,
1687 uint64_t keep_alive_timeout =
1690 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
1692 keep_alive_timeout);
1703 "ERROR %s(): nvme write keep_alive_timeout command "
1704 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
1720 __func__, fmt_fw_api_ver1, fmt_fw_api_ver2);
1731 "ERROR %s(): nvme write sw_version command "
1732 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
1755 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n", __func__,
1763 "%s(): p_ctx->device_handle=0x%" PRIx64
", p_ctx->hw_id=%d, "
1764 "p_ctx->session_id=%d\n",
1823 ni_log2(p_ctx,
NI_LOG_INFO,
"Warn %s(): forceLowDelay is not available for fw < 6r3\n",
1834 "%s(): p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, "
1835 "p_ctx->session_id=%d\n",
1841 decoder_dump_dir_open(p_ctx);
1844#ifdef XCODER_DUMP_DATA
1845 char dir_name[256] = {0};
1847 (void)snprintf(dir_name,
sizeof(dir_name),
"%ld-%u-dec-fme", (long)getpid(),
1849 DIR *dir = opendir(dir_name);
1852 mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
1878 uint32_t ui32LBA = 0;
1889 if (NI_INVALID_DEVICE_HANDLE == device_handle)
1902 "session_id=%d\n", __func__, (int64_t)device_handle, session_id);
1908 "SUCCESS %s(): device_handle=%" PRIx64
" , "
1909 "session_id=%d\n", __func__, (int64_t)device_handle, session_id);
2021 void* p_buffer = NULL;
2022 uint32_t ui32LBA = 0;
2054 "Decoder_complete_info:session_id 0x%x, total frames input:%u "
2055 "buffered: %u completed: %u output: %u dropped: %u error: %u corrupted: %u\n",
2066 "Decoder_complete_info:session_id 0x%x, total frames input:%u "
2067 "buffered: %u completed: %u output: %u dropped: %u error: %u\n",
2116 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
2117 "p_ctx->session_id=%d, close_mode=1\n",
2186 low_delay_signal(p_ctx);
2203 uint32_t sent_size = 0;
2204 uint32_t packet_size = 0;
2205 int current_pkt_size;
2210 int query_retry = 0;
2211 uint32_t ui32LBA = 0;
2215 if ((!p_ctx) || (!p_packet))
2232 low_delay_wait(p_ctx);
2234#ifdef MEASURE_LATENCY
2239 abs_time_ns, p_packet->
dts);
2245 current_pkt_size = (int)packet_size;
2248 int max_retry = 200;
2330 "Warning: dec write query fail rc %d or available buf size %u < "
2331 "pkt size %u , retry: %d max_retry_fail_count %d\n",
2334 if (query_retry > max_retry ||
2343 if (query_retry > max_retry)
2362 "size %u >= pkt size %u !\n",
2405 "%s() had data to send: packet_size=%u, "
2406 "p_packet->sent_size=%d, p_packet->data_len=%u, "
2407 "p_packet->start_of_stream=%u, p_packet->end_of_stream=%u, "
2408 "p_packet->video_width=%u, p_packet->video_height=%u\n",
2413 uint8_t *p_data = (uint8_t *)p_packet->
p_data;
2424 p_data, packet_size, ui32LBA);
2444 char dump_file[512] = {0};
2447 (void)snprintf(dump_file,
sizeof(dump_file),
"%s/pkt-%04ld.bin",
2454 (void)fwrite(p_packet->
p_data, sent_size, 1, f);
2495 "%s: (first packet) pkt_index %d i %u "
2496 "pkt_offsets_index_min %" PRIu64
" pkt_offsets_index %" PRIu64
2497 " pts_offsets %" PRId64
"\n",
2509 "%s: pkt_index %d i %u pkt_offsets_index_min "
2510 "%" PRIu64
" pkt_offsets_index %" PRIu64
" pts_offsets %" PRId64
2523 "%s: (wrap) pkt_index %d i %u "
2524 "pkt_offsets_index_min %" PRIu64
" pkt_offsets_index %" PRIu64
2525 " pts_offsets %" PRId64
"\n",
2548 "Error %s: failed to allocate custom SEI buffer for pkt.\n",
2564 "ERROR %s(): ni_timestamp_register() for dts returned %d\n",
2574 "%s(): exit: packets: %" PRIu64
" offset %" PRIx64
""
2575 " sent_size = %u, status=%d\n",
2576 __func__, p_ctx->
pkt_num, (uint64_t)p_packet->
pos, sent_size,
2578 return (
int)sent_size;
2582 "ERROR %s(): exit: returnErr: %d, p_ctx->status: %d\n", __func__,
2588static int64_t guess_correct_pts(
ni_session_context_t* p_ctx, int64_t reordered_pts, int64_t dts)
2596 "%s: pts_correction_last_dts %" PRId64
" "
2597 "pts_correction_num_faulty_dts %d\n",
2612 "%s: pts_correction_last_pts %" PRId64
" "
2613 "pts_correction_num_faulty_pts %d\n",
2626 pts = reordered_pts;
2638 pts = reordered_pts;
2646static int rotated_array_binary_search(uint64_t *lefts, uint64_t *rights,
2647 int32_t size, uint64_t target)
2653 int mid = lo + (hi - lo) / 2;
2654 if (lefts[mid] <= target && target < rights[mid])
2659 if (rights[mid] == 0)
2666 if (rights[lo] <= rights[mid])
2668 if (lefts[lo] <= target && target < lefts[mid])
2679 if (rights[mid] <= target && target < rights[hi])
2705 uint64_t frame_offset = 0;
2706 uint32_t frame_dropped = 0;
2707 uint8_t *p_data_buffer = NULL;
2713 uint32_t total_bytes_to_read = 0;
2714 uint32_t read_size_bytes = 0;
2719 int query_retry = 0;
2720 uint32_t ui32LBA = 0;
2721 unsigned int bytes_read_so_far = 0;
2723 int low_delay_notify = 0;
2724 uint32_t frames_dropped = 0;
2725 uint8_t get_first_metadata = 0;
2726 uint8_t sequence_change = 0;
2730 if ((!p_ctx) || (!p_frame))
2748 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
2753 p_frame->
data_len[2] + metadata_hdr_size;
2804 ni_log2(p_ctx,
NI_LOG_TRACE,
"Warning: dec read query fail rc %d retry %d max_retry_fail_count %d\n",
2807 if (query_retry >= 1000)
2810 low_delay_notify = 1;
2827 total_bytes_to_read = metadata_hdr_size;
2828 sequence_change = 1;
2851 "WARNING: Dec eos reached but also exceeded max dec read query "
2852 "retries. is_flushed=%u try=%d.\n",
2857 "Dec eos reached. is_flushed=%u try=%d.\n",
2861 low_delay_notify = 1;
2867 " retrying ..\n", query_retry);
2881 query_retry < 1000 / 2)
2888 low_delay_signal(p_ctx);
2896 "size %u >= required size %u !\n",
2913 low_delay_signal(p_ctx);
2916 "Warning: ceased using low delay decoding mode after "
2917 "excessively long decoder read query.\n");
2920 low_delay_signal(p_ctx);
2930 if(query_retry <= 2000)
2939 "Warning: decoder pkt_num %u frame_num %u "
2940 "timeout, increasing pkt_delay_cnt to %u\n",
2964 "At least %d packets should be sent before reading the "
2981 "%ux%u frame-rate %u is_flushed %u\n",
3015#ifdef XCODER_SELF_KILL_ERR
3020 kill(getpid(), SIGTERM);
3037 p_frame->
data_len[2] + metadata_hdr_size;
3038 p_data_buffer = (uint8_t*) p_frame->
p_buffer;
3050 "%u cb len %u hdr %d\n",
3053 p_frame->
data_len[2], metadata_hdr_size);
3059 "ERROR %s() avaliable size(%u)"
3060 "less than needed (%u)\n",
3072 void *p_metadata_buffer = NULL;
3078 "ERROR %d: %s() Cannot allocate metadata buffer.\n",
3083 p_data_buffer = (uint8_t *)p_metadata_buffer;
3084 get_first_metadata = 1;
3086 sequence_change = 0;
3107 p_data_buffer, read_size_bytes, ui32LBA);
3116 }
else if (get_first_metadata) {
3124 get_first_metadata = 0;
3138 low_delay_notify = 1;
3151 total_bytes_to_read = total_bytes_to_read + sei_size;
3153 "include sei %u sei_size %d\n",
3154 retval, total_bytes_to_read, sei_size);
3157 bytes_read_so_far = total_bytes_to_read ;
3164 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, &frame_dropped,
false);
3168 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
false);
3184 "is cancelled due to has_b_frames, frame_num %u\n",
3195 int64_t tmp_dts, prev_dts = INT64_MIN, ts_diff = 0;
3204 "### %s(): Warning: ui32FramesDropped %u should be %u + %u\n",
3221 "%s(): First frame : session_id 0x%x, pic_reorder_delay: %d "
3222 "total frames input:%u buffered: %u completed: %u output: %u "
3223 "dropped: %u (%u %u) error: %u\n",
3243 "decoder dts queue %d %ld failed !\n",
3244 __func__, i, tmp_dts);
3249 "decoder dts queue %d %ld success !\n",
3250 __func__, i, tmp_dts);
3251 if (prev_dts != INT64_MIN) {
3252 ts_diff += llabs(tmp_dts - prev_dts);
3260 ts_diff = ts_diff / nb_diff;
3264 "average diff: %ld\n", __func__, ts_diff);
3279 "decoder dts queue %d %ld failed !\n",
3280 __func__, i, tmp_dts);
3307 for (i = 0; (int)i < p_ctx->pic_reorder_delay; i++)
3314 if (p_frame->
pts >= p_frame->
dts &&
3315 p_frame->
pts - p_frame->
dts < 1000)
3331 "decoder dts queue %d %ld success !\n",
3332 __func__, i, p_frame->
dts);
3368 "%s: (found pts) dts %" PRId64
" pts "
3369 "%" PRId64
" frame_offset %" PRIu64
" j %d "
3370 "pkt_offsets_index_min %" PRIu64
" pkt_offsets_index "
3371 "%" PRIu64
" pkt_pos %" PRIu64
" \n",
3372 __func__, p_frame->
dts, p_frame->
pts, frame_offset, j,
3387 while (p_frame->
dts < p_frame->
pts &&
3388 llabs(p_frame->
pts - p_frame->
dts) > ts_diff)
3391 "dts %lld diff. %lld > ts_diff %lld\n",
3392 __func__, p_frame->
pts, p_frame->
dts,
3393 llabs(p_frame->
pts - p_frame->
dts), ts_diff);
3400 "pop decoder dts queue error.\n", __func__);
3423 "ERROR: Frame pts %" PRId64
" not found for offset "
3424 "%" PRIu64
"\n", p_frame->
pts, frame_offset);
3426 "%s: (not found use default) dts %" PRId64
" pts %" PRId64
3428 __func__, p_frame->
dts, p_frame->
pts);
3440 p_frame->
pts = guess_correct_pts(p_ctx, p_frame->
pts, p_frame->
dts);
3448 __func__, p_frame->
pts);
3458#ifdef MEASURE_LATENCY
3465#ifdef XCODER_DUMP_DATA
3466 char dump_file[256];
3467 (void)snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-dec-fme/fme-%04ld.yuv",
3481 "%s(): p_frame->start_of_stream=%u, "
3482 "p_frame->end_of_stream=%u, p_frame->video_width=%u, "
3483 "p_frame->video_height=%u\n",
3492 "Decoder pts queue size = %u dts queue size = %u\n\n",
3499#ifdef MEASURE_LATENCY
3515 if (get_first_metadata && p_data_buffer)
3517 if (sequence_change && p_ctx->
frame_num)
3532 low_delay_signal(p_ctx);
3538 if (low_delay_notify)
3540 low_delay_signal(p_ctx);
3560 device_type, g_device_type_str[device_type]);
3583 switch (device_type)
3605 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 "
3606 "total_contexts:%u fw_video_mem_usage:%u "
3607 "fw_video_shared_mem_usage:%u fw_share_mem_usage:%u "
3608 "fw_p2p_mem_usage:%u active_hwuploaders:%u\n", __func__,
3624 "Overall load %u, model load %u, instance count %u\n",
3651 device_type, g_device_type_str[device_type]);
3682 void *p_buffer = NULL;
3684 uint32_t ui32LBA = 0;
3685 uint32_t max_cu_size;
3686 uint32_t block_size;
3687 int32_t width, height;
3688 int m_threshold = 0;
3689 char fmt_fw_api_ver1[5], fmt_fw_api_ver2[5];
3707 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() RGBA / BGRA / ARGB / AGBR resolution invalid, return\n",
3721 "ERROR: %s() MCTF does not support hwframe input, return\n",
3731 "ERROR: %s() MCTF only supports 8-bit input, return\n",
3741#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
3750 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): not support enableCpuAffinity parameter, "
3751 "enable with [./build.sh -c] on linux\n", __func__);
3764 width = (width / 8) * 8;
3765 height = (height / 8) * 8;
3769 ((width + max_cu_size - 1) & (~(max_cu_size - 1))) *
3770 ((height + max_cu_size - 1) & (~(max_cu_size - 1))) /
3772 p_ctx->
roi_len = ((block_size + 63) & (~63));
3850 "ERROR %s(): p_ctx->device_handle=%" PRIx64
", "
3851 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
3862 uint64_t keep_alive_timeout =
3865 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
3867 keep_alive_timeout);
3878 "ERROR %s(): nvme write keep_alive_timeout command "
3879 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
3895 __func__, fmt_fw_api_ver1, fmt_fw_api_ver2);
3906 "ERROR %s(): nvme write sw_version command "
3907 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
3952 ni_log2(p_ctx,
NI_LOG_ERROR,
"The bit depth or resoultion is not supported on ai enhance mode\n");
3966 "ERROR %s(): p_ctx->device_handle=%" PRIx64
", "
3967 "p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
4004 if (m_threshold > (
size_t)4 * 1024 * 1024 *
sizeof(long))
4007 "DEFAULT_MMAP_THRESHOLD_MAX, use default value (%d)\n",
4008 m_threshold, (
size_t)4 * 1024 * 1024 *
sizeof(
long));
4009 m_threshold = (size_t)4 * 1024 * 1024 *
sizeof(
long);
4014#if defined(__linux__) && !defined(_ANDROID) && !defined(__OPENHARMONY__)
4018 if (mallopt(M_MMAP_THRESHOLD, m_threshold) == 0)
4031 if (mallopt(M_TRIM_THRESHOLD, 3 * m_threshold) == 0)
4040 "Warning: this platform does not support staticMmapThreshold\n");
4047 m_threshold = (int) (m_threshold * 1.25);
4048 void *temp_buf = malloc((
size_t) m_threshold);
4049 ni_log2(p_ctx,
NI_LOG_TRACE,
"trigger a pre-mature increase in mmap&trim threshold: 0x%p = malloc(%d)\n",
4050 temp_buf, m_threshold);
4057 bool device_in_ctxt =
true;
4073 for (uint8_t ui8Index = 0; ui8Index < 20; ui8Index++)
4096 "p_ctx->sender_handle=%" PRIx64
", p_ctx->hw_id=%d, p_ctx->session_id=%u\n",
4105 "p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, p_ctx->session_id=%u\n",
4111 if ((sender_vf_ns_id.
ns_id != curr_vf_ns_id.
ns_id) ||
4112 (sender_vf_ns_id.
vf_id != curr_vf_ns_id.
vf_id))
4129 "p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
4140 "ERROR: ni_ai_query_network_ready returned %d\n", retval);
4177 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() line-%d return %d\n", __func__, __LINE__, retval);
4193 "%s(): p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, "
4194 "p_ctx->session_id=%d\n",
4198#ifdef XCODER_DUMP_DATA
4199 char dir_name[256] = {0};
4200 (void)snprintf(dir_name,
sizeof(dir_name),
"%ld-%u-enc-pkt", (long)getpid(),
4202 DIR *dir = opendir(dir_name);
4205 mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
4213 (void)snprintf(dir_name,
sizeof(dir_name),
"%ld-%u-enc-fme", (long)getpid(),
4215 dir = opendir(dir_name);
4218 mkdir(dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
4290 void* p_buffer = NULL;
4291 uint32_t ui32LBA = 0;
4316 "Encoder_complete_info:session_id 0x%x, total frames input:%u "
4317 "buffered: %u completed: %u output: %u dropped: %u error: %u\n",
4359 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
4360 "p_ctx->session_id=%d, close_mode=1\n",
4431 for (i = 0; i < 120 ; i++)
4445 low_delay_signal(p_ctx);
4456 int32_t width_stride[4] = {0};
4457 int32_t height_stride[4] = {0};
4472 width_stride, height_stride);
4475 for (
int i = 0; i < 120; i++)
4496 for (
int j = 0; j < source_height; j++)
4499 ni_frame->
p_data[0] + (ptrdiff_t)j * width_stride[0],
4502 for (
int j = 0; j < (source_height + 1) / 2; j++)
4505 ni_frame->
p_data[1] + (ptrdiff_t)j * width_stride[1],
4508 for (
int j = 0; j < (source_height + 1) / 2; j++)
4511 ni_frame->
p_data[2] + (ptrdiff_t)j * width_stride[2],
4527 for (
int j = 0; j < source_height; j++)
4530 ni_frame->
p_data[0] + (ptrdiff_t)j * width_stride[0],
4533 for (
int j = 0; j < (source_height + 1) / 2; j++)
4536 ni_frame->
p_data[1] + (ptrdiff_t)j * width_stride[1],
4539 for (
int j = 0; j < (source_height + 1) / 2; j++)
4542 ni_frame->
p_data[2] + (ptrdiff_t)j * width_stride[2],
4565 bool ishwframe =
false;
4567 uint32_t send_count = 0;
4569 uint32_t sent_size = 0;
4570 uint32_t frame_size_bytes = 0;
4576 bool checkMCTF =
false;
4577 int waitCnt = MCTF_LOOKAHEAD;
4580 if (!p_ctx || !p_frame)
4603 if (!((input_frame_idx > 0 &&
4609 __func__, input_frame_idx);
4616 uint8_t separate_metadata = 0;
4617 uint8_t separate_start = 0;
4629 p_orig_frame = p_frame;
4632 low_delay_wait(p_ctx);
4634#ifdef MEASURE_LATENCY
4651 if (waitCnt > 0 && waitCnt < MCTF_LOOKAHEAD && p_frame != p_orig_frame) {
4653 p_frame = get_mctf_result(p_ctx, waitCnt);
4657 if (is_eos && p_frame == p_orig_frame && p_ctx->
frame_num > 0 &&
4658 p_ctx->
mctf != NULL) {
4662 if (ret == MCTF_RET_EOS_PENDING && waitCnt > 0) {
4663 p_frame = get_mctf_result(p_ctx, waitCnt);
4665 }
else if (ret == MCTF_RET_EOS_DONE) {
4684 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: passed video_height and video_width are not valid!, return\n");
4696 "%s: data_len[0] %u data_len[1] %u "
4697 "data_len[2] %u extra_data_len %u frame_size_bytes %u\n",
4731 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() line-%d retrun %d\n", __func__, __LINE__, retval);
4738 "Enc write query retry %d. rc=%d. Available buf size %u < "
4739 "frame size %u\n", retval, send_count,
4743 int retval_backup = retval;
4756 "Enc write query buf info exceeded max retries: "
4757 "%d, rc=%d. Available buf size %u < frame size %u\n",
4771 "Info enc write query success, available buf "
4772 "size %u >= frame size %u !\n",
4780 if (checkMCTF && p_ctx->
mctf == NULL && !is_eos)
4782 int ret = initMCTF(p_ctx);
4793 if (ret == MCTF_RET_NOT_REF || ret == MCTF_RET_LOOKBACK_REF) {
4795 }
else if (ret == MCTF_RET_BUFFERED) {
4800 retval = frame_size_bytes;
4802 }
else if (ret == MCTF_RET_FILTERED) {
4805 p_frame = get_mctf_result(p_ctx, waitCnt);
4824 if (separate_metadata)
4830 p_frame->
p_data[2 + ishwframe] +
4845 "use_cur_src_as_long_term_pic %d use_long_term_ref %d\n",
4860 "%s(): ctx->force_frame_type"
4861 " %d frame->force_key_frame %d force frame_num %" PRIu64
""
4910 "%s(): %d.%u p_ctx->frame_num=%" PRIu64
", "
4911 "p_frame->start_of_stream=%u, p_frame->end_of_stream=%u, "
4912 "p_frame->video_width=%u, p_frame->video_height=%u, pts=0x%08x 0x%08x, "
4913 "dts=0x%08x 0x%08x, sei_len=%u, roi size=%u avg_qp=%u reconf_len=%u "
4914 "force_pic_qp=%u use_cur_src_as_long_term_pic %u use_long_term_ref "
4915 "%u start_len [%u,%u,%u] inconsecutive_transfer %u "
4916 "get_recon_frame_mode %u\n",
4920 (uint32_t)(p_frame->
pts & 0xFFFFFFFF),
4921 (uint32_t)((p_frame->
dts >> 32) & 0xFFFFFFFF),
4968 "ni_timestamp_register() for dts returned: %d\n",
4972 if (separate_metadata)
4974 uint32_t ui32LBA_metadata =
4977 "%s: p_metadata_buffer = %p, metadata_buffer_size "
4978 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
5007 "%s: p_start_buffer = %p, p_frame->start_buffer_size "
5008 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
5036 "%s: p_data = %p, p_frame->buffer_size "
5037 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
5069 "%s: p_data = %p, p_frame->buffer_size "
5070 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
5074 sent_size = frame_size_bytes;
5075 if (separate_metadata)
5108 int ret =
hwdl_frame(p_ctx, &hwdl_session_data, p_frame,
5129 "%s(): session=0x%x ui16FrameIdx=%u\n",
5137 size = frame_size_bytes;
5141 if (p_orig_frame != p_frame)
5148 p_frame = p_orig_frame;
5155#ifdef XCODER_DUMP_DATA
5156 char dump_file[256];
5157 (void)snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-enc-fme/fme-%04ld.yuv",
5205 switch (video_codec_id)
5231 "Av_QP: f=%.6f FrameSize: i32=%d InitialQP: i32=%d max_QP: i32=%d MbQPs_1_: f=%.6f "
5232 "FrameType: i32=%d Sec_Codec: i32=%d Seq_Profile: i32=%d "
5233 "MbQPs_5_: f=%.6f MbQPs_6_: f=%.6f AnalyzedMBs: i32=%d "
5234 "MbTypes_5_: i32=%d MbTypes_6_: i32=%d MbTypes_0_: i32=%d MbTypes_1_: i32=%d "
5235 "quality_pixel_count: i32=%d\n",
5242 quality_pixel_count);
5249 uint32_t actual_read_size = 0;
5250 uint32_t to_read_size = 0;
5252 static long long encq_count = 0LL;
5254 int query_retry = 0;
5256 uint32_t ui32LBA = 0;
5261 int low_delay_notify = 0;
5264 if (!p_ctx || !p_packet || !p_packet->
p_data)
5284 ni_log2(p_ctx,
NI_LOG_DEBUG,
"frame_num=%" PRIu64
", pkt_num=%" PRIu64
", av1_pkt_num=%" PRIu64
"\n",
5297 low_delay_notify = 1;
5329 if(query_retry == 0)
5330 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: initial_frame_delay %d max_frame_delay %d ui8AdditionalFramesDelay %u current_frame_delay %d\n",
5344 "Info enc read query rc %d, available buf size %u, "
5345 "frame_num=%" PRIu64
", pkt_num=%" PRIu64
"\n",
5382 "%" PRIu64
" >= %" PRIu64
" pkt_num, keep querying p_ctx->status %d\n",
5390 low_delay_notify = 1;
5407 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",
5408 __FUNCTION__, p_ctx->
frame_num, pkt_num,
5426 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",
5427 __FUNCTION__, p_ctx->
frame_num, pkt_num,
5454 actual_read_size = to_read_size;
5467 "ERROR %s(): packet buffer size %u allocation "
5469 __func__, actual_read_size);
5476 p_packet->
p_data, actual_read_size, ui32LBA);
5502 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s MetaDataSize %d FrameType %d AvgFrameQp %d ssim %d %d %d\n",
5520 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",
5544 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",
5561 if (p_meta->
ssimY != 0)
5569#ifdef NI_LOG_SSIM_AT_INFO
5574 "%s: pkt #%" PRId64
" pts %" PRId64
" ssim "
5575 "Y %.4f U %.4f V %.4f\n", __FUNCTION__, p_ctx->
pkt_num,
5576 p_packet->
pts, (
float)p_meta->
ssimY/10000,
5577 (
float)p_meta->
ssimU/10000, (
float)p_meta->
ssimV/10000);
5609 get_bitstream_features_from_cu_info(p_ctx, p_packet);
5617 ni_write_bitstream_features_internal(p_ctx, p_packet);
5651 low_delay_notify = 1;
5656#ifdef MEASURE_LATENCY
5663#ifdef XCODER_DUMP_DATA
5664 char dump_file[256];
5665 (void)snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-enc-pkt/pkt-%04ld.bin",
5679 "%s(): %d.%u p_packet->start_of_stream=%u, "
5680 "p_packet->end_of_stream=%u, p_packet->video_width=%u, "
5681 "p_packet->video_height=%u, p_packet->dts=0x%08x 0x%08x, "
5682 "p_packet->pts=0x%08x 0x%08x, type=%u, avg_frame_qp=%u, show_frame=%d\n",
5685 (uint32_t)((p_packet->
dts >> 32) & 0xFFFFFFFF),
5686 (uint32_t)(p_packet->
dts & 0xFFFFFFFF),
5687 (uint32_t)((p_packet->
pts >> 32) & 0xFFFFFFFF),
5688 (uint32_t)(p_packet->
pts & 0xFFFFFFFF), p_packet->
frame_type,
5694 if (encq_count % 500 == 0)
5697 "Encoder pts queue size = %u dts queue size = %u\n\n",
5703#ifdef MEASURE_LATENCY
5723 if (low_delay_notify)
5725 low_delay_signal(p_ctx);
5749 p_ctx->
last_gop_size = g_map_preset_to_gopsize[lookAheadEnable][gop_preset_index + 1];
5761 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR %s(): config encoder sequence change command failed\n",
5766 else if (p_ctx->
mctf)
5793 void* p_buffer = NULL;
5794 uint32_t ui32LBA = 0;
5795 char fmt_fw_api_ver1[5], fmt_fw_api_ver2[5];
5810 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use stack filter on device with FW API version < 6.4\n");
5820 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use rotate filter on device with FW API version < 6.7\n");
5830 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use in-place overlay filter on device with FW API version < 6.L\n");
5840 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Cannot use ai align filter on device with FW API version < 6.sI\n");
5910 "ERROR %s(): p_ctx->device_handle=%" PRIx64
5911 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
5919 "%s(): p_ctx->device_handle=%" PRIx64
5920 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
5925 uint64_t keep_alive_timeout =
5928 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
5930 keep_alive_timeout);
5941 "ERROR %s(): nvme write keep_alive_timeout command "
5942 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
5958 __func__, fmt_fw_api_ver1, fmt_fw_api_ver2);
5969 "ERROR %s(): nvme write sw_version command "
5970 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
5986#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OPEN_HARMONY__) && !defined(_ANDROID)
5989 retval = p2p_fill_pcie_address(p_ctx);
6017 void * p_buffer = NULL;
6018 uint32_t ui32LBA = 0;
6052 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
6053 "p_ctx->session_id=%d, close_mode=1\n",
6105 void *p_scaler_config = NULL;
6109 uint32_t ui32LBA = 0;
6113 if (!p_ctx || !p_params)
6139 memset(p_scaler_config, 0, buffer_size);
6157 "on device with FW API version < 6rL\n", __func__);
6163 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6164 "hw_id, %d, xcoder_inst_id: %d\n",
6191 "on device with FW API version < 6s1\n", __func__);
6197 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6198 "hw_id, %d, xcoder_inst_id: %d\n",
6211 "be in [0 , 5]. scaler_params_b is %lf, scaler_params_c is %lf\n",
6218 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6219 "hw_id, %d, xcoder_inst_id: %d\n",
6256 "on device with FW API version < 6t6\n", __func__);
6262 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6263 "hw_id, %d, xcoder_inst_id: %d\n",
6275 "%s: kernel_taps=%u exceeds hardware maximum %d\n",
6285 for (
int idx = 0; idx < 2; idx++)
6289 int32_t row_sum = 0;
6290 const uint16_t *row =
6293 for (tap = 0; tap < (int)p_params->
kernel_taps; tap++)
6294 row_sum += (int16_t)row[padding + tap];
6299 "%s: Warning: USER_KERNEL idx %d row[%d] Q14 sum=0x%04x, "
6300 "expected 0x%04x (taps=%u, padding=%d)\n",
6301 __func__, idx, pos, (uint32_t)(uint16_t)row_sum,
6313 "%s: USER_KERNEL configured, taps=%u\n",
6327 "%s: kernel_taps=%u exceeds hardware maximum %d\n",
6345 p_scaler_config, buffer_size, ui32LBA);
6346 if ((int32_t)retval < 0)
6349 "ERROR: ni_nvme_send_write_cmd failed: blk_io_handle: %" PRIx64
6350 ", hw_id, %d, xcoder_inst_id: %d\n",
6357 "ERROR: %s failed: blk_io_handle: %" PRIx64
","
6358 "hw_id, %d, xcoder_inst_id: %d\n",
6403 int rectangle_width,
6404 int rectangle_height,
6413 uint32_t ui32LBA = 0;
6414 uint32_t query_retry = 0;
6419 dataLen = dataLen & 0xFFFFF000;
6436 if (rgba_color == 0)
6443 "WARNING: Allocate framepool size 0 for session 0x%x\n", p_ctx->
session_id);
6449 "ERROR: %s() try to free session 0x%x framepool while it's not allocated\n",
6460 "ERROR: %s() try to free session 0x%x framepool of type %u while "
6461 "passing type %u\n",
6476 "ERROR: allocate framepool multiple times for session 0x%x "
6477 "not supported in FW API version < 6r3\n",
6484 "Expand frame pool of scaler 0x%x with %u more frames\n",
6490 "ERROR: try to expand session 0x%x framepool with type %u "
6491 "while pool type is %u\n",
6506 memset(p_data, 0x00, dataLen);
6565 ni_log2(p_ctx,
NI_LOG_ERROR,
"Resolution %d x %d not supported for %d format!\n", width, height, format);
6570 "Session=0x%x: Dev alloc frame: FrameIndex=%d; W=%d; H=%d; C=%d; RW=%d; RH=%d; RX=%d; RY=%d\n",
6584 p_data, dataLen, ui32LBA);
6611 "ERROR: ni_nvme_send_admin_cmd failed: "
6612 "blk_io_handle: %" PRIx64
", hw_id, %u, xcoder_inst_id: %d\n",
6641 uint32_t ui32LBA = 0;
6646 dataLen = dataLen & 0xFFFFF000;
6648 if (!p_ctx || !p_cfg)
6667 memset(p_data, 0x00, dataLen);
6712 "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",
6723 p_data, dataLen, ui32LBA);
6729 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
6730 ", hw_id, %u, xcoder_inst_id: %d\n",
6734 "ERROR ni_scaler_config(): nvme command failed!\n");
6765 uint32_t ui32LBA = 0;
6771 dataLen = dataLen & 0xFFFFF000;
6773 if (!p_ctx || (!p_cfg_in && numInCfgs))
6792 memset(p_data, 0x00, dataLen);
6794 p_data_orig = p_data;
6796 for (i = 0; i < numInCfgs; i++)
6813 "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",
6838 "Session=0x%x: Dev out config frame: FrameIndex=%u; W=%d; H=%d; C=%d; RW=%d; RH=%d; RX=%d; RY=%d\n",
6856 p_data_orig, dataLen, ui32LBA);
6862 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
6863 ", hw_id, %u, xcoder_inst_id: %d\n",
6867 "ERROR ni_scaler_config(): nvme command failed!\n");
6889 void* p_buffer = NULL;
6891 uint32_t ui32LBA = 0;
6896 if ((!p_ctx) || (!p_gen_status))
6907 __func__, device_type);
6922 memset(p_buffer, 0, dataLen);
6957 void* p_buffer = NULL;
6959 uint32_t ui32LBA = 0;
6960 uint32_t dataLen = 0;
6961 uint32_t copyLen = 0;
6982 if ((!p_ctx) || (!p_detail_status))
6993 __func__, device_type);
7006 memset(p_buffer, 0, dataLen);
7016 memcpy(p_detail_status, p_buffer, copyLen);
7039 void* p_buffer = NULL;
7041 uint32_t ui32LBA = 0;
7046 if ((!p_ctx) || (!p_stream_info))
7058 __func__, device_type);
7080 memset(p_buffer, 0, dataLen);
7127 void* p_buffer = NULL;
7128 uint64_t session_timestamp;
7129 uint32_t ui32LBA = 0;
7138 if ((!p_ctx) || (!p_session_stats))
7149 __func__, device_type);
7171 memset(p_buffer, 0, dataLen);
7203 session_timestamp <<= 32;
7215 "query timestamp:%" PRIu64
"\n", p_ctx->
session_id,
7224 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 "
7225 "ready_to_close %u session_run_state %d active_video_width %u active_video_height %u\n",
7239#if __linux__ || __APPLE__
7240#if !defined(_ANDROID) && !defined(__OPENHARMONY__)
7241#ifndef DISABLE_BACKTRACE_PRINT
7242 ni_print_backtrace();
7256 "%s(): device 0x%" PRIx64
" last command Failed due to wrong "
7257 "session ID. Expected 0x%x, got 0x%x keep alive last access "
7258 "time %" PRIu64
", current %" PRIu64
"\n", __func__,
7261 if (dt > 1000000000)
7264 "%s():long delay between last command dt = %" PRId64
" ns, "
7265 "process was possibly blocked.\n", __func__, dt);
7299 void* p_buffer = NULL;
7301 uint32_t ui32LBA = 0;
7306 if (!p_ctx || !p_stream_complete)
7318 __func__, device_type);
7340 memset(p_buffer, 0, dataLen);
7362static const char* ni_get_device_type_str(
int type)
7366 return "Invalid device type";
7368 return g_device_type_str[type];
7376 memcpy((
void *)p_session_statistic, p_buffer,
7380 p_session_statistic->ui32RdBufAvailSize =
7381 ni_htonl(p_session_statistic->ui32RdBufAvailSize);
7382 p_session_statistic->ui32WrBufAvailSize =
7383 ni_htonl(p_session_statistic->ui32WrBufAvailSize);
7385 p_session_statistic->ui32FramesInput =
7386 ni_htonl(p_session_statistic->ui32FramesInput);
7387 p_session_statistic->ui32FramesBuffered =
7388 ni_htonl(p_session_statistic->ui32FramesBuffered);
7389 p_session_statistic->ui32FramesCompleted =
7390 ni_htonl(p_session_statistic->ui32FramesCompleted);
7391 p_session_statistic->ui32FramesOutput =
7392 ni_htonl(p_session_statistic->ui32FramesOutput);
7393 p_session_statistic->ui32FramesDropped =
7394 ni_htonl(p_session_statistic->ui32FramesDropped);
7395 p_session_statistic->ui32InstErrors =
7396 ni_htonl(p_session_statistic->ui32InstErrors);
7398 p_session_statistic->ui16SessionId =
7399 ni_htons(p_session_statistic->ui16SessionId);
7400 p_session_statistic->ui16ErrorCount =
7401 ni_htons(p_session_statistic->ui16ErrorCount);
7402 p_session_statistic->ui32LastTransactionId =
7403 ni_htonl(p_session_statistic->ui32LastTransactionId);
7404 p_session_statistic->ui32LastTransactionCompletionStatus =
7405 ni_htonl(p_session_statistic->ui32LastTransactionCompletionStatus);
7406 p_session_statistic->ui32LastErrorTransactionId =
7407 ni_htonl(p_session_statistic->ui32LastErrorTransactionId);
7408 p_session_statistic->ui32LastErrorStatus =
7409 ni_htonl(p_session_statistic->ui32LastErrorStatus);
7410 p_session_statistic->ui32Session_timestamp_high =
7411 ni_htonl(p_session_statistic->ui32Session_timestamp_high);
7412 p_session_statistic->ui32Session_timestamp_low =
7413 ni_htonl(p_session_statistic->ui32Session_timestamp_low);
7417 if (p_ctx->
session_id != p_session_statistic->ui16SessionId)
7422 "%s(): %s device 0x%" PRIx64
" last command Failed due to wrong "
7423 "session ID. Expected 0x%x, got 0x%x w_r <%u %u> keep alive "
7424 "last access time %" PRIu64
", current %" PRIu64
"\n", __func__,
7427 p_session_statistic->ui16SessionId,
7428 p_session_statistic->ui32WrBufAvailSize,
7431 if (dt > 1000000000)
7434 "%s():long delay between last command dt = %" PRId64
" ns, "
7435 "process was possibly blocked.\n", __func__, dt);
7437 p_session_statistic->ui32LastErrorStatus =
7447 __func__, p_session_statistic->ui16ErrorCount,
7448 p_session_statistic->ui32LastTransactionCompletionStatus,
7449 p_session_statistic->ui32LastErrorStatus);
7469 void *p_buffer = NULL;
7471 uint32_t ui32LBA = 0;
7477 if (!p_ctx || !p_session_statistic)
7480 "ERROR: %s() passed parameters are null!, return\n", __func__);
7488 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: %s() not supported on device with FW api version < 6.5\n", __func__);
7497 __func__, device_type);
7519 memset(p_buffer, 0, dataLen);
7528 p_buffer, dataLen, ui32LBA) < 0)
7539 ni_parse_session_statistic_info(p_ctx, p_session_statistic, p_buffer);
7544 __func__, ni_get_device_type_str((
int)p_ctx->
device_type));
7573 void* p_buffer = NULL;
7575 uint32_t ui32LBA = 0;
7583 if (!p_ctx || !p_inst_buf_info)
7597 __func__, device_type);
7664 memset(p_buffer, 0, dataLen);
7701 uint8_t enable, uint8_t hw_action,
7705 uint32_t ui32LBA = 0;
7706 void * p_buffer = NULL;
7707 uint32_t buffer_size = 0;
7736 memset(p_buffer, 0, buffer_size);
7795 uint32_t ui32LBA = 0;
7811 __func__, device_type);
7849 uint32_t ui32LBA = 0;
7865 __func__, device_type);
7904 uint32_t ui32LBA = 0;
7919 __func__, device_type);
7966 uint32_t ui32LBA = 0;
7967 void * p_buffer = NULL;
7968 uint32_t buffer_size = 0;
7984 __func__, device_type);
8005 memset(p_buffer, 0, buffer_size);
8006 memcpy(p_buffer, &len,
sizeof(len));
8036 uint32_t ui32LBA = 0;
8037 void * p_buffer = NULL;
8038 uint32_t buffer_size = 0;
8052 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: Seq Change not supported for device type %d, return\n", device_type);
8073 memset(p_buffer, 0, buffer_size);
8101 void* p_encoder_config = NULL;
8102 void* p_encoder_roi_qp_map = NULL;
8104 uint32_t buffer_size = 0;
8106 uint32_t ui32LBA = 0;
8132 if (
ni_posix_memalign(&p_encoder_roi_qp_map, sysconf(_SC_PAGESIZE), buffer_size))
8139 memset(p_encoder_roi_qp_map, 0, buffer_size);
8143 p_encoder_roi_qp_map, buffer_size, ui32LBA);
8161 ni_log2(p_ctx,
NI_LOG_INFO,
"customizeQpMapFile is ignored since customizeQpLevel=0");
8175 memset(p_encoder_config, 0, buffer_size);
8182 (void)fflush(stdout);
8187 (void)fflush(stdout);
8236 p_encoder_config, buffer_size, ui32LBA);
8273 uint32_t ui32LBA = 0;
8277 if (!p_ctx || !p_params)
8311 buffer_size, ui32LBA) < 0)
8338 p_frame_offset, uint32_t* p_frame_dropped,
bool is_hw_frame)
8343 if (!p_frame || !p_frame_offset)
8350 *p_frame_offset = 0;
8351 if (p_frame_dropped)
8352 *p_frame_dropped = 0;
8356 unsigned int video_data_size = p_frame->
data_len[0] + p_frame->
data_len[1] +
8363 if (rx_size == metadata_size)
8365 video_data_size = 0;
8368 if (rx_size > video_data_size)
8375 rx_size -= metadata_size;
8386 "%s: [metadata] cropRight=%u, cropLeft=%u, "
8387 "cropBottom=%u, cropTop=%u, frame_offset=%" PRIu64
", pic=%ux%u, "
8388 "pict_type=%d, crop=%ux%u, sei header: 0x%0x number %u size %u num_frame_dropped %u\n",
8410 if (p_frame_dropped)
8418 ni_log(
NI_LOG_DEBUG,
"ui32SeiHeader 0x%x ui16SeiNumber %d ui16SeiSize %d SEI 0x%02x%02x\n",
8420 *((uint8_t*)p_meta + metadata_size),
8421 *((uint8_t*)p_meta + metadata_size+1));
8424 uint16_t ui16SeiProcessed = 0;
8426 uint32_t ui32Offset = 0;
8435 if (pEntryHeader->
status)
8437 ui32Size = pEntryHeader->
size;
8445 ui16SeiProcessed, pEntryHeader->
status,
8446 pEntryHeader->
size, pEntryHeader->
type, ui32Size,
8448 *((uint8_t *)p_meta + metadata_size + ui32Offset),
8449 *((uint8_t *)p_meta + metadata_size + ui32Offset + 1));
8456 switch(pEntryHeader->
type)
8461 uint8_t *ptr = (uint8_t*)p_meta + metadata_size + ui32Offset;
8468 video_data_size + metadata_size + ui32Offset;
8495 "%s: close caption size %u ,"
8496 "offset %u = video size %u meta size %d off "
8499 video_data_size, metadata_size, ui32Offset);
8504 "%s: unsupported T35; type %u size %u status %u "
8506 __func__, pEntryHeader->
type, pEntryHeader->
size,
8507 pEntryHeader->
status, ui32Offset);
8513 "Error %s: T35 SEI dropped due to %s; type %u size %u status %u offset %u\n",
8514 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8515 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8532 "Error %s: User Data Unreg dropped due to %s; type %u size %u status %u offset %u\n",
8533 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8534 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8543 video_data_size + metadata_size + ui32Offset;
8548 *)((uint8_t *)p_meta + metadata_size + ui32Offset);
8570 "Error %s: mastering display info dropped due to %s; type %u size %u status %u offset %u\n",
8571 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8572 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8581 video_data_size + metadata_size + ui32Offset;
8587 (uint8_t*)p_meta + metadata_size + ui32Offset);
8596 "Error %s: content light level info dropped due to %s; type %u size %u status %u offset %u\n",
8597 __func__, pEntryHeader->
status ?
"missing payload" :
"payload size exceeded SEI buffer size",
8598 pEntryHeader->
type, pEntryHeader->
size, pEntryHeader->
status, ui32Offset);
8607 video_data_size + metadata_size + ui32Offset;
8616 "Warning %s: SEI message dropped (unsupported - check "
8617 "decoder SEI bitmap settings);"
8618 " type %u size %u status %u offset %u payload bytes %u\n",
8619 __func__, pEntryHeader->
type, pEntryHeader->
size,
8620 pEntryHeader->
status, ui32Offset, ui32Size);
8623 ui32Offset += ui32Size;
8624 pEntryHeader = (
ni_sei_header_t *)((uint8_t*)p_meta + metadata_size + ui32Offset);
8626 }
while (ui32Offset <= p_meta->sei_size && ui16SeiProcessed < p_meta->sei_number);
8632 "Error %s: number of SEI messages reported %u != processed %u\n",
8633 __func__, p_meta->
sei_number, ui16SeiProcessed);
8642 ni_sei_user_data_entry_t *pEntry;
8643 uint32_t ui32CCOffset = 0, ui32CCSize = 0;
8647 pEntry = (ni_sei_user_data_entry_t *)((uint8_t*)p_meta + metadata_size);
8650 &ui32CCOffset, &ui32CCSize))
8654 video_data_size + metadata_size + ui32CCOffset;
8667 &ui32CCOffset, &ui32CCSize))
8671 ptr = (uint8_t*)pEntry + ui32CCOffset;
8674 ui32CCSize = (ptr[8] & 0x1F) * 3;
8680 + ui32CCOffset + 10;
8685 "%s: close caption size %u ,"
8686 "offset %u = video size %u meta size %u off "
8689 video_data_size, metadata_size, ui32CCOffset);
8699 &ui32CCOffset, &ui32CCSize))
8703 video_data_size + metadata_size + ui32CCOffset;
8707 ni_dec_mastering_display_colour_volume_t* pColourVolume =
8708 (ni_dec_mastering_display_colour_volume_t*)((uint8_t*)pEntry + ui32CCOffset);
8711 pColourVolume->display_primaries_x[0],
8712 pColourVolume->display_primaries_y[0]);
8714 pColourVolume->display_primaries_x[1],
8715 pColourVolume->display_primaries_y[1]);
8717 pColourVolume->display_primaries_x[2],
8718 pColourVolume->display_primaries_y[2]);
8721 pColourVolume->white_point_x,
8722 pColourVolume->white_point_y);
8724 pColourVolume->max_display_mastering_luminance, pColourVolume->min_display_mastering_luminance);
8728 &ui32CCOffset, &ui32CCSize))
8732 video_data_size + metadata_size + ui32CCOffset;
8736 ni_content_light_level_info_t* pLightLevel =
8737 (ni_content_light_level_info_t*)((uint8_t*)pEntry + ui32CCOffset);
8739 pLightLevel->max_content_light_level, pLightLevel->max_pic_average_light_level);
8744 &ui32CCOffset, &ui32CCSize) ||
8747 &ui32CCOffset, &ui32CCSize))
8751 video_data_size + metadata_size + ui32CCOffset;
8782 return (
int)rx_size;
8793 ni_device_handle_t device_handle,
bool device_in_ctxt)
8795 int i, total_types = 0, total_modules = 0;
8803 if (!p_cap || !p_data)
8816 "ERROR: Previously in context device got an invalid vendor ID 0x%X SSVID 0x%X. Netint "
8817 "ID 0x%X. Retrying\n",
8821 (
int)
sizeof(p_id_data->
ai8Sn), p_id_data->
ai8Sn);
8823 (
int)
sizeof(p_id_data->
ai8Mn), p_id_data->
ai8Mn);
8825 (
int)
sizeof(p_id_data->
ai8Fr), p_id_data->
ai8Fr);
8829 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
8840 "ERROR: %s(): Retry got an invalid vendor ID too 0x%X SSVID "
8845 (
int)
sizeof(p_id_data->
ai8Sn), p_id_data->
ai8Sn);
8847 (
int)
sizeof(p_id_data->
ai8Mn), p_id_data->
ai8Mn);
8849 (
int)
sizeof(p_id_data->
ai8Fr), p_id_data->
ai8Fr);
8857 "Retry got valid a vendor ID 0x%X SSVID 0x%X. Netint ID 0x%X\n",
8900 "Error: mismatch; xcoder_num_elements: %d (calculated: %d) "
8901 "xcoder_num_devices: %d (calculated: %d)\n",
8958 "ERROR: Previously in context device is not a xcoder device "
8978 if (total_modules >= 1)
8993 if (total_modules >= 2)
9008 if (total_modules >= 3)
9023 if (total_modules >= 4)
9091static uint32_t presetGopSize[] = {
9111 int pos_byte = (pos/8);
9112 int pos_in_byte = pos%8;
9113 int remaining_bytes_in_current_byte = 8 - pos_in_byte;
9115 if (pos_in_byte == 0)
9117 vui[pos_byte] = (uint8_t)(value >> 24);
9118 vui[pos_byte+1] = (uint8_t)(value >> 16);
9119 vui[pos_byte+2] = (uint8_t)(value >> 8);
9120 vui[pos_byte+3] = (uint8_t)(value);
9124 vui[pos_byte] = vui[pos_byte] + (uint8_t)(value >> (32-remaining_bytes_in_current_byte));
9125 vui[pos_byte+1] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-8));
9126 vui[pos_byte+2] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-16));
9127 vui[pos_byte+3] = (uint8_t)(value >> (32-remaining_bytes_in_current_byte-24));
9128 vui[pos_byte+4] = vui[pos_byte+4] + ((uint8_t)(value << remaining_bytes_in_current_byte));
9143 uint32_t max_pkt_size)
9147 if ((!p_ctx) || (!p_cfg) || (!p_src))
9156 bool shift_params =
false;
9185 ni_log2(p_ctx,
NI_LOG_INFO,
"%s height %d width %d fps_number %d fps_denominator %d\n",
9195 shift_params =
true;
9196 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Output 2 used before output 1, Shifting output2 settings to output1 and disabling output 2\n");
9201 if (!shift_params || i == 0)
9207 j = (i == 1) ? 2 : 1;
9213 (uint16_t)((p_dec->
crop_whxy[j][0]) & 0xFFFE);
9215 (uint16_t)((p_dec->
crop_whxy[j][1]) & 0xFFFE);
9217 (uint16_t)((p_dec->
crop_whxy[j][2]) & 0xFFFE);
9219 (uint16_t)((p_dec->
crop_whxy[j][3]) & 0xFFFE);
9281 0 : ((p_dec->
scale_wh[j][0]+1) & 0xFFFE));
9283 0 : ((p_dec->
scale_wh[j][1]+1) & 0xFFFE));
9301 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): maxExtraHwFrameCnt is not support for FW < 6rB\n", __func__);
9308 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): extendPoolSize is not support for FW < 6t2\n", __func__);
9317 ni_log2(p_ctx,
NI_LOG_ERROR,
"Warning %s(): decoderMode is only supported for H.264/H.265, resetting to default normal\n", __func__);
9322 ni_log2(p_ctx,
NI_LOG_ERROR,
"Warning %s(): decoderMode is not supported for FW < 6tC, resetting to default normal\n", __func__);
9333 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): (enableAdvancedEc == 2) is not support for FW < 6rO\n", __func__);
9340 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): (EcPolicy == limited_error) not supported for FW < 6ri\n", __func__);
9347 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): setting ecErrThreshold not supported for FW < 6ri\n", __func__);
9354 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): (EcPolicy == best_effort_out_dc) not supported for FW < 6s1\n", __func__);
9362 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): surviveStreamErr is not supported for FW < 6rl\n", __func__);
9371 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s():Not support to reduce dpb delay and reset.\n", __func__);
9431 if ((!p_ctx) || (!p_cfg) || (!p_src))
9486 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");
9490 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__,
9502 if (p_enc->
crf != -1 || p_enc->
crfFloat != -1.0f) {
9505 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): CRF disabled due to preset enabled\n", __func__);
9544 ni_log2(p_ctx,
NI_LOG_DEBUG,
"### %s: Slow sequence happened retain last_bitrate %d. assigned bitrate %d\n",
9556 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__,
9610 ni_log2(p_ctx,
NI_LOG_DEBUG,
"### %s: Slow sequence happened retain last_framerate num %d den %d. assigned num %d den %d\n",
9627 uint32_t numUnitsInTick = 1000;
9712 "ERROR: %s() unknown value for p_t408->decoding_refresh_type: %d\n",
9736 ni_log2(p_ctx,
NI_LOG_DEBUG,
"force intraRefreshMode to 1 because quadra only supports intra refresh by rows\n");
9746 int mbRows = (p_cfg->
i32picHeight + mbHeight - 1) / mbHeight;
9781 "for profile 3 (extended) or 1 (baseline)\n");
9791 "force EnableRdoQuant 0 to accommodate HW limiation\n");
9911 if (p_enc->
crf != -1)
10059 "Turning off strongIntraSmoothing because hvsQPEnable=1 "
10060 "for better subjective VQ\n");
10072 "Turning off strongIntraSmoothing because hvsQPEnable=1 for "
10073 "better subjective VQ\n");
10107 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): spatialLayers is not supported for FW < 6rw\n", __func__);
10115 ni_log2(p_ctx,
NI_LOG_INFO,
"Warning %s(): spatialLayers is not supported for FW < 6s0\n", __func__);
10133 ni_log(
NI_LOG_INFO,
"Warning h.265 psnr_y is only supported for YUV420P, YUV420P10LE, NV12, and P010LE\n");
10143 ni_log(
NI_LOG_INFO,
"Warning reconstructed frames only supported for YUV420P, NV12\n");
10149 ni_log(
NI_LOG_INFO,
"Warning reconstructed frames feature is not supported when cropWidth x cropHeight are set\n");
10159 ni_log(
NI_LOG_INFO,
"Warning get psnr feature only support YUV420P (except for h.265 psnr_y)\n");
10165 ni_log(
NI_LOG_INFO,
"Warning get psnr feature is not supported when cropWidth x cropHeight are set\n");
10202 int gopSize = g_map_preset_to_gopsize[lookAheadEnable][p_t408->
gop_preset_index + 1];
10208 if (lookAheadEnable)
10210 int firstGopEnd = gopSize + 1 + mulitcoreDelay;
10211 int lookaheadGopEnd = mulitcoreDelay ?
10214 int initialDelayNum = (firstGopEnd > lookaheadGopEnd) ? firstGopEnd : lookaheadGopEnd;
10216 int maxLookaheadQueue = initialDelayNum + (gopSize - 1) + mulitcoreDelay;
10219 p_ctx->
max_frame_delay = ((maxDelayNum > maxLookaheadQueue) ? maxDelayNum : maxLookaheadQueue) + (mulitcoreDelay ? 4 : 0);
10242 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: firstGopEnd %d lookaheadGopEnd %d initialDelayNum %d maxDelayNum %d maxLookaheadQueue %d\n",
10243 __FUNCTION__, firstGopEnd, lookaheadGopEnd, initialDelayNum, maxDelayNum, maxLookaheadQueue);
10251 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: preset %d lookAheadDepth %d gopSize %d mulitcoreDelay %d "
10252 "last_gop_size %d linitial_frame_delay %d current_frame_delay %d max_frame_delay %d\n",
10264 if (p_enc->
crfMax != -1)
10269 if (p_enc->
qcomp != (
float)0.6)
10289 if (p_enc->
ipRatio != (
float)1.4)
10294 if (p_enc->
pbRatio != (
float)1.3)
10319 if (p_enc->
crfFloat != (
float)-1.0)
10532 for (i = 0; i < 8; i++)
10780 if( (!p_ctx) || (!p_config) )
11052 p_config->
i8crf = -1;
11111 p_config->
i8crfMax = (int8_t)(-1) + 1;
11112 p_config->
i32qcomp = (int32_t)(0.6 * 1000) + 1000;
11116 p_config->
i32ipRatio = (int32_t)(1.4 * 1000) + 1000;
11117 p_config->
i32pbRatio = (int32_t)(1.3 * 1000) + 1000;
11118 p_config->
i32cplxDecay = (int32_t)(0.5 * 1000) + 1000;
11122 p_config->
i8pass1Qp = (int8_t)(-1) + 1;
11179 uint32_t max_err_len)
11185 char *p_param_warn = NULL;
11188 if (!p_ctx || !p_cfg || !p_param_err)
11206 memset(p_param_err, 0, max_err_len);
11207 memset(p_param_warn, 0, max_err_len);
11220 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);
11230 ni_strncpy(p_param_err, max_err_len,
"ddr_priority_mode not supported on device with FW api version < 6.e",
11239 ni_strncpy(p_param_err, max_err_len,
"LowDelay is not supported on jpeg/vp9 decoder",
11253 ni_strncpy(p_param_err, max_err_len,
"Invalid crop offset: extends past 48x48 minimum window", max_err_len - 1);
11260 ni_strncpy(p_param_err, max_err_len,
"Invalid crop w or h: must be at least 48x48 minimum window", max_err_len - 1);
11267 ni_strncpy(p_param_err, max_err_len,
"Invalid crop w or h: must be smaller than input", max_err_len - 1);
11274 ni_strncpy(p_param_err, max_err_len,
"Invalid crop rect: must fit in input", max_err_len - 1);
11283 ni_strncpy(p_param_err, max_err_len,
"Invalid crop value: even values only", max_err_len - 1);
11289 ni_strncpy(p_param_warn, max_err_len,
"crop param used but output not enabled!", max_err_len - 1);
11304 ni_strncpy(p_param_err, max_err_len,
"Invalid scale dimensions: zero", max_err_len - 1);
11312 ni_strncpy(p_param_err, max_err_len,
"Invalid scale value: even values only", max_err_len - 1);
11322 ni_strncpy(p_param_err, max_err_len,
"Invalid scale value: downscale only", max_err_len - 1);
11334 ni_strncpy(p_param_err, max_err_len,
"Invalid scale dimensions: downscale only after cropping", max_err_len - 1);
11341 ni_strncpy(p_param_warn, max_err_len,
"scale param used but output not enabled!", max_err_len - 1);
11349 ni_strncpy(p_param_warn, max_err_len,
"force8bit or semiPlanar used but output not enabled!", max_err_len - 1);
11364 "Invalid pairing: out=HW must be set with tiled format",
11371 ni_strncpy(p_param_err, max_err_len,
"Invalid pairing: VP9 not compatible with tiled format",
11383 "Invalid scale height: mult of 4 only, >= 128",
11393 "Invalid scale width: mult of 128 only, >= 144",
11405 "Invalid crop height: mult of 4 only, >= 128",
11415 "Invalid crop width: mult of 128 only, >= 144",
11423 ni_strncpy(p_param_err, max_err_len,
"Force 8 bit: not supported with tiled format\n", max_err_len - 1);
11433 ni_strncpy(p_param_err, max_err_len, p_param_warn, max_err_len - 1);
11438 free(p_param_warn);
11443static ni_retcode_t ni_check_level(
int level,
int codec_id,
int *level_index)
11446 const int l_levels_264[] = {10, 99, 11, 12, 13, 20, 21, 22, 30, 31, 32,
11447 40, 41, 42, 50, 51, 52, 60, 61, 62, 0};
11448 const int l_levels_265[] = {10, 20, 21, 30, 31, 40, 41,
11449 50, 51, 52, 60, 61, 62, 0};
11450 const int l_levels_av1[] = {20, 21, 30, 31, 40, 41, 50, 51, 52, 53, 60, 61, 62, 63, 0};
11451 const int *l_levels = l_levels_264;
11463 l_levels = l_levels_265;
11466 l_levels = l_levels_av1;
11469 while (*l_levels != 0)
11471 if (*l_levels == level)
11473 *level_index = index;
11483static uint32_t get_max_pic_size(
ni_codec_format_t codecFormat , int32_t levelIdx )
11485 assert( levelIdx >= 0);
11486 int32_t level =
MAX(0, levelIdx);
11487 uint32_t maxPicSize = 0;
11489 switch( codecFormat )
11494 maxPicSize = max_pic_size_h265[ level ];
11500 maxPicSize = max_pic_size_h264[ level ];
11505 maxPicSize = max_pic_size_av1[ level ];
11515static uint64_t get_max_sample_rate_second(
ni_codec_format_t codecFormat , int32_t levelIdx )
11517 assert( levelIdx >= 0);
11518 int32_t level =
MAX(0, levelIdx);
11519 uint64_t maxSBPS = 0;
11521 switch( codecFormat )
11526 maxSBPS = max_sample_rate_second_h265[ level ];
11532 maxSBPS = max_sample_rate_second_h264[ level ];
11537 maxSBPS = max_sample_rate_second_av1[ level ];
11548static uint32_t get_max_cpb_bitrate(
ni_codec_format_t codecFormat , int32_t levelIdx, int32_t profile, int32_t tier, int32_t type )
11550 assert( levelIdx >= 0);
11551 int32_t level =
MAX(0, levelIdx);
11552 uint32_t maxBR = 0;
11554 switch( codecFormat )
11559 maxBR = (tier ==
HIGH_TIER) ? max_cpb_hightier_second_h265[ level ] : max_cpb_second_h265[ level ];
11565 float h264_high10_factor = 1;
11567 h264_high10_factor = (float)1.25;
11568 else if(profile == 5)
11569 h264_high10_factor = (float)3.0;
11571 maxBR = (uint32_t)((
float)max_bitrate_h264[ level ] * h264_high10_factor);
11573 maxBR = (uint32_t)((
float)max_cpb_second_h264[ level ] * h264_high10_factor);
11578 maxBR = ((level > 7) && (tier ==
HIGH_TIER)) ? max_cpb_hightier_second_av1[ level ] : max_cpb_second_av1[ level ];
11589static ni_retcode_t ni_check_level_tier_compliance(
int level,
11594 char* p_param_warn,
11595 uint32_t max_err_len,
11599 if( (!p_ctx) || (!p_cfg) || (!p_src) || (!p_param_err) || (!p_param_warn) || (!warning) )
11613 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",
11616 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): max_pic_size %d max_sample_rate_second %" PRIu64
" max_bitrate %u\n",
11617 __func__, max_pic_size, max_sample_rate_second, max_bitrate);
11619 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): i8crf %d i32bitRate %d ui32vbvMaxRate %u i32vbvBufferSize %d\n",
11622 if (p_cfg->
i8crf != -1)
11626 (void)snprintf(p_param_warn, max_err_len,
"Level (%.1f): Switched crf to capped crf to be compliant with the level",
11635 ni_strncpy(p_param_warn, max_err_len,
"Enabled rate control because level parameter is used", max_err_len - 1);
11641 if(sample_per_picture > max_pic_size)
11643 (void)snprintf(p_param_err, max_err_len,
"Invalid Encoder Level (%.1f): picture size %u exceeds supported limits %u",
11644 (
float) level/10, sample_per_picture, max_pic_size);
11648 if(sample_per_second > max_sample_rate_second)
11650 (void)snprintf(p_param_err, max_err_len,
"Invalid Encoder Level (%.1f): picture sample rate %" PRIu64
" exceeds supported limits %" PRIu64
"",
11651 (
float) level/10, sample_per_second, max_sample_rate_second);
11655 if(p_cfg->
i32bitRate > (int32_t)max_bitrate)
11657 (void)snprintf(p_param_warn, max_err_len,
"Level (%.1f): bitrate %d exceeds supported limit. Changed it to maximum %u",
11658 (
float) level/10, p_cfg->
i32bitRate, max_bitrate);
11665 (void)snprintf(p_param_warn, max_err_len,
"Level (%.1f): vbvMaxRate %u exceeds supported limit. Changed it to maximum %u",
11685 uint32_t max_err_len)
11692 int level_index = 0;
11694 if( (!p_ctx) || (!p_cfg) || (!p_src) || (!p_param_err) )
11704 memset(p_param_err, 0, max_err_len);
11705 memset(p_param_warn, 0, max_err_len);
11709 ni_strncpy(p_param_err, max_err_len,
"Invalid frame_rate of 0 value", max_err_len - 1);
11717 ni_strncpy(p_param_err, max_err_len,
"Invalid i32frameRateInfo: too big", max_err_len - 1);
11725 ni_strncpy(p_param_err, max_err_len,
"Invalid i32bitRate: smaller than or equal to frame rate", max_err_len - 1);
11732 ni_strncpy(p_param_err, max_err_len,
"Invalid i32bitRate: too big", max_err_len - 1);
11739 ni_strncpy(p_param_err, max_err_len,
"Invalid i32bitRate: too low", max_err_len - 1);
11746 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Width: too small", max_err_len - 1);
11753 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Width: too big", max_err_len - 1);
11760 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Height: too small", max_err_len - 1);
11767 ni_strncpy(p_param_err, max_err_len,
"Invalid Picture Height: too big", max_err_len - 1);
11777 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height (%u x %u): both need to be specified",
11785 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height (%u x %uu): must be even",
11793 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width: less than %d",
11800 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Height: less than %d",
11807 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width: exceeds %d",
11814 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Height: exceeds %d",
11821 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height: exceeds %d",
11831 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width: exceeds %d",
11838 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Height: exceeds %d",
11845 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width x Height: exceeds %d",
11855 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop horOffset %u and/or verOffset %u: must be even",
11863 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Width: offset %u + crop width %u too big > %d",
11870 (void)snprintf(p_param_err, max_err_len,
"Invalid Crop Height: offset %u + crop height %u too big > %d",
11877 (void)snprintf(p_param_err, max_err_len,
"roiEnable must disabled when Crop Width > 0 || Crop Height > 0");
11888 (void)snprintf(p_param_err, max_err_len,
"Invalid Picture Width: exceeds %d",
11895 (void)snprintf(p_param_err, max_err_len,
"Invalid Picture Height: exceeds %d",
11902 (void)snprintf(p_param_err, max_err_len,
"Invalid Picture Width x Height: exceeds %d",
11912 ni_strncpy(p_param_err, max_err_len,
"Invalid input planar format: out of range", max_err_len - 1);
11921 ni_strncpy(p_param_err, max_err_len,
"Invalid input planar format for device with FW api version < 6.8",
11928 ni_strncpy(p_param_err, max_err_len,
"Invalid Encoder Selected: Tiled format must be on same device",
11936 "Invalid Picture Height: tiled format only supports "
11945 "Invalid Picture Width: tiled format only supports "
11960 ni_strncpy(p_param_err, max_err_len,
"zeroCopyMode must not be disabled for RGBA / BGRA / ABGR / ARGB pixel formats", max_err_len - 1);
11970 ni_strncpy(p_param_err, max_err_len,
"RGBA / BGRA pixel formats not supported on device with FW api version < 6.Y",
11984 (void)snprintf(p_param_err, max_err_len,
"Unsupported pixel format %d in encoder", p_cfg->
ui8PixelFormat);
11994 ni_strncpy(p_param_err, max_err_len,
"ddr_priority_mode not supported on device with FW api version < 6.e",
12006 ni_strncpy(p_param_err, max_err_len,
"Invalid Encoder Level: out of range", max_err_len - 1);
12011 param_ret = ni_check_level_tier_compliance(
12012 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);
12024 ni_strncpy(p_param_err, max_err_len,
"Invalid intra_mb_refresh_mode: out of range",
12036 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too small", max_err_len - 1);
12043 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too big", max_err_len - 1);
12056 "Invalid custom GOP paramaters: custom gop size must > 0",
12068 "Invalid custom GOP paramaters: selected gopPresetIdx is "
12069 "not compatible with custom gop",
12076 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too small", max_err_len - 1);
12083 ni_strncpy(p_param_err, max_err_len,
"Invalid custom GOP paramaters: custom_gop_size too big", max_err_len - 1);
12093 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: poc_offset larger"
12094 " than GOP size", max_err_len - 1);
12106 ni_strncpy(p_param_warn, max_err_len,
"useLowDelayPocType is only supported for H.264. Change useLowDelayPocType to 0", max_err_len - 1);
12115 "entropyCodingMode is only supported for H.264.",
12126 "av1ErrorResilientMode is only supported for AV1.",
12136 (void)snprintf(p_param_err, max_err_len,
"%s is not supported for JPEG.",
12146 ni_strncpy(p_param_err, max_err_len,
"qLevel is only supported for JPEG.",
12159 ni_strncpy(p_param_warn, max_err_len,
"enableSSIM only supported on device with FW api version < 6.2 "
12160 "and the encoder is not av1_ni_quadra_enc. Reported ssim will be 0.", max_err_len - 1);
12169 ni_strncpy(p_param_err, max_err_len,
"sliceMode/sliceArg is only supported for H.264 or H.265.",
12178 int max_num_ctu_mb_row = (p_src->
source_height + ctu_mb_size - 1) / ctu_mb_size;
12182 (void)snprintf(p_param_err, max_err_len,
"Invalid number of rows per slice: should be between 1 and %d",
12193 ni_strncpy(p_param_err, max_err_len,
"useLowDelayPocType is only supported for H.264.",
12206 ni_strncpy(p_param_warn, max_err_len,
"ui8enableCompensateQp only supported when device with FW api version < 6rt "
12207 "and the encoder is not av1_ni_quadra_enc and ui16maxFrameSize > 0. Reported enableCompensateQp will be 0.", max_err_len - 1);
12219 ni_strncpy(p_param_warn, max_err_len,
"enableTimecode does not need to be set for H.265. Use ni_enc_insert_timecode API"
12220 "from libxcoder directly to insert time code SEI", max_err_len - 1);
12224 ni_strncpy(p_param_warn, max_err_len,
"enableTimecode not supported for the codec used. Forcing value to 0.", max_err_len - 1);
12242 "this gopPreset is not supported for lookahead and/or CRF",
12250 bool bIsgopLowdelay =
true;
12258 bIsgopLowdelay =
false;
12264 bIsgopLowdelay =
false;
12268 if (bIsgopLowdelay)
12270 ni_strncpy(p_param_err, max_err_len,
"B-frames low delay custom gop is not supported for "
12271 "lookahead and/or CRF", max_err_len - 1);
12280 "bitrateMode is invalid when lookahead is enabled (or in CRF mode)",
12292 "totalCuTreeDepth is invalid without lookahead",
12300 ni_strncpy(p_param_warn, max_err_len,
"totalCuTreeDepth does not take effects when its value <= lookahead depth", max_err_len - 1);
12309 "totalCuTreeDepth is not supported in multicoreJointMode",
12319 "totalCuTreeDepth does not support multi spatial layers",
12331 "qpScaleEnable is invalid without lookahead",
12337 if (p_cfg->
i8crf < 0)
12340 "qpScaleEnable is only supported in CRF or Capped CRF modes",
12349 "adaptiveCrfMode is invalid when qpScaleEnable",
12358 "qpScaleEnable does not supported multi spatial layers",
12381 "gopPresetIdx 2 is obsolete, suggest to use gopPresetIdx 9 "
12405 "gopPresetIdx 6 is obsolete, suggest to use gopPresetIdx 7 "
12443 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");
12455 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Set newRcEnable to 0 in spatial layer separated rate control mode\n");
12468 ni_strncpy(p_param_warn, max_err_len,
"StillImageDetect or SceneChangeDetect only support gopPresetIdx=9 with FW > 6rm\n", max_err_len - 1);
12479 "currently do not support gop preset in multi spatial layers encode or spatial layer separated rate control mode",
12493 "higher spatial layers referencing base layer is only supported in multi spatial layers encode",
12511 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);
12521 ni_strncpy(p_param_err, max_err_len,
"spatialLayerBitrate is not supported in multicoreJointMode for FW api version < 6sD", max_err_len - 1);
12539 ni_strncpy(p_param_err, max_err_len,
"Invalid av1OpLevel: out of range", max_err_len - 1);
12544 param_ret = ni_check_level_tier_compliance(
12545 p_cfg->
ui8av1OpLevel[i], p_ctx, p_cfg, p_src, p_param_err, p_param_warn, max_err_len, &warning, level_index);
12556 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel and level cannot be both specified", max_err_len - 1);
12563 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);
12574 "crfMaxIframeEnable is only supported in Capped CRF mode with lookahead enabled",
12590 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 5 (high10)",
12600 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (baseline), 2 (main),"
12601 " 3 (extended), 4 (high), or 5 (high10)", max_err_len - 1);
12612 ni_strncpy(p_param_err, max_err_len,
"Invalid gopPresetIdx for H.264 baseline profile:"
12613 " must be 1, 2, 6 or 0 (custom with no B frames)", max_err_len - 1);
12625 ni_strncpy(p_param_err, max_err_len,
"H.264 baseline profile: custom GOP can not "
12626 "have B frames", max_err_len - 1);
12637 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (baseline), 2 (main),"
12638 " 4 (high), or 5 (high10)", max_err_len - 1);
12644 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);
12655 ni_strncpy(p_param_err, max_err_len,
"H.264 baseline profile: custom GOP can not "
12656 "have B frames", max_err_len - 1);
12671 "Must use gopPresetIdx 1,9,10 (no "
12672 "B frames) for profile 1",
12682 ni_strncpy(p_param_err, max_err_len,
"Tier is not supported for H.264", max_err_len - 1);
12689 "spatialLayers is not supported for h.264 encode",
12696 ni_strncpy(p_param_err, max_err_len,
"disableAv1TimingInfo is not supported for h.264",
12703 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel is not supported for h.264",
12718 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 2 (main10)",
12728 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (main) or 2 (main10)",
12739 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (main) or 2 (main10)",
12746 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);
12752 "spatialLayers is not supported for h.265 encode",
12759 ni_strncpy(p_param_err, max_err_len,
"disableAv1TimingInfo is not supported for h.265",
12766 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel is not supported for h.265",
12773 ni_strncpy(p_param_err, max_err_len,
"getBitstreamFeatures is not supported for h.265 encoder",
12783 ni_strncpy(p_param_err, max_err_len,
"TuneBframeVisual MEDIUM is not supported for AV1", max_err_len - 1);
12789 ni_strncpy(p_param_err, max_err_len,
"Invalid profile: must be 1 (main)",
12800 "AV1 level < 2.0 is not supported, change to level 2.0",
12807 "AV1 level > 6.3 is not supported, change to level 6.3",
12817 ni_strncpy(p_param_warn, max_err_len,
"confWinTop is not supported in AV1",
12825 ni_strncpy(p_param_warn, max_err_len,
"confWinBottom is not supported in AV1",
12833 ni_strncpy(p_param_warn, max_err_len,
"confWinLeft is not supported in AV1",
12841 ni_strncpy(p_param_warn, max_err_len,
"confWinRight is not supported in AV1",
12847 ni_strncpy(p_param_err, max_err_len,
"hrdEnable is not supported on av1 encoder",
12854 ni_strncpy(p_param_err, max_err_len,
"enableAUD is not supported on av1 encoder",
12861 ni_strncpy(p_param_err, max_err_len,
"repeatHeaders is not supported on av1 encoder",
12867 ni_strncpy(p_param_err, max_err_len,
"enableSSIM is not supported on av1 encoder",
12874 ni_strncpy(p_param_err, max_err_len,
"EnableRdoQuant is not supported on av1 encoder",
12881 ni_strncpy(p_param_err, max_err_len,
"fillerEnable is not supported on av1 encoder",
12888 ni_strncpy(p_param_err, max_err_len,
"ppsInitQp is not supported for av1 encoder",
12895 ni_strncpy(p_param_err, max_err_len,
"vbvBufferReencode is not supported for av1 multicoreJointMode", max_err_len - 1);
12901 ni_strncpy(p_param_err, max_err_len,
"getBitstreamFeatures is not supported for av1 encoder",
12910 ni_strncpy(p_param_err, max_err_len,
"crop Parameters not supported for JPEG", max_err_len - 1);
12916 ni_strncpy(p_param_err, max_err_len,
"Tier is not supported for JPEG", max_err_len - 1);
12922 ni_strncpy(p_param_err, max_err_len,
"TuneBframeVisual is not supported for JPEG", max_err_len - 1);
12929 "masterDisplay not supported for jpeg",
12935 ni_strncpy(p_param_err, max_err_len,
"confWinTop is not supported in jpeg",
12942 ni_strncpy(p_param_err, max_err_len,
"confWinBottom is not supported in jpeg",
12949 ni_strncpy(p_param_err, max_err_len,
"confWinLeft is not supported in jpeg",
12956 ni_strncpy(p_param_err, max_err_len,
"confWinRight is not supported in jpeg",
12963 ni_strncpy(p_param_err, max_err_len,
"hrdEnable is not supported on jpeg encoder",
12970 ni_strncpy(p_param_err, max_err_len,
"enableAUD is not supported on jpeg encoder",
12977 ni_strncpy(p_param_err, max_err_len,
"repeatHeaders is not supported on jpeg encoder",
12984 ni_strncpy(p_param_err, max_err_len,
"prefTRC is not supported on jpeg encoder",
12991 ni_strncpy(p_param_err, max_err_len,
"maxCLL is not supported on jpeg encoder",
12998 ni_strncpy(p_param_err, max_err_len,
"colorPri is not supported on jpeg encoder",
13005 ni_strncpy(p_param_err, max_err_len,
"colorTrc is not supported on jpeg encoder",
13012 ni_strncpy(p_param_err, max_err_len,
"colorSpc is not supported on jpeg encoder",
13019 ni_strncpy(p_param_err, max_err_len,
"sarNum is not supported on jpeg encoder",
13026 ni_strncpy(p_param_err, max_err_len,
"sarDenom is not supported on jpeg encoder",
13034 "videoFullRangeFlag is not supported on jpeg encoder",
13042 "temporalLayersEnable is not supported on jpeg encoder",
13050 "spatialLayers is not supported for jpeg encode",
13057 ni_strncpy(p_param_err, max_err_len,
"LowDelay is not supported on jpeg encoder",
13064 ni_strncpy(p_param_err, max_err_len,
"rdoLevel is not supported on jpeg encoder",
13071 ni_strncpy(p_param_err, max_err_len,
"EnableRdoQuant is not supported on jpeg encoder",
13079 "enable2PassGop is not supported on jpeg encoder",
13087 "lookAheadDepth is not supported on jpeg encoder",
13095 "gopPresetIdx is not supported on jpeg encoder",
13102 ni_strncpy(p_param_err, max_err_len,
"roiEnable is not supported on jpeg encoder",
13110 "RoiDemoMode is not supported on jpeg encoder",
13117 ni_strncpy(p_param_err, max_err_len,
"cacheRoi is not supported on jpeg encoder",
13125 "ReconfDemoMode is not supported on jpeg encoder",
13133 "intraRefreshMode is not supported on jpeg encoder",
13141 "intraRefreshArg is not supported on jpeg encoder",
13149 "intraPeriod is not supported on jpeg encoder",
13157 p_param_err, max_err_len,
13158 "IntraRefreshResetOnForceIDR is not supported on jpeg encoder",
13166 "longTermReferenceEnable is not supported on jpeg encoder",
13174 "longTermReferenceInterval is not supported on jpeg encoder",
13182 "longTermReferenceCount is not supported on jpeg encoder",
13190 "multicoreJointMode is not supported on jpeg encoder",
13197 ni_strncpy(p_param_err, max_err_len,
"enableSSIM is not supported on jpeg encoder",
13205 "vbvBufferSize is not supported on jpeg encoder",
13213 "fillerEnable is not supported on jpeg encoder",
13220 ni_strncpy(p_param_err, max_err_len,
"picSkip is not supported on jpeg encoder",
13227 ni_strncpy(p_param_err, max_err_len,
"maxFrameSize is not supported on jpeg encoder",
13235 "cuLevelRCEnable is not supported on jpeg encoder",
13242 ni_strncpy(p_param_err, max_err_len,
"hvsQPEnable is not supported on jpeg encoder",
13249 ni_strncpy(p_param_err, max_err_len,
"profile is not supported on jpeg encoder",
13256 ni_strncpy(p_param_err, max_err_len,
"intraRefreshMode or intraRefreshArg is not supported on jpeg encoder",
13261 if (p_cfg->
i8crf != -1)
13263 ni_strncpy(p_param_err, max_err_len,
"crf is not supported on jpeg encoder",
13270 ni_strncpy(p_param_err, max_err_len,
"tolCtbRcInter is not supported on jpeg encoder",
13277 ni_strncpy(p_param_err, max_err_len,
"tolCtbRcIntra is not supported on jpeg encoder",
13285 "rcQpDeltaRange is not supported on jpeg encoder",
13292 ni_strncpy(p_param_err, max_err_len,
"bitrateWindow is not supported on jpeg encoder",
13299 ni_strncpy(p_param_err, max_err_len,
"ctbRowQpStep is not supported on jpeg encoder",
13307 "enableAIEnhance is not supported on jpeg encoder",
13314 ni_strncpy(p_param_err, max_err_len,
"ppsInitQp is not supported for jpeg encoder",
13321 ni_strncpy(p_param_err, max_err_len,
"pass1Qp is not supported for jpeg encoder",
13328 ni_strncpy(p_param_err, max_err_len,
"bitrateMode is not supported for jpeg encoder",
13336 "vbvBufferReencode is not supported on jpeg encoder",
13344 "getPsnrMode or getReconstructedMode is not supported on jpeg encoder",
13352 "spatialLayers is not supported for Jpeg encode",
13359 ni_strncpy(p_param_err, max_err_len,
"disableAv1TimingInfo is not supported for Jpeg",
13366 ni_strncpy(p_param_err, max_err_len,
"av1OpLevel is not supported for Jpeg",
13374 "getBitstreamFeatures is not supported for jpeg encoder",
13383 ni_strncpy(p_param_err, max_err_len,
"Invalid forceFrameType: out of range",
13391 ni_strncpy(p_param_err, max_err_len,
"Invalid forcedHeaderEnable: out of range",
13400 ni_strncpy(p_param_err, max_err_len,
"Invalid decoding_refresh_type: out of range", max_err_len - 1);
13410 ni_strcpy(p_param_err, max_err_len,
"Invalid gop_preset_index: out of range");
13423 ni_strcpy(p_param_err, max_err_len,
"GOP size must be 1 when lowDelay is enabled");
13432 ni_strncpy(p_param_err, max_err_len,
"Invalid gopSize out of range", max_err_len - 1);
13440 ni_strncpy(p_param_err, max_err_len,
"GOP size must be <= 4 for low delay GOP", max_err_len - 1);
13449 ni_strncpy(p_param_err, max_err_len,
"Invalid LookAheadDepth: out of range. <[4-40]>", max_err_len - 1);
13455 ni_strncpy(p_param_err, max_err_len,
"2-pass encode does not support low delay GOP", max_err_len - 1);
13461 ni_strncpy(p_param_err, max_err_len,
"2-pass encode does not support tile4x4 format",
13471 ni_strncpy(p_param_err, max_err_len,
"lookahead encode with multi spatial layers is not supported on device with FW API version < 6t8", max_err_len - 1);
13487 ni_strncpy(p_param_err, max_err_len,
"Custom GOP must not include backward prediction when lowDelay is enabled", max_err_len - 1);
13489 ni_strncpy(p_param_err, max_err_len,
"Custom GOP must not include backward prediction when picSkip is enabled", max_err_len - 1);
13502 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);
13509 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);
13516 ni_strncpy(p_param_err, max_err_len,
"lookAheadDepth must be 0 when lowDelay is enabled", max_err_len - 1);
13518 ni_strncpy(p_param_err, max_err_len,
"lookAheadDepth must be 0 when picSkip is enabled", max_err_len - 1);
13527 "Cannot use multicoreJointMode when lowDelay is enabled",
13531 "Cannot use multicoreJointMode when picSkip is enabled",
13541 "Cannot enable minFramesDelay when lowDelay is enabled",
13545 "Cannot enable minFramesDelay when picSkip is enabled",
13562 ni_strncpy(p_param_err, max_err_len,
"Custom GOP size must be 1 when useLowDelayPocType is enabled", max_err_len - 1);
13568 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);
13591 "minimum frame size %d bytes in low delay mode\n", __func__,
13597 "mode. Set it to half of the maximum frame size %d bytes\n",
13604 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: maxFrameSize %u is too small. Changed to minimum value (bitrate/framerate in byte): %u\n",
13613 ni_strncpy(p_param_err, max_err_len,
"maxFrameSize can only be used when lowDelay is enabled", max_err_len - 1);
13630 ni_strncpy(p_param_err, max_err_len,
"Custom GOP can not have B frames for intra refresh", max_err_len - 1);
13641 "Must use gopPresetIdx 9 (consecutive P frame) for intra refresh",
13646 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);
13654 "intra refresh cycle (height / intraRefreshArg MB or CTU) must > 1",
13661 ni_strncpy(p_param_err, max_err_len,
"lookaheadDepth must be 0 for intra refresh", max_err_len - 1);
13670 ni_strncpy(p_param_warn, max_err_len,
"intraPeriod forced to match intra refersh cycle (intraPeriod must >= intra refersh cycle)", max_err_len - 1);
13679 ni_strncpy(p_param_warn, max_err_len,
"intraPeriod forced to match intra refersh cycle (intraPeriod must >= intra refersh cycle)", max_err_len - 1);
13690 ni_strncpy(p_param_warn, max_err_len,
"HRD conformance is not guaranteed in multicoreJointMode", max_err_len - 1);
13699 (void)snprintf(p_param_err, max_err_len,
"HRD conformance with multiple temporal layers is currently not supported");
13707 int capped_crf_filler = 0;
13715 ni_strncpy(p_param_err, max_err_len,
"fillerEnable with crf is not supported on device with FW API version < 6t7", max_err_len - 1);
13722 capped_crf_filler = 1;
13727 "fillerEnable with crf requires vbvBufferSize and vbvMinRate",
13754 (void)snprintf(p_param_err, max_err_len,
"vbvMaxRate %u cannot be smaller than bitrate %d",
13766 (void)snprintf(p_param_err, max_err_len,
"vbvMinRate %u cannot be larger than bitrate %d",
13781 (void)snprintf(p_param_err, max_err_len,
"vbvBufferSize must be greater than the average frame size. Minimum is %d msec for framerate %d fps",
13793 (void)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",
13805 (void)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",
13817 (void)snprintf(p_param_warn, max_err_len,
"vbvMaxRate %u vbvMinRate %u does not take effect when vbvBufferSize is 0, force vbvMaxRate vbvMinRate to 0",
13830 "Can't enable ltrRefInterval and longTermReferenceEnable "
13841 ni_strncpy(p_param_err, max_err_len,
"Custom GOP size can not be > 1 for long term reference", max_err_len - 1);
13851 "Must use low delay GOP (gopPresetIdx 1,3,7,9) for long term reference",
13856 ni_strncpy(p_param_warn, max_err_len,
"GOP size forced to 1 for long term reference", max_err_len - 1);
13863 ni_strncpy(p_param_err, max_err_len,
"lookaheadDepth must be 0 for long term reference", max_err_len - 1);
13867 if (p_cfg->
i8crf >= 0)
13869 ni_strncpy(p_param_err, max_err_len,
"crf must < 0 for long term reference", max_err_len - 1);
13878 p_param_err, max_err_len,
13879 "Must set longTermReferenceEnable for longTermReferenceInterval",
13889 ni_strncpy(p_param_warn, max_err_len,
"AV1 err resilient mode forced to 0 when using other codecs", max_err_len - 1);
13899 ni_strncpy(p_param_warn, max_err_len,
"Motion Constrained mode force disabled for codecs other than HEVC", max_err_len - 1);
13913 p_param_err, max_err_len,
13914 "motionConstrainedMode 3 is not supported on device with FW API version < 6t3");
13923 p_param_err, max_err_len,
13924 "rdoLevel must be 1 for Motion Constrained mode 1, 2, or 3",
13935 p_param_err, max_err_len,
13936 "multicoreJointMode must be 0 for Motion Constrained mode 2 or 3",
13947 p_param_err, max_err_len,
13948 "input resolution (or cropping window) must be 64x64 aligned "
13949 "for Motion Constrained mode 2 or 3",
13963 ni_strncpy(p_param_warn, max_err_len,
"AVCC HVCC forced to 0 for codecs other than AVC HEVC", max_err_len - 1);
13977 "getBitstreamFeatures is only supported for gopPresetIndex 1, 3, 7, 9",
13986 "getBitstreamFeatures is not supported when Crop Width > 0 || Crop Height > 0",
13997 "getBitstreamFeatures is not supported in FW API version < 6sM\n",
14008 ni_strncpy(p_param_err, max_err_len,
"Invalid cu_size_mode: out of range", max_err_len - 1);
14018 ni_strncpy(p_param_err, max_err_len,
"Invalid use_recommend_enc_params: out of range", max_err_len - 1);
14036 ni_strncpy(p_param_err, max_err_len,
"Invalid max_num_merge: out of range", max_err_len - 1);
14050 ni_strncpy(p_param_err, max_err_len,
"Invalid intra_qp: out of range", max_err_len - 1);
14057 if (p_cfg->
i8crf >= 0 && p_cfg->
i8crf <= 51)
14064 ni_strncpy(p_param_err, max_err_len,
"CRF requres LookAheadDepth <[4-40]>", max_err_len - 1);
14072 ni_strncpy(p_param_warn, max_err_len,
"enable lookahead of current frame", max_err_len - 1);
14079 ni_strncpy(p_param_err, max_err_len,
"CRF requires RcEnable 0", max_err_len - 1);
14086 ni_strncpy(p_param_warn,
sizeof(p_param_warn),
"Lookahead with cuLevelRCEnable or hvsQPEnable may degrade quality", max_err_len - 1);
14097 ni_strncpy(p_param_err, max_err_len,
"tuneBframeVisual level 1 (medium) requires lookahead or crf encode", max_err_len - 1);
14107 ni_strncpy(p_param_err, max_err_len,
"Invalid enable_mb_level_rc: out of range", max_err_len - 1);
14116 ni_strncpy(p_param_err, max_err_len,
"Invalid min_qp: out of range", max_err_len - 1);
14124 ni_strncpy(p_param_err, max_err_len,
"Invalid max_qp: out of range", max_err_len - 1);
14132 ni_strncpy(p_param_err, max_err_len,
"Invalid enable_cu_level_rate_control: out of range", max_err_len - 1);
14142 ni_strncpy(p_param_err, max_err_len,
"Invalid enable_hvs_qp: out of range", max_err_len - 1);
14152 ni_strncpy(p_param_err, max_err_len,
"Invalid max_delta_qp: out of range", max_err_len - 1);
14161 ni_strncpy(p_param_err, max_err_len,
"Invalid i32vbvBufferSize: out of range", max_err_len - 1);
14184 ni_strncpy(p_param_err, max_err_len, p_param_warn, max_err_len - 1);
14188 free(p_param_warn);
14194 char *p_param_err, uint32_t max_err_len)
14197 int32_t low_delay = 0;
14198 int32_t intra_period_gop_step_size;
14201 if (!p_param || !p_src || !p_param_err)
14210 memset(p_param_err, 0, max_err_len - 1);
14244 intra_period_gop_step_size = 1;
14254 intra_period_gop_step_size = (int32_t)presetGopSize[p_param->
gop_preset_index];
14261 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);
14266 if (((!low_delay) && (p_param->
intra_period != 0) && ((p_param->
intra_period % intra_period_gop_step_size) != 0)) ||
14269 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);
14282 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id larger than 7", max_err_len - 1);
14289 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id is zero or negative", max_err_len - 1);
14294 if (min_poc > temp_poc[i])
14296 min_poc = temp_poc[i];
14304 if (temp_poc[j] == min_poc)
14313 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: poc_offset is invalid", max_err_len - 1);
14329 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id larger than 7", max_err_len - 1);
14336 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: temporal_id is negative", max_err_len - 1);
14345 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: ref pic delta cannot be 0", max_err_len - 1);
14356 ni_log(
NI_LOG_ERROR,
"g%drefPic%d specified without g%drefPic%dUsed specified!\n", i, j, i, j);
14363 if (min_poc > temp_poc[i])
14365 min_poc = temp_poc[i];
14373 if (temp_poc[j] == min_poc)
14382 ni_strncpy(p_param_err, max_err_len,
"Invalid custom gop parameters: poc_offset is invalid", max_err_len - 1);
14400 if (((p_param->
cu_size_mode & 0x1) == 0) && ((align_8_width_flag != 0) || (align_8_height_flag != 0)))
14402 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);
14406 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)))
14408 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);
14412 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)))
14414 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);
14423 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_top: out of range", max_err_len - 1);
14429 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_top: not multiple of 2", max_err_len - 1);
14436 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_bottom: out of range", max_err_len - 1);
14442 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_bottom: not multiple of 2", max_err_len - 1);
14449 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_left: out of range", max_err_len - 1);
14455 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_left: not multiple of 2", max_err_len - 1);
14462 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_right: out of range", max_err_len - 1);
14468 ni_strncpy(p_param_err, max_err_len,
"Invalid conf_win_right: not multiple of 2", max_err_len - 1);
14482 if( (!p_cfg) || (!p_param_err) )
14492 memset(p_param_err, 0, max_err_len - 1);
14496 ni_strncpy(p_param_err, max_err_len,
"Invalid roiEnable: out of range", max_err_len - 1);
14503 ni_strncpy(p_param_err, max_err_len,
"hvsQPEnable and roiEnable: not mutually exclusive", max_err_len - 1);
14512 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);
14533 if (!p_encoder_params)
14662 ni_pthread_mutex_t *p_mutex;
14667 struct sched_param sched_param;
14673 sigfillset(&signal);
14684 sched_param.sched_priority = sched_get_priority_max(SCHED_RR);
14685 if ((sched_param.sched_priority == -1) ||
14686 sched_setscheduler((
int)syscall(SYS_gettid), SCHED_RR, &sched_param) < 0)
14692 if (setpriority(PRIO_PROCESS, 0, -20) != 0)
14700#elif defined(_WIN32)
14705 if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL) ==
14716 char name[16] = {0};
14717 (void)snprintf(name,
sizeof(name),
"%s%.2x%.4x",
"KAT", args->
hw_id, args->
session_id);
14719 prctl(PR_SET_NAME, name);
14721 pthread_setname_np(name);
14745 "%s creation timeout. session_id=0x%X requested timeout: %" PRIu64
14746 "ns, ping time delta: %" PRIu64
"ns\n ",
14776 session_ctx->
hw_id,
14795 session_ctx->
hw_id,
14800 "Persistent failures detected, %s() line-%d: session_no 0x%x sess_err_no %u "
14801 "inst_err_no %u\n",
14814 "%s was possibly blocked. session_id=0x%X requested timeout: %" PRIu64
14815 "ns, ping time delta: %" PRIu64
"ns\n ",
14836 endtime += interval;
14881 void * p_buffer = NULL;
14882 uint32_t ui32LBA = 0;
14883 uint32_t modelled_load;
14959 "ERROR %s(): p_ctx->device_handle=%" PRIx64
14960 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
14968 "Uploader open session ID:0x%x,timestamp:%" PRIu64
"\n",
14972 uint64_t keep_alive_timeout =
14975 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
14977 keep_alive_timeout);
14988 "ERROR %s(): nvme write keep_alive_timeout command "
14989 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
15013 modelled_load >>= 10;
15018 memcpy(p_buffer, &modelled_load, 4);
15049 "%s(): p_ctx->device_handle=%" PRIx64
", p_ctx->hw_id=%d, "
15050 "p_ctx->session_id=%d\n",
15055#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__OPEN_HARMONY__) && !defined(_ANDROID)
15059 retval = p2p_fill_pcie_address(p_ctx);
15083 if (!src_p_ctx || !dst_p_ctx)
15085 ni_log(
NI_LOG_ERROR,
"ERROR %s(): passed parameters are null!, return\n", __func__);
15096 if (src_p_ctx->
isP2P)
15101 dst_p_ctx->
bus = src_p_ctx->
bus;
15102 dst_p_ctx->
dev = src_p_ctx->
dev;
15103 dst_p_ctx->
fn = src_p_ctx->
fn;
15126 int query_retry = 0;
15138 "Session=0x%x: %s buffered_frame_index=%d return %d\n",
15148 query_sleep(p_ctx);
15149 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: query by ni_query_instance_buf_info INST_BUF_INFO_RW_UPLOAD\n", __func__);
15163 "scaler write exceeded max query retries. rc=%d try=%d\n",
15164 retval, query_retry);
15186 "Session=0x%x: %s got FrameIndex=%u buffered_frame_index=%d\n",
15196 "%s Warning scalar read hwdesc fail rc %d or ind !\n",
15218 uint32_t frame_size_bytes = 0;
15219 int retry_count = 0;
15238 abs_time_ns, p_frame->pts);
15249 query_sleep(p_ctx);
15261 "hwupload write exceeded max query retries. rc=%d try=%d"
15263 retval, retry_count);
15287 "size %u >= frame size %u , retry %u\n",
15326 uint32_t sent_size = 0;
15327 uint32_t frame_size_bytes = 0;
15328 int retry_count = 0;
15337 if (!p_ctx || !p_frame)
15356#ifdef MEASURE_LATENCY
15361 abs_time_ns, p_frame->
pts);
15385 query_sleep(p_ctx);
15397 "hwupload write exceeded max query retries. rc=%d try=%d"
15399 retval, retry_count);
15420 "size %u >= frame size %u , retry %u\n",
15425#ifdef XCODER_TIMESTAMP_DTS_ENABLED
15431 "ERROR %s(): ni_timestamp_register() for dts "
15444 if (separate_metadata)
15449 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR %s(): uploader separated metadata not supported on device with FW api version < 6.S\n",
15457 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR %s(): p_metadata_buffer is NULL, allocation failed?\n",
15467 if (separate_start)
15480 "%s(): %d.%u p_ctx->frame_num=%" PRIu64
", "
15481 "p_frame->video_width=%u, p_frame->video_height=%u, "
15482 "start_len [%u,%u,%u] inconsecutive_transfer %u\n",
15488 uint32_t ui32LBA_metadata =
15491 "%s: p_metadata_buffer = %p, metadata_buffer_size "
15492 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15516 if (separate_start)
15529 "%s: p_start_buffer = %p, p_frame->start_buffer_size "
15530 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15558 "%s: p_data = %p, p_frame->buffer_size "
15559 "= %u, p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15566 if (separate_start)
15591 "%s: p_data = %p, p_frame->buffer_size = %u, "
15592 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
15596 sent_size = frame_size_bytes;
15597 if (separate_start)
15625 size = frame_size_bytes;
15627#ifdef XCODER_DUMP_DATA
15628 char dump_file[256];
15629 (void)snprintf(dump_file,
sizeof(dump_file),
"%ld-%u-hwup-fme/fme-%04ld.yuv",
15642#ifdef MEASURE_LATENCY
15654 retval = (int)size;
15681 int query_retry = 0;
15685 if (!p_ctx || !hwdesc)
15703 query_sleep(p_ctx);
15722 if (query_retry >= 1000)
15764 void* p_buffer = NULL;
15766 uint32_t ui32LBA = 0;
15791 NI_INVALID_DEVICE_HANDLE, p_buffer,
15820 uint64_t frame_offset = 0;
15821 uint32_t frame_dropped = 0;
15822 uint8_t *p_data_buffer = NULL;
15828 uint32_t total_bytes_to_read = 0;
15829 uint32_t total_yuv_met_size = 0;
15830 uint32_t read_size_bytes = 0;
15832 int query_retry = 0;
15833 uint32_t ui32LBA = 0;
15834 unsigned int bytes_read_so_far = 0;
15836 int low_delay_notify = 0;
15838 uint32_t frames_dropped = 0;
15840 uint8_t get_first_metadata = 0;
15841 uint8_t sequence_change = 0;
15845 if (!p_ctx || !p_frame)
15864 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
15869 total_bytes_to_read = p_frame->
data_len[3] + metadata_hdr_size;
15872 "Total bytes to read %u total_yuv_met_size %u, low_delay %u\n",
15893 query_sleep(p_ctx);
15902 &sessionStatistic);
15926 if (query_retry >= 1000)
15929 "\n", query_retry, retval);
15931 low_delay_notify = 1;
15946 "Dec read desc only hdr metadata is available. Seq change may "
15947 "have occured.\n");
15948 total_bytes_to_read = metadata_hdr_size;
15949 sequence_change = 1;
15953 ni_log2(p_ctx,
NI_LOG_TRACE,
"Dec read desc buf_size < frame_size. Retry %d\n", query_retry);
15959 "Dec read desc query, ready_to_close %u, query eos\n",
15974 "WARNING: Dec read desc query eos reached but exceeded max "
15975 "retries. is_flushed=%u try=%d.\n",
15980 "Dec read desc query eos reached. is_flushed=%u try=%d"
15985 low_delay_notify = 1;
15992 "Dec read desc available buf size == %d, query try %d, "
16006 query_retry < 1000 / 2)
16013 low_delay_signal(p_ctx);
16021 "size %u >= required size %u !\n",
16039 low_delay_signal(p_ctx);
16042 "input (B frames)? Just cancel the low delay mode then\n");
16045 low_delay_signal(p_ctx);
16055 if(query_retry <= 2000)
16064 "Warning: decoder pkt_num %u frame_num %u "
16065 "timeout, increasing pkt_delay_cnt to %u\n",
16072 "\n", query_retry, retval);
16088 "At least %d packets should be sent before reading the "
16105 "%ux%u frame-rate %u is_flushed %u\n",
16133 total_bytes_to_read = p_frame->
data_len[3] + metadata_hdr_size;
16134 p_data_buffer = (uint8_t*)p_frame->
p_buffer;
16144 ni_log2(p_ctx,
NI_LOG_DEBUG,
"total_bytes_to_read %u max_nvme_io_size %u ylen %u cr len "
16145 "%u cb len %u hdr %d\n",
16148 p_frame->
data_len[2], metadata_hdr_size);
16156 "ERROR %s() avaliable size(%u) less than "
16160 }
else if (total_bytes_to_read == metadata_hdr_size && !p_ctx->
frame_num)
16167 void *p_metadata_buffer = NULL;
16177 p_data_buffer = (uint8_t *)p_metadata_buffer;
16178 get_first_metadata = 1;
16179 sequence_change = 0;
16190 read_size_bytes = total_bytes_to_read;
16198 p_data_buffer, read_size_bytes, ui32LBA);
16207 }
else if (get_first_metadata) {
16215 get_first_metadata = 0;
16231 low_delay_notify = 1;
16234 p_data_buffer = (uint8_t *)p_frame->
p_buffer +
16236 memcpy(p_meta, p_data_buffer, metadata_hdr_size);
16241 metadata_hdr_size);
16273 "p_data3_1:sei_size=%d device_handle=%d == hw_id=%d ses_id=%d\n",
16277 "p_data3_1: ui16FrameIdx=%d NodeAddre=0x%x planar=%d bd=%d\n",
16282 "p_data3_2:sei_size=%d device_handle=%d == hw_id=%d ses_id=%d\n",
16286 "p_data3_2: ui16FrameIdx=%d NodeAddre=0x%x planar=%d bd=%d\n",
16291 "%s:sei_size=%d device_handle=%d == hw_id=%d "
16296 "%s: session=0x%x ui16FrameIdx=%u NodeAddress=0x%x, "
16297 "planar=%d bd=%d\n",
16312 total_bytes_to_read = total_bytes_to_read + sei_size;
16314 "%s decoder read desc success, retval %d "
16315 "total_bytes_to_read include sei %u sei_size %d\n",
16316 __func__, retval, total_bytes_to_read, sei_size);
16330 bytes_read_so_far = total_bytes_to_read;
16335 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, &frame_dropped,
true);
16339 rx_size =
ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
true);
16355 "is cancelled due to has_b_frames, frame_num %u\n",
16366 int64_t tmp_dts, prev_dts = INT64_MIN, ts_diff = 0;
16375 "### %s(): Warning: ui32FramesDropped %u should be %u + %u\n",
16388 "%s(): First frame : session_id 0x%x, pic_reorder_delay: %d "
16389 "total frames input:%u buffered: %u completed: %u output: %u "
16390 "dropped: %u (%u %u) error: %u\n",
16410 "decoder dts queue %d %ld failed !\n",
16411 __func__, i, tmp_dts);
16416 "decoder dts queue %d %ld success !\n",
16417 __func__, i, tmp_dts);
16418 if (prev_dts != INT64_MIN) {
16419 ts_diff += llabs(tmp_dts - prev_dts);
16422 prev_dts = tmp_dts;
16427 ts_diff = ts_diff / nb_diff;
16431 "average diff: %ld\n", __func__, ts_diff);
16446 "decoder dts queue %d %ld failed !\n",
16447 __func__, i, tmp_dts);
16474 for (i = 0; (int)i < p_ctx->pic_reorder_delay; i++)
16481 if (p_frame->
pts >= p_frame->
dts &&
16482 p_frame->
pts - p_frame->
dts < 1000)
16498 "decoder dts queue %d %ld success !\n",
16499 __func__, i, p_frame->
dts);
16535 "%s: (found pts) dts %" PRId64
" pts "
16536 "%" PRId64
" frame_offset %" PRIu64
" j %d "
16537 "pkt_offsets_index_min %" PRIu64
" "
16538 "pkt_offsets_index %" PRIu64
" pkt_pos %" PRIu64
"\n",
16539 __func__, p_frame->
dts, p_frame->
pts, frame_offset, j,
16554 while (p_frame->
dts < p_frame->
pts &&
16555 llabs(p_frame->
pts - p_frame->
dts) > ts_diff)
16558 "dts %ld diff. %ld > ts_diff %ld\n",
16559 __func__, p_frame->
pts, p_frame->
dts,
16560 llabs(p_frame->
pts - p_frame->
dts), ts_diff);
16567 "pop decoder dts queue error.\n", __func__);
16590 "ERROR: Frame pts %" PRId64
" not found for offset "
16591 "%" PRIu64
"\n", p_frame->
pts, frame_offset);
16593 "%s: (not found use default) dts %" PRId64
" pts %" PRId64
16595 __func__, p_frame->
dts, p_frame->
pts);
16608 p_frame->
pts = guess_correct_pts(p_ctx, p_frame->
pts, p_frame->
dts);
16616 __func__, p_frame->
pts);
16629 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: ppu reconfig done. ppu_reconfig_pkt_pos = %u, frame_num = %u droped = %u\n",
16633#ifdef MEASURE_LATENCY
16644 "%s(): p_frame->start_of_stream=%u, "
16645 "p_frame->end_of_stream=%u, p_frame->video_width=%u, "
16646 "p_frame->video_height=%u\n",
16655 "Decoder pts queue size = %d dts queue size = %d\n\n",
16662#ifdef MEASURE_LATENCY
16667 ni_log2(p_ctx,
NI_LOG_INFO,
"DTS:%" PRId64
",DELTA:%" PRId64
",dLAT:%" PRIu64
";\n",
16678 if (get_first_metadata && p_data_buffer)
16680 if (sequence_change && p_ctx->
frame_num)
16694 low_delay_signal(p_ctx);
16701 if (low_delay_notify)
16703 low_delay_signal(p_ctx);
16721 uint64_t frame_offset = 0;
16722 uint8_t *p_data_buffer;
16725 uint32_t total_bytes_to_read = 0;
16726 uint32_t read_size_bytes = 0;
16727 uint32_t ui32LBA = 0;
16736 if ((!p_ctx) || (!p_frame))
16751 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
16753 if (!p_frame->
p_data[0] || !p_data_buffer)
16775 "ERROR %s(): NI_PIXEL_PLANAR_FORMAT_TILED4X4 not supported in download.\n",
16782 unsigned int bytes_read_so_far = 0;
16785 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Total bytes to download %u, start offset = %u, chunkOffset "
16786 "%u, minorOffset %u\n",
16788 output_chunk_offset, output_minor_offset);
16790 ni_log2(p_ctx,
NI_LOG_DEBUG,
"total_bytes_to_read %u max_nvme_io_size %u ylen %u cr len "
16791 "%u cb len %u hdr %d\n",
16794 p_frame->
data_len[2], metadata_hdr_size);
16813 "Config HW download read desc success, retval %d total_bytes_to_read %u\n",
16814 retval, total_bytes_to_read);
16817 read_size_bytes = total_bytes_to_read;
16819 ui32LBA += output_chunk_offset;
16827 NI_INVALID_DEVICE_HANDLE, p_data_buffer, read_size_bytes, ui32LBA);
16839 "HW download read desc success, retval %d total_bytes_to_read %u\n",
16840 retval, total_bytes_to_read);
16857 "Unconfig HW download read desc success, retval %d total_bytes_to_read %u\n",
16858 retval, total_bytes_to_read);
16861 bytes_read_so_far = total_bytes_to_read;
16866 rx_size = (int)bytes_read_so_far;
16870 ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
false);
16875 __func__, rx_size);
16877 "%s(): p_frame->start_of_stream=%u, "
16878 "p_frame->end_of_stream=%u, p_frame->video_width=%u, "
16879 "p_frame->video_height=%u\n",
16883 "%s(): p_ctx->frame_num %" PRIu64
", "
16884 "p_frame->data_len[0/1/2]=%u/%u/%u\n",
16913 uint64_t frame_offset = 0;
16914 uint8_t *p_data_buffer;
16917 uint32_t total_bytes_to_read = 0;
16918 uint32_t read_size_bytes = 0;
16919 uint32_t ui32LBA = 0;
16921 const char *error_flag =
"NetintQuadraErr";
16925 p_data_buffer = (uint8_t *)p_frame->
p_buffer;
16927 if (!p_frame->
p_data[0] || !p_data_buffer || 0 == p_frame->
data_len[0])
16929 ni_log(
NI_LOG_ERROR,
"ERROR %s(): passed parameters are null or p_frame->data_len is 0.\n",
16941 "ERROR %s(): Unsupported format %d for hw download.\n",
16948 unsigned int bytes_read_so_far = 0;
16953 "%u cb len %u hdr %d\n",
16954 total_bytes_to_read,
16956 p_frame->
data_len[2], metadata_hdr_size);
16961 memcpy(global_state->
error_flag, error_flag, strlen(error_flag)+1);
16965 read_size_bytes = total_bytes_to_read;
16967 ui32LBA += output_chunk_offset;
16973 "%u, minorOffset %u hwdesc->ui16FrameIdx %d ui32LBA 0x%x\n",
16975 output_chunk_offset, output_minor_offset, hwdesc->
ui16FrameIdx, ui32LBA);
16979 NI_INVALID_DEVICE_HANDLE, p_data_buffer, read_size_bytes, ui32LBA);
16988 if (!strcmp(global_state->
error_flag, error_flag) &&
16992 "size %u + offset %u out of range\n",
16993 __func__, hwdesc->
ui16FrameIdx, read_size_bytes, output_chunk_offset);
16998 bytes_read_so_far = total_bytes_to_read;
17003 rx_size = (int)bytes_read_so_far;
17007 ni_create_frame(p_frame, bytes_read_so_far, &frame_offset, 0,
false);
17011 "HW download read desc success, retval %d total_bytes_to_read %u\n",
17012 retval, total_bytes_to_read);
17031 uint8_t *p_data = NULL;
17033 uint32_t ui32LBA = 0;
17054 memset(p_data, 0, dataLen);
17056 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s(): ui16DstIdx %u, ui16SrcIdx %u, size %u, offset %u\n", __func__,
17062 p_data, dataLen, ui32LBA);
17119 uint32_t pool_size,
17122 void* p_uploader_config = NULL;
17126 uint32_t ui32LBA = 0;
17154 memset(p_uploader_config, 0, buffer_size);
17176 ni_log2(p_ctx,
NI_LOG_DEBUG,
"ni_config_instance_set_uploader_params():%d x %d x Format %d with %d framepool\n",
17184 p_uploader_config, buffer_size, ui32LBA);
17223 void* p_decoder_config = NULL;
17226 uint32_t ui32LBA = 0;
17247 ni_log2(p_ctx,
NI_LOG_INFO,
"%s() FW rev %s < 6rT-- load balancing might be affected\n", __func__,
17259 memset(p_decoder_config, 0, buffer_size);
17266 (void)fflush(stdout);
17272 (void)fflush(stdout);
17312 p_decoder_config, buffer_size, ui32LBA);
17345 void *p_dec_ppu_config,
int buffer_size)
17347 void* p_ppu_config = NULL;
17349 uint32_t tmp_buffer_size = buffer_size;
17351 uint32_t ui32LBA = 0;
17355 if (!p_ctx || !p_dec_ppu_config)
17375 ni_log2(p_ctx,
NI_LOG_INFO,
"%s() FW rev %s < 6rT-- load balancing might be affected\n", __func__,
17387 memset(p_ppu_config, 0, tmp_buffer_size);
17389 memcpy(p_ppu_config, p_dec_ppu_config, buffer_size);
17394 p_ppu_config, tmp_buffer_size, ui32LBA);
17439 int query_retry = 0;
17441 if (!p_ctx || !p_frame || !p_frame->
p_data[3])
17475 ni_log2(p_ctx,
NI_LOG_DEBUG,
"%s: query by ni_query_instance_buf_info INST_BUF_INFO_RW_UPLOAD\n",
17486 if (query_retry >= 1000)
17509 if (query_retry >= 1000)
17520 "Session=0x%x: %s got FrameIndex=%u\n",
17536 "%s Warning scalar read hwdesc fail rc %d or ind !\n",
17618 uint32_t *p_offset)
17630 "FrameIdx %d OOR (%d,%d]. DDR config %d \n", __func__, hwdesc->
ui16FrameIdx,
17645 void *nb_data, uint32_t nb_size)
17647 void *p_ai_config = NULL;
17648 void *p_nb_data = NULL;
17649 uint32_t buffer_size;
17653 uint32_t ui32LBA = 0;
17654 uint32_t config_size;
17655 void *p_buffer = NULL;
17658 int retry_count = 0;
17669 if (!nb_data || nb_size == 0) {
17671 __func__, nb_data, nb_size);
17694 ((
ni_ai_config_t *)p_ai_config)->ui32NetworkBinarySize = nb_size;
17707 memcpy(p_nb_data, nb_data, nb_size);
17715 p_ai_config, config_size, ui32LBA);
17721 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17722 ", hw_id, %u, xcoder_inst_id: %d\n",
17729 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17730 ", hw_id, %u, xcoder_inst_id: %d\n",
17751 memset(p_buffer, 0, dataLen);
17764 p_buffer, dataLen, ui32LBA);
17796 "AI write query failed or buf_size %u < "
17802 "Info ai write query success, available buf "
17803 "size %u >= frame size %u !\n",
17827 p_nb_data, buffer_size, ui32LBA);
17834 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17835 ", hw_id, %u, xcoder_inst_id: %d\n",
17842 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17843 ", hw_id, %u, xcoder_inst_id: %d\n",
17855 for (transferred = 0; transferred < buffer_size; transferred += this_size)
17859 (buffer_size - transferred);
17861 if (this_size & (4096 - 1))
17863 this_size = (this_size + (4096 - 1)) & ~(4096 - 1);
17867 (transferred >> 12);
17869 "%s(): write nb LBA 0x%x, this_size %u, page_offset %u\n",
17870 __func__, ui32LBA, this_size, (transferred >> 12));
17871 p_data = (uint8_t *)p_nb_data + transferred;
17874 (uint8_t *)p_nb_data + transferred, this_size, ui32LBA);
17882 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17883 ", hw_id, %u, xcoder_inst_id: %d\n",
17891 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
17892 ", hw_id, %u, xcoder_inst_id: %d\n",
17918 void *p_stream_info = NULL;
17919 void *p_ai_config = NULL;
17920 void *p_nb_data = NULL;
17922 uint32_t ui32LBA = 0;
17923 uint32_t config_size;
17971 ni_log2(p_ctx,
NI_LOG_ERROR,
"ERROR: USM filter not support for FW version lower than 6sW\n");
17980 "### %s: width %d %d height %d model type %d level %d pix_format %d\n", __func__,
17991 p_stream_info, config_size, ui32LBA);
17997 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
17998 ", hw_id, %u, xcoder_inst_id: %d\n",
18005 "ERROR: ni_ai_session_close failed: blk_io_handle: %" PRIx64
18006 ", hw_id, %u, xcoder_inst_id: %d\n",
18030 void *p_buffer = NULL;
18031 uint32_t ui32LBA = 0;
18032 int retry_count = 0;
18043 memset(p_buffer, 0, dataLen);
18048 p_buffer, dataLen, ui32LBA);
18086 uint32_t ui32LBA = 0;
18088 uint32_t frame_size_bytes;
18089 uint32_t sent_size = 0;
18090 int32_t query_retry = 0;
18096 if (!p_ctx || !p_frame)
18123 frame_size_bytes = p_frame->
data_len[0];
18134 "Info ai write query success, available buf "
18135 "size %u >= frame size %u !\n",
18162 "AI write query failed or buf_size < frame_size. Retry %d\n",
18168 "AI write query exceeded max retries: %d\n",
18185 if (!p_frame->
iovec) {
18202 ni_log2(p_ctx,
NI_LOG_DEBUG,
"Ai session write: p_data = %p, p_frame->buffer_size = %u, "
18203 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
18207 sent_size = frame_size_bytes;
18215 p_data, sent_size, ui32LBA);
18244 uint32_t rel_offset = 0;
18245 int32_t iovec_index = 0;
18246 int32_t iovec_left;
18248 if (!p_frame->
iovec) {
18254 for (i = 0; i < p_frame->
iovec_num; i++) {
18258 this_iovec->
ptr, this_iovec->
size);
18259 if ((this_iovec->
ptr == NULL) || (this_iovec->
size == 0) ||
18262 (int64_t)this_iovec->
ptr, this_iovec->
size);
18277 memset(buffer_info, 0x00, dataLen);
18280 iovec_left = (int32_t)p_frame->
iovec_num;
18283 uint32_t rel_lba = 0;
18288 for (i = 0; (int)i < iovec_batch; i++) {
18294 rel_offset += iovec->
size;
18304 buffer_info, dataLen, ui32LBA);
18312 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
18313 ", hw_id, %u, xcoder_inst_id: %d\n",
18322 for (i = 0; (int)i < iovec_batch; i++) {
18327 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
18340 for (i = 0; (int)i < iovec_batch; i++) {
18344 "p_ctx->frame_num = %" PRIu64
", LBA = 0x%x\n",
18351 iovec->
ptr, sent_size, ui32LBA);
18360 iovec_index += iovec_batch;
18361 iovec_left -= iovec_batch;
18362 }
while (iovec_left);
18393 retval = (int)frame_size_bytes;
18409 uint32_t actual_read_size = 0;
18411 uint32_t ui32LBA = 0;
18416 if (!p_ctx || !p_packet || !p_packet->
p_data)
18441 "Info ai read query success, available buf "
18442 "size %u >= frame size %u !\n",
18465 "Info ai read query rc %d, available buf size %u, "
18466 "frame_num=%" PRIu64
", pkt_num=%" PRIu64
"\n",
18487 actual_read_size = p_packet->
data_len;
18495 p_packet->
p_data, actual_read_size, ui32LBA);
18545 void *p_buffer = NULL;
18546 void *p_info = NULL;
18548 uint32_t ui32LBA = 0;
18550 int32_t query_retry = 0;
18553 uint32_t buffer_size;
18554 uint32_t this_size;
18556 uint32_t total_io_num;
18560 if (!p_ctx || !p_network)
18572 "ERROR: %s(): network parameters data is already initialized\n",
18598 memset(p_buffer, 0, dataLen);
18614 p_buffer, dataLen, ui32LBA);
18630 if (query_retry > 50000)
18633 __func__, query_retry - 1);
18678 if (!network_data->
inset)
18701 memset(p_info, 0, dataLen);
18705 p_info, dataLen, ui32LBA);
18706 if ((int32_t)retval < 0)
18728 memset(p_info, 0, dataLen);
18732 p_info, dataLen, ui32LBA);
18733 if ((int32_t)retval < 0)
18743 for (l = 0, network_data->
input_num = 0; l < 4; l++)
18753 for (l = 0, network_data->
output_num = 0; l < 4; l++)
18764 for (l = 0, buffer_size = 0; l < network_data->
input_num; l++)
18770 network_data->
inset[l].
offset = (int32_t)buffer_size;
18771 buffer_size += this_size;
18775 "%s(): network input layer %d: dims %u, %u/%u/%u/%u, f %d, q %d\n",
18781 for (l = 0, buffer_size = 0; l < network_data->
output_num; l++)
18787 network_data->
outset[l].
offset = (int32_t)buffer_size;
18788 buffer_size += this_size;
18792 "%s(): network output layer %d: dims %u, %u/%u/%u/%u, f %d, q %d\n",
18807 ni_unreference_network_data(network_data);
18818 void *p_buffer = NULL;
18819 uint32_t ui32LBA = 0;
18899 "ERROR %s(): p_ctx->device_handle=%" PRIx64
18900 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
18917 "%s(): p_ctx->device_handle=%" PRIx64
18918 ", p_ctx->hw_id=%d, p_ctx->session_id=%d\n",
18923 uint64_t keep_alive_timeout =
18926 memcpy(p_buffer, &keep_alive_timeout,
sizeof(keep_alive_timeout));
18928 keep_alive_timeout);
18940 "ERROR %s(): nvme write keep_alive_timeout command "
18941 "failed, blk_io_handle: %" PRIx64
", hw_id, %d\n",
18952 "ERROR %s(): Unable to allocate network_data memory\n");
18967 if (!p_ctx->
iocbs) {
18974 p_ctx->
iocbs[i] = (ni_iocb_t *)malloc(
sizeof(ni_iocb_t));
18975 if (!p_ctx->
iocbs[i]) {
19008 (void)eos_recieved;
19010 void *p_buffer = NULL;
19011 uint32_t ui32LBA = 0;
19047 "%s(): p_ctx->blk_io_handle=%" PRIx64
", p_ctx->hw_id=%d, "
19048 "p_ctx->session_id=%d, close_mode=1\n",
19093 if (p_ctx->
iocbs) {
19097 free((
void *)p_ctx->
iocbs);
19098 p_ctx->
iocbs = NULL;
19134 void *p_read_data = NULL;
19136 uint32_t ui32LBA = 0;
19153 int32_t query_retry = 0;
19161 "Info ai write query success, available buf "
19178 "AI write query failed or buf_size < frame_size. Retry %d\n",
19184 "AI write query exceeded max retries: %d\n",
19207 memset(p_data, 0x00, dataLen);
19213 for(
int i = 0; i < numInCfgs; i++){
19225 p_data, dataLen, ui32LBA);
19233 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
19234 ", hw_id, %u, xcoder_inst_id: %d\n",
19245 if (p_read_data != NULL)
19257 void *p_read_data = NULL;
19259 uint32_t ui32LBA = 0;
19280 "Error: %s function not supported on device with FW API version < 6rL\n",
19287 int query_retry = 0;
19298 memset(p_read_data, 0, dataLen);
19306 p_read_data, dataLen, ui32LBA);
19330 if (query_retry > 2000)
19333 __func__, query_retry - 1);
19351 if (p_read_data != NULL)
19359 int height,
int options,
int pool_size,
19364 void *p_read_data = NULL;
19366 uint32_t ui32LBA = 0;
19386 int query_retry = 0;
19397 memset(p_read_data, 0, dataLen);
19405 p_read_data, dataLen, ui32LBA);
19422 if (query_retry > 2000)
19425 __func__, query_retry - 1);
19443 int32_t query_retry = 0;
19451 "Info ai write query success, available buf "
19468 "AI write query failed or buf_size < frame_size. Retry %d\n",
19474 "AI write query exceeded max retries: %d\n",
19497 memset(p_data, 0x00, dataLen);
19512 p_data, dataLen, ui32LBA);
19520 "ERROR: ni_nvme_send_admin_cmd failed: blk_io_handle: %" PRIx64
19521 ", hw_id, %u, xcoder_inst_id: %d\n",
19533 if (p_read_data != NULL)
19556 int retry_count = 0;
19583 if (retry_count >= 500)
19609 if (retry_count >= 500)
19646 void *p_buffer = NULL;
19649 ni_event_handle_t event_handle = NI_INVALID_EVENT_HANDLE;
19655 if (NI_INVALID_DEVICE_HANDLE == device_handle)
19730 uint8_t ddr_priority_mode)
19732 void *p_buffer = NULL;
19741 ddr_priority_mode);
19743 if (NI_INVALID_DEVICE_HANDLE == device_handle)
19762 p_cfg->
ddr_mode = ddr_priority_mode;
19767 ddr_priority_mode);
19795 void *metadata_buffer = NULL;
19798 if ((!p_frame) || (extra_len <= 0))
19801 "ERROR: %s passed parameters are null or not supported, "
19802 "p_frame %p, extra_len %d",
19803 __func__, p_frame, extra_len);
19807 int buffer_size = extra_len;
19819 "%s: free current p_frame metadata buffer, "
19820 "p_frame->buffer_size=%u\n",
19833 "ERROR %d: %s() Cannot allocate metadata buffer.\n",
19840 memset(metadata_buffer, 0, buffer_size);
19851 "%s: success: p_frame->p_metadata_buffer %p "
19852 "p_frame->metadata_buffer_size=%u\n",
19881 void *start_buffer = NULL;
19887 "ERROR: %s passed parameters are null or not supported, "
19889 __func__, p_frame);
19900 "ERROR %d: %s() Cannot allocate start buffer.\n",
19918 "%s: success: p_frame->p_start_buffer %p "
19919 "p_frame->start_buffer_size=%u\n",
19936 void *p_buffer = NULL;
19938 uint32_t ui32LBA = 0;
19941 if (!p_ctx || !p_metrics)
19944 "ERROR: %s() passed parameters are null!, return\n", __func__);
19968 p_buffer, dataLen, ui32LBA);
20011 uint32_t *u32_buf = (uint32_t *)buf;
20013 u32_buf[1] = value;
20026 CoreName = (
char *)
"all";
20029 CoreName = (
char *)
"np";
20032 CoreName = (
char *)
"ep";
20035 CoreName = (
char *)
"dp";
20038 CoreName = (
char *)
"tp";
20041 CoreName = (
char *)
"fp";
20044 CoreName = (
char *)
"fl";
20047 CoreName = (
char *)
"Not Found";
20085static int ni_write_fl_log_decoded_file(
void *p_data, uint32_t buf_len, FILE *p_file)
20089 uint32_t log_lines;
20090 uint64_t payload_u;
20091 size_t payload_len;
20092 size_t max_payload;
20097 if (buf_len < 4 || !p_data || !p_file)
20100 memcpy(&flsign, p_data,
sizeof(flsign));
20105 memcpy(&fllen, (
const uint8_t *)p_data + 4,
sizeof(fllen));
20106 log_lines = fllen & 0xFFFFFFU;
20107 payload_u = (uint64_t)log_lines * 128ULL;
20108 max_payload = (size_t)buf_len - 4;
20109 payload_len = (payload_u > max_payload) ? max_payload : (size_t)payload_u;
20111 in = (
const uint8_t *)p_data + 8;
20112 out = (uint8_t *)malloc(payload_len ? payload_len : 1);
20116 for (i = 0, j = 0; i < payload_len; i++)
20120 if (j > 0 && fwrite(out, 1, j, p_file) != j) {
20133 char *core_name = NULL;
20134 FILE *p_file = NULL;
20137 if (!p_ctx || !p_data)
20140 __func__, __LINE__, p_ctx, p_data);
20153 *(uint8_t *)p_data = 0x55;
20159 __func__, __LINE__, core_id);
20170 __func__, __LINE__, rc, core_name);
20172 else if (gen_log_file)
20175 char filename[80] =
"raw_";
20176 ni_strcat(filename,
sizeof(filename), core_name);
20177 ni_strcat(filename,
sizeof(filename),
"_");
20179 bool pcie_id_name =
false;
20180 char devFilePath[1024] = {0};
20181 char devFDPath[1024] = {0};
20182 char pcie[64] = {0};
20183 char domain[5] = {0}, slot[3] = {0}, dev[3] = {0}, func[2] = {0};
20185 (void)snprintf(devFDPath,
sizeof(devFDPath),
"/proc/self/fd/%d", p_ctx->
blk_io_handle);
20186 ssize_t len = readlink(devFDPath, devFilePath,
sizeof(devFilePath)-1);
20188 devFilePath[len] =
'\0';
20190 if (strstr(devFilePath,
"/dev/nvme") != NULL)
20193 if (strlen(pcie) > 0 && strlen(slot) > 0 && strlen(domain) > 0)
20195 char bdf[16] = {0};
20196 (void)snprintf(bdf,
sizeof(bdf),
"%s_%s_%s_%s",
20197 domain, slot, dev, func);
20198 ni_strcat(filename,
sizeof(filename), bdf);
20199 pcie_id_name =
true;
20204 ni_log2(p_ctx,
NI_LOG_INFO,
"%s:():%d: For dev %d can't look up PCI slot info, defaulting to hw_id\n",
20207 (void)snprintf(num, 4,
"%d", p_ctx->
hw_id);
20208 ni_strcat(filename,
sizeof(filename), num);
20213 if (sscanf(devFilePath,
"/dev/nvme%dn", &ctrl_idx) == 1)
20215 char sysfs_serial[64] = {0};
20216 (void)snprintf(sysfs_serial,
sizeof(sysfs_serial),
20217 "/sys/class/nvme/nvme%d/serial", ctrl_idx);
20218 FILE *sn_f = fopen(sysfs_serial,
"r");
20221 char raw_sn[21] = {0};
20222 if (fgets(raw_sn,
sizeof(raw_sn), sn_f))
20224 raw_sn[strcspn(raw_sn,
" \t\r\n")] =
'\0';
20225 (void)snprintf(sn,
sizeof(sn),
"%s", raw_sn);
20227 (void)fclose(sn_f);
20232 ni_strcat(filename,
sizeof(filename),
"_");
20233 ni_strcat(filename,
sizeof(filename), sn);
20237 ni_log2(p_ctx,
NI_LOG_INFO,
"%s:():%d: For dev %d could not read NVMe serial from sysfs, omitting SN from log filename\n",
20241 time_t now = time(NULL);
20243 struct tm *tm_info = localtime_r(&now, &tm_buf);
20245 (void)strftime(ts,
sizeof(ts),
"%Y%m%d-%H%M%S", tm_info);
20248 ni_strcat(filename,
sizeof(filename),
"_");
20249 ni_strcat(filename,
sizeof(filename), ts);
20251 ni_strcat(filename,
sizeof(filename),
".bin");
20256 (void)snprintf(num, 4,
"%02x", p_ctx->
hw_id);
20257 ni_strcat(filename,
sizeof(filename), num);
20259 time_t now = time(NULL);
20262 struct tm *tm_info = (localtime_s(&tm_buf, &now) == 0) ? &tm_buf : NULL;
20264 struct tm *tm_info = localtime_r(&now, &tm_buf);
20267 (void)strftime(ts,
sizeof(ts),
"%Y%m%d-%H%M%S", tm_info);
20270 ni_strcat(filename,
sizeof(filename),
"_");
20271 ni_strcat(filename,
sizeof(filename), ts);
20273 ni_strcat(filename,
sizeof(filename),
".bin");
20277 ni_fopen(&p_file, filename,
"wb");
20283 int wrc = ni_write_fl_log_decoded_file(p_data, data_len, p_file);
20287 __func__, __LINE__);
20290 else if (wrc == -3)
20293 __func__, __LINE__);
20296 else if (wrc == -1)
20299 __func__, __LINE__);
20302 else if (wrc == -4)
20305 __func__, __LINE__);
20310 else if (fwrite((uint8_t *)p_data ,
20311 data_len, 1, p_file) != 1)
20314 __func__, __LINE__, data_len);
20318 if (fflush(p_file))
20324 (void)fclose(p_file);
20329 __func__, __LINE__, filename);
20342 if (!p_ctx || !p_data)
20345 __func__, __LINE__, p_ctx, p_data);
20358 for (i =
NVME_CORE; i<= max_cores; i++)
20381 bool gen_artifacts_file)
20385 uint32_t artifacts_size;
20387 void *p_buf = NULL;
20388 FILE *p_file = NULL;
20391 static const uint8_t GZIP_MAGIC[2] = {0x1f, 0x8b};
20420 if (artifacts_size == 0)
20423 "%s: artifacts size is 0 — firmware has not loaded artifacts\n",
20431 if (artifacts_size > max_data_size)
20434 "%s: artifacts size %u exceeds maximum %u — corrupt or stale DDR data\n",
20435 __func__, artifacts_size, max_data_size);
20443 ni_log2(p_ctx,
NI_LOG_ERROR,
"%s: invalid gzip magic — stale data or firmware too old\n", __func__);
20450 if (gen_artifacts_file)
20452 char filename[64] =
"artifacts_slot_";
20454 bool pcie_id_name =
false;
20455 char devFilePath[1024] = {0};
20456 char devFDPath[1024] = {0};
20457 char pcie[64] = {0};
20458 char domain[5] = {0}, slot[3] = {0}, dev[3] = {0}, func[2] = {0};
20459 (void)snprintf(devFDPath,
sizeof(devFDPath),
"/proc/self/fd/%d", p_ctx->
blk_io_handle);
20460 ssize_t len = readlink(devFDPath, devFilePath,
sizeof(devFilePath) - 1);
20462 devFilePath[len] =
'\0';
20463 if (strstr(devFilePath,
"/dev/nvme") != NULL)
20466 if (strlen(pcie) > 0 && strlen(slot) > 0 && strlen(domain) > 0)
20468 ni_strcat(filename,
sizeof(filename), slot);
20469 ni_strcat(filename,
sizeof(filename),
"_");
20470 ni_strcat(filename,
sizeof(filename), domain);
20471 pcie_id_name =
true;
20477 (void)snprintf(num,
sizeof(num),
"%d", p_ctx->
hw_id);
20478 ni_strcat(filename,
sizeof(filename), num);
20479 ni_strcat(filename,
sizeof(filename),
"_0000");
20483 (void)snprintf(num,
sizeof(num),
"%02x", p_ctx->
hw_id);
20484 ni_strcat(filename,
sizeof(filename), num);
20485 ni_strcat(filename,
sizeof(filename),
"_0000");
20487 ni_strcat(filename,
sizeof(filename),
".tar.gz");
20490 ni_fopen(&p_file, filename,
"wb");
20494 if (fwrite(p_data, artifacts_size, 1, p_file) != 1)
20497 __func__, ferror(p_file));
20500 if (fflush(p_file))
20503 __func__, ferror(p_file));
20506 (void)fclose(p_file);
20540 void *p_buffer = NULL;
20542 uint32_t ui32LBA = 0;
20567 p_data = (uint8_t *) p_buffer;
20571 memcpy(p_data + 8, &dmaAddrs->
ui32DMALen[0], 4);
20574 memcpy(p_data + 18, &ui16Direction, 2);
20579 uint32_t ui32NeedsSplit = 0;
20580 uint32_t ui32EntryIdx = 0;
20582 for (ui32EntryIdx = 0; ui32EntryIdx < dmaAddrs->
ui32NumEntries; ui32EntryIdx++)
20586 ui32NeedsSplit = 1;
20591 if (ui32NeedsSplit)
20594 uint32_t ui32SglIdx = 0;
20597 memset(&sSplitSgl, 0,
sizeof(sSplitSgl));
20598 for (ui32EntryIdx = 0;
20602 uint64_t ui64BaseAddr = dmaAddrs->
ui64DMAAddr[ui32EntryIdx];
20603 uint32_t ui32RemainingData = dmaAddrs->
ui32DMALen[ui32EntryIdx];
20604 uint32_t ui32Offset = 0;
20610 sSplitSgl.
ui64DMAAddr[ui32SglIdx] = ui64BaseAddr + ui32Offset;
20612 ui32Offset += ui32Seg;
20613 ui32RemainingData -= ui32Seg;
20617 if (ui32RemainingData > 0)
20620 "%s: SGL overflow: table full (%u slots) at entry"
20621 " %u/%u, %u bytes unprocessed\n",
20623 ui32EntryIdx, ui32OrigEntries, ui32RemainingData);
20629 if (ui32EntryIdx < ui32OrigEntries)
20632 "%s: SGL overflow: table full (%u slots), "
20633 "%u/%u entries not processed\n",
20635 ui32OrigEntries - ui32EntryIdx, ui32OrigEntries);
20643 "%s: SGL split: %u original entr%s -> %u chunks "
20644 "(max 0x%X bytes/chunk)\n", __func__,
20645 ui32OrigEntries, ui32OrigEntries == 1 ?
"y" :
"ies",
20651 memcpy(&p_data[24] + ((
size_t)i * 8), &sSplitSgl.
ui64DMAAddr[i], 8);
20655 memcpy(&p_data[24] + ((
size_t)sSplitSgl.
ui32NumEntries * 8) + ((
size_t)i * 4),
20664 memcpy(&p_data[24] + ((
size_t)i * 8), &dmaAddrs->
ui64DMAAddr[i], 8);
20668 memcpy(&p_data[24] + ((
size_t)dmaAddrs->
ui32NumEntries * 8) + ((
size_t)i * 4),
20688 if (p_buffer != NULL)
20698 void *p_buffer = NULL;
20700 uint32_t ui32LBA = 0;
20704 uint32_t ui32Dummy = 0;
20726 p_data = (uint8_t *) p_buffer;
20730 memcpy(p_data + 8, &ui32Dummy, 4);
20733 memcpy(p_data + 18, &ui16Direction, 2);
20738 memcpy(&p_data[24] + ((
size_t)i*8), &dmaAddrs->
ui64DMAAddr[i], 8);
20760 if (p_buffer != NULL)
20781#if defined(__linux__) && defined(XCODER_ENABLE_CPU_AFFINITY)
20783 if (numa_available() == -1) {
20801#if defined(LIBNUMA_API_VERSION) && (LIBNUMA_API_VERSION == 2)
20802 struct bitmask *node_mask = numa_allocate_nodemask();
20809 numa_bitmask_setbit(node_mask, numa_node);
20810 numa_bind(node_mask);
20811 numa_bitmask_free(node_mask);
20813 nodemask_t node_mask;
20814 nodemask_zero(&node_mask);
20815 nodemask_set(&node_mask, numa_node);
20816 numa_bind(&node_mask);
20824#ifdef PRINT_FW_LOGS
20830static inline bool is_log_start_marker(
const uint8_t* data) {
20839static inline bool is_log_end_marker(
const uint8_t* data) {
20848static inline uint64_t extract_timestamp(uint8_t* timestamp_bytes) {
20849 uint64_t timestamp = 0;
20851 for (
int i = 0; i < 8; i++) {
20852 timestamp |= ((uint64_t)timestamp_bytes[i] << (i * 8));
20864static void ni_find_latest_complete_log(
const uint8_t* data,
size_t data_size,
20867 uint64_t timestamp = 0, max_timestamp = 0;
20869 uint64_t data_start;
20871 const uint8_t* end_ptr;
20877 latest_entry->
end_ptr = NULL;
20881 if (!is_log_start_marker(data + index)) {
20892 timestamp = extract_timestamp(header->
timestamp);
20895 if (timestamp == 0) {
20906 if (is_log_end_marker(data + j)) {
20913 if (found_end && end_ptr != NULL) {
20915 if (timestamp > max_timestamp) {
20916 max_timestamp = timestamp;
20917 latest_entry->
start_ptr = data + index;
20918 latest_entry->
end_ptr = end_ptr;
20928 index = end_ptr - data;
20947static void ni_extract_64k_from_end_marker(
const uint8_t* data,
size_t data_size,
20948 const uint8_t* end_marker_ptr,
20949 uint8_t* output,
bool wrap_around) {
20950 uint64_t end_marker_offset = end_marker_ptr - data;
20951 uint64_t extract_start;
20959 }
else if (wrap_around) {
20962 uint64_t second_part_size = end_marker_offset;
20964 memcpy(output, data + data_size - first_part_size, first_part_size);
20966 if (second_part_size > 0) {
20967 memcpy(output + first_part_size, data, second_part_size);
20983ni_retcode_t ni_extract_64k_from_latest_log_end(
const uint8_t* data, uint8_t* output) {
20986 if (data == NULL || output == NULL) {
20995 " it is not expected, So will print the first 64K fw logs\n");
21001 ni_extract_64k_from_end_marker(
21015 const uint8_t *p_data, uint32_t core_id) {
21017 uint8_t *output = NULL;
21019 if (!p_ctx || !p_data) {
21021 __func__, __LINE__, p_ctx);
21030 if (output == NULL) {
21036 ret = ni_extract_64k_from_latest_log_end(p_data, output);
21040 uint8_t print_buffer[260];
21043 for (
int i = 0; i < chunks; i++) {
21044 uint8_t* ptr = print_buffer;
21051 memcpy(ptr, output + (i * 256), 256);
21059 for (
int j = 0; j <
sizeof(print_buffer); j++) {
21085 bool gen_log_file =
false;
21086 void *p_log_buffer = NULL;
21092 __func__, __LINE__, p_ctx);
21115 for (i =
NVME_CORE; i<= max_cores; i++)
21125 retval = ni_device_print_firmware_logs(p_ctx, p_log_buffer, i);
#define LOG_ARTIFACTS_MAX_SIZE
#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 CPU_LOG_ARTIFACTS_HEADER_SIZE
#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_SCALER_Q14_ONE
#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
#define NI_SCALER_KERNEL_SLOTS
@ 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_HDR10P_SEI_HDR_AV1_LEN
#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_CC_SEI_HDR_AV1_LEN
#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.
#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
#define NI_SCALER_MAX_KERNEL_TAPS
@ NI_CODEC_HW_PAYLOAD_OFFSET
#define NI_SCALER_KERNEL_POSITIONS
#define NI_HDR10P_SEI_BYTE5
#define NI_SCALER_ALGORITHM_USER_KERNEL
#define NI_PARAM_MAX_WIDTH
struct _ni_network_layer_info ni_network_layer_info_t
#define MOTION_CONSTRAINED_QUALITY_MODE_ADVANCED
struct _ni_sei_header ni_sei_header_t
#define NI_MAX_DEFAULT_RETRY
#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_dump_log_artifacts(ni_session_context_t *p_ctx, bool gen_artifacts_file)
Read log artifacts (tar.gz) from the device via NVMe and write them to "artifacts_slot_s_dddd....
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
struct _ni_scaler_config ni_scaler_config_t
#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 ARTIFACTS_OFFSET_IN_4K
#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
ni_retcode_t ni_strtoi(const char *str, int32_t *out_val)
Safely convert a decimal string to a 32-bit integer with full validation. Trailing whitespace is tole...
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
uint8_t ui8ExtendPoolSize
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
uint16_t kernel_array[2][NI_SCALER_KERNEL_POSITIONS *NI_SCALER_KERNEL_SLOTS]
uint16_t kernel_array[2][17 *9]
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
uint8_t itu_t_t35_hdr10p_sei_hdr_av1[NI_HDR10P_SEI_HDR_AV1_LEN]
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
uint8_t itu_t_t35_cc_sei_hdr_av1[NI_CC_SEI_HDR_AV1_LEN]
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