![]() |
libxcoder
3.5.1
|
NETINT audio/video related utility functions. More...
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include "ni_defs_logan.h"
#include "ni_util_logan.h"
#include "ni_nvme_logan.h"
#include "ni_bitstream_logan.h"
#include "ni_av_codec_logan.h"
Go to the source code of this file.
Macros | |
#define | BR_SHIFT 6 |
#define | CPB_SHIFT 4 |
#define | SAMPLE_SPS_MAX_SUB_LAYERS_MINUS1 0 |
#define | MAX_VPS_MAX_SUB_LAYERS 16 |
#define | MAX_CPB_COUNT 16 |
#define | MAX_DURATION 0.5 |
Enumerations | |
enum | slice_type_t { SLICE_TYPE_B = 0 , SLICE_TYPE_P = 1 , SLICE_TYPE_I = 2 , SLICE_TYPE_MP = 3 } |
enum | gop_preset_t { GOP_PRESET_CUSTOM = 0 , GOP_PRESET_I_1 = 1 , GOP_PRESET_P_1 = 2 , GOP_PRESET_B_1 = 3 , GOP_PRESET_BP_2 = 4 , GOP_PRESET_BBBP_3 = 5 , GOP_PRESET_LP_4 = 6 , GOP_PRESET_LD_4 = 7 , GOP_PRESET_RA_8 = 8 , GOP_PRESET_SP_1 = 9 , GOP_PRESET_BSP_2 = 10 , GOP_PRESET_BBBSP_3 = 11 , GOP_PRESET_LSP_4 = 12 , GOP_PRESET_BBP_3 = 13 , GOP_PRESET_BBSP_3 = 14 , GOP_PRESET_BBBBBBBP_8 = 15 , GOP_PRESET_BBBBBBBSP_8 = 16 , NUM_GOP_PRESET_NUM = 17 } |
Functions | |
int | ni_logan_should_send_sei_with_frame (ni_logan_session_context_t *p_enc_ctx, ni_logan_pic_type_t pic_type, ni_logan_encoder_params_t *p_param) |
Whether SEI (HDR) should be sent together with this frame to encoder. More... | |
void | ni_logan_set_vui (ni_logan_encoder_params_t *p_param, ni_logan_session_context_t *p_ctx, ni_color_primaries_t color_primaries, ni_color_transfer_characteristic_t color_trc, ni_color_space_t color_space, int video_full_range_flag, int sar_num, int sar_den, ni_logan_codec_format_t codec_format) |
Set SPS VUI part of encoded stream header. More... | |
void | ni_logan_reset_vui (ni_logan_encoder_params_t *p_param, ni_aux_data_t *aux_data, ni_logan_codec_format_t codec_format) |
Reset vui info from decoder. More... | |
uint32_t | ni_logan_enc_buffering_period_sei (ni_logan_encoder_params_t *p_param, ni_logan_session_context_t *p_ctx, uint32_t frame_idx, int buf_len, uint8_t *p_buf) |
Buffered period sei. More... | |
uint32_t | ni_logan_enc_buffering_custom_sei (void *p_data, ni_logan_session_context_t *p_ctx, uint32_t index) |
Buffered customer sei. More... | |
uint32_t | ni_logan_enc_pic_timing_sei2 (ni_logan_encoder_params_t *p_param, ni_logan_session_context_t *p_ctx, int is_i_or_idr, int is_idr, uint32_t frame_idx, int buf_len, uint8_t *p_buf) |
Generate pic timing sei2. More... | |
void | ni_logan_dec_retrieve_aux_data (ni_logan_frame_t *frame) |
Retrieve auxiliary data (close caption, various SEI) associated with this frame that is returned by decoder, convert them to appropriate format and save them in the frame's auxiliary data storage for future use by encoding. Usually they would be sent together with this frame to encoder at encoding. More... | |
void | ni_logan_enc_init_aux_params (ni_logan_session_data_io_t *p_api_fme) |
Initialize auxiliary data that should be sent together with this frame to encoder based on the auxiliary data of the decoded frame. More... | |
void | ni_logan_enc_prep_aux_data (ni_logan_session_context_t *p_enc_ctx, ni_logan_frame_t *p_enc_frame, ni_logan_frame_t *p_dec_frame, ni_logan_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 data of the decoded frame. More... | |
void | ni_logan_enc_copy_aux_data (ni_logan_session_context_t *p_enc_ctx, ni_logan_frame_t *p_enc_frame, ni_logan_frame_t *p_dec_frame, ni_logan_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) |
Copy auxiliary data that should be sent together with this frame to encoder. More... | |
int | ni_logan_enc_fill_reconfig_params (ni_logan_encoder_params_t *p_param, ni_logan_session_context_t *p_ctx, ni_logan_frame_t *p_api_fme, int reconfigCount) |
Fill reconfig params. More... | |
int | ni_logan_enc_fill_reconfig_vui (ni_logan_encoder_params_t *p_param, ni_logan_session_context_t *p_ctx, ni_logan_frame_t *p_api_fme, int reconfigCount, ni_aux_data_t *aux_data) |
Fill reconfig vui. More... | |
const uint8_t * | ni_logan_find_start_code (const uint8_t *p, const uint8_t *end, uint32_t *state) |
Find the next start code. More... | |
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 the standard protocol, which is added by customes, for example SEI type 100, note that custom SEI is not user data unregistered SEI. b. the SEI NAL location does not conform to protocol. It's after VCL NALs. So there are cases to handle here: case a: enable custom_sei, detext custom SEIs before VCL. case b: enable custom_sei and enable_check_packet, detect custom SEIs before VCL, and all SEIs after VCL. all of these SEIs are passthroughed in the same places after encoding. More... | |
void | ni_logan_enc_reconfig_vfr (ni_logan_session_context_t *p_session_ctx, ni_logan_encoder_params_t *p_encoder_params, ni_logan_frame_t *ni_frame, int64_t pts, uint32_t timebase) |
Fill reconfig vfr. More... | |
NETINT audio/video related utility functions.
Copyright (C) 2018 NETINT Technologies.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
Definition in file ni_av_codec_logan.c.
#define BR_SHIFT 6 |
Definition at line 392 of file ni_av_codec_logan.c.
#define CPB_SHIFT 4 |
Definition at line 393 of file ni_av_codec_logan.c.
#define MAX_CPB_COUNT 16 |
Definition at line 397 of file ni_av_codec_logan.c.
#define MAX_DURATION 0.5 |
Definition at line 398 of file ni_av_codec_logan.c.
#define MAX_VPS_MAX_SUB_LAYERS 16 |
Definition at line 396 of file ni_av_codec_logan.c.
#define SAMPLE_SPS_MAX_SUB_LAYERS_MINUS1 0 |
Definition at line 395 of file ni_av_codec_logan.c.
enum gop_preset_t |
Definition at line 41 of file ni_av_codec_logan.c.
enum slice_type_t |
Enumerator | |
---|---|
SLICE_TYPE_B | |
SLICE_TYPE_P | |
SLICE_TYPE_I | |
SLICE_TYPE_MP |
Definition at line 33 of file ni_av_codec_logan.c.
void ni_logan_dec_retrieve_aux_data | ( | ni_logan_frame_t * | frame | ) |
Retrieve auxiliary data (close caption, various SEI) associated with this frame that is returned by decoder, convert them to appropriate format and save them in the frame's auxiliary data storage for future use by encoding. Usually they would be sent together with this frame to encoder at encoding.
[in/out] | frame that is returned by decoder |
Definition at line 1405 of file ni_av_codec_logan.c.
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 the standard protocol, which is added by customes, for example SEI type 100, note that custom SEI is not user data unregistered SEI. b. the SEI NAL location does not conform to protocol. It's after VCL NALs. So there are cases to handle here: case a: enable custom_sei, detext custom SEIs before VCL. case b: enable custom_sei and enable_check_packet, detect custom SEIs before VCL, and all SEIs after VCL. all of these SEIs are passthroughed in the same places after encoding.
uint8_t | *data - packet data |
int | size - pkt data size |
ni_logan_session_context_t | *p_api_ctx - Netint session context |
ni_logan_decoder_params_t | *api_param - Netint xcoder params |
ni_logan_packet_t | *p_packet - netint internal packet |
Definition at line 3511 of file ni_av_codec_logan.c.
uint32_t ni_logan_enc_buffering_custom_sei | ( | void * | p_data, |
ni_logan_session_context_t * | p_ctx, | ||
uint32_t | index | ||
) |
Buffered customer sei.
[in] | p_data | input side data of customer sei |
[out] | p_ctx | session context, update its pkt_custom_sei. |
[in] | index | fifo index |
Definition at line 1170 of file ni_av_codec_logan.c.
uint32_t ni_logan_enc_buffering_period_sei | ( | ni_logan_encoder_params_t * | p_param, |
ni_logan_session_context_t * | p_ctx, | ||
uint32_t | frame_idx, | ||
int | buf_len, | ||
uint8_t * | p_buf | ||
) |
Buffered period sei.
[in/out] | p_param encoder parameters, its GOP information will be updated. | |
[in] | p_ctx | session context, use its HRD parameters (hrd_params). |
[in] | frame_idx | frame index |
[in] | buf_len | output buffer length |
[out] | p_buf | output sei buffer. |
Definition at line 1052 of file ni_av_codec_logan.c.
void ni_logan_enc_copy_aux_data | ( | ni_logan_session_context_t * | p_enc_ctx, |
ni_logan_frame_t * | p_enc_frame, | ||
ni_logan_frame_t * | p_dec_frame, | ||
ni_logan_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 | ||
) |
Copy auxiliary data that should be sent together with this frame to encoder.
[in] | p_enc_ctx | encoder session context |
[out] | p_enc_frame | frame to be sent to encoder |
[in] | p_dec_frame | frame returned by decoder |
[in] | mdcv_data | SEI for HDR mastering display color volume info |
[in] | cll_data | SEI for HDR content light level info |
[in] | cc_data | SEI for close caption |
[in] | udu_data | SEI for User data unregistered |
[in] | hdrp_data | SEI for HDR10+ |
Definition at line 2948 of file ni_av_codec_logan.c.
int ni_logan_enc_fill_reconfig_params | ( | ni_logan_encoder_params_t * | p_param, |
ni_logan_session_context_t * | p_ctx, | ||
ni_logan_frame_t * | p_api_fme, | ||
int | reconfigCount | ||
) |
Fill reconfig params.
[in] | p_param | encoder parameters. |
[in/out] | p_ctx session context, its enc_change_params may be updated. | |
[in/out] | p_api_fme extra_data_len and reconf_len may be updated | |
[in] | reconfigCount | reconfig count, may be updated. |
Definition at line 3084 of file ni_av_codec_logan.c.
int ni_logan_enc_fill_reconfig_vui | ( | ni_logan_encoder_params_t * | p_param, |
ni_logan_session_context_t * | p_ctx, | ||
ni_logan_frame_t * | p_api_fme, | ||
int | reconfigCount, | ||
ni_aux_data_t * | aux_data | ||
) |
Fill reconfig vui.
[in] | p_param | encoder parameters. |
[in/out] | p_ctx session context, its enc_change_params may be updated. | |
[in/out] | p_api_fme extra_data_len and reconf_len may be updated | |
[in] | reconfigCount | reconfig count, may be updated. |
[in] | aux_data | aux_data may be updated |
Definition at line 3290 of file ni_av_codec_logan.c.
void ni_logan_enc_init_aux_params | ( | ni_logan_session_data_io_t * | p_api_fme | ) |
Initialize auxiliary data that should be sent together with this frame to encoder based on the auxiliary data of the decoded frame.
[in/out] | ni_logan_session_data_io_t session data |
Definition at line 2084 of file ni_av_codec_logan.c.
uint32_t ni_logan_enc_pic_timing_sei2 | ( | ni_logan_encoder_params_t * | p_param, |
ni_logan_session_context_t * | p_ctx, | ||
int | is_i_or_idr, | ||
int | is_idr, | ||
uint32_t | frame_idx, | ||
int | buf_len, | ||
uint8_t * | p_buf | ||
) |
Generate pic timing sei2.
[in/out] | p_param encoder parameters, its GOP information will be updated. | |
[in/out] | p_ctx session context, its HRD parameters (hrd_params) may be updated. | |
[in] | is_i_or_idr | True if it is i or idr packet. |
[in] | is_idr | True if it is idr packet. |
[in] | frame_idx | frame index |
[in] | buf_len | output buffer length |
[out] | p_buf | output sei buffer. |
Definition at line 1297 of file ni_av_codec_logan.c.
void ni_logan_enc_prep_aux_data | ( | ni_logan_session_context_t * | p_enc_ctx, |
ni_logan_frame_t * | p_enc_frame, | ||
ni_logan_frame_t * | p_dec_frame, | ||
ni_logan_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 data of the decoded frame.
Note: Some of the SEI (e.g. HDR) will be updated and stored in encoder context whenever received through decoded frame; they will be sent out with the encoded frame to encoder only when appropriate, i.e. should_send_sei_with_frame is true. When a type of aux data is to be sent, its associated length will be set in the encoder frame.
[in/out] | p_enc_ctx encoder session contextwhose various SEI type header can be updated as the result of this function | |
[out] | p_enc_frame | frame to be sent to encoder |
[in] | p_dec_frame | frame that is returned by decoder |
[in] | codec_format | H.264 or H.265 |
[in] | should_send_sei_with_frame | if need to send a certain type of SEI with this frame |
[out] | mdcv_data | SEI for HDR mastering display color volume info |
[out] | cll_data | SEI for HDR content light level info |
[out] | cc_data | SEI for close caption |
[out] | udu_data | SEI for User data unregistered |
[out] | hdrp_data | SEI for HDR10+ |
Definition at line 2132 of file ni_av_codec_logan.c.
void ni_logan_enc_reconfig_vfr | ( | ni_logan_session_context_t * | p_session_ctx, |
ni_logan_encoder_params_t * | p_encoder_params, | ||
ni_logan_frame_t * | ni_frame, | ||
int64_t | pts, | ||
uint32_t | timebase | ||
) |
Fill reconfig vfr.
[in/out] | p_session_ctx session context, some parameters may be updated. | |
[in] | p_param | encoder parameters. |
[in/out] | ni_frame aux_data may be updated | |
[in] | pts | frame pts |
[in] | timebase | timebase |
Definition at line 3716 of file ni_av_codec_logan.c.
const uint8_t* ni_logan_find_start_code | ( | const uint8_t * | p, |
const uint8_t * | end, | ||
uint32_t * | state | ||
) |
Find the next start code.
[in] | p | pointer to buffer start address. |
[in] | end | pointer to buffer end address. |
[state] | state pointer to nalu type address |
Definition at line 3341 of file ni_av_codec_logan.c.
void ni_logan_reset_vui | ( | ni_logan_encoder_params_t * | p_param, |
ni_aux_data_t * | aux_data, | ||
ni_logan_codec_format_t | codec_format | ||
) |
Reset vui info from decoder.
[in] | p_param | encoder parameters. |
[in] | aux_data | aux_data may be updated |
[in] | codec_format | encoder format |
Definition at line 793 of file ni_av_codec_logan.c.
void ni_logan_set_vui | ( | ni_logan_encoder_params_t * | p_param, |
ni_logan_session_context_t * | p_ctx, | ||
ni_color_primaries_t | color_primaries, | ||
ni_color_transfer_characteristic_t | color_trc, | ||
ni_color_space_t | color_space, | ||
int | video_full_range_flag, | ||
int | sar_num, | ||
int | sar_den, | ||
ni_logan_codec_format_t | codec_format | ||
) |
Set SPS VUI part of encoded stream header.
[in/out] | p_param encoder parameters, its VUI data member will be updated. | |
[out] | p_ctx | session context, its HRD parameters (hrd_params) may be updated. |
[in] | color_primaries | color primaries |
[in] | color_trc | color transfer characteristic |
[in] | color_space | YUV colorspace type |
[in] | video_full_range_flag | |
[in] | sar_num/sar_den | sample aspect ration in numerator/denominator |
[in] | codec_format | H.264 or H.265 |
Definition at line 464 of file ni_av_codec_logan.c.
int ni_logan_should_send_sei_with_frame | ( | ni_logan_session_context_t * | p_enc_ctx, |
ni_logan_pic_type_t | pic_type, | ||
ni_logan_encoder_params_t * | p_param | ||
) |
Whether SEI (HDR) should be sent together with this frame to encoder.
Whether SEI should be sent together with this frame to encoder.
[in] | p_enc_ctx | encoder session context |
[in] | pic_type | frame type |
[in] | p_param | encoder parameters |
Definition at line 409 of file ni_av_codec_logan.c.