 |
libxcoder
5.2.0
|
Go to the documentation of this file.
37 #define USER_DATA_UNREGISTERED_SEI_PAYLOAD_TYPE 5
38 #define NI_DEC_PKT_BUF_NUM_MAX 300
41 static void ni_quadra_xcoder_strncpy(
char *dst,
const char *src,
int max)
43 if (dst && src && max)
46 strncpy(dst, src, max);
47 *(dst + max - 1) =
'\0';
71 "Recycle trace ui16FrameIdx = [%d] DevHandle %d\n",
77 "ERROR Failed to recycle trace ui16frameidx = [%d] "
104 "Failed to close Decode Session (status = %d)\n", ret);
117 "File BLK handle %d close suspended to frames Uninit\n",
145 }
while (p_ni_packet);
154 }
while (p_ni_packet);
173 free(p_session_data);
177 free(p_session_data1);
181 free(p_session_data2);
193 int min_resolution_width, min_resolution_height;
201 "ERROR %d:%s() line %d, alloc p_session_data failed\n",
NI_ERRNO,
202 __FUNCTION__, __LINE__);
210 if (!p_session_data1)
213 "ERROR %d:%s() line %d, alloc p_session_data failed\n",
NI_ERRNO,
214 __FUNCTION__, __LINE__);
222 if (!p_session_data2)
225 "ERROR %d:%s() line %d, alloc p_session_data failed\n",
NI_ERRNO,
226 __FUNCTION__, __LINE__);
238 "ERROR %d:%s() line %d, alloc session context failed\n",
244 ni_dec_ctx->
api_ctx = p_session_ctx;
275 }
else if (ni_dec_ctx->
width < min_resolution_width ||
276 ni_dec_ctx->
height < min_resolution_height)
281 min_resolution_width, min_resolution_height);
300 "ERROR %d:%s() line %d, alloc session context failed\n",
325 "%s(): line %d initialize enc frame buffer pool failed\n",
326 __FUNCTION__, __LINE__);
339 free(p_session_data);
341 free(p_session_data1);
343 free(p_session_data2);
362 p_session_ctx = ni_dec_ctx->
api_ctx;
363 if (!p_param || !p_session_ctx)
366 __FUNCTION__, __LINE__, p_param, p_session_ctx);
400 "is cancelled due to has_b_frames with enable_low_delay_check\n");
429 "api_ctx %p api_ctx/s: user_data_sei_passthru = %d/%d, custom_sei = "
462 "Failed to open decoder (status = %d), "
463 "resource unavailable\n",
472 "XCoder %s Index %d (inst: %d) opened successfully\n",
520 }
while (p_ni_packet);
529 }
while (p_ni_packet);
545 const uint8_t *data,
int size, uint8_t *extradata,
549 int vps_num, sps_num, pps_num;
552 if (!(pkt_flag &
NI_PKT_FLAG_KEY) || !data || !extradata || !extradata_size)
558 memcmp(ni_dec_ctx->
extradata, extradata, extradata_size) == 0)
577 ni_dec_ctx->
extradata = malloc(extradata_size);
584 memcpy(ni_dec_ctx->
extradata, extradata, extradata_size);
590 vps_num = sps_num = pps_num = 0;
596 const uint8_t *ptr = ni_dec_ctx->
extradata;
611 nalu_type = (int)stc & 0x1f;
616 }
else if(8 == nalu_type)
620 #define H264_MAX_SPS_COUNT 32
621 #define H264_MAX_PPS_COUNT 256
631 nalu_type = (int)(stc >> 1) & 0x3F;
636 }
else if (33 == nalu_type)
639 }
else if(34 == nalu_type)
644 #define HEVC_MAX_VPS_COUNT 16
645 #define HEVC_MAX_SPS_COUNT 16
646 #define HEVC_MAX_PPS_COUNT 64
663 uint8_t *data,
int pkt_size,
664 uint8_t *lonedata,
int lone_size, int64_t pkt_pts,
665 int64_t pkt_dts,
int pkt_pos,
int width,
int height,
666 uint8_t *extradata,
int extradata_size)
672 int need_draining = 0;
679 int extra_prev_size = 0;
687 "Decoder is flushing and cannot accept new "
688 "buffer until all output buffers have been released\n");
719 xpkt->
flags = pkt_flags;
732 extradata, extradata_size))
737 "ff_xcoder_dec_send extradata_size %d "
738 "exceeding max size supported: %d\n",
743 "ff_xcoder_dec_send extradata_size %d "
744 "copied to pkt start.\n",
775 if (svct_skip_packet)
778 "ff_xcoder_dec_send packet: pts:%" PRIi64
","
804 "%s got first IDR in decoder low delay mode, "
805 "delay time %dms, pkt_nal_bitmap %d\n",
810 __FUNCTION__, pkt_size);
817 __FUNCTION__, lone_size);
820 lonedata, lone_size);
834 ppu_config.
ppu_w[idx] =
836 ppu_config.
ppu_h[idx] =
849 if ((pkt_size + p_session_ctx->
prev_size) > 0)
871 "ni_packet_copy before: size=%d, s->prev_size=%d, send_size=%d, "
873 pkt_size, p_session_ctx->
prev_size, send_size);
876 extra_prev_size = p_session_ctx->
prev_size;
881 xpkt->
pos = (
long long)ni_dec_ctx->
offset;
882 ni_dec_ctx->
offset += pkt_size + extra_prev_size;
885 "ni_packet_copy after: size=%d, s->prev_size=%d, send_size=%d, "
886 "xpkt->data_len=%d (end of stream)\n",
898 if (need_draining && !ni_dec_ctx->
draining)
923 "dec_send EAGAIN this better not happen "
933 "Failed to send eos signal (status = %d)\n", sent);
953 free((p_ni_packet->
data.
packet).p_custom_sei_set);
954 (p_ni_packet->
data.
packet).p_custom_sei_set = NULL;
993 }
else if (sent == 0)
1004 if ((p_ni_packet->
data.
packet).data_len == 0)
1006 free((p_ni_packet->
data.
packet).p_custom_sei_set);
1007 (p_ni_packet->
data.
packet).p_custom_sei_set = NULL;
1021 ni_dec_ctx->
eos = 1;
1052 uint8_t *dst_data,
int type,
int size)
1058 memcpy(dst_data, aux->
data, size);
1066 "Got output buffer pts=%lld "
1067 "dts=%lld eos=%d sos=%d\n",
1118 int avctx_height,
int frame_planar)
1122 int retry_read_cnt = 0;
1123 int fifo_flush_cnt = 0;
1125 int height, actual_width, alloc_mem;
1140 "ff_xcoder_dec_receive burst return%" PRId64
" frame\n",
1166 alloc_mem, actual_width, height,
1172 &(p_session_data->
data.
frame), actual_width, height,
1197 diff < p_session_ctx->pkt_delay_cnt &&
1213 if ((p_ni_packet->
data.
packet).data_len == 0)
1215 free((p_ni_packet->
data.
packet).p_custom_sei_set);
1216 (p_ni_packet->
data.
packet).p_custom_sei_set = NULL;
1220 }
else if (sent == 0) {
1249 if (fifo_flush_cnt > 0 &&
1250 retry_read_cnt < 1 &&
1318 "ff_xcoder_dec_receive: resolution "
1319 "changed: %dx%d to %dx%d\n",
1329 (frame_planar == 0) ?
1331 (frame_planar == 2) ?
"tiled" :
"planar");
1356 0, 1, 1, frame_planar);
1367 "ni_quadra_dec_receive VPU recovery, need to reset ..\n");
1386 #ifdef MEASURE_LATENCY
1398 ni_dec_ctx->
eos = 0;
1420 const char *
name,
char *value)
1482 if (pdec_param->
cr_expr[i][0][0] && pdec_param->
cr_expr[i][1][0])
1489 if (pdec_param->
cr_expr[i][2][0])
1494 if (pdec_param->
cr_expr[i][3][0])
1499 if (pdec_param->
sc_expr[i][0][0] && pdec_param->
sc_expr[i][1][0])
1505 }
else if (type == 2)
1513 for (j = 0; j < 4; j++)
1518 "Setting crop parameters without "
1519 "setting crop mode to manual?\n");
1533 void *p_session_data)
@ NI_RETCODE_ERROR_VPU_RECOVERY
unsigned long long offset
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.
int ni_quadra_symbolic_decoder_param(ni_quadra_dec_context_t *ni_dec_ctx, int type)
sync ni_decoder_input_params_t and ni_xcoder_params_t
#define NI_MAX_RESOLUTION_HEIGHT
ni_log_level_t ff_to_ni_log_level(int fflog_level)
Convert ffmpeg log level integer to appropriate ni_log_level_t.
ni_custom_sei_set_t * p_custom_sei_set
#define NI_GENERATE_ALL_NAL_HEADER_BIT
#define NI_MIN_RESOLUTION_WIDTH
Utility definitions to operate on bits in a bitstream.
ni_fifo_buffer_t * input_data_fifo
ni_retcode_t ni_frame_buffer_free(ni_frame_t *p_frame)
Free frame buffer that was previously allocated with either ni_frame_buffer_alloc or ni_encoder_frame...
#define NI_DEC_PKT_BUF_NUM_MAX
unsigned int sei_hdr_mastering_display_color_vol_len
unsigned int sei_hdr_content_light_level_info_offset
ni_quadra_frame_t niframe
@ NI_QUADRA_ERROR_VPU_RECOVERY
#define NI_MIN_RESOLUTION_WIDTH_JPEG
int ni_quadra_dec_init(ni_quadra_dec_context_t *ni_dec_ctx)
Initialize decode parameters and open decoder device including ni_quadra_dec_context_t,...
char dev_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
#define H264_MAX_SPS_COUNT
void ni_device_close(ni_device_handle_t device_handle)
Close device and release resources.
uint8_t * ni_fifo_generic_write(ni_fifo_buffer_t *p_fifo)
Get free buffer to write in the fifo.
u_int32_t ui32FramesCorrupted
int ni_fifo_return_read(ni_fifo_buffer_t *p_fifo)
Push back the last read buffer to the fifo.
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...
void ni_quadra_dec_close(ni_quadra_dec_context_t *ni_dec_ctx)
Decode close, including ni_quadra_dec_context_t,.
uint32_t active_video_width
uint8_t * ni_fifo_generic_read(ni_fifo_buffer_t *p_fifo)
Get first filled buffer to read in the fifo.
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
uint32_t actual_video_width
uint64_t ni_gettime_ns(void)
uint8_t * ni_quadra_dec_frame_buffer_alloc(ni_quadra_dec_context_t *ni_dec_ctx, void *p_session_data)
alloc session p_data
uint32_t vui_num_units_in_tick
Public definitions for managing NETINT video processing devices.
Audio/video related utility definitions.
void ni_quadra_frame_copy_aux_data(ni_quadra_dec_context_t *ni_dec_ctx, uint8_t *dst_data, int type, int size)
Retrieve from the frame auxiliary data of a given type if exists.
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
unsigned int sei_user_data_unreg_len
uint32_t ui32FramesCorrupted
unsigned int sei_user_data_unreg_len
void ni_quadra_frame_free(void *opaque, uint8_t *data)
frame free, including void*
@ NI_RETCODE_INVALID_PARAM
#define NI_DEFAULT_KEEP_ALIVE_TIMEOUT
uint32_t active_video_width
int ni_fifo_is_empty(ni_fifo_buffer_t *p_fifo)
Check if a fifo is empty.
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...
uint16_t ppu_w[NI_MAX_NUM_OF_DECODER_OUTPUTS]
@ NI_RETCODE_ERROR_MEM_ALOC
@ SESSION_RUN_STATE_NORMAL
int ni_quadra_dec_flush(ni_quadra_dec_context_t *ni_dec_ctx)
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.
uint32_t number_of_buffers_used
@ NI_RETCODE_PARAM_INVALID_VALUE
unsigned int sei_hdr_mastering_display_color_vol_offset
unsigned int sei_cc_offset
unsigned int sei_cc_offset
uint32_t vui_num_units_in_tick
#define HEVC_MAX_SPS_COUNT
void ni_quadra_dec_wipe_aux_data(ni_quadra_dec_context_t *ni_dec_ctx)
Free and remove all auxiliary data from the ni_dec_ctx frame.
unsigned int sei_hdr_mastering_display_color_vol_offset
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_pic_type_t ni_pict_type
#define NI_MAX_RESOLUTION_WIDTH
Common NETINT definitions used by all modules.
uint32_t data_len[NI_MAX_NUM_DATA_POINTERS]
uint8_t * p_data[NI_QUADRA_MAX_NUM_DATA_POINTERS]
struct _ni_buf_pool_t * pool
#define NI_MIN_RESOLUTION_HEIGHT_JPEG
@ NI_RETCODE_ERROR_NVME_CMD_FAILED
uint32_t active_video_height
ni_device_handle_t device_handle
int enable_low_delay_check
ni_buf_pool_t * dec_fme_buf_pool
void ni_quadra_dec_aux_data(ni_quadra_dec_context_t *ni_dec_ctx)
ni_retcode_t ni_decoder_params_set_value(ni_xcoder_params_t *p_params, const char *name, char *value)
Set value referenced by name in decoder parameters structure.
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.
const uint8_t * ni_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
Find the next start code.
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
#define NI_XCODER_REVISION_API_MAJOR_VER_IDX
int svct_skip_next_packet
uint32_t keep_alive_timeout
void ni_usleep(int64_t usec)
int ni_packet_copy(void *p_destination, const void *const p_source, int cur_size, void *p_leftover, int *p_prev_size)
Copy video packet accounting for alignment.
void ni_quadra_frame_sync(ni_quadra_dec_context_t *ni_dec_ctx)
@ NI_RETCODE_PARAM_WARNING_DEPRECATED
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...
void ni_device_session_context_clear(ni_session_context_t *p_ctx)
Clear already allocated session context.
int ni_quadra_frame_get_aux_size(ni_quadra_dec_context_t *ni_dec_ctx, int type)
get size from the frame auxiliary data of a given type if exists
@ NI_RETCODE_PARAM_ERROR_TOO_BIG
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
ni_fifo_buffer_t * ni_fifo_initialize(uint32_t number_of_buffers, uint32_t size)
Initialize a fifo buffer.
ni_retcode_t ni_decoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default decoder parameters.
int ni_fifo_is_full(ni_fifo_buffer_t *p_fifo)
Check if a fifo is full.
unsigned int sei_hdr_content_light_level_info_len
uint32_t ni_fifo_number_of_buffers(ni_fifo_buffer_t *p_fifo)
Get number of buffers used in fifo.
int ni_device_session_read(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data packet from decoder If ...
#define NI_MAX_DEVICE_NAME_LEN
#define HEVC_MAX_VPS_COUNT
#define NI_PKT_FLAG_KEY
The packet contains a keyframe.
union _ni_session_data_io::@19 data
char blk_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
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...
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.
@ NI_RETCODE_ERROR_INVALID_SESSION
@ NI_QUADRA_ERROR_INVALID_SESSION
unsigned int sei_hdr_content_light_level_info_len
@ SESSION_RUN_STATE_RESETTING
#define USER_DATA_UNREGISTERED_SEI_PAYLOAD_TYPE
unsigned int sei_hdr_mastering_display_color_vol_len
int video_full_range_flag
#define NI_MAX_PPU_PARAM_EXPR_CHAR
#define NI_MAX_NUM_OF_DECODER_OUTPUTS
int ni_quadra_dec_receive(ni_quadra_dec_context_t *ni_dec_ctx, int avctx_width, int avctx_height, int frame_planar)
Receive decoded data from decoder, including ni_quadra_dec_context_t,.
uint16_t ppu_w[NI_QUADRA_MAX_NUM_OF_DECODER_OUTPUTS]
int ni_quadra_dec_is_flushing(ni_quadra_dec_context_t *ni_dec_ctx)
Decode is flushing or not, including ni_quadra_dec_context_t,.
ni_quadra_ppu_config_t ni_quadra_ppu_config
uint16_t ppu_h[NI_QUADRA_MAX_NUM_OF_DECODER_OUTPUTS]
uint32_t ui32FramesDropped
uint8_t video_full_range_flag
@ NI_QUADRA_PARAM_WARNING_DEPRECATED
@ NI_RETCODE_PARAM_INVALID_NAME
int ni_quadra_add_headers(ni_quadra_dec_context_t *ni_dec_ctx, int pkt_flag, const uint8_t *data, int size, uint8_t *extradata, int extradata_size)
unsigned int sei_user_data_unreg_offset
void ni_quadra_align_free(void *opaque, uint8_t *data)
buffer free, including void*
NETINT decoder API header file.
uint32_t active_video_height
uint16_t ppu_h[NI_MAX_NUM_OF_DECODER_OUTPUTS]
void ni_fifo_free(ni_fifo_buffer_t *p_fifo)
Free a fifo.
ni_dec_input_params_t niparam
#define HEVC_MAX_PPS_COUNT
int enable_user_data_sei_passthru
int ni_quadra_dec_params_set_value(ni_quadra_dec_context_t *ni_dec_ctx, const char *name, char *value)
Set value referenced by name in decoder parameters structure.
char blk_dev_name[NI_MAX_DEVICE_NAME_LEN]
ni_session_run_state_t session_run_state
int enable_low_delay_check
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.
ni_retcode_t ni_hwframe_buffer_recycle(niFrameSurface1_t *surface, int32_t device_handle)
Recycle a frame buffer on card.
uint32_t max_nvme_io_size
int enable_user_data_sei_passthru
uint16_t out_enabled[NI_QUADRA_MAX_NUM_OF_DECODER_OUTPUTS]
@ NI_RETCODE_PARAM_ERROR_TOO_SMALL
int ni_device_session_read_hwdesc(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Read data from the device If device_type is NI_DEVICE_TYPE_DECODER reads data hwdesc from decoder If ...
int ni_quadra_setup_decoder(ni_quadra_dec_context_t *ni_dec_ctx)
Initialize init device session_context and init default params including ni_quadra_dec_context_t,...
#define ni_aligned_free(p_memptr)
#define NI_MIN_RESOLUTION_HEIGHT
ni_retcode_t ni_device_session_flush(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a flush command to the device If device_type is NI_DEVICE_TYPE_DECODER sends EOS command to deco...
@ NI_RETCODE_PARAM_ERROR_ZERO
int ni_quadra_dec_send(ni_quadra_dec_context_t *ni_dec_ctx, int pkt_flags, uint8_t *data, int pkt_size, uint8_t *lonedata, int lone_size, int64_t pkt_pts, int64_t pkt_dts, int pkt_pos, int width, int height, uint8_t *extradata, int extradata_size)
Parse the packet and send the packet to decode device.
@ NI_RETCODE_PARAM_ERROR_OOR
ni_retcode_t ni_device_session_context_init(ni_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
#define MAX_CHAR_IN_DEVICE_NAME
unsigned int sei_hdr_content_light_level_info_offset
void ni_decoder_frame_buffer_pool_return_buf(ni_buf_t *buf, ni_buf_pool_t *p_buffer_pool)
Return a memory buffer to memory buffer pool.
ni_decoder_input_params_t dec_input_params
int ni_quadra_dec_reset(ni_quadra_dec_context_t *ni_dec_ctx)
unsigned int sei_user_data_unreg_offset
#define H264_MAX_PPS_COUNT
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...
ni_custom_sei_set_t * p_custom_sei_set
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,...
#define NI_MAX_RESOLUTION_AREA
uint32_t data_len[NI_QUADRA_MAX_NUM_DATA_POINTERS]
ni_session_statistic_t session_statistic
void ni_frame_wipe_aux_data(ni_frame_t *frame)
Free and remove all auxiliary data from the frame.