 |
libxcoder
5.2.0
|
Go to the documentation of this file.
45 uint32_t i, j, sumQp = 0;
46 uint32_t mbWidth, mbHeight, numMbs;
50 int importanceLevelCentre = p_param->
roi_demo_mode == 1 ? 40 : 10;
51 int importanceLevelRest = p_param->
roi_demo_mode == 1 ? 10 : 40;
52 int32_t width, height;
63 uint32_t roiMapBlockUnitSize = 64;
64 uint32_t max_cu_size = 64;
68 roiMapBlockUnitSize = 16;
76 width = (width / 8) * 8;
77 height = (height / 8) * 8;
81 ((width + max_cu_size - 1) & (~(max_cu_size - 1))) /
84 ((height + max_cu_size - 1) & (~(max_cu_size - 1))) /
86 numMbs = mbWidth * mbHeight;
91 uint32_t entryPerMb = (roiMapBlockUnitSize / 8) * (roiMapBlockUnitSize / 8);
93 for (i = 0; i < numMbs; i++)
95 if ((i % mbWidth > mbWidth / 3) && (i % mbWidth < mbWidth * 2 / 3))
100 for (j = 0; j < entryPerMb; j++)
113 bIsCenter ? importanceLevelCentre : importanceLevelRest;
119 (sumQp + (numMbs >> 1)) / numMbs;
141 "Error %s(): no mem for reconf BR aux_data\n",
145 *((int32_t *)aux_data->data) =
164 int32_t intraprd = *((int32_t *)aux_data->data) =
167 "xcoder_send_frame: frame #%lu reconf "
213 "Error %s(): no mem for reconf LTR aux_data\n",
224 "%s(): frame #%lu reconf LTR "
225 "use_cur_src_as_long_term_pic %u use_long_term_ref "
242 "Error %s(): no mem for reconf max&min QP aux_data\n",
269 *((int32_t *)aux_data->data) =
273 *((int32_t *)aux_data->data));
292 *((int32_t *)aux_data->data) =
296 *((int32_t *)aux_data->data));
310 "Error %s(): no mem for reconf framerate aux_data\n",
321 "%s(): frame #%lu reconfig framerate (%d/%d) by frame aux data\n",
337 "Error %s(): no mem for reconf maxFrameSize aux_data\n",
341 *((int32_t *)aux_data->data) =
358 "Error %s(): no mem for reconf crf aux_data\n",
362 *((int32_t *)aux_data->data) =
379 "Error %s(): no mem for reconf crf aux_data\n",
385 *((
float *)aux_data->data) = crf;
387 "%s(): frame #%lu reconfig float type crf %f by frame "
388 "aux data\n", __func__, p_enc_ctx->
frame_num, crf);
401 "Error %s(): no mem for reconf vbfMaxRate aux_data\n",
405 *((int32_t *)aux_data->data) =
411 "Error %s(): no mem for reconf vbvBufferSize aux_data\n",
415 *((int32_t *)aux_data->data) =
418 "%s(): frame #%lu reconfig vbfMaxRate %d vbvBufferSize "
419 "%d by frame aux data\n",
431 if (maxFrameSizeRatio < 1) {
440 "Error %s(): no mem for reconf maxFrameSizeRatio aux_data\n",
445 int32_t bitrate, framerate_num, framerate_denom;
446 uint32_t min_maxFrameSize, maxFrameSize;
456 framerate_num = (int32_t) api_param->
fps_number;
460 min_maxFrameSize = ((uint32_t)bitrate / framerate_num * framerate_denom) / 8;
463 *((int32_t *)aux_data->data) = maxFrameSize;
465 "xcoder_send_frame: frame #%lu reconf "
466 "maxFrameSizeRatio %d maxFrameSize %d\n",
467 p_enc_ctx->
frame_num, maxFrameSizeRatio, maxFrameSize);
479 "Error %s(): no mem for reconf sliceArg aux_data\n",
483 *((int16_t *)aux_data->data) =
486 "xcoder_send_frame: frame #%lu reconf "
524 "xcoder_send_frame: frame #%lu API reconfig intraPeriod %d\n",
553 "colorDescPresent %d colorPrimaries %d "
554 "colorTrc %d colorSpace %d aspectRatioWidth %d "
555 "aspectRatioHeight %d videoFullRange %d\n",
596 "%s(): frame %llu minQpI %d maxQpI %d maxDeltaQp %d minQpPB %d maxQpPB %d\n",
638 "%s(): frame #%lu API reconfig framerate (%d/%d)\n",
688 ni_log(
NI_LOG_DEBUG,
"%s(): frame #%lu API reconfig vbvMaxRate %d vbvBufferSize %d\n",
702 "xcoder_send_frame: frame #%lu reconf maxFrameSizeRatio %d\n",
714 "xcoder_send_frame: frame #%lu API reconfig sliceArg %d\n",
737 int input_video_width,
int input_video_height,
749 "for previous session to end\n");
808 uint64_t abs_time_ns;
827 "Error: failed ni_device_session_write() for encoder\n");
857 "encoder_send_data: session_run_state change to %d\n",
879 int input_video_width,
int input_video_height)
882 int data_len_to_send;
909 #ifdef ENCODER_FLUSH_INJECT
957 bool alignment_2pass_wa = (
965 dst_stride, dst_height_aligned);
967 if (alignment_2pass_wa && !is_hwframe) {
972 dst_height_aligned[1] = (((dst_height_aligned[0] + 31) / 32) * 32) / 2;
976 dst_height_aligned[2] = (((dst_height_aligned[0] + 31) / 32) * 32) / 2;
1013 p_enc_ctx, p_in_frame, &(p_dec_out_data->
data.
frame),
1034 p_in_frame, input_video_width, input_video_height, dst_stride,
1037 if (!p_in_frame->
p_data[0])
1047 if (!p_in_frame->
p_data[3])
1055 "p_dst alloc linesize = %d/%d/%d src height=%d "
1056 "dst height aligned = %d/%d/%d force_key_frame=%d, "
1058 " sei_size=%u (hdr_content_light_level %u hdr_mastering_display_"
1059 "color_vol %u hdr10+ %u hrd %d) reconf_size=%u roi_size=%u "
1060 "force_pic_qp=%u udu_sei_size=%u "
1061 "use_cur_src_as_long_term_pic %u use_long_term_ref %u\n",
1062 dst_stride[0], dst_stride[1], dst_stride[2], input_video_height,
1063 dst_height_aligned[0], dst_height_aligned[1], dst_height_aligned[2],
1079 src_height[1] = src_height[2] = src_height[0] / 2;
1086 src_stride[2] = src_stride[1];
1102 (uint8_t **)(p_in_frame->
p_data), p_src, input_video_width,
1105 ->cfg_enc_params.conf_win_right,
1106 dst_stride, dst_height_aligned, src_stride, src_height);
1129 data_len_to_send = (int)(p_in_frame->
data_len[0] + p_in_frame->
data_len[1] +
1147 }
else if (oneSent == 0)
1181 int input_video_width,
int input_video_height,
int eos)
1225 "Error: failed ni_device_session_write() for encoder\n");
1261 bool check_zerocopy)
1264 bool isrgba =
false;
1274 p_enc_ctx->
hw_id = iXcoderGUID;
1316 int linesize_aligned = width;
1326 linesize_aligned = ((width + 1) / 2) * 2;
1328 (linesize_aligned - width) / 2 * 2;
1333 int height_aligned = height;
1343 height_aligned = ((height + 1) / 2) * 2;
1345 (height_aligned - height) / 2 * 2;
1363 src_stride[1] = src_stride[2] = 0;
1367 src_stride[1] = isnv12frame ? src_stride[0] : src_stride[0] / 2;
1368 src_stride[2] = isnv12frame ? 0 : src_stride[0] / 2;
1372 p_enc_params, width, height,
1373 (
const int *)src_stride,
true);
1382 ni_log(
NI_LOG_INFO,
"Encoder device %d session open successful.\n", iXcoderGUID);
1410 int new_stride, ori_stride;
1411 bool bIsSmallPicture =
false;
1414 int new_width, new_height;
1439 src_stride[1] = is_semiplanar ? src_stride[0] : src_stride[0] / 2;
1440 src_stride[2] = is_semiplanar ? 0 : src_stride[0] / 2;
1444 p_api_param, new_width, new_height,
1465 "lookaheadDepth %d\n",
1469 bIsSmallPicture =
true;
1475 bIsSmallPicture =
true;
1484 bIsSmallPicture =
true;
1490 "due to crop width x height\n");
1491 bIsSmallPicture =
true;
1495 "pix fmt: %d->%d bIsSmallPicture %d codec %d\n",
1496 ori_stride, p_enc_ctx->
ori_height, new_stride, new_height,
1497 p_enc_ctx->
ori_pix_fmt, new_pix_fmt, bIsSmallPicture,
1501 if (ori_stride*p_enc_ctx->
ori_height < new_stride*new_height ||
1506 ni_log(
NI_LOG_INFO,
"XCoder encode sequence change by close / re-open session\n");
1509 p_enc_ctx->
hw_id, p_api_param, new_width,
1510 new_height, new_pix_fmt,
true);
1513 ni_log(
NI_LOG_ERROR,
"Failed to Re-open Encoder Session upon Sequence Change (status = %d)\n", ret);
1528 "resolution change: AV1 Picture Width not aligned to %d - picture will be cropped\n",
1533 "resolution change: AV1 Picture Height not aligned to %d - picture will be cropped\n",
1536 ni_log(
NI_LOG_INFO,
"XCoder encode sequence change by re-config session (fast path)\n");
1550 uint32_t frame_denom, FILE *p_file)
1555 uint8_t start_header[32] = {
1556 0x44, 0x4b, 0x49, 0x46,
1559 0x41, 0x56, 0x30, 0x31,
1562 0x1e, 0x00, 0x00, 0x00,
1563 0x01, 0x00, 0x00, 0x00,
1564 0x00, 0x00, 0x00, 0x00,
1565 0x00, 0x00, 0x00, 0x00
1568 if (width && height)
1570 start_header[12] = width & 0xff;
1571 start_header[13] = ((width >> 8) & 0xff);
1572 start_header[14] = height & 0xff;
1573 start_header[15] = ((height >> 8) & 0xff);
1576 if (frame_num && frame_denom)
1578 start_header[16] = frame_num & 0xff;
1579 start_header[17] = ((frame_num >> 8) & 0xff);
1580 start_header[18] = ((frame_num >> 16) & 0xff);
1581 start_header[19] = ((frame_num >> 24) & 0xff);
1582 start_header[20] = frame_denom & 0xff;
1583 start_header[21] = ((frame_denom >> 8) & 0xff);
1584 start_header[22] = ((frame_denom >> 16) & 0xff);
1585 start_header[23] = ((frame_denom >> 24) & 0xff);
1588 if (fwrite(start_header,
sizeof(start_header), 1, p_file) != 1)
1612 uint32_t pkt_size = p_out_pkt->
data_len - meta_size;
1626 uint8_t ivf_frame_header[12] = {((pkt_size & 0xff)),
1627 ((pkt_size >> 8) & 0xff),
1628 ((pkt_size >> 16) & 0xff),
1629 ((pkt_size >> 24) & 0xff),
1631 ((pts >> 8) & 0xff),
1632 ((pts >> 16) & 0xff),
1633 ((pts >> 24) & 0xff),
1634 0x00, 0x00, 0x00, 0x00};
1635 if (fwrite(ivf_frame_header, 12, 1, p_file) != 1)
1658 if (fwrite((uint8_t *)p_out_pkt->
av1_p_data[i] + meta_size,
1659 p_out_pkt->
av1_data_len[i] - meta_size, 1, p_file) != 1)
1667 if (fwrite((uint8_t *)p_out_pkt->
p_data + meta_size,
1668 p_out_pkt->
data_len - meta_size, 1, p_file) != 1)
1691 uint8_t frame_cnt[4] = {
1692 (muxed_num_packets & 0xff),
1693 ((muxed_num_packets >> 8) & 0xff),
1694 ((muxed_num_packets >> 16) & 0xff),
1695 ((muxed_num_packets >> 24) & 0xff)};
1696 fseek(p_file, 24, SEEK_SET);
1697 if (fwrite(frame_cnt, 4, 1, p_file) != 1)
1739 "encode session id invalid, the session should be closed\n");
1758 if (rx_size > meta_size)
1771 p_out_pkt->
p_data = NULL;
1789 p_out_pkt->
p_data = NULL;
1802 "pts %lld dts %lld\n", p_out_pkt->
pts, p_out_pkt->
dts);
1825 (fwrite((uint8_t *)p_out_pkt->
p_data + meta_size,
1826 p_out_pkt->
data_len - meta_size, 1, p_file) != 1))
1845 }
else if (rx_size != 0)
1848 rx_size, meta_size);
1850 }
else if (end_flag)
1857 "change completed, return SEQ_CHANGE_DONE and will reopen "
1858 "or reconfig codec!\n");
1956 int bit_depth_factor;
1965 bit_depth_factor = 1;
1970 bit_depth_factor = 2;
1974 bit_depth_factor = 1;
1981 ni_log(
NI_LOG_ERROR,
"Failed to send Sequence Change to Encoder Session (status = %d)\n", ret);
2001 int output_total,
char p_enc_conf_params[][2048],
2002 char p_enc_conf_gop[][2048],
2003 ni_frame_t *p_ni_frame,
int width,
int height,
2004 int fps_num,
int fps_den,
int bitrate,
2006 int aspect_ratio_idc,
int xcoder_guid,
2008 bool check_zerocopy)
2016 int video_full_range_flag = 0;
2018 if (p_ni_frame != NULL)
2053 for (i = 0; i < output_total; i++)
2057 fps_den, bitrate, width, height,
2058 enc_ctx_list[i].codec_format);
2070 &p_api_param_list[i], &enc_ctx_list[i]))
2077 &p_api_param_list[i], &enc_ctx_list[i]))
2087 "in the session context!\n", i);
2093 if (color_prim != p_api_param_list[i].color_primaries &&
2097 "%d to overwrite source %d\n",
2098 i, p_api_param_list[i].color_primaries, color_prim);
2103 if (color_trc != p_api_param_list[i].color_transfer_characteristic &&
2107 "overwrite source %d\n", i,
2108 p_api_param_list[i].color_transfer_characteristic, color_trc);
2113 if (color_space != p_api_param_list[i].color_space &&
2117 "to overwrite source %d\n",
2118 i, p_api_param_list[i].color_space, color_space);
2123 if (p_api_param_list[i].video_full_range_flag >= 0)
2126 "flag %d\n", i, p_api_param_list[i].video_full_range_flag);
2133 sar_num = ni_h264_pixel_aspect_list[aspect_ratio_idc].num;
2134 sar_den = ni_h264_pixel_aspect_list[aspect_ratio_idc].den;
2135 }
else if (p_api_param_list[i].sar_denom)
2137 sar_num = p_api_param_list[i].
sar_num;
2138 sar_den = p_api_param_list[i].
sar_denom;
2142 if (p_surface != NULL)
2169 &p_api_param_list[i], width, height,
2170 pix_fmt, check_zerocopy);
2185 int output_total, FILE **pfs_list)
2187 int i, recycle_index;
2192 for (i = 0; i < output_total; i++)
2196 p_out_pkt = &pkt[i];
2203 height, pfs_list[i], in_frame);
2207 enc_ctx_list[i].
hw_action && recycle_index > 0 &&
2217 "number_of_packets_list %u recycle_index %u\n", i,
2239 if (recv_fin_flag < 0)
2249 return recv_fin_flag;
2262 for (i = 0; i < output_total; i++)
2264 ni_log(
NI_LOG_ERROR,
"Encoder %d closing, Got: Packets=%u FPS=%.2f Total bytes %llu\n",
2302 p_dec_frame = &frame_list->
frames[frame_list->
head];
2314 if (p_enc_ctx_list[i].hw_action)
2330 }
else if (p_enc_ctx_list[0].hw_action && !p_ctx->
enc_eos_sent[i])
2340 }
else if (p_enc_ctx_list[0].hw_action)
2365 return (
void *)(long)ret;
2375 int end_of_all_streams = 0;
2386 p_enc_recv_param->
p_file);
2387 for (i = 0; ret >= 0 && i < p_enc_recv_param->
output_total; i++)
2392 end_of_all_streams = 0;
2397 end_of_all_streams = 1;
2405 ni_log(
NI_LOG_INFO,
"Encoder %d stats: received %u packets, fps %.2f, total bytes %u\n",
2426 return (
void *)(long)ret;
@ XCODER_TEST_RECONF_LTR_INTERVAL_API
uint8_t use_long_term_ref
uint8_t ivf_header_written
@ NI_FRAME_AUX_DATA_MAX_FRAME_SIZE
int encoder_send_data(ni_demo_context_t *p_ctx, ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_in_data, void *yuv_buf, int input_video_width, int input_video_height, int is_last_input)
Send encoder input data, read from input file.
@ XCODER_TEST_RECONF_CRF_FLOAT
int encoder_reinit_session(ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_in_data, ni_session_data_io_t *p_out_data)
Reopen or reconfig encoder upon sequence change.
uint32_t av1_muxed_num_packets[MAX_OUTPUT_FILES]
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...
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE
void ni_hw_frame_ref(const niFrameSurface1_t *p_surface)
int ni_retrieve_xcoder_gop(char xcoderGop[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
Retrieve custom gop config values from –xcoder-gop.
void encoder_stat_report_and_close(ni_demo_context_t *p_ctx, ni_session_context_t *p_enc_ctx_list, int output_total)
struct _ni_encoder_change_params_t ni_encoder_change_params_t
This is a data structure for encoding parameters that have changed.
@ XCODER_TEST_RECONF_LTR_INTERVAL
@ XCODER_TEST_RECONF_FRAMERATE_API
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.
void ni_device_close(ni_device_handle_t device_handle)
Close device and release resources.
@ SESSION_RUN_STATE_FLUSHING
void * encoder_send_thread(void *args)
ni_retcode_t ni_force_idr_frame_type(ni_session_context_t *p_ctx)
Force next frame to be IDR frame during encoding.
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_API
void ni_hw_frame_unref(uint16_t hwframe_index)
uint8_t cll_data[NI_MAX_SEI_DATA]
ni_retcode_t ni_reconfig_intraprd(ni_session_context_t *p_ctx, int32_t intra_period)
Reconfigure intraPeriod dynamically during encoding.
ni_retcode_t ni_device_session_sequence_change(ni_session_context_t *p_ctx, int width, int height, int bit_depth_factor, ni_device_type_t device_type)
Send sequence change information to device.
ni_codec_format_t src_codec
@ XCODER_TEST_RECONF_SLICE_ARG
ni_retcode_t ni_encoder_sw_frame_buffer_alloc(bool planar, ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int alignment, int extra_len, bool alignment_2pass_wa)
This API is a wrapper for ni_encoder_frame_buffer_alloc(), used for planar pixel formats,...
ni_retcode_t ni_reconfig_framerate(ni_session_context_t *p_ctx, ni_framerate_t *framerate)
Reconfigure framerate dynamically during encoding.
#define NI_2PASS_ENCODE_MIN_WIDTH
#define NI_INVALID_SESSION_ID
int ni_retrieve_xcoder_params(char xcoderParams[], ni_xcoder_params_t *params, ni_session_context_t *ctx)
retrieve encoder config parameter values from –xcoder-params
void prep_reconf_demo_data(ni_demo_context_t *p_ctx, ni_session_context_t *p_enc_ctx, ni_frame_t *frame)
@ XCODER_TEST_RECONF_VUI_HRD
uint64_t ni_gettime_ns(void)
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.
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_REDUNDANT
uint32_t vui_num_units_in_tick
ni_retcode_t ni_set_frame_ref_invalid(ni_session_context_t *p_ctx, int32_t frame_num)
Set frame reference invalidation.
@ XCODER_TEST_RECONF_FRAMERATE
Audio/video related utility definitions.
#define NI_2PASS_ENCODE_MIN_HEIGHT
ni_retcode_t ni_reconfig_crf(ni_session_context_t *p_ctx, int32_t crf)
Reconfigure crf value dynamically during encoding.
@ XCODER_TEST_RECONF_INTRAPRD
ni_retcode_t ni_packet_buffer_free(ni_packet_t *p_packet)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc.
ni_device_handle_t blk_io_handle
ni_demo_context_t * p_ctx
uint8_t * p_av1_seq_header[MAX_OUTPUT_FILES]
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.
int enc_sos_sent[MAX_OUTPUT_FILES]
#define NI_MULTICORE_ENCODE_MIN_HEIGHT
@ NI_FRAME_AUX_DATA_SLICE_ARG
unsigned int sei_user_data_unreg_len
uint8_t * av1_p_data[MAX_AV1_ENCODER_GOP_NUM]
void ni_copy_hw_descriptors(uint8_t *p_dst[NI_MAX_NUM_DATA_POINTERS], uint8_t *p_src[NI_MAX_NUM_DATA_POINTERS])
Copy Descriptor data to Netint HW descriptor frame layout to be sent to encoder for encoding....
int encoder_sequence_change(ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_in_data, ni_session_data_io_t *p_out_data, int width, int height, ni_pix_fmt_t pix_fmt)
uint32_t av1_buffer_size[MAX_AV1_ENCODER_GOP_NUM]
unsigned int sei_total_len
ni_retcode_t ni_reconfig_vbv_value(ni_session_context_t *p_ctx, int32_t vbvMaxRate, int32_t vbvBufferSize)
Reconfigure vbv buffer size and vbv max rate dynamically during encoding.
int video_full_range_flag
uint16_t aspectRatioHeight
@ XCODER_TEST_INVALID_REF_FRAME
#define NI_TEST_RETCODE_NEXT_INPUT
uint32_t av1_data_len[MAX_AV1_ENCODER_GOP_NUM]
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_API_REDUNDANT
This is a data structure for encoding parameters that have changed.
int scan_and_clean_hwdescriptors(void)
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....
@ NI_FRAME_AUX_DATA_VBV_BUFFER_SIZE
ni_retcode_t ni_reconfig_crf2(ni_session_context_t *p_ctx, float crf)
Reconfigure crf float point value dynamically during encoding.
@ NI_FRAME_AUX_DATA_VBV_MAX_RATE
ni_demo_context_t * p_ctx
@ NI_SET_CHANGE_PARAM_VUI_HRD_PARAM
@ NI_FRAME_AUX_DATA_MAX_MIN_QP
@ SESSION_RUN_STATE_SEQ_CHANGE_DRAINING
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...
@ SESSION_RUN_STATE_NORMAL
ni_retcode_t ni_packet_buffer_alloc(ni_packet_t *p_packet, int packet_size)
Allocate memory for the packet buffer based on provided packet size.
bool frame_list_is_empty(ni_test_frame_list_t *list)
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.
uint8_t udu_data[NI_MAX_SEI_DATA]
ni_session_context_t * p_enc_ctx
#define NI_MULTICORE_ENCODE_MIN_WIDTH
#define NI_APP_ENC_FRAME_META_DATA_SIZE
@ XCODER_TEST_RECONF_BR_API
ni_pic_type_t ni_pict_type
#define NI_TEST_RETCODE_END_OF_STREAM
ni_encoder_cfg_params_t cfg_enc_params
@ XCODER_TEST_RECONF_INTRAPRD_API
uint32_t data_len[NI_MAX_NUM_DATA_POINTERS]
unsigned int extra_data_len
int enc_eos_sent[MAX_OUTPUT_FILES]
int enc_resend[MAX_OUTPUT_FILES]
ni_retcode_t ni_encoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height, ni_codec_format_t codec_format)
Initialize default encoder parameters.
int reconf_hash[NI_BITRATE_RECONFIG_FILE_MAX_LINES][NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE]
@ NI_FRAME_AUX_DATA_FRAMERATE
#define NI_TEST_RETCODE_EAGAIN
int encoder_open_session(ni_session_context_t *p_enc_ctx, int dst_codec_format, int iXcoderGUID, ni_xcoder_params_t *p_enc_params, int width, int height, ni_pix_fmt_t pix_fmt, bool check_zerocopy)
Encoder session open.
int encoder_receive(ni_demo_context_t *p_ctx, ni_session_context_t *enc_ctx_list, ni_session_data_io_t *in_frame, ni_session_data_io_t *pkt, int width, int height, int output_total, FILE **pfs_list)
struct timeval previous_time
#define NI_NUM_PIXEL_ASPECT_RATIO
int write_av1_ivf_trailer(ni_demo_context_t *p_ctx, ni_packet_t *p_out_pkt, uint32_t meta_size, FILE *p_file)
struct timeval current_time
#define NI_TEST_RETCODE_FAILURE
ni_device_handle_t device_handle
ni_encoder_change_params_t * enc_change_params
unsigned int sei_hdr_plus_len
@ XCODER_TEST_RECONF_SLICE_ARG_API
uint8_t * av1_p_buffer[MAX_AV1_ENCODER_GOP_NUM]
ni_pixel_planar_format get_pixel_planar(ni_pix_fmt_t pix_fmt)
uint8_t cc_data[NI_MAX_SEI_DATA]
void * encoder_receive_thread(void *args)
struct _ni_enc_quad_roi_custom_map::@6 field
int encoder_close_session(ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_in_data, ni_session_data_io_t *p_out_data)
encoder session close
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
ni_device_handle_t sender_handle
void set_demo_roi_map(ni_session_context_t *p_enc_ctx)
Set up hard coded demo ROI map.
#define NI_TEST_RETCODE_SUCCESS
uint64_t num_frames_sent[MAX_OUTPUT_FILES]
ni_session_context_t * p_enc_ctx
ni_retcode_t ni_reconfig_bitrate(ni_session_context_t *p_ctx, int32_t bitrate)
Reconfigure bitrate dynamically during encoding.
ni_retcode_t ni_packet_buffer_free_av1(ni_packet_t *p_packet)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc for AV1 packets merge.
void ni_usleep(int64_t usec)
#define NI_GET_MAX_HWDESC_FRAME_INDEX(x)
@ NI_PIXEL_PLANAR_FORMAT_SEMIPLANAR
ni_test_frame_list_t * frame_list
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP
ni_session_data_io_t frames[NI_MAX_BUFFERED_FRAME]
void write_av1_ivf_header(ni_demo_context_t *p_ctx, uint32_t width, uint32_t height, uint32_t frame_num, uint32_t frame_denom, FILE *p_file)
ni_enc_quad_roi_custom_map * roi_map
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
@ XCODER_TEST_RECONF_VBV_API
@ XCODER_TEST_FORCE_IDR_FRAME
#define NI_TEST_RETCODE_SEQ_CHANGE_DONE
int encoder_open(ni_session_context_t *enc_ctx_list, ni_xcoder_params_t *p_api_param_list, int output_total, char p_enc_conf_params[][2048], char p_enc_conf_gop[][2048], ni_frame_t *p_ni_frame, int width, int height, int fps_num, int fps_den, int bitrate, int codec_format, ni_pix_fmt_t pix_fmt, int aspect_ratio_idc, int xcoder_guid, niFrameSurface1_t *p_surface, int multi_thread, bool check_zerocopy)
#define NI_PARAM_AV1_ALIGN_WIDTH_HEIGHT
int ni_device_session_read(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data packet from decoder If ...
ni_retcode_t ni_frame_buffer_alloc_hwenc(ni_frame_t *p_frame, int video_width, int video_height, int extra_len)
Allocate memory for the hwDescriptor buffer based on provided parameters taking into account pic size...
#define NI_MAX_NUM_DATA_POINTERS
ni_retcode_t ni_device_session_restart(ni_session_context_t *p_ctx, int video_width, int video_height, ni_device_type_t device_type)
Send a restart command after flush command Only support Encoder now.
union _ni_session_data_io::@19 data
ni_retcode_t ni_device_session_open(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Open a new device session depending on the device_type parameter If device_type is NI_DEVICE_TYPE_DEC...
@ XCODER_TEST_RECONF_VUI_HRD_API
@ XCODER_TEST_RECONF_LONG_TERM_REF
ni_retcode_t ni_reconfig_max_frame_size(ni_session_context_t *p_ctx, int32_t max_frame_size)
Reconfigure maxFrameSize dynamically during encoding.
unsigned int sei_hdr_content_light_level_info_len
int frame_list_drain(ni_test_frame_list_t *list)
unsigned int sei_hdr_mastering_display_color_vol_len
int video_full_range_flag
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO_API
ni_retcode_t ni_reconfig_max_frame_size_ratio(ni_session_context_t *p_ctx, int32_t max_frame_size_ratio)
Reconfigure maxFrameSizeRatio dynamically during encoding.
ni_retcode_t ni_reconfig_vui(ni_session_context_t *p_ctx, ni_vui_hrd_t *vui)
Reconfigure VUI HRD dynamically during encoding.
@ XCODER_TEST_RECONF_LTR_API
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_API
uint64_t enc_total_bytes_sent[MAX_OUTPUT_FILES]
uint32_t av1_seq_header_len[MAX_OUTPUT_FILES]
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,
@ XCODER_TEST_CRF_FLOAT_API
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO
ni_retcode_t ni_set_ltr_interval(ni_session_context_t *p_ctx, int32_t ltr_interval)
Set Long Term Reference interval.
uint8_t mdcv_data[NI_MAX_SEI_DATA]
@ NI_FRAME_AUX_DATA_LTR_INTERVAL
void ni_get_hw_yuv420p_dim(int width, int height, int factor, int is_semiplanar, int plane_stride[NI_MAX_NUM_DATA_POINTERS], int plane_height[NI_MAX_NUM_DATA_POINTERS])
Get dimension information of Netint HW YUV420p frame to be sent to encoder for encoding....
#define MAX_AV1_ENCODER_GOP_NUM
ni_retcode_t ni_reconfig_min_max_qp(ni_session_context_t *p_ctx, ni_rc_min_max_qp *p_min_max_qp)
Reconfigure min&max qp dynamically during encoding.
uint64_t num_packets_received[MAX_OUTPUT_FILES]
@ NI_FRAME_AUX_DATA_LONG_TERM_REF
int encoder_receive_data(ni_demo_context_t *p_ctx, ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_out_data, int output_video_width, int output_video_height, FILE *p_file, ni_session_data_io_t *p_in_data)
Receive output data from encoder.
void write_av1_ivf_packet(ni_demo_context_t *p_ctx, ni_packet_t *p_out_pkt, uint32_t meta_size, FILE *p_file)
#define NI_MAX_FRAME_SIZE
ni_session_run_state_t session_run_state
uint8_t use_cur_src_as_long_term_pic
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...
int enc_eos_received[MAX_OUTPUT_FILES]
@ XCODER_TEST_INVALID_REF_FRAME_API
encoder AVC ROI custom map (1 MB = 8bits)
uint32_t meta_size
Params used in VFR mode Done///.
int32_t aspectRatioHeight
ni_test_frame_list_t * frame_list
@ SESSION_RUN_STATE_SEQ_CHANGE_OPENING
int encoder_send_data2(ni_demo_context_t *p_ctx, ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_dec_out_data, ni_session_data_io_t *p_enc_in_data, int input_video_width, int input_video_height)
@ NI_FRAME_AUX_DATA_CRF_FLOAT
#define ni_aligned_free(p_memptr)
ni_retcode_t ni_device_session_flush(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a flush command to the device If device_type is NI_DEVICE_TYPE_DECODER sends EOS command to deco...
uint8_t use_cur_src_as_long_term_pic
@ NI_FRAME_AUX_DATA_INVALID_REF_FRAME
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.
#define NI_FRAME_LITTLE_ENDIAN
uint8_t hdrp_data[NI_MAX_SEI_DATA]
uint64_t enc_total_bytes_received[MAX_OUTPUT_FILES]
uint16_t aspectRatioWidth
@ NI_FRAME_AUX_DATA_INTRAPRD
int color_transfer_characteristic
ni_retcode_t ni_device_session_close(ni_session_context_t *p_ctx, int eos_recieved, ni_device_type_t device_type)
Close device session that was previously opened by calling ni_device_session_open() If device_type is...
int encoder_send_data3(ni_demo_context_t *p_ctx, ni_session_context_t *p_enc_ctx, ni_session_data_io_t *p_in_data, int input_video_width, int input_video_height, int eos)
Send encoder input data, read from uploader instance hwframe.
ni_retcode_t ni_set_ltr(ni_session_context_t *p_ctx, ni_long_term_ref_t *ltr)
Set a frame's support of Long Term Reference frame during encoding.
ni_retcode_t ni_decoder_frame_buffer_free(ni_frame_t *p_frame)
Free decoder frame buffer that was previously allocated with ni_decoder_frame_buffer_alloc,...
ni_retcode_t ni_reconfig_slice_arg(ni_session_context_t *p_ctx, int16_t sliceArg)
Reconfigure sliceArg dynamically during encoding.
@ NI_FRAME_AUX_DATA_BITRATE
uint8_t use_long_term_ref
void ni_frame_wipe_aux_data(ni_frame_t *frame)
Free and remove all auxiliary data from the frame.