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 char key[64], value[64];
131 char *curr = filter_params, *colon_pos;
139 if (strncmp(
"ni_quadra_scale", curr, 15) == 0)
144 else if (strncmp(
"ni_quadra_drawbox", curr, 17) == 0)
151 ni_log(
NI_LOG_ERROR,
"Error: invalid filter, must be one of [ni_quadra_scale, ni_quadra_drawbox]");
157 colon_pos = strchr(curr,
':');
164 if (strlen(curr) >
sizeof(key) +
sizeof(value) - 1 ||
167 ni_log(
NI_LOG_ERROR,
"Error: cannot retrieve key/value from filter param: %s\n", curr);
186 curr = colon_pos + 1;
189 curr += strlen(curr);
203 int in_rec_height,
int in_rec_x,
int in_rec_y,
int out_rec_x,
int out_rec_y)
205 p_scaler_params->
op = op;
219 p_scaler_params->
in_rec_x = in_rec_x;
220 p_scaler_params->
in_rec_y = in_rec_y;
273 p_scaler_params->
in_rec_x = in_rec_x;
274 p_scaler_params->
in_rec_y = in_rec_y;
293 p_scaler_ctx->
hw_id = iXcoderGUID;
402 int iXcoderGUID,
int input_format,
int output_format)
412 box_width = ((int)((p_box_params->
box_w + 1) / 2) * 2);
413 box_height = ((int)((p_box_params->
box_h + 1) / 2) * 2);
414 box_x = p_box_params->
box_x;
415 box_y = p_box_params->
box_y;
441 box_height, box_x, box_y, 0, 0);
444 p_frame_in, &crop_data, crop_params);
462 line_width, line_width);
465 &crop_data.
data.
frame, &pad_data, pad_params);
485 int overlay_x = box_x - line_width;
486 int overlay_y = box_y - line_width;
488 overlay_x, overlay_y, 0, 0);
493 p_data_out, overlay_params);
497 &ovly_data, overlay_params);
539 int scale_width,
int scale_height,
int in_format,
int out_format)
555 p_data_out, scale_params);
@ NI_SCALER_OPCODE_OVERLAY
enum _ni_scaler_opcode ni_scaler_opcode_t
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_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
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 retrieve_filter_params(char filter_params[], ni_scale_params_t *scale_params, ni_drawbox_params_t *drawbox_params)
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 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 scaler_session_open(ni_session_context_t *p_scaler_ctx, int iXcoderGUID, ni_scaler_opcode_t op)
open scaler session
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_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...
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