35 if (!params || !name || !value)
41 if (!strcmp(
"width", name))
48 }
else if (!strcmp(
"height", name))
55 }
else if (!strcmp(
"format", name))
57 if (!strcmp(value,
"yuv420p"))
60 }
else if (!strcmp(value,
"yuv420p10le"))
63 }
else if (!strcmp(value,
"nv12"))
66 }
else if (!strcmp(value,
"p010le"))
85 if (!params || !name || !value)
91 if (!strcmp(
"width", name))
98 }
else if (!strcmp(
"height", name))
105 }
else if (!strcmp(
"x", name))
112 }
else if (!strcmp(
"y", name))
130 if (!params || !name || !value)
136 if (!strcmp(
"nb", name))
139 }
else if (!strcmp(
"width", name))
146 }
else if (!strcmp(
"height", name))
165 char key[256], value[256];
166 char *curr = filter_params, *colon_pos;
175 if (strncmp(
"ni_quadra_scale", curr, 15) == 0)
180 else if (strncmp(
"ni_quadra_drawbox", curr, 17) == 0)
185 else if (strncmp(
"ni_quadra_ai_pre", curr, 16) == 0)
192 ni_log(
NI_LOG_ERROR,
"Error: invalid filter, must be one of [ni_quadra_scale, ni_quadra_drawbox, ni_quadra_ai_pre]");
198 colon_pos = strchr(curr,
':');
205 if (strlen(curr) >
sizeof(key) +
sizeof(value) - 1 ||
208 ni_log(
NI_LOG_ERROR,
"Error: cannot retrieve key/value from filter param: %s\n", curr);
216 }
else if (ai_pre_params->
enabled)
230 curr = colon_pos + 1;
233 curr += strlen(curr);
247 int in_rec_height,
int in_rec_x,
int in_rec_y,
int out_rec_x,
int out_rec_y)
249 p_scaler_params->
op = op;
263 p_scaler_params->
in_rec_x = in_rec_x;
264 p_scaler_params->
in_rec_y = in_rec_y;
317 p_scaler_params->
in_rec_x = in_rec_x;
318 p_scaler_params->
in_rec_y = in_rec_y;
337 p_scaler_ctx->
hw_id = iXcoderGUID;
446 int iXcoderGUID,
int input_format,
int output_format)
456 box_width = ((int)((p_box_params->
box_w + 1) / 2) * 2);
457 box_height = ((int)((p_box_params->
box_h + 1) / 2) * 2);
458 box_x = p_box_params->
box_x;
459 box_y = p_box_params->
box_y;
485 box_height, box_x, box_y, 0, 0);
488 p_frame_in, &crop_data, crop_params);
506 line_width, line_width);
509 &crop_data.
data.
frame, &pad_data, pad_params);
529 int overlay_x = box_x - line_width;
530 int overlay_y = box_y - line_width;
532 overlay_x, overlay_y, 0, 0);
537 p_data_out, overlay_params);
541 &ovly_data, overlay_params);
583 int scale_width,
int scale_height,
int in_format,
int out_format)
599 p_data_out, scale_params);
620 int in_width,
int in_height,
int in_gc620_format)
636 p_ai_ctx->
hw_id = iXcoderGUID;
@ NI_SCALER_OPCODE_OVERLAY
enum _ni_scaler_opcode ni_scaler_opcode_t
ni_retcode_t ni_ai_config_network_binary(ni_session_context_t *p_ctx, ni_network_data_t *p_network, const char *file)
configure a network context based with the network binary
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...
ni_retcode_t ni_scaler_frame_pool_alloc(ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params)
init output pool of scaler frames
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...
ni_retcode_t ni_scaler_dest_frame_alloc(ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params, niFrameSurface1_t *p_surface)
allocate device destination frame from scaler hwframe pool
ni_retcode_t ni_scaler_input_frame_alloc(ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params, niFrameSurface1_t *p_src_surface)
allocate device input frame by hw descriptor. This call won't actually allocate a frame but sends the...
ni_retcode_t ni_device_alloc_frame(ni_session_context_t *p_ctx, int width, int height, int format, int options, int rectangle_width, int rectangle_height, int rectangle_x, int rectangle_y, int rgba_color, int frame_index, ni_device_type_t device_type)
Allocate a frame on the device for 2D engine or AI engine to work on based on provided parameters.
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...
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 ...
#define NI_INVALID_SESSION_ID
#define NI_DEFAULT_KEEP_ALIVE_TIMEOUT
#define NI_VPU_CEIL(_data, _align)
void init_scaler_params(ni_scaler_input_params_t *p_scaler_params, ni_scaler_opcode_t op, int in_rec_width, int in_rec_height, int in_rec_x, int in_rec_y, int out_rec_x, int out_rec_y)
Init scaler params here - both user setting params and fixed params.
int scale_filter(ni_session_context_t *p_ctx, ni_frame_t *p_frame_in, ni_session_data_io_t *p_data_out, int iXcoderGUID, int scale_width, int scale_height, int in_format, int out_format)
Do a scale and/or format-change operation.
int ni_scaler_params_set_value(ni_scale_params_t *params, const char *name, const char *value)
int drawbox_filter(ni_session_context_t *p_crop_ctx, ni_session_context_t *p_pad_ctx, ni_session_context_t *p_overlay_ctx, ni_session_context_t *p_fmt_ctx, ni_frame_t *p_frame_in, ni_session_data_io_t *p_data_out, ni_drawbox_params_t *p_box_params, int iXcoderGUID, int input_format, int output_format)
Use crop->pad->overlay to simulate a drawbox filter.
int ni_ai_pre_params_set_value(ni_ai_pre_params_t *params, const char *name, const char *value)
int ai_pre_filter(ni_session_context_t *p_ai_ctx, ni_network_data_t *p_network, ni_frame_t *p_frame_in, ni_session_data_io_t *p_data_out, ni_ai_pre_params_t *params, int in_gc620_format)
Run one AI preprocess operation on a hardware frame. The output is a new hardware frame preserving th...
int launch_scaler_operation(ni_session_context_t *p_scaler_ctx, int iXcoderGUID, ni_frame_t *p_frame_in_up, ni_frame_t *p_frame_in_bg, ni_session_data_io_t *p_data_out, ni_scaler_input_params_t scaler_params)
Launch scaler operation and get the result hw frame.
int retrieve_filter_params(char filter_params[], ni_scale_params_t *scale_params, ni_drawbox_params_t *drawbox_params, ni_ai_pre_params_t *ai_pre_params)
int scaler_session_open(ni_session_context_t *p_scaler_ctx, int iXcoderGUID, ni_scaler_opcode_t op)
open scaler session
int ai_pre_filter_init(ni_session_context_t *p_ai_ctx, ni_network_data_t *p_network, int iXcoderGUID, ni_ai_pre_params_t *params, int in_width, int in_height, int in_gc620_format)
Open an AI session, configure the network binary and create the hardware output frame pool used by th...
int ni_drawbox_params_set_value(ni_drawbox_params_t *params, const char *name, const char *value)
void ni_hw_frame_unref(uint16_t hwframe_index)
void ni_hw_frame_ref(const niFrameSurface1_t *p_surface)
void ni_log(ni_log_level_t level, const char *fmt,...)
print log message using ni_log_callback
int ni_param_get_key_value(char *p_str, char *key, char *value)
retrieve key and value from 'key=value' pair
ni_retcode_t ni_strcpy(char *dest, size_t dmax, const char *src)
uint64_t ni_gettime_ns(void)
ni_retcode_t ni_strtoi(const char *str, int32_t *out_val)
Safely convert a decimal string to a 32-bit integer with full validation. Trailing whitespace is tole...
char nb_file[FILE_NAME_LEN]
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
uint32_t keep_alive_timeout
ni_device_handle_t device_handle
ni_device_handle_t blk_io_handle
uint32_t scaler_operation
union _ni_session_data_io::@19 data