30 #define NI_LOGAN_DEC_PKT_BUF_NUM_MAX 300
55 __FUNCTION__, __LINE__, p_session_ctx);
154 "their load, and exit ...\n");
220 __FUNCTION__, __LINE__);
254 if (!p_param || !p_session_ctx)
257 __FUNCTION__, __LINE__, p_param, p_session_ctx);
280 if(xcoder_high_priority != 0)
336 "resource unavailable\n", ret);
340 "resource unavailable\n", ret);
373 if (NI_INVALID_DEVICE_HANDLE == p_session_ctx->
blk_io_handle ||
383 int pkt_flags, uint8_t *extradata,
int extradata_size)
386 const uint8_t *ptr = pkt_data;
387 const uint8_t *end = pkt_data + pkt_size;
389 uint8_t nalu_type = 0;
409 nalu_type = stc & 0x1F;
425 ni_dec_ctx->
extradata = malloc(extradata_size);
433 memcpy(ni_dec_ctx->
extradata, extradata, extradata_size);
442 if (7 == nalu_type || 8 == nalu_type)
447 ni_dec_ctx->
extradata = malloc(extradata_size);
456 __FUNCTION__, extradata_size);
457 memcpy(ni_dec_ctx->
extradata, extradata, extradata_size);
464 else if (nalu_type >= 1 && nalu_type <= 5)
473 nalu_type = (stc >> 1) & 0x3F;
489 ni_dec_ctx->
extradata = malloc(extradata_size);
498 __FUNCTION__, extradata_size);
499 memcpy(ni_dec_ctx->
extradata, extradata, extradata_size);
508 if (32 == nalu_type || 33 == nalu_type || 34 == nalu_type)
513 ni_dec_ctx->
extradata = malloc(extradata_size);
522 __FUNCTION__, extradata_size);
523 memcpy(ni_dec_ctx->
extradata, extradata, extradata_size);
530 else if (nalu_type >= 0 && nalu_type <= 31)
557 int pkt_sei_alone = 0;
560 int pkt_nal_bitmap = 0;
562 const uint8_t *ptr = pkt_data;
563 const uint8_t *end = pkt_data + pkt_size;
564 uint8_t nalu_type = 0;
570 return pkt_sei_alone;
580 while ((pkt_sei_alone || low_delay || chk_pkt) && ptr < end)
597 nalu_type = stc & 0x1F;
600 pkt_sei_alone = (pkt_sei_alone && 6 == nalu_type);
603 if (got_slice && (6 == nalu_type))
611 else if ((nalu_type >= 1) && (nalu_type <= 5))
646 "decoder low delay mode.\n", __FUNCTION__);
664 nalu_type = (stc >> 1) & 0x3F;
667 pkt_sei_alone = (pkt_sei_alone && (39 == nalu_type || 40 == nalu_type));
670 if (got_slice && (39 == nalu_type || 40 == nalu_type))
678 else if ((nalu_type >= 0) && (nalu_type <= 31))
721 "enable decoder low delay mode.\n", __FUNCTION__);
747 return pkt_sei_alone;
754 dst_pkt->
pts = src_pkt->
pts;
755 dst_pkt->
dts = src_pkt->
dts;
766 int pkt_size,
int pkt_flags,
long long pkt_pts,
767 long long pkt_dts,
int avctx_width,
int avctx_height,
768 uint8_t *extradata,
int extradata_size)
775 int need_draining = 0;
782 int extra_prev_size = 0;
789 "buffer until all output buffers have been released\n");
801 ni_log(
NI_LOG_DEBUG,
"Decoder is need_draining= %d , draining=%d,session_run_state=%d,eos=%d\n",
824 xpkt->
flags = pkt_flags;
833 if (extradata_size > 0 && extradata_size != ni_dec_ctx->
extradata_size &&
839 "supported: %d\n", __FUNCTION__, extradata_size,
845 __FUNCTION__, extradata_size);
846 p_session_ctx->
prev_size = extradata_size;
847 memcpy(p_session_ctx->
p_leftover, extradata, extradata_size);
857 "delay time %dms, pkt_nal_bitmap %d\n", __FUNCTION__,
875 __FUNCTION__, pkt_size);
907 if ((pkt_size + p_session_ctx->
prev_size) > 0)
928 " send_size=%d len_of_sei_after_slice=%d (end of stream)\n",
932 extra_prev_size = p_session_ctx->
prev_size;
937 ni_dec_ctx->
offset += pkt_size + extra_prev_size;
940 " send_size=%d xpkt->data_len=%d, len_of_sei_after_slice=%d (end of "
941 "stream)\n", pkt_size, p_session_ctx->
prev_size, send_size,
952 if (need_draining && !ni_dec_ctx->
draining)
1035 if (&(p_ni_packet->
data.
packet).data_len == 0)
1037 free(&(p_ni_packet->
data.
packet).p_all_custom_sei);
1038 (p_ni_packet->
data.
packet).p_all_custom_sei = NULL;
1112 if (&(p_ni_packet->
data.
packet).data_len == 0)
1114 free(&(p_ni_packet->
data.
packet).p_all_custom_sei);
1115 (p_ni_packet->
data.
packet).p_all_custom_sei = NULL;
1124 free(&(p_ni_packet->
data.
packet).p_all_custom_sei);
1125 (p_ni_packet->
data.
packet).p_all_custom_sei = NULL;
1127 ni_dec_ctx->
eos = 1;
1136 ni_dec_ctx->
eos = 0;
1163 int ret, width, height, alloc_mem;
1269 }
while(p_ni_packet);
1277 }
while(p_ni_packet);
const uint8_t * ni_logan_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
Find the next start code.
int ni_logan_detect_custom_sei(const uint8_t *data, int size, ni_logan_session_context_t *p_api_ctx, ni_logan_decoder_params_t *p_api_param, ni_logan_packet_t *p_packet)
detect custom SEI payload data in Packet data, custom SEI has two meanings: a. the SEI type is not in...
#define NI_LOGAN_NAL_PPS_BIT
#define NI_LOGAN_NAL_SPS_BIT
#define NI_LOGAN_NAL_VPS_BIT
#define NI_LOGAN_GENERATE_ALL_NAL_HEADER_BIT
#define NI_LOGAN_DEC_PKT_BUF_NUM_MAX
void ni_logan_decode_flush_buffers(ni_logan_dec_context_t *ni_dec_ctx)
decoder flush buffers
int ni_logan_xcoder_add_headers(ni_logan_dec_context_t *ni_dec_ctx, uint8_t *pkt_data, int pkt_size, int pkt_flags, uint8_t *extradata, int extradata_size)
int ni_logan_dec_receive(ni_logan_dec_context_t *ni_dec_ctx, ni_logan_session_data_io_t *p_session_data, int avctx_width, int avctx_height)
Receive decoded data from decoder, including ni_logan_dec_context_t,.
int ni_logan_dec_flush(ni_logan_dec_context_t *ni_dec_ctx)
void ni_logan_decoder_frame_free(ni_logan_session_data_io_t *p_session_data)
void ni_logan_buf_pool_free(void *opaque, uint8_t *data)
decoder frame buffer pool free, including void*
int ni_logan_dec_is_flushing(ni_logan_dec_context_t *ni_dec_ctx)
Decode is flushing or not, including ni_logan_dec_context_t,.
void ni_logan_dec_close(ni_logan_dec_context_t *ni_dec_ctx)
Decode close, including ni_logan_dec_context_t,.
int ni_logan_setup_decoder(ni_logan_dec_context_t *ni_dec_ctx)
Initialize init device session_context and init default params including ni_logan_dec_context_t,...
int ni_logan_dec_reinit(ni_logan_dec_context_t *ni_dec_ctx)
int ni_logan_decode_reset(ni_logan_dec_context_t *ni_dec_ctx)
int ni_logan_decoder_frame_alloc(ni_logan_dec_context_t *ni_dec_ctx, ni_logan_session_data_io_t *p_session_data, int avctx_width, int avctx_height)
int ni_logan_packet_buffer_clone(ni_logan_packet_t *dst_pkt, ni_logan_packet_t *src_pkt)
int ni_logan_packet_parse(ni_logan_dec_context_t *ni_dec_ctx, uint8_t *pkt_data, int pkt_size, ni_logan_packet_t *p_packet)
int ni_logan_dec_init(ni_logan_dec_context_t *ni_dec_ctx)
Initialize decode parameters and open decoder device including ni_logan_dec_context_t,...
int ni_logan_dec_send(ni_logan_dec_context_t *ni_dec_ctx, uint8_t *pkt_data, int pkt_size, int pkt_flags, long long pkt_pts, long long pkt_dts, int avctx_width, int avctx_height, uint8_t *extradata, int extradata_size)
Parse the packet and send the packet to decode device.
int ni_logan_xcoder_dec_close(ni_logan_dec_context_t *ni_dec_ctx)
@ NI_LOGAN_DECODE_FLUSH_STATUS_FLUSHING
@ NI_LOGAN_DECODE_FLUSH_STATUS_START
@ NI_LOGAN_DECODE_FLUSH_STATUS_OFF
@ NI_LOGAN_RETCODE_INVALID_PARAM
@ NI_LOGAN_RETCODE_ERROR_MEM_ALOC
@ NI_LOGAN_RETCODE_ERROR_VPU_RECOVERY
@ NI_LOGAN_RETCODE_SUCCESS
@ NI_LOGAN_RETCODE_FAILURE
#define NI_LOGAN_INVALID_SEI_TYPE
#define NI_LOGAN_POLL_INTERVAL
@ NI_LOGAN_DEVICE_TYPE_DECODER
@ NI_LOGAN_DECODE_FLUSH_BUFFER_OFF
ni_logan_retcode_t ni_logan_packet_buffer_alloc(ni_logan_packet_t *p_packet, int packet_size)
Allocate memory for the packet buffer based on provided packet size.
ni_logan_retcode_t ni_logan_device_session_flush(ni_logan_session_context_t *p_ctx, ni_logan_device_type_t device_type)
Sends a flush command to the device ni_logan_device_session_open() If device_type is NI_LOGAN_DEVICE_...
ni_logan_retcode_t ni_logan_device_session_close(ni_logan_session_context_t *p_ctx, int eos_recieved, ni_logan_device_type_t device_type)
Closes device session that was previously opened by calling ni_logan_device_session_open() If device_...
ni_logan_retcode_t ni_logan_packet_buffer_free(ni_logan_packet_t *p_packet)
Free packet buffer that was previously allocated with either ni_logan_packet_buffer_alloc.
ni_logan_retcode_t ni_logan_decoder_frame_buffer_alloc(ni_logan_buf_pool_t *p_pool, ni_logan_frame_t *p_frame, int alloc_mem, int video_width, int video_height, int alignment, int factor)
Allocate memory for decoder frame buffer based on provided parameters; the memory is retrieved from a...
ni_logan_retcode_t ni_logan_decoder_frame_buffer_free(ni_logan_frame_t *p_frame)
Free decoder frame buffer that was previously allocated with ni_logan_decoder_frame_buffer_alloc,...
void ni_logan_device_session_context_init(ni_logan_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
int ni_logan_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 allighment.
int ni_logan_device_session_read(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_data, ni_logan_device_type_t device_type)
Reads data the device If device_type is NI_LOGAN_DEVICE_TYPE_DECODER reads data packet from decoder I...
void ni_logan_device_session_context_clear(ni_logan_session_context_t *p_ctx)
Clear already allocated session context to all zeros.
ni_logan_retcode_t ni_logan_device_session_open(ni_logan_session_context_t *p_ctx, ni_logan_device_type_t device_type)
Opens a new device session depending on the device_type parameter If device_type is NI_LOGAN_DEVICE_T...
int ni_logan_device_session_write(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_data, ni_logan_device_type_t device_type)
Sends data the device If device_type is NI_LOGAN_DEVICE_TYPE_DECODER sends data packet to decoder If ...
void ni_logan_device_close(ni_device_handle_t device_handle)
Closes device and releases resources.
ni_logan_retcode_t ni_logan_decoder_init_default_params(ni_logan_decoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default decoder parameters.
void ni_logan_decoder_frame_buffer_pool_return_buf(ni_logan_buf_t *buf, ni_logan_buf_pool_t *p_buffer_pool)
Return a memory buffer to memory buffer pool.
#define BEST_MODEL_LOAD_STR
#define NI_LOGAN_MAX_RESOLUTION_HEIGHT
#define NI_LOGAN_MAX_SEI_DATA
#define NI_LOGAN_DEFAULT_KEEP_ALIVE_TIMEOUT
@ LOGAN_SESSION_RUN_STATE_RESETTING
@ LOGAN_SESSION_RUN_STATE_NORMAL
@ NI_LOGAN_CODEC_FORMAT_H265
@ NI_LOGAN_CODEC_FORMAT_H264
#define NI_LOGAN_MAX_RESOLUTION_AREA
#define NI_LOGAN_MAX_RESOLUTION_WIDTH
ni_logan_retcode_t ni_logan_decoder_session_flush_buffers(ni_logan_session_context_t *p_ctx)
Flush decoder output.
ni_log_level_t ff_to_ni_log_level(int fflog_level)
Convert ffmpeg log level integer to appropriate ni_log_level_t.
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
LIB_API void ni_logan_rsrc_print_all_devices_capability(void)
Print detailed capability information of all devices on the system.
uint8_t * ni_logan_fifo_generic_read(ni_logan_fifo_buffer_t *p_fifo)
Get first filled buffer to read in the fifo.
uint8_t * ni_logan_fifo_generic_write(ni_logan_fifo_buffer_t *p_fifo)
Get free buffer to write in the fifo.
int ni_logan_fifo_return_read(ni_logan_fifo_buffer_t *p_fifo)
Push back the last read buffer to the fifo.
int ni_logan_fifo_is_empty(ni_logan_fifo_buffer_t *p_fifo)
Check if a fifo is empty.
int ni_logan_fifo_is_full(ni_logan_fifo_buffer_t *p_fifo)
Check if a fifo is full.
ni_logan_fifo_buffer_t * ni_logan_fifo_initialize(uint32_t number_of_buffers, uint32_t size)
Initialize a fifo buffer.
void ni_logan_fifo_free(ni_logan_fifo_buffer_t *p_fifo)
Free a fifo.
struct _ni_logan_buf_pool_t * pool
int enable_user_data_sei_passthru
ni_logan_fifo_buffer_t * input_data_fifo
unsigned long long offset
ni_logan_packet_t seq_hdr_pkt
ni_logan_decoder_input_params_t dec_input_params
uint32_t number_of_buffers_used
ni_logan_all_custom_sei_t * p_all_custom_sei
uint32_t set_high_priority
uint32_t keep_alive_timeout
uint8_t buf_lone_sei[NI_LOGAN_MAX_SEI_DATA]
ni_device_handle_t device_handle
ni_logan_session_run_state_t session_run_state
char blk_xcoder_name[LOGAN_MAX_CHAR_IN_DEVICE_NAME]
ni_device_handle_t blk_io_handle
uint32_t max_nvme_io_size
ni_logan_buf_pool_t * dec_fme_buf_pool
char dev_xcoder[LOGAN_MAX_CHAR_IN_DEVICE_NAME]
uint32_t active_video_width
uint32_t active_video_height
char dev_xcoder_name[LOGAN_MAX_CHAR_IN_DEVICE_NAME]
union _ni_logan_session_data_io::@4 data