85static const int32_t LT_GOP_PRESET_I_1[6] = {
SLICE_TYPE_I, 1, 0, 0, 0, 0};
86static const int32_t LT_GOP_PRESET_P_1[6] = {
SLICE_TYPE_MP, 1, 1, 0, 0, -1};
87static const int32_t LT_GOP_PRESET_B_1[6] = {
SLICE_TYPE_B, 1, 1, 0, 0, -1};
89static const int32_t LT_GOP_PRESET_BP_2[12] = {
90 SLICE_TYPE_MP, 2, 1, 0, 0, -2,
SLICE_TYPE_B, 1, 3, 0, 0, 2,
93static const int32_t LT_GOP_PRESET_BBBP_4[24] = {
94 SLICE_TYPE_MP, 4, 1, 0, 0, -4,
SLICE_TYPE_B, 2, 3, 0, 0, 4,
95 SLICE_TYPE_B, 1, 5, 0, 0, 2,
SLICE_TYPE_B, 3, 5, 0, 2, 4,
98static const int32_t LT_GOP_PRESET_LP_4[24] = {
99 SLICE_TYPE_MP, 1, 5, 0, 0, -4,
SLICE_TYPE_MP, 2, 3, 0, 1, 0,
100 SLICE_TYPE_MP, 3, 5, 0, 2, 0,
SLICE_TYPE_MP, 4, 1, 0, 3, 0,
102static const int32_t LT_GOP_PRESET_LD_4[24] = {
103 SLICE_TYPE_B, 1, 5, 0, 0, -4,
SLICE_TYPE_B, 2, 3, 0, 1, 0,
104 SLICE_TYPE_B, 3, 5, 0, 2, 0,
SLICE_TYPE_B, 4, 1, 0, 3, 0,
108static const int32_t LT_GOP_PRESET_RA_8[48] = {
109 SLICE_TYPE_B, 8, 1, 0, 0, -8,
SLICE_TYPE_B, 4, 3, 0, 0, 8,
110 SLICE_TYPE_B, 2, 5, 0, 0, 4,
SLICE_TYPE_B, 1, 8, 0, 0, 2,
111 SLICE_TYPE_B, 3, 8, 0, 2, 4,
SLICE_TYPE_B, 6, 5, 0, 4, 8,
112 SLICE_TYPE_B, 5, 8, 0, 4, 6,
SLICE_TYPE_B, 7, 8, 0, 6, 8,
115static const int32_t LT_GOP_PRESET_SP_1[6] = {
SLICE_TYPE_P, 1, 1, 0, 0, -1};
117static const int32_t LT_GOP_PRESET_BSP_2[12] = {
118 SLICE_TYPE_P, 2, 1, 0, 0, -2,
SLICE_TYPE_B, 1, 3, 0, 0, 2,
120static const int32_t LT_GOP_PRESET_BBBSP_4[24] = {
121 SLICE_TYPE_P, 4, 1, 0, 0, -4,
SLICE_TYPE_B, 2, 3, 0, 0, 4,
122 SLICE_TYPE_B, 1, 5, 0, 0, 2,
SLICE_TYPE_B, 3, 5, 0, 2, 4,
124static const int32_t LT_GOP_PRESET_LSP_4[24] = {
125 SLICE_TYPE_P, 1, 5, 0, 0, -4,
SLICE_TYPE_P, 2, 3, 0, 1, 0,
126 SLICE_TYPE_P, 3, 5, 0, 2, 0,
SLICE_TYPE_P, 4, 1, 0, 3, 0,
129static const int32_t LT_GOP_PRESET_BBP_3[18] = {
130 SLICE_TYPE_MP, 3, 1, 0, 0, -3,
SLICE_TYPE_B, 1, 3, 0, 0, 3,
134static const int32_t LT_GOP_PRESET_BBSP_3[18] = {
135 SLICE_TYPE_P, 3, 1, 0, 0, 0,
SLICE_TYPE_B, 1, 3, 0, 0, 3,
139static const int32_t LT_GOP_PRESET_BBBBBBBP_8[48] = {
140 SLICE_TYPE_MP, 8, 1, 0, 0, -8,
SLICE_TYPE_B, 4, 3, 0, 0, 8,
141 SLICE_TYPE_B, 2, 5, 0, 0, 4,
SLICE_TYPE_B, 1, 8, 0, 0, 2,
142 SLICE_TYPE_B, 3, 8, 0, 2, 4,
SLICE_TYPE_B, 6, 5, 0, 4, 8,
143 SLICE_TYPE_B, 5, 8, 0, 4, 6,
SLICE_TYPE_B, 7, 8, 0, 6, 8,
146static const int32_t LT_GOP_PRESET_BBBBBBBSP_8[48] = {
147 SLICE_TYPE_P, 8, 1, 0, 0, 0,
SLICE_TYPE_B, 4, 3, 0, 0, 8,
148 SLICE_TYPE_B, 2, 5, 0, 0, 4,
SLICE_TYPE_B, 1, 8, 0, 0, 2,
149 SLICE_TYPE_B, 3, 8, 0, 2, 4,
SLICE_TYPE_B, 6, 5, 0, 4, 8,
150 SLICE_TYPE_B, 5, 8, 0, 4, 6,
SLICE_TYPE_B, 7, 8, 0, 6, 8,
159 LT_GOP_PRESET_BBBP_4,
166 LT_GOP_PRESET_BBBSP_4,
170 LT_GOP_PRESET_BBSP_3,
171 LT_GOP_PRESET_BBBBBBBP_8,
172 LT_GOP_PRESET_BBBBBBBSP_8,
178#define SAMPLE_SPS_MAX_SUB_LAYERS_MINUS1 0
179#define MAX_VPS_MAX_SUB_LAYERS 16
180#define MAX_CPB_COUNT 16
181#define MAX_DURATION 0.5
245 uint8_t *sei_buf = NULL;
247 int start_offset = 0;
256 sei_buf = (uint8_t *)frame->
p_data[start_offset] +
263 "unregisted SEI!\n");
293 "mastering display color SEI!\n");
301 ((uint8_t *)frame->
p_data[start_offset] +
309 static const int src_idx_av1[3] = {0, 1, 2};
310 static const int src_idx_hevc[3] = {2, 0, 1};
311 const int *src_idx = is_av1 ? src_idx_av1 : src_idx_hevc;
320 for (
int dst = 0; dst < 3; dst++)
322 int s = src_idx[dst];
354 "content light level SEI !\n");
361 *)((uint8_t *)frame->
p_data[start_offset] +
381 int w, i, j, i_limit, j_limit;
386 sei_buf = (uint8_t *)frame->
p_data[start_offset] +
445 "hdr10+ targeted_system_display_maximum_luminance "
449 "hdr10+ targeted_system_display_actual_peak_lumi"
464 "hdr10+ num_rows_targeted_system_display_actual"
466 "num_cols_targeted_system_display_actual_"
467 "peak_luminance %d x %d\n",
470 i_limit = i_limit > 25 ? 25 : i_limit;
471 j_limit = j_limit > 25 ? 25 : j_limit;
472 for (i = 0; i < i_limit; i++)
473 for (j = 0; j < j_limit; j++)
482 "hdr10+ targeted_system_display_actual_peak"
483 "_luminance[%d][%d] %d\n",
493 for (i = 0; i < 3; i++)
511 "hdr10+ num_distribution_maxrgb_percentiles[%d] %d\n",
514 i_limit = i_limit > 15 ? 15 : i_limit;
515 for (i = 0; i < i_limit; i++)
524 "hdr10+ distribution_maxrgb_percentage[%d][%d] "
529 "hdr10+ distribution_maxrgb_percentile[%d][%d] "
547 "hdr10+ mastering_display_actual_peak_luminance_flag %u\n",
558 "hdr10+ num_rows_mastering_display_actual_peak_"
560 "num_cols_mastering_display_actual_peak_luminance "
564 i_limit = i_limit > 25 ? 25 : i_limit;
565 j_limit = j_limit > 25 ? 25 : j_limit;
566 for (i = 0; i < i_limit; i++)
567 for (j = 0; j < j_limit; j++)
574 "hdr10+ mastering_display_actual_peak_lumi"
575 "nance[%d][%d] %d\n",
578 ->mastering_display_actual_peak_luminance[i]
607 "hdr10+ num_bezier_curve_anchors[%d] %u\n", w,
616 "hdr10+ bezier_curve_anchors[%d][%d] %d\n", w,
624 "hdr10+ color_saturation_mapping_flag[%d] %u\n", w,
632 "hdr10+ color_saturation_weight[%d] %d\n", w,
666 "ni_dec_retrieve_aux_data VUI "
667 "aspect_ratio_idc %u "
668 "sar_width %u sar_height %u "
669 "video_full_range_flag %d "
670 "color-pri %u color-trc %u color-space %u "
671 "vui_num_units_in_tick %u "
672 "vui_time_scale %u\n",
683 sei_buf = (uint8_t *)frame->
p_data[start_offset] +
688 "writting VUI color-trc value %u\n",
700 int height,
int intra_qp)
707 uint32_t self_size = roi->self_size;
710 uint8_t isAbsQp_flag = 0;
719 width = (width / 8) * 8;
720 height = (height / 8) * 8;
725 uint32_t roiMapBlockUnitSize =
727 uint32_t mbWidth = ((width + max_cu_size - 1) & (~(max_cu_size - 1))) /
729 uint32_t mbHeight = ((height + max_cu_size - 1) & (~(max_cu_size - 1))) /
731 uint32_t numMbs = mbWidth * mbHeight;
732 uint32_t subMbWidth = roiMapBlockUnitSize / 8;
733 uint32_t subMbHeight = subMbWidth;
734 uint32_t subNumMbs = subMbWidth * subMbHeight;
738 uint32_t block_size = ((width + max_cu_size - 1) & (~(max_cu_size - 1))) *
739 ((height + max_cu_size - 1) & (~(max_cu_size - 1))) / (8 * 8);
742 uint32_t customMapSize = ((block_size + 63) & (~63));
743 if (!p_enc_ctx->roi_map)
747 if (!p_enc_ctx->roi_map)
754 memset(p_enc_ctx->roi_map, 0, customMapSize);
758 for (r = nb_roi - 1; r >= 0; r--)
761 if (!roi->qoffset.den)
772 set_qp = (int32_t)((
float)roi->qoffset.num * 1.0f /
780 set_qp = (int32_t)((
float)roi->qoffset.num * 1.0f /
789 "set_roi_map: left %d right %d top %d bottom %d num %d den"
791 roi->left, roi->right, roi->top, roi->bottom, roi->qoffset.num,
792 roi->qoffset.den, set_qp);
795 for (j = 0; j < mbHeight; j++)
797 for (i = 0; i < mbWidth; i++)
799 k = j * (int)mbWidth + i;
801 for (m = 0; m < subNumMbs; m++)
803 if (((
int)(i % mbWidth) >=
804 (
int)((roi->left + roiMapBlockUnitSize - 1) /
805 roiMapBlockUnitSize) -
807 ((int)(i % mbWidth) <=
808 (int)((roi->right + roiMapBlockUnitSize - 1) /
809 roiMapBlockUnitSize) -
811 ((int)(j % mbHeight) >=
812 (int)((roi->top + roiMapBlockUnitSize - 1) /
813 roiMapBlockUnitSize) -
815 ((int)(j % mbHeight) <=
816 (int)((roi->bottom + roiMapBlockUnitSize - 1) /
817 roiMapBlockUnitSize) -
820 p_enc_ctx->roi_map[k * subNumMbs + m].field.ipcm_flag =
822 p_enc_ctx->roi_map[k * subNumMbs + m]
823 .field.roiAbsQp_flag = isAbsQp_flag;
824 p_enc_ctx->roi_map[k * subNumMbs + m].field.qp_info =
830 sumQp += p_enc_ctx->roi_map[(size_t)k * subNumMbs].field.qp_info;
835 p_enc_ctx->roi_len = customMapSize;
836 p_enc_ctx->roi_avg_qp = (numMbs != 0 ? (sumQp + (numMbs >> 1)) / numMbs : 0) +
NI_DEFAULT_INTRA_QP;
869 int should_send_sei_with_frame, uint8_t *mdcv_data,
870 uint8_t *cll_data, uint8_t *cc_data,
871 uint8_t *udu_data, uint8_t *hdrp_data)
903 intraprd = *((int32_t *)aux_data->
data);
904 if (intraprd < 0 || intraprd > 1024)
925 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): NOT allowed to reconfig intraPeriod %d in intra_mb_refresh_mode %d or gop_preset_index %d\n",
934 should_send_sei_with_frame = 1;
940 intraprd - (p_enc_ctx->
frame_num % intraprd);
950 ni_log(
NI_LOG_INFO,
"%s(): set intraPeriod %d on frame %u, update intra offset %u\n", __func__,
970 (is_h264 ? 8 : 9) + 24;
992 uint32_t max_lum = htonl(
993 (uint32_t)lrint(luma_max_den * ni_q2d(p_src->
max_luminance)));
994 uint32_t min_lum = htonl(
995 (uint32_t)lrint(luma_min_den * ni_q2d(p_src->
min_luminance)));
997 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"### %s: luma_max_den %d luma_min_den %d\n", __func__, luma_max_den, luma_min_den);
1033 dst[0] = dst[1] = dst[2] = 0; dst[3] = 1;
1041 dst[0] = dst[1] = dst[2] = 0; dst[3] = 1;
1061 static const int src_idx_av1[3] = {0, 1, 2};
1062 static const int src_idx_hevc[3] = {1, 2, 0};
1063 const int *src_idx = is_av1 ? src_idx_av1 : src_idx_hevc;
1065 for (
int d = 0; d < 3; d++)
1075 htons((uint16_t)lrint(chroma_den * ni_q2d(p_src->
white_point[0])));
1077 htons((uint16_t)lrint(chroma_den * ni_q2d(p_src->
white_point[1])));
1079 dst += 6 * 2 + 2 * 2;
1114 uint16_t max_content_light_level =
1116 uint16_t max_pic_average_light_level =
1126 &max_pic_average_light_level,
sizeof(uint16_t));
1141 should_send_sei_with_frame)
1155 dst[0] = dst[1] = dst[2] = 0; dst[3] = 1;
1162 dst[0] = dst[1] = dst[2] = 0; dst[3] = 1;
1189 int cc_size = aux_data->
size;
1196 memcpy(cc_data_emu_prevent, aux_data->
data, cc_size);
1198 int cc_size_emu_prevent = cc_size;
1204 if (cc_size_emu_prevent != cc_size)
1207 "emulation prevention bytes added: %d\n",
1208 cc_size_emu_prevent - cc_size);
1225 memcpy(dst, cc_data_emu_prevent, cc_size_emu_prevent);
1226 dst += cc_size_emu_prevent;
1240 memcpy(dst, cc_data_emu_prevent, cc_size_emu_prevent);
1241 dst += cc_size_emu_prevent;
1265 for (
int i = 3; i < 11; i++)
1271 uint8_t cc_count_byte = (uint8_t)((cc_size / 3) | 0xc0);
1287 memcpy(dst, aux_data->
data, cc_size);
1346 ui_tmp = lrint(10000 *
1355 "hdr10+ targeted_system_display_actual_peak_luminance_"
1370 "hdr10+ num_rows_targeted_system_display_actual_peak_luminance "
1371 "x num_cols_targeted_system_display_actual_peak_luminance %u x "
1391 "luminance[%d][%d] %u\n",
1398 for (i = 0; i < 3; i++)
1400 ui_tmp = lrint(100000 * ni_q2d(hdrp->
params[w].
maxscl[i]));
1411 "hdr10+ num_distribution_maxrgb_percentiles[%d] %d\n", w,
1424 "hdr10+ distribution_maxrgb_percentage[%d][%d] %u\n", w, i,
1427 "hdr10+ distribution_maxrgb_percentile[%d][%d] %u\n", w, i,
1440 "hdr10+ mastering_display_actual_peak_luminance_flag %u\n",
1449 "hdr10+ num_rows_mastering_display_actual_peak_luminance x "
1450 "num_cols_mastering_display_actual_peak_luminance %u x %u\n",
1469 "mastering_display_actual_peak_luminance[%d][%d] %u\n",
1526 int emu_bytes_inserted;
1539 emu_bytes_inserted =
1541 dst += hdr10p_num_bytes + emu_bytes_inserted;
1546 (uint32_t)hdr10p_num_bytes + emu_bytes_inserted +
1559 emu_bytes_inserted =
1561 dst += hdr10p_num_bytes + emu_bytes_inserted;
1566 (uint8_t)hdr10p_num_bytes + emu_bytes_inserted +
1579 uint32_t obu_payload_size = 1 + 1 + (uint32_t)hdr10p_num_bytes +
1600 dst += hdr10p_num_bytes;
1609 "ni_enc_prep_aux_data: codec %d not supported for HDR10+ "
1627 int udu_sei_size = aux_data->
size;
1628 int ext_udu_sei_size, sei_len;
1630 uint8_t *sei_data = malloc(udu_sei_size * 3 / 2);
1633 memcpy(sei_data, (uint8_t *)aux_data->
data, udu_sei_size);
1634 int emu_bytes_inserted =
1637 ext_udu_sei_size = udu_sei_size + emu_bytes_inserted;
1644 6 + ((udu_sei_size + 0xFE) / 0xFF) + ext_udu_sei_size + 1;
1650 7 + ((udu_sei_size + 0xFE) / 0xFF) + ext_udu_sei_size + 1;
1657 "ni_enc_prep_aux_data sei total length %u + sei_len %d "
1658 "exceeds maximum sei size %u, discarding it !\n",
1663 int payload_size = udu_sei_size;
1682 while (payload_size > 0)
1685 (payload_size > 0xFF ? 0xFF : (uint8_t)payload_size);
1686 payload_size -= 0xFF;
1690 memcpy(dst, sei_data, ext_udu_sei_size);
1691 dst += ext_udu_sei_size;
1712 int is_new_rois = 1;
1714 uint32_t self_size = 0;
1718 if (!self_size || aux_data->
size % self_size)
1721 "aux_data size %d self_size %u\n",
1722 aux_data->
size, self_size);
1725 int nb_roi = aux_data->
size / (int)self_size;
1753 if (set_roi_map(p_enc_ctx, codec_format, aux_data, nb_roi,
1777 if (aux_data && p_enc_ctx->
roi_map)
1795 "aux_data %d ctx->roi_map %d frame->roi_len %u ctx->roi_len %u\n",
1796 api_params->
cacheRoi, aux_data != NULL,
1809 "%s(): frame aux data LTR use_cur_src_as_ltr %u "
1823 "%s(): frame API set LTR use_cur_src_as_ltr %u "
1844 "%s(): frame aux data qp info max/min I qp <%d %d> maxDeltaQp <%d> max/min PB qp <%d %d>",
1861 int32_t bitrate = -1;
1865 bitrate = *((int32_t *)aux_data->
data);
1887 ni_log2(p_enc_ctx,
NI_LOG_INFO,
"%s: bitrate %d updated for reconfig\n", __func__, bitrate);
1910 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): invalid colorDescPresent in aux data %d\n",
1946 vui = p_enc_ctx->
vui;
1955 "colorDescPresent %d colorPrimaries %d "
1956 "colorTrc %d colorSpace %d aspectRatioWidth %d "
1957 "aspectRatioHeight %d videoFullRange %d\n",
1981 int32_t ltr_interval = -1;
1986 ltr_interval = *((int32_t *)aux_data->
data);
1999 if (ltr_interval > 0)
2017 if ((framerate_num <= 0) || (framerate_denom <= 0))
2020 "ERROR: %s(): invalid framerate in aux data (%d/%d)\n",
2021 __func__, framerate_num, framerate_denom);
2024 if ((framerate_num % framerate_denom) != 0)
2026 uint32_t numUnitsInTick = 1000;
2027 framerate_num = framerate_num / framerate_denom;
2028 framerate_denom = (int32_t)(numUnitsInTick + 1);
2030 framerate_num = (int32_t)(framerate_num * numUnitsInTick);
2033 framerate_num = framerate_num / framerate_denom;
2034 framerate_denom = 1;
2036 if (((framerate_num + framerate_denom - 1) / framerate_denom) >
2040 "ERROR: %s(): invalid framerate in aux data (%d/%d)\n",
2048 __func__, framerate_num, framerate_denom);
2075 ni_log2(p_enc_ctx,
NI_LOG_INFO,
"%s: framerate num %d denom %d updated for reconfig\n",
2081 int32_t frame_num = -1;
2086 frame_num = *((int32_t *)aux_data->
data);
2088 __func__, frame_num);
2110 should_send_sei_with_frame)
2129 int32_t max_frame_size = 0;
2133 max_frame_size = *((int32_t *)aux_data->
data);
2134 uint32_t maxFrameSize = (uint32_t)max_frame_size / 2000;
2135 uint32_t min_maxFrameSize;
2141 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size %d is valid only when lowDelay mode is enabled\n",
2142 __func__, max_frame_size);
2147 int32_t tmp_bitrate, tmp_framerate_num, tmp_framerate_denom;
2157 tmp_framerate_num = (int32_t)api_params->
fps_number;
2161 min_maxFrameSize = (((uint32_t)tmp_bitrate / tmp_framerate_num * tmp_framerate_denom) / 8) / 2000;
2163 if (maxFrameSize < min_maxFrameSize)
2165 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): max_frame_size %d is too small (invalid)\n",
2166 __func__, max_frame_size);
2180 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s(): API set max_frame_size %d\n", __func__, max_frame_size);
2183 if (max_frame_size > 0)
2198 crf = (float)(*((int32_t *)aux_data->
data));
2204 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %d is valid only in CRF mode\n",
2210 if (crf < 0 || crf > 51)
2212 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %d is invalid (valid range in [0..51])\n",
2221 crf = *((
float *)aux_data->
data);
2227 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): reconfigure crf value %f is valid only in CRF mode\n",
2233 if (crf < 0 || crf > 51)
2235 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s(): crf value %f is invalid (valid range in [0..51])\n",
2262 int32_t vbvMaxRate = 0;
2266 vbvMaxRate = *((int32_t *)aux_data->
data);
2275 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s(): API set reconfig_vbv_max_rate %d\n", __func__, vbvMaxRate);
2287 int32_t vbvBufferSize = 0;
2291 vbvBufferSize = *((int32_t *)aux_data->
data);
2292 if ((vbvBufferSize < 10 && vbvBufferSize != 0) || vbvBufferSize > 3000)
2294 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"%s(): invalid frame aux data vbvBufferSize %d\n", __func__,
2309 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s(): API set reconfig_vbv_max_rate %d\n", __func__, vbvBufferSize);
2321 int16_t sliceArg = 0;
2325 sliceArg = *((int16_t *)aux_data->
data);
2329 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"%s():not support to reconfig slice_arg when slice_mode disable.\n",
2340 int max_num_ctu_mb_row = (api_params->
source_height + ctu_mb_size - 1) / ctu_mb_size;
2341 if (sliceArg < 1 || sliceArg > max_num_ctu_mb_row)
2358 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"%s(): API set reconfig_slice_arg %d\n", __func__, sliceArg);
2364 ni_log2(p_enc_ctx,
NI_LOG_INFO,
"%s(): slice arg > NI_MAX_SLICE_SIZE, change from %d to %d\n",
2396 const uint8_t *mdcv_data,
const uint8_t *cll_data,
2397 const uint8_t *cc_data,
const uint8_t *udu_data,
2398 const uint8_t *hdrp_data,
int is_hwframe,
2406 if (is_hwframe != 0 && is_hwframe != 1 && is_semiplanar != 0 &&
2410 "ni_enc_copy_aux_data: error, illegal hwframe or nv12frame\n");
2427 uint8_t *dst = (uint8_t *)p_enc_frame->
p_data[2 + is_hwframe] +
2428 p_enc_frame->
data_len[2 + is_hwframe] + frame_metadata_size;
2432 dst = (uint8_t *)p_enc_frame->
p_data[2 - is_semiplanar] +
2433 p_enc_frame->
data_len[2 - is_semiplanar] +
2434 frame_metadata_size;
2441 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"ni_enc_copy_aux_data: p_metadata_buffer %p frame_metadata_size %u dst %p\n",
2478 memset(dst, 0, p_enc_ctx->
roi_len);
2493 memcpy(dst, mdcv_data,
2504 memcpy(dst, cll_data,
2512 ni_log2(p_enc_ctx,
NI_LOG_DEBUG,
"ni_enc_copy_aux_data: preferred characteristics size: %u to %p\n",
2515 dst[0] = dst[1] = dst[2] = 0;
2543 memcpy(dst, cc_data, p_enc_frame->
sei_cc_len);
2584 uint8_t *dst = timecode_data;
2585 uint8_t *extradata_dst;
2587 uint32_t header_len, payload_len, total_len;
2588 int emu_bytes_inserted, is_hwframe, is_semiplanar;
2590 if (!p_enc_ctx || !p_enc_frame || !p_timecode) {
2596 ni_log2(p_enc_ctx,
NI_LOG_ERROR,
"ERROR: %s insertion of timecode in SEI is only supported on H264 and H265 encoder\n", __func__);
2603 extradata_dst = (uint8_t *)p_enc_frame->
p_data[2 + is_hwframe] +
2607 extradata_dst = (uint8_t *)p_enc_frame->
p_data[2 - is_semiplanar] +
2635 "ERROR: %s timecode injection for H264 hrdEnable=1 case is not "
2636 "supported on FW API version < 6t9\n", __func__);
2644 "ERROR: %s cannot insert timecode data because current sei total "
2645 "length %u + timecode data len %u exceeds maximum sei size %u\n",
2667 memcpy(extradata_dst, &raw_tc,
sizeof(raw_tc));
2678 "%s: H264 hrdEnable=1 path - appended %zu-byte raw timecode struct "
2679 "to frame buffer (extra_data_len=%u)\n",
2772 dst[6] = payload_len;
2774 dst[7] = payload_len;
2780 dst += payload_len + emu_bytes_inserted;
2784 total_len = header_len + payload_len + emu_bytes_inserted + 1;
2790 "ERROR: %s cannot insert timecode data because current sei total length %u "
2791 "+ pic_timing/timecode SEI length %u exceeds maximum sei size %u\n",
2797 memcpy(extradata_dst, timecode_data, total_len);
2832 ni_frame_t *p_enc_frame, uint8_t *p_yuv_buffer)
2836 bool need_copy =
true;
2839 bool alignment_2pass_wa =
false;
2842 if (!p_ctx || !p_enc_frame)
2859 __func__, p_yuv_buffer);
2877 "%s: resolution change %dx%d -> %dx%d "
2878 "or pixel format change %d -> %d\n",
2911 int should_send_sei_with_frame =
2923 should_send_sei_with_frame, mdcv_data, cll_data,
2924 cc_data, udu_data, hdrp_data);
2943 is_semiplanar, dst_stride, dst_height_aligned);
2954 src_height[0] = frame_height;
2955 p_src[0] = p_yuv_buffer;
2970 src_stride[1] = is_semiplanar ? src_stride[0] : src_stride[0] / 2;
2971 src_stride[2] = is_semiplanar ? 0 : src_stride[0] / 2;
2973 src_height[1] = src_height[0] / 2;
2974 src_height[2] = is_semiplanar ? 0 : src_height[1];
2976 p_src[1] = p_src[0] + (ptrdiff_t)src_stride[0] * src_height[0];
2977 p_src[2] = p_src[1] + (ptrdiff_t)src_stride[1] * src_height[1];
2980 alignment_2pass_wa = (
2987 if (alignment_2pass_wa && !is_hwframe) {
2988 if (is_semiplanar) {
2992 dst_height_aligned[1] = (((dst_height_aligned[0] + 31) / 32) * 32) / 2;
2996 dst_height_aligned[2] = (((dst_height_aligned[0] + 31) / 32) * 32) / 2;
3002 p_param, frame_width, frame_height,
3008 p_enc_frame, frame_width,
3009 frame_height, (
const int *)src_stride, (
const uint8_t **)p_src,
3025 dst_height_aligned[0], dst_stride,
3035 "%s: src_stride %d dst_stride "
3036 "%d dst_height_aligned %d src_height %d need_copy %d\n",
3037 __func__, src_stride[0],
3038 dst_stride[0], dst_height_aligned[0],
3039 src_height[0], need_copy);
3047 dst_height_aligned, src_stride, src_height);
3052 "p_dst alloc linesize = %d/%d/%d src height=%d "
3053 "dst height aligned = %d/%d/%d force_key_frame=%d, "
3055 " sei_size=%u (hdr_content_light_level %u hdr_mastering_display_"
3056 "color_vol %u hdr10+ %u hrd %d) reconf_size=%u roi_size=%u "
3057 "force_pic_qp=%u udu_sei_size=%u "
3058 "use_cur_src_as_long_term_pic %u use_long_term_ref %u\n",
3059 dst_stride[0], dst_stride[1], dst_stride[2], frame_height,
3060 dst_height_aligned[0], dst_height_aligned[1], dst_height_aligned[2],
3072 mdcv_data, cll_data, cc_data, udu_data, hdrp_data,
3087 p_enc_frame->
p_data[i] = NULL;
3110 for (i = 0; i < 3; i++) {
3111 uint32_t tmp = *state << 8;
3112 *state = tmp + *(p++);
3113 if (tmp == 0x100 || p == end)
3122 else if (p[-3] | (p[-1] - 1))
3130 p = ((p) < (end) ? (p - 4) : (end - 4));
3132 (((uint32_t) (p)[0] << 24) | ((p)[1] << 16) | ((p)[2] << 8) | (p)[3]);
3151 ni_packet_t *p_packet, uint8_t sei_type,
int vcl_found)
3178 ni_log(
NI_LOG_INFO,
"number of custom sei in current frame is out of limit(%d).\n",
3182 sei_data = &p_custom_sei->
data[0];
3192 while (index < pkt_size && pkt_data[index] == 0xff)
3194 sei_size += pkt_data[index++];
3197 if (index >= pkt_size)
3202 sei_size += pkt_data[index++];
3211 udata = &pkt_data[index];
3214 sei_data[0] = sei_type;
3220 for (i = 0, len = 0; (i < pkt_size - index) && len < sei_size; i++, len++)
3224 if (i >= 2 && udata[i - 2] == 0 && udata[i - 1] == 0 && udata[i] == 3)
3229 sei_data[len] = udata[i];
3232 if (len != sei_size)
3235 "required size:%d, actual size:%d.\n", sei_size, len);
3239 p_custom_sei->
type = sei_type;
3240 p_custom_sei->
size = sei_size;
3246 __FUNCTION__, sei_size, sei_type);
3272 uint8_t *data,
int size,
ni_packet_t *p_packet,
int low_delay,
3273 int codec_format,
int pkt_nal_bitmap,
int custom_sei_type,
3274 int *svct_skip_next_packet,
int *is_lone_sei_pkt)
3276 int pkt_sei_alone = 1;
3284 const uint8_t *ptr = data;
3285 const uint8_t *end = data + size;
3288 uint8_t sei_type = 0;
3293 const uint8_t *next = NULL;
3294 int sei_size = 0, i = 0;
3299 "ni_dec_packet_parse(): already find the header of streams.\n");
3314 if (0 == nalu_count)
3326 nalu_type = (int)stc & 0x1f;
3329 pkt_sei_alone = (pkt_sei_alone && 6 == nalu_type);
3349 "ni_dec_packet_parse(): Detect SPS, PPS and IDR, "
3350 "enable decoder low delay mode.\n");
3361 if (next >= data + 5 && *(next - 5) == 0)
3367 while (next - ptr > 1)
3371 custom_sei_type == sei_type ||
3381 (
long)(ptr + 1 - data), p_packet,
3382 sei_type, vcl_found);
3392 while (ptr + 1 < next && *ptr == 0xff)
3397 for (i = 0; i < sei_size && next - ptr > 1; i++)
3399 if (i >= 2 && *(ptr - 2) == 0 && *(ptr - 1) == 0 && *ptr == 3)
3404 }
else if (nalu_type >= 1 &&
3408 }
else if (14 == nalu_type)
3415 if (temporal_id > svct_layer)
3419 *svct_skip_next_packet = 1;
3421 "ni_dec_packet_parse(): temporal_id %d"
3422 " is bigger than decoded layer %d, skip the next "
3424 temporal_id, svct_layer);
3429 nalu_type = (int)(stc >> 1) & 0x3F;
3432 pkt_sei_alone = (pkt_sei_alone &&
3454 if (pkt_nal_bitmap ==
3460 "ni_dec_packet_parse(): Detect VPS, SPS, PPS and "
3461 "IDR enable decoder low delay mode.\n");
3468 if (39 == nalu_type ||
3473 if (next >= data + 5 && *(next - 5) == 0)
3482 while (next - ptr > 1)
3486 custom_sei_type == sei_type ||
3496 sei_type, vcl_found);
3506 while (ptr + 1 < next && *ptr == 0xff)
3511 for (i = 0; i < sei_size && next - ptr > 1; i++)
3513 if (i >= 2 && *(ptr - 2) == 0 && *(ptr - 1) == 0 && *ptr == 3)
3518 }
else if (nalu_type >= 0 &&
3525 ni_log2(p_session_ctx,
NI_LOG_DEBUG,
"%s() wrong codec %d !\n", __FUNCTION__, codec_format);
3533 *is_lone_sei_pkt = pkt_sei_alone;
3561 uint8_t *data,
int size,
ni_packet_t *p_packet,
int low_delay,
3562 int codec_format,
int *p_pkt_nal_bitmap,
int custom_sei_type,
3563 int *svct_skip_next_packet,
int *is_lone_sei_pkt)
3565 int pkt_sei_alone = 1;
3567 int tmp_low_delay = 0;
3570 int pkt_nal_bitmap = 0;
3575 uint8_t sei_type = 0;
3580 const uint8_t *next = NULL;
3581 int sei_size = 0, i = 0;
3590 if (!p_ctx || !p_param || !p_packet || !p_pkt_nal_bitmap || !svct_skip_next_packet || !is_lone_sei_pkt)
3601 pkt_nal_bitmap = *p_pkt_nal_bitmap;
3608 "%s(): already find the header of streams.\n",
3624 if (0 == nalu_count)
3636 nalu_type = (int)stc & 0x1f;
3639 pkt_sei_alone = (pkt_sei_alone && 6 == nalu_type);
3659 "%s(): Detect SPS, PPS and IDR, "
3660 "enable decoder low delay mode.\n",
3672 if (next >= data + 5 && *(next - 5) == 0)
3678 while (next - ptr > 1)
3682 custom_sei_type == sei_type ||
3692 (
long)(ptr + 1 - data), p_packet,
3693 sei_type, vcl_found);
3703 while (ptr + 1 < next && *ptr == 0xff)
3708 for (i = 0; i < sei_size && next - ptr > 1; i++)
3710 if (i >= 2 && *(ptr - 2) == 0 && *(ptr - 1) == 0 && *ptr == 3)
3715 }
else if (nalu_type >= 1 &&
3719 }
else if (14 == nalu_type)
3726 if (temporal_id > svct_layer)
3730 *svct_skip_next_packet = 1;
3732 "%s(): temporal_id %d"
3733 " is bigger than decoded layer %d, skip the next "
3735 __func__, temporal_id, svct_layer);
3740 nalu_type = (int)(stc >> 1) & 0x3F;
3743 pkt_sei_alone = (pkt_sei_alone &&
3765 if (pkt_nal_bitmap ==
3771 "%s(): Detect VPS, SPS, PPS and "
3772 "IDR enable decoder low delay mode.\n", __func__);
3779 if (39 == nalu_type ||
3784 if (next >= data + 5 && *(next - 5) == 0)
3793 while (next - ptr > 1)
3797 custom_sei_type == sei_type ||
3807 sei_type, vcl_found);
3817 while (ptr + 1 < next && *ptr == 0xff)
3822 for (i = 0; i < sei_size && next - ptr > 1; i++)
3824 if (i >= 2 && *(ptr - 2) == 0 && *(ptr - 1) == 0 && *ptr == 3)
3829 }
else if (nalu_type >= 0 &&
3844 *is_lone_sei_pkt = pkt_sei_alone;
3847 *p_pkt_nal_bitmap = pkt_nal_bitmap;
3866 int raw_width,
int raw_height,
int ni_fmt,
int nb_planes)
3868 int i, j, h, tenBit = 0;
3869 int vpad[3], hpad[3], src_height[3], src_width[3], src_stride[3];
3870 uint8_t *src_line, *dst_line, *sample, *dest, YUVsample;
3877 src_width[0] =
NIALIGN(raw_width, 2);
3878 src_width[1] =
NIALIGN(raw_width, 2) / 2;
3879 src_width[2] =
NIALIGN(raw_width, 2) / 2;
3882 src_height[0] =
NIALIGN(raw_height, 2);
3883 src_height[1] =
NIALIGN(raw_height, 2) / 2;
3884 src_height[2] =
NIALIGN(raw_height, 2) / 2;
3887 src_stride[0] =
NIALIGN(src_width[0], 128);
3888 src_stride[1] =
NIALIGN(src_width[1], 128);
3889 src_stride[2] =
NIALIGN(src_width[2], 128);
3894 hpad[0] = dst_stride[0] - src_width[0];
3895 hpad[1] = dst_stride[1] - src_width[1];
3896 hpad[2] = dst_stride[2] - src_width[2];
3907 src_width[0] =
NIALIGN(raw_width, 2);
3908 src_width[1] =
NIALIGN(raw_width, 2) / 2;
3909 src_width[2] =
NIALIGN(raw_width, 2) / 2;
3912 src_height[0] =
NIALIGN(raw_height, 2);
3913 src_height[1] =
NIALIGN(raw_height, 2) / 2;
3914 src_height[2] =
NIALIGN(raw_height, 2) / 2;
3917 src_stride[0] =
NIALIGN(src_width[0] * 2, 128);
3918 src_stride[1] =
NIALIGN(src_width[1] * 2, 128);
3919 src_stride[2] =
NIALIGN(src_width[2] * 2, 128);
3924 hpad[0] = dst_stride[0] - src_width[0] * 2;
3925 hpad[1] = dst_stride[1] - src_width[1] * 2;
3926 hpad[2] = dst_stride[2] - src_width[2] * 2;
3937 src_width[0] =
NIALIGN(raw_width, 2);
3938 src_width[1] =
NIALIGN(raw_width, 2);
3942 src_height[0] =
NIALIGN(raw_height, 2);
3943 src_height[1] =
NIALIGN(raw_height, 2) / 2;
3947 src_stride[0] =
NIALIGN(src_width[0], 128);
3948 src_stride[1] =
NIALIGN(src_width[1], 128);
3954 hpad[0] = dst_stride[0] - src_width[0];
3955 hpad[1] = dst_stride[1] - src_width[1];
3967 src_width[0] =
NIALIGN(raw_width, 2);
3968 src_width[1] =
NIALIGN(raw_width, 2);
3972 src_height[0] =
NIALIGN(raw_height, 2);
3973 src_height[1] =
NIALIGN(raw_height, 2) / 2;
3977 src_stride[0] =
NIALIGN(src_width[0] * 2, 128);
3978 src_stride[1] =
NIALIGN(src_width[1] * 2, 128);
3984 hpad[0] = dst_stride[0] - src_width[0] * 2;
3985 hpad[1] = dst_stride[1] - src_width[1] * 2;
4002 dst_line = dst->
p_data[i];
4003 src_line = src->
p_data[i];
4005 for (h = 0; i < 3 && h < src_height[i]; h++)
4007 memcpy(dst_line, src_line, (
size_t)src_width[i] * (tenBit + 1));
4012 lastidx = src_width[i];
4016 sample = &src_line[(ptrdiff_t)(lastidx - 1) * 2];
4017 dest = &dst_line[(ptrdiff_t)lastidx * 2];
4020 for (j = 0; j < hpad[i] / 2; j++)
4022 memcpy(dest, sample, 2);
4027 YUVsample = dst_line[lastidx - 1];
4028 memset(&dst_line[lastidx], YUVsample, hpad[i]);
4032 src_line += src_stride[i];
4033 dst_line += dst_stride[i];
4037 src_line = dst_line - dst_stride[i];
4039 for (h = 0; h < vpad[i]; h++)
4041 memcpy(dst_line, src_line, dst_stride[i]);
4042 dst_line += dst_stride[i];
4064 int sei_size, size, len;
4065 int ret = 0, i = 0, j = 0;
4066 uint8_t *p_src_sei_data, *p_dst_sei_data;
4069 if (!p_session_ctx || !p_param || !ppu_config)
4080 ni_log2(p_session_ctx,
NI_LOG_ERROR,
"%s: not supported on device with FW API version < 6rx\n", __func__);
4088 "h264 and h265 decoder\n", __func__);
4093 if (p_dec_input_param->
hwframes != 1)
4096 "So can't reconfig ppu\n", __func__);
4103 "So can't reconfig ppu1\n", __func__);
4110 "So can't reconfig ppu2\n", __func__);
4123 "out of range\n", __func__, ppu_config->
ppu_w[i], ppu_config->
ppu_h[i]);
4127 if ((ppu_config->
ppu_w[i] & 1) || (ppu_config->
ppu_h[i] & 1))
4130 __func__, ppu_config->
ppu_w[i], ppu_config->
ppu_h[i]);
4137 if (p_dst_custom_sei == NULL)
4140 "to allocate memory for custom sei data\n", __func__);
4149 p_src_sei_data = (uint8_t *)ppu_config;
4150 p_dst_sei_data = &p_dst_custom_sei->
data[0];
4154 p_dst_sei_data[size++] = 0x00;
4155 p_dst_sei_data[size++] = 0x00;
4156 p_dst_sei_data[size++] = 0x00;
4157 p_dst_sei_data[size++] = 0x01;
4161 p_dst_sei_data[size++] = 0x06;
4165 p_dst_sei_data[size++] = 0x4e;
4166 p_dst_sei_data[size++] = 0x01;
4176 p_dst_sei_data[size++] = len > 0xff ? 0xff : len;
4183 if (j >= 2 && !p_dst_sei_data[size - 2] && !p_dst_sei_data[size - 1] && p_src_sei_data[j] <= 0x03)
4186 p_dst_sei_data[size++] = 0x03;
4188 p_dst_sei_data[size++] = p_src_sei_data[j];
4194 "idx=%u, size=%d\n", __func__,
4196 free(p_dst_custom_sei);
4201 p_dst_sei_data[size++] = 0x80;
4204 p_dst_sei_data, size);
4206 free(p_dst_custom_sei);
void ni_dec_retrieve_aux_data(ni_frame_t *frame)
Retrieve auxiliary data (close caption, various SEI) associated with this frame that is returned by d...
int ni_extract_custom_sei(uint8_t *pkt_data, int pkt_size, long index, ni_packet_t *p_packet, uint8_t sei_type, int vcl_found)
Extract custom sei payload data from pkt_data, and save it to ni_packet_t.
int ni_should_send_sei_with_frame(ni_session_context_t *p_enc_ctx, ni_pic_type_t pic_type, ni_xcoder_params_t *p_param)
Whether SEI (HDR) should be sent together with this frame to encoder.
void ni_enc_prep_aux_data(ni_session_context_t *p_enc_ctx, ni_frame_t *p_enc_frame, ni_frame_t *p_dec_frame, ni_codec_format_t codec_format, int should_send_sei_with_frame, uint8_t *mdcv_data, uint8_t *cll_data, uint8_t *cc_data, uint8_t *udu_data, uint8_t *hdrp_data)
Prepare auxiliary data that should be sent together with this frame to encoder based on the auxiliary...
const uint8_t * ni_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
Find the next start code.
int ni_expand_frame(ni_frame_t *dst, ni_frame_t *src, int dst_stride[], int raw_width, int raw_height, int ni_fmt, int nb_planes)
Expand frame form src frame.
int ni_reconfig_ppu_output(ni_session_context_t *p_session_ctx, ni_xcoder_params_t *p_param, ni_ppu_config_t *ppu_config)
Reset decoder ppu resolution.
int ni_dec_packet_parse2(ni_session_context_t *p_ctx, ni_xcoder_params_t *p_param, uint8_t *data, int size, ni_packet_t *p_packet, int low_delay, int codec_format, int *p_pkt_nal_bitmap, int custom_sei_type, int *svct_skip_next_packet, int *is_lone_sei_pkt)
Decode parse packet.
LIB_API int ni_enc_insert_timecode(ni_session_context_t *p_enc_ctx, ni_frame_t *p_enc_frame, ni_timecode_t *p_timecode)
Insert timecode data into picture timing SEI (H264) or time code SEI (H265)
int ni_enc_write_from_yuv_buffer(ni_session_context_t *p_ctx, ni_frame_t *p_enc_frame, uint8_t *p_yuv_buffer)
Send an input data frame to the encoder with YUV data given in the inputs.
NI_DEPRECATED int ni_dec_packet_parse(ni_session_context_t *p_session_ctx, ni_xcoder_params_t *p_param, uint8_t *data, int size, ni_packet_t *p_packet, int low_delay, int codec_format, int pkt_nal_bitmap, int custom_sei_type, int *svct_skip_next_packet, int *is_lone_sei_pkt)
Decode parse packet.
void ni_enc_copy_aux_data(ni_session_context_t *p_enc_ctx, ni_frame_t *p_enc_frame, ni_frame_t *p_dec_frame, ni_codec_format_t codec_format, const uint8_t *mdcv_data, const uint8_t *cll_data, const uint8_t *cc_data, const uint8_t *udu_data, const uint8_t *hdrp_data, int is_hwframe, int is_semiplanar)
Copy auxiliary data that should be sent together with this frame to encoder.
Audio/video related utility definitions.
#define AV1_MASTERING_DISP_LUMA_MAX_DEN
#define AV1_MASTERING_DISP_LUMA_MIN_DEN
#define NI_SEI_TYPE_PPU_RECONFIG
enum _ni_hdr_plus_overlap_process_option ni_hdr_plus_overlap_process_option_t
#define MASTERING_DISP_LUMA_DEN
#define AV1_MASTERING_DISP_CHROMA_DEN
#define MASTERING_DISP_CHROMA_DEN
#define NI_GENERATE_ALL_NAL_HEADER_BIT
int ni_bs_writer_leb128(ni_bitstream_writer_t *stream, uint32_t data)
write unsigned LEB128 bit string to bitstream and return bytes written. Commonly used for OBU sizes i...
void ni_bitstream_writer_init(ni_bitstream_writer_t *stream)
init a bitstream writer
void ni_bs_writer_copy(uint8_t *dst, const ni_bitstream_writer_t *stream)
copy bitstream data to dst Note: caller must ensure sufficient space in dst
void ni_bs_writer_align_zero(ni_bitstream_writer_t *stream)
align the bitstream with zero
void ni_bitstream_reader_init(ni_bitstream_reader_t *br, const uint8_t *data, int bit_size)
init a bitstream reader Note: bitstream_reader takes reading ownership of the data
uint32_t ni_bs_reader_get_bits(ni_bitstream_reader_t *br, int n)
read bits (up to 32) from the bitstream reader, after reader init
void ni_bs_writer_clear(ni_bitstream_writer_t *stream)
clear and reset bitstream
uint64_t ni_bs_writer_tell(const ni_bitstream_writer_t *const stream)
return the number of bits written to bitstream so far
void ni_bs_writer_put(ni_bitstream_writer_t *stream, uint32_t data, uint8_t bits)
write a specified number (<= 32) of bits to bitstream, buffer individual bits until a full byte is ma...
void ni_bs_reader_skip_bits(ni_bitstream_reader_t *br, int n)
skip a number of bits ahead in the bitstream reader
Utility definitions to operate on bits in a bitstream.
Common NETINT definitions used by all modules.
#define NI_INVALID_SEI_TYPE
#define NI_XCODER_REVISION_API_MAJOR_VER_IDX
#define NI_MAX_NUM_DATA_POINTERS
#define NI_APP_ENC_FRAME_META_DATA_SIZE_UNDER_MAJOR_6_MINOR_rc
#define NI_APP_ENC_FRAME_META_DATA_SIZE
#define NI_MAX_CUSTOM_SEI_CNT
#define NI_MAX_NUM_OF_DECODER_OUTPUTS
#define NI_APP_ENC_FRAME_META_DATA_SIZE_UNDER_MAJOR_6_MINOR_Q
#define NI_MEM_PAGE_ALIGNMENT
@ NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
@ NI_RETCODE_PARAM_INVALID_VALUE
@ NI_RETCODE_ERROR_MEM_ALOC
@ NI_RETCODE_INVALID_PARAM
ni_aux_data_t * ni_frame_new_aux_data(ni_frame_t *frame, ni_aux_data_type_t type, int data_size)
Add a new auxiliary data to a frame.
ni_retcode_t ni_encoder_frame_zerocopy_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, const int linesize[], const uint8_t *data[], int extra_len)
Allocate memory for encoder zero copy (metadata, etc.) for encoding based on given parameters,...
ni_retcode_t ni_encoder_frame_zerocopy_check(ni_session_context_t *p_enc_ctx, ni_xcoder_params_t *p_enc_params, int width, int height, const int linesize[], bool set_linesize)
Check if incoming frame is encoder zero copy compatible or not.
ni_aux_data_t * ni_frame_get_aux_data(const ni_frame_t *frame, ni_aux_data_type_t type)
Retrieve from the frame auxiliary data of a given type if exists.
ni_aux_data_t * ni_frame_new_aux_data_from_raw_data(ni_frame_t *frame, ni_aux_data_type_t type, const uint8_t *raw_data, int data_size)
Add a new auxiliary data to a frame and copy in the raw data.
ni_retcode_t ni_encoder_sw_frame_buffer_alloc(bool planar, ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int alignment, int extra_len, bool alignment_2pass_wa)
This API is a wrapper for ni_encoder_frame_buffer_alloc(), used for planar pixel formats,...
int ni_device_session_write(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Sends data to the device If device_type is NI_DEVICE_TYPE_DECODER sends data packet to decoder If dev...
Public definitions for operating NETINT video processing devices for video processing.
@ SESSION_RUN_STATE_SEQ_CHANGE_DRAINING
@ NI_CUSTOM_SEI_LOC_AFTER_VCL
@ NI_CUSTOM_SEI_LOC_BEFORE_VCL
#define NI_CC_SEI_TRAILER_LEN
#define NI_CC_SEI_HDR_H264_LEN
#define NI_MAX_CUSTOM_SEI_DATA
#define NI_MAX_FRAME_SIZE
struct _ni_encoder_change_params_t ni_encoder_change_params_t
This is a data structure for encoding parameters that have changed.
@ NI_FRAME_AUX_DATA_MASTERING_DISPLAY_METADATA
@ NI_FRAME_AUX_DATA_BITRATE
@ NI_FRAME_AUX_DATA_SLICE_ARG
@ NI_FRAME_AUX_DATA_CRF_FLOAT
@ NI_FRAME_AUX_DATA_UDU_SEI
@ NI_FRAME_AUX_DATA_MAX_MIN_QP
@ NI_FRAME_AUX_DATA_FRAMERATE
@ NI_FRAME_AUX_DATA_LTR_INTERVAL
@ NI_FRAME_AUX_DATA_HDR_PLUS
@ NI_FRAME_AUX_DATA_VBV_MAX_RATE
@ NI_FRAME_AUX_DATA_INTRAPRD
@ NI_FRAME_AUX_DATA_MAX_FRAME_SIZE
@ NI_FRAME_AUX_DATA_INVALID_REF_FRAME
@ NI_FRAME_AUX_DATA_A53_CC
@ NI_FRAME_AUX_DATA_CONTENT_LIGHT_LEVEL
@ NI_FRAME_AUX_DATA_REGIONS_OF_INTEREST
@ NI_FRAME_AUX_DATA_LONG_TERM_REF
@ NI_FRAME_AUX_DATA_VBV_BUFFER_SIZE
#define NI_MAX_RESOLUTION_WIDTH
#define NI_MAX_SLICE_SIZE
#define NI_ENC_MAX_SEI_BUF_SIZE
struct _ni_ppu_config ni_ppu_config_t
#define NI_HDR10P_SEI_HDR_H264_LEN
#define NI_DEFAULT_INTRA_QP
#define NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL
Max number of lines supported for qpoffset level.
enum _ni_codec_format ni_codec_format_t
This is an enumeration for supported codec formats.
#define NI_MIN_RESOLUTION_WIDTH_SCALER
#define NI_HDR10P_SEI_HDR_HEVC_LEN
#define NI_MAX_ASPECTRATIO
#define NI_MAX_RESOLUTION_HEIGHT
#define NI_INTRA_QP_RANGE
@ NI_SET_CHANGE_PARAM_INVALID_REF_FRAME
@ NI_SET_CHANGE_PARAM_RC_TARGET_RATE
@ NI_SET_CHANGE_PARAM_RC_FRAMERATE
@ NI_SET_CHANGE_PARAM_CRF
@ NI_SET_CHANGE_PARAM_LTR_INTERVAL
@ NI_SET_CHANGE_PARAM_VBV
@ NI_SET_CHANGE_PARAM_VUI_HRD_PARAM
@ NI_SET_CHANGE_PARAM_RC_MIN_MAX_QP
@ NI_SET_CHANGE_PARAM_SLICE_ARG
@ NI_SET_CHANGE_PARAM_INTRA_PERIOD
@ NI_SET_CHANGE_PARAM_MAX_FRAME_SIZE
#define NI_INVALID_SVCT_DECODING_LAYER
#define NI_CC_SEI_HDR_HEVC_LEN
#define NI_RBSP_TRAILING_BITS_LEN
int ni_get_planar_from_pixfmt(int pix_fmt)
Grab planar info from NI_PIX_FMT.
Private definitions used by ni_device_api.c for video processing tasks.
struct _ni_enc_timecode_raw ni_timecode_raw_t
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,
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
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....
int ni_insert_emulation_prevent_bytes(uint8_t *buf, int size)
Insert emulation prevention byte(s) as needed into the data buffer.
void ni_copy_hw_yuv420p(uint8_t *p_dst[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_MAX_NUM_DATA_POINTERS], int frame_width, int frame_height, int factor, int is_semiplanar, int conf_win_right, int dst_stride[NI_MAX_NUM_DATA_POINTERS], int dst_height[NI_MAX_NUM_DATA_POINTERS], int src_stride[NI_MAX_NUM_DATA_POINTERS], int src_height[NI_MAX_NUM_DATA_POINTERS])
Copy YUV data to Netint HW YUV420p frame layout to be sent to encoder for encoding....
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...
payload format of HDR SEI content light level info
uint16_t max_content_light_level
uint16_t max_pic_average_light_level
ni_custom_sei_t custom_sei[NI_MAX_CUSTOM_SEI_CNT]
custom sei payload passthrough
uint8_t data[NI_MAX_CUSTOM_SEI_DATA]
ni_custom_sei_location_t location
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 targeted_system_display_actual_peak_luminance_flag
uint8_t application_version
uint8_t num_cols_targeted_system_display_actual_peak_luminance
uint8_t num_rows_mastering_display_actual_peak_luminance
uint8_t num_rows_targeted_system_display_actual_peak_luminance
uint8_t num_cols_mastering_display_actual_peak_luminance
ni_rational_t targeted_system_display_maximum_luminance
ni_rational_t mastering_display_actual_peak_luminance[25][25]
uint8_t itu_t_t35_country_code
uint8_t mastering_display_actual_peak_luminance_flag
ni_hdr_plus_color_transform_params_t params[3]
ni_rational_t targeted_system_display_actual_peak_luminance[25][25]
encoded payload format of HDR SEI mastering display colour volume
uint16_t display_primaries[3][2]
uint32_t nuit_field_based_flag
uint32_t time_offset_value
uint32_t discontinuity_flag
uint32_t time_offset_length
uint32_t full_timestamp_flag
uint32_t cnt_dropped_flag
int intra_mb_refresh_mode
int preferred_transfer_characteristics
struct _ni_encoder_cfg_params::@16 rc
int customize_roi_qp_level
This is a data structure for encoding parameters that have changed.
uint16_t aspectRatioHeight
uint16_t aspectRatioWidth
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
ni_codec_format_t src_codec
uint8_t preferred_characteristics_data_len
uint32_t vui_num_units_in_tick
uint8_t separate_metadata
unsigned int sei_hdr_plus_len
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
unsigned int sei_hdr_content_light_level_info_len
uint8_t * p_metadata_buffer
unsigned int sei_hdr_mastering_display_color_vol_len
int video_full_range_flag
unsigned int sei_user_data_unreg_offset
uint8_t use_long_term_ref
unsigned int sei_alt_transfer_characteristics_len
unsigned int sei_alt_transfer_characteristics_offset
uint8_t use_cur_src_as_long_term_pic
uint8_t use_long_term_ref
ni_custom_sei_set_t * p_custom_sei_set
uint16_t ppu_h[NI_MAX_NUM_OF_DECODER_OUTPUTS]
uint16_t ppu_w[NI_MAX_NUM_OF_DECODER_OUTPUTS]
uint8_t itu_t_t35_hdr10p_sei_hdr_hevc[NI_HDR10P_SEI_HDR_HEVC_LEN]
int16_t reconfig_slice_arg
int reconfig_vbv_max_rate
int mdcv_max_min_lum_data_len
int32_t ltr_frame_ref_invalid
uint8_t preferred_characteristics_data
uint8_t ui8_light_level_data[5]
int sei_hdr_content_light_level_info_len
uint8_t itu_t_t35_cc_sei_hdr_av1[NI_CC_SEI_HDR_AV1_LEN]
int sei_hdr_mastering_display_color_vol_len
uint32_t actual_video_width
uint8_t sei_trailer[NI_CC_SEI_TRAILER_LEN]
int reconfig_intra_period
uint8_t ui8_mdcv_max_min_lum_data[9]
uint8_t itu_t_t35_cc_sei_hdr_hevc[NI_CC_SEI_HDR_HEVC_LEN]
void * p_master_display_meta_data
uint8_t itu_t_t35_cc_sei_hdr_h264[NI_CC_SEI_HDR_H264_LEN]
ni_framerate_t last_framerate
int reconfig_vbv_buffer_size
uint32_t force_idr_intra_offset
ni_long_term_ref_t ltr_to_set
ni_session_run_state_t session_run_state
ni_encoder_change_params_t * enc_change_params
uint8_t itu_t_t35_hdr10p_sei_hdr_h264[NI_HDR10P_SEI_HDR_H264_LEN]
ni_enc_quad_roi_custom_map * roi_map
ni_region_of_interest_t * av_rois
uint32_t active_video_height
uint32_t time_offset_value
uint8_t full_timestamp_flag
uint8_t nuit_field_based_flag
uint8_t time_offset_length
uint8_t discontinuity_flag
int32_t aspectRatioHeight
ni_encoder_cfg_params_t cfg_enc_params
ni_decoder_input_params_t dec_input_params
encoder AVC ROI custom map (1 MB = 8bits)