libxcoder 5.6.0
Loading...
Searching...
No Matches
ni_filter_utils.c
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (C) 2022 NETINT Technologies
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 * SOFTWARE.
19 *
20 ******************************************************************************/
21
22/*!*****************************************************************************
23 * \file filter_utils.c
24 *
25 * \brief Video filtering utility functions shared by Libxcoder API examples
26 ******************************************************************************/
27
28#include "ni_generic_utils.h"
29#include "ni_filter_utils.h"
30#include "ni_log.h"
31#include "ni_util.h"
32
33int ni_scaler_params_set_value(ni_scale_params_t *params, const char *name, const char *value)
34{
35 if (!params || !name || !value)
36 {
37 ni_log(NI_LOG_ERROR, "Error: Null pointer received in ni_scaler_params_set_value\n");
38 return -1;
39 }
40
41 if (!strcmp("width", name))
42 {
43 params->width = atoi(value);
44 } else if (!strcmp("height", name))
45 {
46 params->height = atoi(value);
47 } else if (!strcmp("format", name))
48 {
49 if (!strcmp(value, "yuv420p"))
50 {
51 params->format = GC620_I420;
52 } else if (!strcmp(value, "yuv420p10le"))
53 {
54 params->format = GC620_I010;
55 } else if (!strcmp(value, "nv12"))
56 {
57 params->format = GC620_NV12;
58 } else if (!strcmp(value, "p010le"))
59 {
60 params->format = GC620_P010_MSB;
61 } else
62 {
63 ni_log(NI_LOG_ERROR, "Error: pixel format %s not supported in scale\n", value);
64 return -1;
65 }
66 } else
67 {
68 ni_log(NI_LOG_ERROR, "Error: invalid scale param name %s\n", name);
69 return -1;
70 }
71
72 return 0;
73}
74
75int ni_drawbox_params_set_value(ni_drawbox_params_t *params, const char *name, const char *value)
76{
77 if (!params || !name || !value)
78 {
79 ni_log(NI_LOG_ERROR, "Error: Null pointer received in ni_drawbox_params_set_value\n");
80 return -1;
81 }
82
83 if (!strcmp("width", name))
84 {
85 params->box_w = atoi(value);
86 } else if (!strcmp("height", name))
87 {
88 params->box_h = atoi(value);
89 } else if (!strcmp("x", name))
90 {
91 params->box_x = atoi(value);
92 } else if (!strcmp("y", name))
93 {
94 params->box_y = atoi(value);
95 } else
96 {
97 ni_log(NI_LOG_ERROR, "Error: invalid drawbox param name %s\n", name);
98 return -1;
99 }
100
101 return 0;
102}
103
104int retrieve_filter_params(char filter_params[], ni_scale_params_t *scale_params, ni_drawbox_params_t *drawbox_params)
105{
106 char key[64], value[64];
107 char *curr = filter_params, *colon_pos;
108 int ret = 0;
109
110 //reset all params to default values first
111 memset(scale_params, 0, sizeof(ni_scale_params_t));
112 memset(drawbox_params, 0, sizeof(ni_drawbox_params_t));
113 scale_params->format = GC620_I420;
114
115 if (strncmp("ni_quadra_scale", curr, 15) == 0)
116 {
117 scale_params->enabled = 1;
118 curr += 16;
119 }
120 else if (strncmp("ni_quadra_drawbox", curr, 17) == 0)
121 {
122 drawbox_params->enabled = 1;
123 curr += 18;
124 }
125 else
126 {
127 ni_log(NI_LOG_ERROR, "Error: invalid filter, must be one of [ni_quadra_scale, ni_quadra_drawbox]");
128 return -1;
129 }
130
131 while (*curr)
132 {
133 colon_pos = strchr(curr, ':');
134
135 if (colon_pos)
136 {
137 *colon_pos = '\0';
138 }
139
140 if (strlen(curr) > sizeof(key) + sizeof(value) - 1 ||
141 ni_param_get_key_value(curr, key, value))
142 {
143 ni_log(NI_LOG_ERROR, "Error: cannot retrieve key/value from filter param: %s\n", curr);
144 ret = -1;
145 break;
146 }
147
148 if (scale_params->enabled)
149 {
150 ret = ni_scaler_params_set_value(scale_params, key, value);
151 } else
152 {
153 ret = ni_drawbox_params_set_value(drawbox_params, key, value);
154 }
155 if (ret != 0)
156 {
157 break;
158 }
159
160 if (colon_pos)
161 {
162 curr = colon_pos + 1;
163 } else
164 {
165 curr += strlen(curr);
166 }
167 }
168 return ret;
169}
170
171/*!*****************************************************************************
172 * \brief Init scaler params here - both user setting params and fixed params.
173 *
174 * \param
175 *
176 * \return 0 if successful, < 0 otherwise
177 ******************************************************************************/
178void init_scaler_params(ni_scaler_input_params_t *p_scaler_params, ni_scaler_opcode_t op, int in_rec_width,
179 int in_rec_height, int in_rec_x, int in_rec_y, int out_rec_x, int out_rec_y)
180{
181 p_scaler_params->op = op;
182 // input_format/width/height, output_format/width/height should be assigned by users for all ops
183 if (op == NI_SCALER_OPCODE_CROP)
184 {
185 // fixed numbers
186 p_scaler_params->out_rec_width = 0;
187 p_scaler_params->out_rec_height = 0;
188 p_scaler_params->out_rec_x = 0;
189 p_scaler_params->out_rec_y = 0;
190 p_scaler_params->rgba_color = 0;
191
192 // params set by user
193 p_scaler_params->in_rec_width = in_rec_width;
194 p_scaler_params->in_rec_height = in_rec_height;
195 p_scaler_params->in_rec_x = in_rec_x;
196 p_scaler_params->in_rec_y = in_rec_y;
197 } else if (op == NI_SCALER_OPCODE_SCALE)
198 {
199 // fixed params
200 p_scaler_params->in_rec_width = 0;
201 p_scaler_params->in_rec_height = 0;
202 p_scaler_params->in_rec_x = 0;
203 p_scaler_params->in_rec_y = 0;
204
205 p_scaler_params->out_rec_width = 0;
206 p_scaler_params->out_rec_height = 0;
207 p_scaler_params->out_rec_x = 0;
208 p_scaler_params->out_rec_y = 0;
209
210 p_scaler_params->rgba_color = 0;
211 } else if (op == NI_SCALER_OPCODE_PAD)
212 {
213 // fixed params
214 p_scaler_params->in_rec_width = p_scaler_params->input_width;
215 p_scaler_params->in_rec_height = p_scaler_params->input_height;
216 p_scaler_params->in_rec_x = 0;
217 p_scaler_params->in_rec_y = 0;
218
219 p_scaler_params->out_rec_width = p_scaler_params->input_width;
220 p_scaler_params->out_rec_height = p_scaler_params->input_height;
221
222 /*
223 Scaler uses BGRA color, or ARGB in little-endian
224 ui32RgbaColor = (s->rgba_color[3] << 24) | (s->rgba_color[0] << 16) |
225 (s->rgba_color[1] << 8) | s->rgba_color[2];
226 here p_scaler_params->rgba_color = ui32RgbaColor;
227 */
228 p_scaler_params->rgba_color =
229 4278190080; // now padding color is black
230
231 // params set by user
232 p_scaler_params->out_rec_x = out_rec_x;
233 p_scaler_params->out_rec_y = out_rec_y;
234 } else if (op == NI_SCALER_OPCODE_OVERLAY)
235 {
236 // fixed params
237 // set the in_rec params to the w/h of overlay(the upper) frames
238 p_scaler_params->in_rec_width = p_scaler_params->input_width;
239 p_scaler_params->in_rec_height = p_scaler_params->input_height;
240
241 // the output w/h is the main frame's w/h (main frame is the lower/background frame)
242 p_scaler_params->out_rec_width = p_scaler_params->output_width;
243 p_scaler_params->out_rec_height = p_scaler_params->output_height;
244 p_scaler_params->out_rec_x = 0;
245 p_scaler_params->out_rec_y = 0;
246 p_scaler_params->rgba_color = 0;
247
248 // params set by user
249 p_scaler_params->in_rec_x = in_rec_x;
250 p_scaler_params->in_rec_y = in_rec_y;
251 }
252}
253
254/*!*****************************************************************************
255 * \brief open scaler session
256 *
257 * \param
258 *
259 * \return 0 if successful, < 0 otherwise
260 ******************************************************************************/
261int scaler_session_open(ni_session_context_t *p_scaler_ctx, int iXcoderGUID, ni_scaler_opcode_t op)
262{
263 int ret = 0;
264
265 p_scaler_ctx->session_id = NI_INVALID_SESSION_ID;
266
267 p_scaler_ctx->device_handle = NI_INVALID_DEVICE_HANDLE;
268 p_scaler_ctx->blk_io_handle = NI_INVALID_DEVICE_HANDLE;
269 p_scaler_ctx->hw_id = iXcoderGUID;
270 p_scaler_ctx->device_type = NI_DEVICE_TYPE_SCALER;
271 p_scaler_ctx->scaler_operation = op;
273
275
276 if (ret != NI_RETCODE_SUCCESS)
277 {
278 ni_log(NI_LOG_ERROR, "Error: ni_scaler_session_open() failure!\n");
279 return -1;
280 } else
281 {
282#ifdef _WIN32
283 ni_log(NI_LOG_INFO, "Scaler session open: device_handle %p, session_id %u.\n",
284 p_scaler_ctx->device_handle, p_scaler_ctx->session_id);
285#else
286 ni_log(NI_LOG_INFO, "Scaler session open: device_handle %d, session_id %u.\n",
287 p_scaler_ctx->device_handle, p_scaler_ctx->session_id);
288#endif
289 return 0;
290 }
291}
292
293/*!*****************************************************************************
294 * \brief Launch scaler operation and get the result hw frame
295 *
296 * \param
297 *
298 * \return 0 if successful, < 0 otherwise
299 ******************************************************************************/
300int launch_scaler_operation(ni_session_context_t *p_scaler_ctx, int iXcoderGUID,
301 ni_frame_t *p_frame_in_up, ni_frame_t *p_frame_in_bg,
302 ni_session_data_io_t *p_data_out, ni_scaler_input_params_t scaler_params)
303{
304 int ret = 0;
305 niFrameSurface1_t *frame_surface_up;
306 niFrameSurface1_t *frame_surface_bg;
307 niFrameSurface1_t *frame_surface_output;
308
309 if (p_scaler_ctx->session_id == NI_INVALID_SESSION_ID)
310 {
311 // Open scaler session
312 if (0 != scaler_session_open(p_scaler_ctx, iXcoderGUID, scaler_params.op))
313 {
314 ni_log(NI_LOG_ERROR, "Error: scaler open session error\n");
315 return -1;
316 }
317
318 // init scaler hwframe pool
319 if (0 != ni_scaler_frame_pool_alloc(p_scaler_ctx, scaler_params))
320 {
321 ni_log(NI_LOG_ERROR, "Error: init filter hwframe pool\n");
322 return -1;
323 }
324 }
325
326 // allocate a ni_frame_t structure on the host PC
327 ret = ni_frame_buffer_alloc_hwenc(&p_data_out->data.frame,
328 scaler_params.output_width,
329 scaler_params.output_height, 0);
330 if (ret != 0)
331 {
332 return -1;
333 }
334
335 // out_frame retrieved from decoder
336 frame_surface_up = (niFrameSurface1_t *)(p_frame_in_up->p_data[3]);
337 frame_surface_bg = (niFrameSurface1_t *)(p_frame_in_bg->p_data[3]);
338
339 // Allocate scaler input frame
340 ret = ni_scaler_input_frame_alloc(p_scaler_ctx, scaler_params, frame_surface_up);
341 if (ret != 0)
342 {
343 return -1;
344 }
345
346 // Allocate scaler destination frame.
347 ret = ni_scaler_dest_frame_alloc(p_scaler_ctx, scaler_params, frame_surface_bg);
348 if (ret != 0)
349 {
350 return -1;
351 }
352
353 // Retrieve hardware frame info from 2D engine and put it in the ni_frame_t structure.
354 ret = ni_device_session_read_hwdesc(p_scaler_ctx, p_data_out, NI_DEVICE_TYPE_SCALER);
355 frame_surface_output = (niFrameSurface1_t *)(p_data_out->data.frame.p_data[3]);
356 ni_log(NI_LOG_DEBUG, "%s: output FID %u \n", __func__,
357 frame_surface_output->ui16FrameIdx);
358 if (ret < 0)
359 {
360 ni_frame_buffer_free(p_frame_in_up);
361 ni_frame_buffer_free(p_frame_in_bg);
362 ni_frame_buffer_free(&p_data_out->data.frame);
363 }
364
365 return ret;
366}
367
368/*!*****************************************************************************
369 * \brief Use crop->pad->overlay to simulate a drawbox filter.
370 *
371 * \param
372 *
373 * \return 0 if successful, < 0 otherwise
374 ******************************************************************************/
376 ni_session_context_t *p_overlay_ctx, ni_session_context_t *p_fmt_ctx,
377 ni_frame_t *p_frame_in, ni_session_data_io_t *p_data_out, ni_drawbox_params_t *p_box_params,
378 int iXcoderGUID, int input_format, int output_format)
379{
380 // set default box params
381 int box_width = 80;
382 int box_height = 60;
383 int box_x = 160;
384 int box_y = 100;
385 int line_width = 4;
386 if (p_box_params)
387 {
388 box_width = ((int)((p_box_params->box_w + 1) / 2) * 2);
389 box_height = ((int)((p_box_params->box_h + 1) / 2) * 2);
390 box_x = p_box_params->box_x;
391 box_y = p_box_params->box_y;
392 }
393
394 /*
395 To simulate a drawbox filter, we need to
396 1. Crop at the box set position
397 2. Padding the crop output frame for fixed fixels (depends on the line_width of the box)
398 Recycle the crop hwFrame
399 3. Overlay the padding result on the original frame
400 Recycle the padding hwFrame
401 4. if format-change is needed, launch a scale operation and do format change
402 Recycle the overlay hwFrame
403 */
404
405 int ret = 0;
406 niFrameSurface1_t *p_surface_in;
407 p_surface_in = (niFrameSurface1_t *)(p_frame_in->p_data[3]);
408
409 ni_scaler_input_params_t crop_params = {0};
410 crop_params.input_format = input_format;
411 crop_params.input_width = p_surface_in->ui16width;
412 crop_params.input_height = p_surface_in->ui16height;
413 crop_params.output_format = GC620_I420;
414 crop_params.output_width = box_width;
415 crop_params.output_height = box_height;
416 init_scaler_params(&crop_params, NI_SCALER_OPCODE_CROP, box_width,
417 box_height, box_x, box_y, 0, 0);
418 ni_session_data_io_t crop_data = {0};
419 ret = launch_scaler_operation(p_crop_ctx, iXcoderGUID, p_frame_in,
420 p_frame_in, &crop_data, crop_params);
421 if (ret != 0)
422 {
423 ni_log(NI_LOG_ERROR, "Failed to lauch scaler operation %d\n", crop_params.op);
424 return -1;
425 }
426 niFrameSurface1_t *crop_frame_surface =
427 (niFrameSurface1_t *)(crop_data.data.frame.p_data[3]);
428 ni_hw_frame_ref(crop_frame_surface);
429
430 ni_scaler_input_params_t pad_params = {0};
431 pad_params.input_format = input_format;
432 pad_params.input_width = crop_params.output_width;
433 pad_params.input_height = crop_params.output_height;
434 pad_params.output_format = GC620_I420;
435 pad_params.output_width = crop_params.output_width + line_width * 2;
436 pad_params.output_height = crop_params.output_height + line_width * 2;
437 init_scaler_params(&pad_params, NI_SCALER_OPCODE_PAD, 0, 0, 0, 0,
438 line_width, line_width);
439 ni_session_data_io_t pad_data = {0};
440 ret = launch_scaler_operation(p_pad_ctx, iXcoderGUID, &crop_data.data.frame,
441 &crop_data.data.frame, &pad_data, pad_params);
442 // recycle HwFrameIdx first, then free the frame
443 ni_hw_frame_unref(crop_frame_surface->ui16FrameIdx);
444 ni_frame_buffer_free(&(crop_data.data.frame));
445 if (ret != 0)
446 {
447 ni_log(NI_LOG_ERROR, "Failed to lauch scaler operation %d\n", pad_params.op);
448 return -1;
449 }
450 niFrameSurface1_t *pad_frame_surface =
451 (niFrameSurface1_t *)(pad_data.data.frame.p_data[3]);
452 ni_hw_frame_ref(pad_frame_surface);
453
454 ni_scaler_input_params_t overlay_params = {0};
455 overlay_params.input_format = input_format;
456 overlay_params.input_width = pad_params.output_width;
457 overlay_params.input_height = pad_params.output_height;
458 overlay_params.output_format = GC620_I420;
459 overlay_params.output_width = p_surface_in->ui16width;
460 overlay_params.output_height = p_surface_in->ui16height;
461 int overlay_x = box_x - line_width;
462 int overlay_y = box_y - line_width;
463 init_scaler_params(&overlay_params, NI_SCALER_OPCODE_OVERLAY, 0, 0,
464 overlay_x, overlay_y, 0, 0);
465 ni_session_data_io_t ovly_data = {0};
466 if (output_format == GC620_I420)
467 ret = launch_scaler_operation(p_overlay_ctx, iXcoderGUID,
468 &pad_data.data.frame, p_frame_in,
469 p_data_out, overlay_params);
470 else
471 ret = launch_scaler_operation(p_overlay_ctx, iXcoderGUID,
472 &pad_data.data.frame, p_frame_in,
473 &ovly_data, overlay_params);
474 // recycle HwFrameIdx first, then free the frame
475 ni_hw_frame_unref(pad_frame_surface->ui16FrameIdx);
476 ni_frame_buffer_free(&(pad_data.data.frame));
477 if (ret != 0)
478 {
479 ni_log(NI_LOG_ERROR, "Failed to lauch scaler operation %d\n", overlay_params.op);
480 return -1;
481 }
482
483 if (output_format != GC620_I420) // use scale filter to do format change
484 {
485 niFrameSurface1_t *ovly_frame_surface =
486 (niFrameSurface1_t *)(ovly_data.data.frame.p_data[3]);
487 ni_hw_frame_ref(ovly_frame_surface);
488 ovly_frame_surface->ui16width = overlay_params.output_width;
489 ovly_frame_surface->ui16height = overlay_params.output_height;
490 ret = scale_filter(p_fmt_ctx, &(ovly_data.data.frame), p_data_out,
491 iXcoderGUID, overlay_params.output_width,
492 overlay_params.output_height, GC620_I420,
493 output_format);
494 ni_hw_frame_unref(ovly_frame_surface->ui16FrameIdx);
495 ni_frame_buffer_free(&ovly_data.data.frame);
496 if (ret != 0)
497 {
498 ni_log(NI_LOG_ERROR, "Failed to lauch scaler operation 0\n");
499 return -1;
500 }
501 }
502
503 return 0;
504}
505
506/*!*****************************************************************************
507 * \brief Do a scale and/or format-change operation.
508 *
509 * \param
510 *
511 * \return 0 if successful, < 0 otherwise
512 ******************************************************************************/
514 ni_session_data_io_t *p_data_out, int iXcoderGUID,
515 int scale_width, int scale_height, int in_format, int out_format)
516{
517 int ret;
518 niFrameSurface1_t *p_surface_in;
519 ni_scaler_input_params_t scale_params;
520
521 p_surface_in = (niFrameSurface1_t *)p_frame_in->p_data[3];
522 scale_params.output_format = out_format; // rgba or bgrp or yuv420p;
523 scale_params.output_width = scale_width;
524 scale_params.output_height = scale_height;
525 scale_params.input_format = in_format;
526 scale_params.input_width = p_surface_in ? p_surface_in->ui16width : 0;
527 scale_params.input_height = p_surface_in ? p_surface_in->ui16height : 0;
528 init_scaler_params(&scale_params, NI_SCALER_OPCODE_SCALE, 0, 0, 0, 0, 0, 0);
529
530 ret = launch_scaler_operation(p_ctx, iXcoderGUID, p_frame_in, p_frame_in,
531 p_data_out, scale_params);
532 if (ret != 0)
533 {
534 ni_log(NI_LOG_ERROR, "Failed to lauch scaler operation %d\n", scale_params.op);
535 return -1;
536 }
537
538 return ret;
539}
@ NI_DEVICE_TYPE_SCALER
Definition ni_defs.h:362
@ NI_SCALER_OPCODE_PAD
Definition ni_defs.h:592
@ NI_SCALER_OPCODE_OVERLAY
Definition ni_defs.h:593
@ NI_SCALER_OPCODE_CROP
Definition ni_defs.h:590
@ NI_SCALER_OPCODE_SCALE
Definition ni_defs.h:589
enum _ni_scaler_opcode ni_scaler_opcode_t
@ NI_RETCODE_SUCCESS
Definition ni_defs.h:443
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
#define atoi(p_str)
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 GC620_I420
#define GC620_NV12
#define GC620_P010_MSB
#define NI_INVALID_SESSION_ID
#define NI_DEFAULT_KEEP_ALIVE_TIMEOUT
#define GC620_I010
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
Definition ni_log.c:183
Logging definitions.
@ NI_LOG_DEBUG
Definition ni_log.h:64
@ NI_LOG_ERROR
Definition ni_log.h:62
@ NI_LOG_INFO
Definition ni_log.h:63
int ni_param_get_key_value(char *p_str, char *key, char *value)
retrieve key and value from 'key=value' pair
Definition ni_util.c:4383
Utility definitions.
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
ni_device_handle_t device_handle
ni_device_handle_t blk_io_handle
union _ni_session_data_io::@19 data