libxcoder 5.8.0
Loading...
Searching...
No Matches
ni_device_api.h
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 ni_device_api.h
24 *
25 * \brief Public definitions for operating NETINT video processing devices for
26 * video processing
27 ******************************************************************************/
28
29#pragma once
30
31
32#ifdef __cplusplus
33extern "C"
34{
35#endif
36
37#include "ni_defs.h"
38#include "ni_rsrc_api.h"
39
40// resource allocation strategy names
41#define NI_BEST_MODEL_LOAD_STR "bestmodelload"
42#define NI_BEST_REAL_LOAD_STR "bestload"
43
44#define NI_DATA_FORMAT_VIDEO_PACKET 0
45#define NI_DATA_FORMAT_YUV_FRAME 1
46#define NI_DATA_FORMAT_Y_FRAME 2
47#define NI_DATA_FORMAT_CB_FRAME 3
48#define NI_DATA_FORMAT_CR_FRAME 4
49
50// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
51// If you change this,you should also change NI_QUADRA_NOPTS_VALUE in ni_quadra_filter_api.h
52#define NI_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
53
54// the following are the default values from FFmpeg
55#define AV_CODEC_DEFAULT_BITRATE 200 * 1000
56#define PRESET_DEFAULT_BITRATE 1000 * 1000
57
58#define NI_MAX_GOP_NUM 8
59
60#define NI_MAX_REF_PIC 4
61
62#ifndef DEPRECATION_AS_ERROR
64#define NI_MAX_VUI_SIZE NI_DEPRECATED_MACRO 32
65#endif
66
67#define NI_MAX_TX_RETRIES 1000
68
69#define NI_MAX_ENCODER_QUERY_RETRIES 5000
70
71// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
72// If you change this,you should also change NI_QUADRA_MAX_SUPPORT_DRAWBOX_NUM, NI_MAX_SUPPORT_WATERMARK_NUM
73// in ni_quadra_filter_api.h
74#define NI_MAX_SUPPORT_DRAWBOX_NUM 5
75#define NI_MAX_SUPPORT_WATERMARK_NUM 6
76
77// Number of pixels for main stream resolutions
78#define NI_NUM_OF_PIXELS_360P (640*360)
79#define NI_NUM_OF_PIXELS_720P (1280*720)
80#define NI_NUM_OF_PIXELS_1080P (1920*1080)
81#define NI_NUM_OF_PIXELS_1440P (2560*1440)
82#define NI_NUM_OF_PIXELS_4K (3840*2160)
83#define NI_NUM_OF_PIXELS_4K_2 (4096*2160)
84#define NI_NUM_OF_PIXELS_8K (7680*4320)
85
86#define NI_MIN_RESOLUTION_WIDTH_JPEG 48
87#define NI_MIN_RESOLUTION_HEIGHT_JPEG 48
88
89#define NI_MIN_RESOLUTION_WIDTH 144
90#define NI_MIN_RESOLUTION_HEIGHT 144
91#define NI_ENC_MIN_RESOLUTION_WIDTH 144
92#define NI_ENC_MIN_RESOLUTION_HEIGHT 128
93
94// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
95// If you change this,you should also change NI_MIN_RESOLUTION_WIDTH_SCALER,
96// NI_MIN_RESOLUTION_HEIGHT_SCALER in ni_quadra_filter_api.h
97#define NI_MIN_RESOLUTION_WIDTH_SCALER 16
98#define NI_MIN_RESOLUTION_HEIGHT_SCALER 16
99
100// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
101// If you change this,you should also change NI_QUADRA_MAX_RESOLUTION_WIDTH,
102// NI_QUADRA_MAX_RESOLUTION_HEIGHT in ni_quadra_filter_api.h
103#define NI_MAX_RESOLUTION_WIDTH 8192
104#define NI_MAX_RESOLUTION_HEIGHT 8192
105#define NI_MAX_RESOLUTION_AREA 8192*8192
106#define NI_MAX_RESOLUTION_RGBA_WIDTH 7040
107#define NI_MAX_RESOLUTION_RGBA_HEIGHT 7040
108
109#define NI_MAX_RESOLUTION_LINESIZE (NI_MAX_RESOLUTION_WIDTH*2)
110
111#define NI_FRAME_LITTLE_ENDIAN 0
112#define NI_FRAME_BIG_ENDIAN 1
113
114#define NI_INVALID_SESSION_ID 0xFFFF
115
116#define NI_MAX_BITRATE 800000000
117#define NI_MIN_BITRATE 10000
118
119#define NI_MAX_FRAMERATE 65535
120#define NI_MAX_ASPECTRATIO 65535
121
122/*Values below used for VPU resolution range checking*/
123// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
124// If you change this,you should also change NI_QUADRA_MAX_WIDTH, NI_QUADRA_MIN_WIDTH,
125// NI_QUADRA_MAX_HEIGHT, NI_QUADRA_MIN_HEIGHT in ni_quadra_filter_api.h
126#define NI_MAX_WIDTH 8192
127#define NI_MIN_WIDTH 144
128#define NI_MAX_HEIGHT 8192
129#define NI_MIN_HEIGHT 128
130
131#define NI_2PASS_ENCODE_MIN_WIDTH ((272 + 31) / 32 * 32)
132#define NI_2PASS_ENCODE_MIN_HEIGHT 256
133
134#define NI_MULTICORE_ENCODE_MIN_WIDTH 256
135#define NI_MULTICORE_ENCODE_MIN_HEIGHT 256
136
137/*Values below used for parameter resolution range checking*/
138#define NI_PARAM_MAX_WIDTH 8192
139#define NI_PARAM_MIN_WIDTH 32
140#define NI_PARAM_MAX_HEIGHT 8192
141#define NI_PARAM_MIN_HEIGHT 32
142
143#define NI_PARAM_JPEG_MIN_WIDTH 48
144#define NI_PARAM_JPEG_MIN_HEIGHT 48
145
146#define NI_PARAM_AV1_MIN_WIDTH 144
147#define NI_PARAM_AV1_MIN_HEIGHT 128
148#define NI_PARAM_AV1_MAX_WIDTH 4096
149#define NI_PARAM_AV1_MAX_HEIGHT 4352
150#define NI_PARAM_AV1_MAX_AREA (4096 * 2304)
151#define NI_PARAM_AV1_ALIGN_WIDTH_HEIGHT 8
152
153#define NI_MAX_GOP_SIZE 8
154#define NI_MIN_GOP_SIZE 1
155#define NI_MAX_GOP_PRESET_IDX 15
156#define NI_MIN_GOP_PRESET_IDX -1
157#define NI_MAX_DECODING_REFRESH_TYPE 2
158#define NI_MIN_DECODING_REFRESH_TYPE 0
159#define NI_MAX_CU_SIZE_MODE 2
160#define NI_MIN_CU_SIZE_MODE 0
161#define NI_DEFAULT_CU_SIZE_MODE 7
162#define NI_MAX_DYNAMIC_MERGE 1
163#define NI_MIN_DYNAMIC_MERGE 0
164#define NI_MAX_USE_RECOMMENDED_ENC_PARAMS 3
165#define NI_MIN_USE_RECOMMENDED_ENC_PARAMS 0
166#define NI_MAX_MAX_NUM_MERGE 3
167#define NI_MIN_MAX_NUM_MERGE 0
168#define NI_MAX_INTRA_QP 51
169#define NI_MIN_INTRA_QP -1
170#define NI_MAX_INTRA_QP_DELTA 51
171#define NI_MIN_INTRA_QP_DELTA -51
172#define NI_DEFAULT_INTRA_QP 22
173#define NI_INTRA_QP_RANGE 25
174#define NI_MIN_QP_DELTA (-25)
175#define NI_MAX_QP_DELTA 25
176#define NI_MAX_QP_INFO 63
177#define NI_MAX_BIN 1
178#define NI_MIN_BIN 0
179#define NI_MAX_NUM_SESSIONS 32
180#define NI_MIN_FRAME_SIZE 0
181#define NI_MAX_FRAME_SIZE (7680*4320*3)
182#define NI_AV1_INVALID_BUFFER_INDEX (-1)
183#define NI_MAX_SPATIAL_LAYERS 4
184
185#define RC_SUCCESS true
186#define RC_ERROR false
187
188#define MAX_CHAR_IN_DEVICE_NAME 32
189
190// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
191// If you change this,you should also change MAX_QUADRA_NUM_FRAMEPOOL_HWAVFRAME in ni_quadra_filter_api.h
192#define MAX_NUM_FRAMEPOOL_HWAVFRAME 128
193
194/* These constants are the values used by the GC620 2D engine */
195#define GC620_NV12 0x104
196#define GC620_NV21 0x105
197#define GC620_I420 0x103
198#define GC620_P010_MSB 0x108
199#define GC620_I010 0x10A
200#define GC620_YUYV 0x100
201#define GC620_UYVY 0x101
202#define GC620_NV16 0x106
203#define GC620_RGBA8888 0
204#define GC620_BGRA8888 4
205#define GC620_BGRX8888 5
206#define GC620_ABGR8888 12
207#define GC620_ARGB8888 15
208#define GC620_RGB565 3
209#define GC620_BGR565 11
210#define GC620_B5G5R5X1 8
211#define GC620_RGB888_PLANAR 0x10C
212
213#define NI_ENABLE_AUD_FOR_GLOBAL_HEADER 2
214
215// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
216// If you change this,you should also change NI_QUADRA_MAX_FIFO_CAPACITY in ni_quadra_filter_api.h
217#define NI_MAX_FIFO_CAPACITY 120
218
219/* These are Namespace and QOS configuration related */
220#define NI_NAMESPACE_MAX_NUM 128
221
222/* These are sliceArg configuration related */
223#define NI_MAX_SLICE_SIZE 127
224
225/*!*
226* Operation modes for QOS
227*/
234
235/*!*
236* Operation codes for ni_device_config_ns_qos
237*/
246
247// XCODER STATE
248typedef enum
249{
250 NI_XCODER_IDLE_STATE = 0x00, // Xcoder idle state
251 NI_XCODER_OPEN_STATE = 0x01 << 1, // Xcoder open state
252 NI_XCODER_WRITE_STATE = 0x01 << 2, // Xcoder write state
253 NI_XCODER_READ_STATE = 0x01 << 3, // Xcoder read state
254 NI_XCODER_CLOSE_STATE = 0x01 << 4, // Xcoder close state
255 // Xcoder flush state, flush at the end of stream
257 // Xcoder inter flush state, flush during transcoding stream
259 NI_XCODER_READ_DESC_STATE = 0x01 << 7, // Xcoder Read Desc state
260 NI_XCODER_HWUP_STATE = 0x01 << 8, // Xcoder HW upload state
261 NI_XCODER_HWDL_STATE = 0x01 << 9, // Xcoder HW download state
262 // Other states, like init, alloc, etc.
265
266typedef enum
267{
268 NI_PIX_FMT_YUV420P = 0, /* 8-bit YUV420 planar */
269 NI_PIX_FMT_YUV420P10LE = 1, /* 10-bit YUV420 planar */
270 NI_PIX_FMT_NV12 = 2, /* 8-bit YUV420 semi-planar */
271 NI_PIX_FMT_P010LE = 3, /* 10-bit YUV420 semi-planar */
272 NI_PIX_FMT_RGBA = 4, /* 32-bit RGBA packed */
273 NI_PIX_FMT_BGRA = 5, /* 32-bit BGRA packed */
274 NI_PIX_FMT_ARGB = 6, /* 32-bit ARGB packed */
275 NI_PIX_FMT_ABGR = 7, /* 32-bit ABGR packed */
276 NI_PIX_FMT_BGR0 = 8, /* 32-bit BGRX packed */
277 NI_PIX_FMT_BGRP = 9, /* 24-bit BGR planar */
278 NI_PIX_FMT_NV16 = 10, /* 8-bit YUV422 semi-planar */
279 NI_PIX_FMT_YUYV422 = 11, /* 8-bit YUV422 packed */
280 NI_PIX_FMT_UYVY422 = 12, /* 8-bit YUV422 packed */
281 NI_PIX_FMT_8_TILED4X4 = 13, /* 8 bit tiled4x4 */
282 NI_PIX_FMT_10_TILED4X4 = 14,/* 10 bit tiled4x4 */
283 NI_PIX_FMT_NONE = 15, /* invalid format */
285
294
295typedef enum {
296 NI_CUS_ROI_DISABLE = 0, // disable 2-pass customize roi
297 NI_CUS_ROI_MAPFILE = 1, // select qp in customizeQpMapFile
298 NI_CUS_ROI_REPLACE = 2, // replace the cutree roimap with the customize roimap
299 NI_CUS_ROI_OVERWRITE = 3, // overwrite the cutree roimap with the customize roimap
300 NI_CUS_ROI_MERGE = 4 // add the customize roimap into the cutree roimap
302
303// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
304// If you change this,you should also change NI_QUADRA_SCALER_FLAG_* in ni_quadra_filter_api.h
305#define NI_SCALER_FLAG_IO 0x0001 /* 0 = source frame, 1 = destination frame */
306#define NI_SCALER_FLAG_PC 0x0002 /* 0 = single allocation, 1 = create pool */
307#define NI_SCALER_FLAG_PA 0x0004 /* 0 = straight alpha, 1 = premultiplied alpha */
308#define NI_SCALER_FLAG_P2 0x0008 /* 0 = normal allocation, 1 = P2P allocation */
309#define NI_SCALER_FLAG_FCE 0x0010 /* 0 = no fill color, 1 = fill color enabled */
310#define NI_SCALER_FLAG_CS 0x0020 /* 0 = BT.709, 1 = BT.2020 */
311#define NI_SCALER_FLAG_LM 0x0040 /* 0 == no memory acquisition limit, 1 == limit memory acquisition */
312#define NI_SCALER_FLAG_CMP 0x0800 /* 0 = no compress, 1 = compress*/
313
314#define NI_AI_FLAG_IO 0x0001 /* 0 = source frame, 1 = destination frame */
315#define NI_AI_FLAG_PC 0x0002 /* 0 = single allocation, 1 = create pool */
316#define NI_AI_FLAG_LM 0x0004 /* 0 == no memory acquisition limit; 1 == limit memory acquisition */
317#define NI_AI_FLAG_IOVEC 0x0008
318#define NI_AI_FLAG_SC 0x0010 /* 0 == size got from network info; 1 == size configured by sw */
319
320#define NI_UPLOADER_FLAG_LM 0x0010 /* 0 == no memory acquisition limit, 1 == limit memory acquisition */
321
322// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
323// If you change this,you should also change NI_QUADRA_MAX_KEEP_ALIVE_TIMEOUT,
324// NI_QUADRA_MIN_KEEP_ALIVE_TIMEOUT,NI_QUADRA_DEFAULT_KEEP_ALIVE_TIMEOUT in ni_quadra_filter_api.h
325#define NI_MAX_KEEP_ALIVE_TIMEOUT 100
326#define NI_MIN_KEEP_ALIVE_TIMEOUT 1
327#define NI_DEFAULT_KEEP_ALIVE_TIMEOUT 3
328
329#define NI_MAX_DEFAULT_RETRY 500
330
331#define NI_MIN_CUSTOM_SEI_PASSTHRU -1
332#define NI_MAX_CUSTOM_SEI_PASSTHRU 254
333#define NI_DISABLE_USR_DATA_SEI_PASSTHRU 0
334#define NI_ENABLE_USR_DATA_SEI_PASSTHRU 1
335#define NI_INVALID_SVCT_DECODING_LAYER -1
336#define NI_EC_POLICY_TOLERANT 1
337#define NI_EC_POLICY_IGNORE 2
338#define NI_EC_POLICY_SKIP 3
339#define NI_EC_POLICY_BEST_EFFORT 4
340#define NI_EC_POLICY_LIMITED_ERROR 5
341#define NI_EC_POLICY_BEST_EFFORT_OUT_DC 6
342#define NI_EC_POLICY_DEFAULT NI_EC_POLICY_BEST_EFFORT
343#define NI_EC_ERR_THRESHOLD_DEFAULT 10
344
345//DecDecoderMode defined in ctrlsw
346#define NI_DEC_MODE_NORMAL 0x00000000
347#define NI_DEC_MODE_LOW_LATENCY 0x00000001
348#define NI_DEC_MODE_LOW_LATENCY_RTL 0x00000002
349#define NI_DEC_MODE_SECURITY 0x00000004
350#define NI_DEC_MODE_PARTIAL_DECODING 0x00000008
351#define NI_DEC_MODE_INTRA_ONLY 0x00000010
352
353// Picked from the xcoder firmware, commit e3b882e7
354#define NI_VPU_CEIL(_data, _align) (((_data)+((_align)-1))&~((_align)-1))
355#define NI_VPU_ALIGN4(_x) (((_x)+0x03)&~0x03)
356#define NI_VPU_ALIGN8(_x) (((_x)+0x07)&~0x07)
357#define NI_VPU_ALIGN16(_x) (((_x)+0x0f)&~0x0f)
358#define NI_VPU_ALIGN32(_x) (((_x)+0x1f)&~0x1f)
359#define NI_VPU_ALIGN64(_x) (((_x)+0x3f)&~0x3f)
360#define NI_VPU_ALIGN128(_x) (((_x)+0x7f)&~0x7f)
361#define NI_VPU_ALIGN256(_x) (((_x)+0xff)&~0xff)
362#define NI_VPU_ALIGN512(_x) (((_x)+0x1ff)&~0x1ff)
363#define NI_VPU_ALIGN2048(_x) (((_x)+0x7ff)&~0x7ff)
364#define NI_VPU_ALIGN4096(_x) (((_x)+0xfff)&~0xfff)
365#define NI_VPU_ALIGN16384(_x) (((_x)+0x3fff)&~0x3fff)
366
367#if 1 // QUADRA_SEI_FMT
368#pragma pack(1)
369typedef struct _ni_sei_header {
370 uint8_t status;
371 uint16_t size;
372 uint8_t type;
374#pragma pack()
375#else // QUADRA_SEI_FMT
376typedef struct _ni_sei_user_data_entry
377{
378 uint32_t offset;
379 uint32_t size;
380} ni_sei_user_data_entry_t;
381#endif // QUADRA_SEI_FMT
382
383typedef enum
384{
390 NI_H265_USERDATA_FLAG_ITU_T_T35_PRE = 5, /* SEI Prefix: user_data_registered_itu_t_t35 */
391 NI_H265_USERDATA_FLAG_UNREGISTERED_PRE = 6, /* SEI Prefix: user_data_unregistered */
392 NI_H265_USERDATA_FLAG_ITU_T_T35_SUF = 7, /* SEI Suffix: user_data_registered_itu_t_t35 */
393 NI_H265_USERDATA_FLAG_UNREGISTERED_SUF = 8, /* SEI Suffix: user_data_unregistered */
394 NI_H265_USERDATA_FLAG_RESERVED_9 = 9, /* SEI RESERVED */
395 NI_H265_USERDATA_FLAG_MASTERING_COLOR_VOL = 10, /* SEI Prefix: mastering_display_color_volume */
396 NI_H265_USERDATA_FLAG_CHROMA_RESAMPLING_FILTER_HINT = 11, /* SEI Prefix: chroma_resampling_filter_hint */
397 NI_H265_USERDATA_FLAG_KNEE_FUNCTION_INFO = 12, /* SEI Prefix: knee_function_info */
398 NI_H265_USERDATA_FLAG_TONE_MAPPING_INFO = 13, /* SEI Prefix: tone_mapping_info */
399 NI_H265_USER_DATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO = 14, /* SEI Prefix: film_grain_characteristics_info */
400 NI_H265_USER_DATA_FLAG_CONTENT_LIGHT_LEVEL_INFO = 15, /* SEI Prefix: content_light_level_info */
401 NI_H265_USER_DATA_FLAG_COLOUR_REMAPPING_INFO = 16, /* SEI Prefix: content_light_level_info */
402 NI_H265_USERDATA_FLAG_ITU_T_T35_PRE_1 = 28, /* SEI Prefix: additional user_data_registered_itu_t_t35 */
403 NI_H265_USERDATA_FLAG_ITU_T_T35_PRE_2 = 29, /* SEI Prefix: additional user_data_registered_itu_t_t35 */
404 NI_H265_USERDATA_FLAG_ITU_T_T35_SUF_1 = 30, /* SEI Suffix: additional user_data_registered_itu_t_t35 */
405 NI_H265_USERDATA_FLAG_ITU_T_T35_SUF_2 = 31, /* SEI Suffix: additional user_data_registered_itu_t_t35 */
407
408typedef enum
409{
410 PIC_TYPE_I = 0, /*!*< I picture */
411 PIC_TYPE_P = 1, /*!*< P picture */
412 PIC_TYPE_B = 2, /*!*< B picture (except VC1) */
413
415 PIC_TYPE_IDR = 3, /*!*< Encoder IDR pic type */
416 DECODER_PIC_TYPE_IDR = 5, /*!*< Decoder-returned IDR pic type */
417 PIC_TYPE_NIDR = 5, /*!*< H.264/H.265 IDR picture */
418 PIC_NOT_CODED = 6, /*!*< Picture dropped in encoder */
419 PIC_TYPE_MAX /*!*< No Meaning */
421
422#if 1 // QUADRA_SEI_FMT
423// user data unreg and custom SEIs have variable length;
424// non-custom SEIs will be dropped if buffer overflow;
425// custom SEIs passthru is via SW and host memory constrained
426#define NI_ENC_MAX_SEI_BUF_SIZE NI_VPU_ALIGN64(1024) // sync with encoder
427
428// PIC_TIMING and BUFFERING_PERIOD apply to encoder only, not needed from decoder
429// For now, only the following will be returned from decoder:
430// - T35 has 3 possible data types: CLOSE_CAPTION, HDR10PLUS, AFD
431// - MASTERING_DISPLAY_COLOUR
432// - CONTENT_LIGHT_LEVEL
433// - USER_DATA_UNREGISTERED
434// - CUSTOM_SEI
435// Note: USER_DATA_UNREGISTERED may have arbitrary size but SEI buffer
436// size is limited. The SEI buffer on decoder has the following format:
437// [byte0: #entries][entry1]..[entryN]
438// up to (1 + sizeof(ni_sei_header_t) + NI_MAX_SEI_DATA) bytes maximum;
439// where [entryX] := [ni_sei_header][payload]
440// [payload] of ni_sei_header.size: present only if ni_sei_header.status == 1
441// X in [1..N] with N <= #entries
442// N == #entries only if NI_MAX_SEI_DATA is large enough to store all #entries
443// ex:
444// entryX header fits in the buffer during SEI extration, but payload can't fit in;
445// so only entryX header is stored but payload is drop with status set 0.
446// entryX header can't fit in the buffer (SEI buffer full); so extryX is not stored
447// in the SEI buffer (neither will any further SEIs)
448//
449// To maintain alignment, current implementation retrieves SEI data buffer from
450// entry 1's payload onwards (skipping byte0, and entry 1's header),
451// while #entries (same value as SEI buffer byte0) and entry 1's header are notified
452// separately via metadata.
453#define NI_MAX_SEI_DATA (NI_ENC_MAX_SEI_BUF_SIZE) // sync with decoder_manager
454// Custom SEI only applies to software delivery
455#define NI_MAX_CUSTOM_SEI_DATA (8192)
456
457#else // QUADRA_SEI_FMT
458#define NI_MAX_SEI_ENTRIES 32
459// 32 user_data_entry_t records + various SEI messages sizes
460#define NI_MAX_SEI_DATA \
461 NI_MAX_SEI_ENTRIES * sizeof(ni_sei_user_data_entry_t) + \
462 NI_MAX_T35_CLOSE_CAPTION_SIZE + \
463 NI_MASTERING_DISPLAY_COLOUR_VOLUME_SIZE + \
464 NI_CONTENT_LIGHT_LEVEL_INFO_SIZE + NI_MAX_T35_HDR10PLUS_SIZE + \
465 NI_MAX_T35_AFD_SIZE
466#endif // QUADRA_SEI_FMT
467
468#define NI_DEC_MAX_CC_BUF_SIZE 93 // max 31 CC entries of 3 bytes each
469
470#define NI_CC_SEI_BYTE0 0xB5 // itu_t_t35_country_code =181 (North America)
471#define NI_CC_SEI_BYTE1 0x00
472#define NI_CC_SEI_BYTE2 0x31 // itu_t_t35_provider_code = 49
473#define NI_CC_SEI_BYTE3 0x47 // ATSC_user_identifier = "GA94"
474#define NI_CC_SEI_BYTE4 0x41
475#define NI_CC_SEI_BYTE5 0x39
476#define NI_CC_SEI_BYTE6 0x34
477#define NI_CC_SEI_BYTE7 0x03 // cc_data = 0x03
478
479#define NI_HDR10P_SEI_BYTE0 0xB5 // itu_t_t35_country_code =181 (North America
480#define NI_HDR10P_SEI_BYTE1 0x00
481#define NI_HDR10P_SEI_BYTE2 0x3c // itu_t_t35_provider_code = 0x003c
482#define NI_HDR10P_SEI_BYTE3 0x00
483#define NI_HDR10P_SEI_BYTE4 0x01 // u16 itu_t_t35_provider_oriented_code = 0x0001
484#define NI_HDR10P_SEI_BYTE5 0x04 // u8 application_identifier = 0x04
485// no longer checking the application version as it was originally 0 but was recently specified as one by AOM.
486#define NI_HDR10P_SEI_BYTE6 0x00 // u8 application version = 0x00
487
488#define NI_CC_SEI_HDR_HEVC_LEN 18
489#define NI_HDR10P_SEI_HDR_HEVC_LEN 9
490#define NI_HDR10P_SEI_HDR_H264_LEN 8
491#define NI_HDR10P_SEI_HDR_AV1_LEN 4
492#define NI_CC_SEI_HDR_H264_LEN 17
493#define NI_CC_SEI_HDR_AV1_LEN 13
494#define NI_CC_SEI_TRAILER_LEN 2
495#define NI_RBSP_TRAILING_BITS_LEN 1
496
497// The macro definition in ni_quadra_filter_api.h need to be synchronized with libxcoder
498// If you change this,you should also change NI_QUADRA_MAX_NUM_AUX_DATA_PER_FRAME in ni_quadra_filter_api.h
499#define NI_MAX_NUM_AUX_DATA_PER_FRAME 16
500
502#define NI_BITRATE_RECONFIG_FILE_MAX_LINES 50000
505#define NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE 10
506
508#define NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL 10
510#define NI_CUSTOMIZE_ROI_QP_NUM 64
511
512#define MOTION_CONSTRAINED_PERFORMANCE_MODE 1
513#define MOTION_CONSTRAINED_QUALITY_MODE 2
514#define MOTION_CONSTRAINED_QUALITY_MODE_ADVANCED 3
515// Highest supported mode id; when adding a mode, define its value then point MAX at the new last id (no separate literal).
516#define MOTION_CONSTRAINED_MODE_MAX MOTION_CONSTRAINED_QUALITY_MODE_ADVANCED
517
518/*!*
519* \brief Frame pool type.
520*/
522{
523 NI_POOL_TYPE_NONE = -1, /* frame pool not inited or allocated */
527
528// frame auxiliary data; mostly used for SEI data associated with frame
530{
532
533 // ATSC A53 Part 4 Closed Captions
535
536 // HDR10 mastering display metadata associated with a video frame
538
539 // HDR10 content light level (based on CTA-861.3). This payload contains
540 // data in the form of ni_content_light_level_t struct.
542
543 // HDR10+ dynamic metadata associated with a video frame. The payload is
544 // a ni_dynamic_hdr_plus_t struct that contains information for color volume
545 // transform - application 4 of SMPTE 2094-40:2016 standard.
547
548 // Regions of Interest, the payload is an array of ni_region_of_interest_t,
549 // the number of array element is implied by:
550 // ni_frame_aux_data.size / sizeof(ni_region_of_interest_t)
552
553 // NETINT: user data unregistered SEI data, which takes SEI payload type
554 // USER_DATA_UNREGISTERED.
555 // There will be no byte reordering.
556 // Usually this payload would be: 16B UUID + other payload Bytes.
558
559 // NETINT: custom SEI data, which takes SEI payload custom types.
560 // There will be no byte reordering.
561 // Usually this payload would be: 1B Custom SEI type + 16B UUID + other
562 // payload Bytes.
564
565 // NETINT: bitrate adjustment, which takes int32_t type data as
566 // payload that indicates the new target bitrate value.
568
569 // NETINT: custom INTRAPRD adjustment, which takes int32_t type data
570 // as payload that specifies the new intra period
572
573 // NETINT: custom VUI adjustment, which is a struct of
574 // ni_vui_hrd_t that specifies a frame's support of vui
576
577 // NETINT: long term reference frame support, which is a struct of
578 // ni_long_term_ref_t that specifies a frame's support of long term
579 // reference frame.
581
582 // NETINT: long term reference interval adjustment, which takes int32_t
583 // type data as payload that indicates the new long term reference interval
584 // value.
586
587 // NETINT: frame reference invalidation, which takes int32_t type data
588 // as payload that indicates the frame number after which all references
589 // shall be invalidated.
591
592 // NETINT: framerate adjustment, which takes int32_t type data as
593 // payload that indicates the new target framerate numerator and denominator values.
595
596 // NETINT: maxFrameSize adjustment, which takes int16_t type data as
597 // payload that indicates the new maxFrameSize value
599
600 // NETINT: max&min QP adjustment, which is a struct of
601 // payload that indicate the new max&min QP values
603
604 // NETINT: crf adjustment, which takes int32_t type data
605 // as payload that indicates the new crf value.
607
608 // NETINT: crf adjustment, which takes float type data
609 // as payload that indicates the new crf value.
611
612 // NETINT: VbvMaxRate adjust, which takes int32_t type
613 // as payload that indicates the VbvMaxRate value.
615
616 // NETINT: VbvBufferSize adjust, which takes int32_t type
617 // as payload that indicates the vbvBufferSize value.
619
620 // NETINT: sliceArg adjust, which takes int16_t type
621 // as payload that indicates the sliceArg value.
623
624 // NETINT: sliceArg adjust, which takes ni_category_classify_t
625 // type as payload that indicates the class and prob.
628
629// rational number (pair of numerator and denominator)
630typedef struct _ni_rational
631{
632 int num; // numerator
633 int den; // denominator
635
636// create an ni_rational_t
637static inline ni_rational_t ni_make_q(int num, int den)
638{
639 ni_rational_t ret = {num, den};
640 return ret;
641}
642
643// convert an ni_rational_t to a double
644static inline double ni_q2d(ni_rational_t a)
645{
646 return a.num / (double)a.den;
647}
648
649// struct to hold auxiliary data for ni_frame_t
656
657// struct describing a Region Of Interest (ROI)
659{
660 // self size: must be set to: sizeof(ni_region_of_interest_t)
661 uint32_t self_size;
662
663 // ROI rectangle: pixels from the frame's top edge to the top and bottom
664 // edges of the rectangle, from the frame's left edge to the left and right
665 // edges of the rectangle.
666 int top;
668 int left;
669 int right;
670
671 // quantisation offset: [-1, +1], 0 means no quality change; < 0 value asks
672 // for better quality (less quantisation), > 0 value asks for worse quality
673 // (greater quantisation).
676
677// struct describing category class and prob
684
685// struct describing VUI HRD support.
686typedef struct _ni_vui_hrd
687{
688 // Indicates the presence of color info such as primaries, trc etc.
690
691 // Indicates the chromaticity of RGB and white components of the
692 // displayed image (See Table E.3 of H.265 spec)
694
695 // The opto-electronic transfer characteristic of the source picture
696 // (See Table E.4 of H.265 spec)
697 int32_t colorTrc;
698
699 // Method to represent brightness, luminance or luma and colour (e.g. RGB)
700 int32_t colorSpace;
701
702 // Luma sample aspect ratio width. With aspectRatioHeight, translates
703 // into specific display ratios such as 16:9, 4:3, etc.
705
706 // Luma sample aspect ratio height
708
709 // Input video signal sample range [0,1].
710 // 0 = Y range in [16..235] Cb,Cr in [16..240]. 1 = Y,Cb,Cr in [0..255]
713
714// struct describing long term reference frame support.
715typedef struct _ni_long_term_ref
716{
717 // A flag for the current picture to be used as a long term reference
718 // picture later at other pictures' encoding
720
721 // A flag to use a long term reference picture in DPB when encoding the
722 // current picture
725
726// struct describing framerate.
727typedef struct _ni_framerate
728{
729 // framerate numerator
731
732 // framerate denominator
735
736typedef struct _ni_rc_min_max_qp
737{
738 int32_t minQpI;
739 int32_t maxQpI;
740 int32_t maxDeltaQp;
741 int32_t minQpPB;
742 int32_t maxQpPB;
744
745typedef struct _ni_dec_win
746{
747 int16_t left;
748 int16_t right;
749 int16_t top;
750 int16_t bottom;
752
754{
756 uint32_t time_scale;
758 uint8_t color_trc;
759 uint8_t color_space;
761 // 48 bytes reserved for receiving more header info
762 uint64_t rsvd0;
763 uint64_t rsvd1;
764 uint64_t rsvd2;
765 uint64_t rsvd3;
766 uint64_t rsvd4;
767 uint64_t rsvd5;
769
770/*!*
771* \brief decoded payload format of H.265 VUI
772*
773*/
775{
780
783
786
787 uint16_t sar_width;
788 uint16_t sar_height;
789
793
797
799
801
806
809
812
819
823
825
827
828/*!*
829* \brief decoded payload format of H.264 VUI
830*
831*/
876
877/*!*
878* \brief encoder HEVC ROI custom map (1 CTU = 64bits)
879*/
881{
882 struct
883 {
884 uint32_t ctu_force_mode : 2; //[ 1: 0]
885 uint32_t ctu_coeff_drop : 1; //[ 2]
886 uint32_t reserved : 5; //[ 7: 3]
887 uint32_t sub_ctu_qp_0 : 6; //[13: 8]
888 uint32_t sub_ctu_qp_1 : 6; //[19:14]
889 uint32_t sub_ctu_qp_2 : 6; //[25:20]
890 uint32_t sub_ctu_qp_3 : 6; //[31:26]
891
892 uint32_t lambda_sad_0 : 8; //[39:32]
893 uint32_t lambda_sad_1 : 8; //[47:40]
894 uint32_t lambda_sad_2 : 8; //[55:48]
895 uint32_t lambda_sad_3 : 8; //[63:56]
898
899/*!*
900* \brief encoder AVC ROI custom map (1 MB = 8bits)
901*/
903{
904 struct
905 {
906 uint8_t mb_force_mode : 2; // [ 1: 0]
907 uint8_t mb_qp : 6; // [ 7: 2]
910
911/*!*
912* \brief encoder AVC ROI custom map (1 MB = 8bits)
913*/
914// QP/CU Control Information Format 1
916{
917 struct
918 {
919 uint8_t roiAbsQp_flag : 1; // [ 0] (0: QP_delta, 1: abs_QP)
920 uint8_t
921 qp_info : 6; // [ 6: 1] (QP_delta: -32 <= qp_info <= 31, QP_info =- QP_delta, abs_QP: 0 <= Qp_info <= 51, Qp_info = abs_QP)
922 uint8_t
923 ipcm_flag : 1; // [ 7] (0: do not force IPCM mode, 1: force IPCM mode)
926// QP/CU Control Information Format 2
927/*
928typedef union _ni_enc_quad_roi_custom_map
929{
930 struct
931 {
932 uint8_t qp_info : 6; // [ 5: 0] (QP_delta: -32 <= qp_info <= 31, QP_info =- QP_delta, abs_QP: 0 <= Qp_info <= 51, Qp_info = abs_QP)
933 uint8_t roiAbsQp_flag : 1; // [ 6] (0: QP_delta, 1: abs_QP)
934 uint8_t skip_flag : 1; // [ 7] (0: do not force skip mode, 1: force skip)
935 } field;
936} ni_enc_quad_roi_custom_map;
937*/
938/*!*
939* \brief This is an enumeration for supported codec formats.
940*/
949
957
964
965
966/*!*
967* \brief This is an enumeration for hw actions
968*/
978
979/*!*
980* \brief This is an enumeration for encoder parameter change.
981*/
983{
984 // COMMON parameters which can be changed frame by frame.
986 //NI_SET_CHANGE_PARAM_INTRA_PARAM = (1 << 1), // not required by customers
988 //NI_SET_CHANGE_PARAM_RC = (1 << 9), // not required by customers
1007 NI_SET_CHANGE_PARAM_INTRA_PERIOD = ((unsigned int)1 << 31),
1008 //bit [2,7] and [13,15] is still unused
1010
1015{
1017
1018 // NI_SET_CHANGE_PARAM_RC_TARGET_RATE
1019 int32_t bitRate;
1022 // NI_SET_CHANGE_PARAM_RC
1023// (rcEnable, cuLevelRc, bitAllocMode, RoiEnable, RcInitQp can't be changed while encoding)
1024 int32_t hvsQPEnable;
1025 int32_t hvsQpScale;
1029 // NI_SET_CHANGE_PARAM_RC_MIN_MAX_QP
1030 int32_t minQpI;
1031 int32_t maxQpI;
1033 int32_t maxDeltaQp;
1034#ifdef QUADRA
1035 int32_t minQpPB;
1036 int32_t maxQpPB;
1037#else
1038 int32_t minQpP;
1039 int32_t minQpB;
1040 int32_t maxQpP;
1041 int32_t maxQpB;
1042#endif
1043
1044 // NI_SET_CHANGE_PARAM_INTRA_PARAM
1045 int32_t intraQP;
1046 int32_t intraPeriod;
1049#ifdef QUADRA
1050 // NI_SET_CHANGE_PARAM_VUI_HRD_PARAM
1053 uint8_t colorTrc;
1054 uint8_t colorSpace;
1059 // RESERVED FOR FUTURE USE
1060 uint8_t reserved[5];
1061
1062 // NI_SET_CHANGE_PARAM_SLICE_ARG
1063 int16_t sliceArg;
1064 //NI_SET_CHANGE_PARAM_VBV also reconfig for ni_vbvBufferSize
1065 int32_t vbvMaxRate;
1066
1067 // NI_SET_CHANGE_PARAM_CRF
1068 // crf reconfig (range in [0.00 .. 51.00])
1069 uint8_t crfDecimal; // crf decimal fraction * 100 (range in [0 .. 99])
1070 uint8_t crf; // crf integer (range in [0 .. 51])
1071
1072 // NI_SET_CHANGE_PARAM_MAX_FRAME_SIZE
1073 uint16_t maxFrameSize; // maxFrameSize reconfig (in unit of 2000 bytes)
1074
1075 // NI_SET_CHANGE_PARAM_INVALID_REF_FRAME
1077
1078 // NI_SET_CHANGE_PARAM_LTR_INTERVAL
1080
1081 // NI_SET_CHANGE_PARAM_RC_FRAMERATE
1084#else
1085 int32_t reserved[8];
1086#endif
1088
1089/*!*
1090* \brief decoded payload format of HDR SEI mastering display colour volume
1091*
1092*/
1101
1102/*!*
1103* \brief payload format of HDR SEI content light level info
1104*
1105*/
1111
1112/*!*
1113* \brief encoded payload format of HDR SEI mastering display colour volume
1114*
1115*/
1124
1125typedef struct _ni_pkt_info
1126{
1127 double psnr_y;
1128 double psnr_u;
1129 double psnr_v;
1131 double ssim_y;
1132 double ssim_u;
1133 double ssim_v;
1134 double reserved[1];
1136
1137/*!*
1138 * \brief This is an enumeration for illustrating the custom SEI locations.
1139 */
1145
1146/*!*
1147 * \brief custom sei payload passthrough
1148 */
1156
1162
1163/*!*
1164* \brief hardware capability type
1165*/
1166typedef struct _ni_hw_capability
1167{
1168 uint8_t hw_id;
1170 uint8_t max_4k_fps;
1172 uint8_t codec_type;
1179 uint8_t reserved; // 16B alignment. Unnecessary?
1181
1182/*!*
1183* \brief device capability type
1184*/
1205
1206/*!*
1207* \brief Session running state type.
1208*/
1217
1218typedef struct _ni_context_query
1219{
1220 uint32_t context_id : 8; //07:00 SW Instance ID (0 to Max number of instances)
1221 uint32_t context_status : 8; //15:08 Instance Status (0-Idle, 1-Active)
1222 uint32_t
1223 codec_format : 8; //23:16 Codec Format (0-H264, 1-H265, 2-VP9, 3-JPEG, 4-AV1)
1224 uint32_t video_width : 16; //39:24 Video Width (0 to Max Width)
1225 uint32_t video_height : 16; //55:40 Video Height (0 to Max Height)
1226 uint32_t fps : 8; //63:56 FPS (0 to 255)
1227 uint32_t reserved : 8; //Alignment
1229
1230typedef struct _ni_load_query
1231{
1234 uint32_t fw_load;
1236 union{
1238 uint32_t pcie_throughput; //PCIe throughput - ni_query_nvme_status
1239 };
1240 union {
1242 uint32_t pcie_load; //PCIe load - ni_query_nvme_status
1243 };
1246 union {
1248 uint32_t tp_fw_load; //TP FW load - ni_query_nvme_status
1249 };
1250
1252
1255
1263
1275
1285
1290
1292{
1293 int hw_id; // Codec ID
1294 uint32_t session_id; // session id
1295 uint64_t session_timestamp; // Session Start Timestamp
1296 bool close_thread; // a flag that the keep alive thread is closed or need to be closed
1297 uint32_t device_type; // Device Type, Either NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER
1298 ni_device_handle_t device_handle; // block device handler
1299 ni_event_handle_t thread_event_handle; // only for Windows asynchronous read and write
1300 void *p_buffer; // only be used when regular-io.
1301 ni_pthread_mutex_t *p_mutex; // referring to mutex of session context.
1302 uint32_t keep_alive_timeout; // keep alive timeout setting
1303 volatile uint64_t *plast_access_time; // shared variable for main thread to verify timeout. Keep alive thread will update last_access_time
1305
1315
1326
1337
1346
1354
1359
1361{
1362 uint32_t num_of_dims; /* The number of dimensions specified in *sizes */
1363 uint32_t sizes[6]; /* The pointer to an array of dimension */
1364 int32_t
1365 data_format; /* Data format for the tensor, see ni_ai_buffer_format_e */
1366 int32_t
1367 quant_format; /* Quantized format see ni_ai_buffer_quantize_format_e */
1368 union
1369 {
1370 struct
1371 {
1372 int32_t
1373 fixed_point_pos; /* Specifies the fixed point position when the input element type is int16, if 0 calculations are performed in integer math */
1375
1376 struct
1377 {
1378 float scale; /* Scale value for the quantized value */
1379 int32_t zeroPoint; /* A 32 bit integer, in range [0, 255] */
1381 } quant_data; /* The union of quantization information */
1382 /* The type of this buffer memory. */
1383 uint32_t memory_type;
1385
1391
1396
1397typedef struct _ni_network_data
1398{
1399 uint32_t input_num;
1400 uint32_t output_num;
1403 *inset; /* point to each input layer start offset from p_frame */
1405 *outset; /* point to each output layer start offset from p_packet */
1407
1408// if change this structure, you need to change ni_quadra_filter_api.h ni_quadra_frameclone_desc_t
1410{
1411 uint16_t ui16SrcIdx;
1412 uint16_t ui16DstIdx;
1413 uint32_t ui32Offset;
1414 uint32_t ui32Size;
1415 uint32_t reserved;
1417
1429
1430typedef struct _ni_input_frame
1431{
1433
1434 uint32_t video_width;
1436
1437 int64_t pts;
1438
1439 int8_t usable;
1441
1442// This is for decoder to reset the ppu value
1443// ppu_set_enable & (0x1 << idx) is which ppu[idx] enabled
1444// for examle, ppu_set_enable is 3, so ppu0 amd ppu1 is enabled
1445// 0x03 & (0x01 << 0) is not 0 and 0x03 &(0x01 << 1) is not 0
1446// 0: all ppu disabled. 1: ppu0 enabled. 2: ppu1 enabled
1447// 3: ppu0 ppu1 enabled. 4: ppu2 enabled. 5: ppu0 ppu2 enabled
1448// 6: ppu1 ppu enabled. 7: all ppu enabled others: disabled
1454
1455typedef float (*ni_kernel_coeff_fn)(int filtersize, double offset, double B, double C);
1457{
1459 /* frame_time_q is pointer to ni_lat_meas_q_t but reserved as void pointer
1460 here as ni_lat_meas_q_t is part of private API */
1462#ifndef DEPRECATION_AS_ERROR
1464#endif
1465
1473
1475
1486
1489 int64_t last_pts;
1490 int64_t last_dts;
1498#ifndef DEPRECATION_AS_ERROR
1500#endif
1501
1502 /* store pts values to create an accurate pts offset */
1511
1514
1516 ni_device_handle_t device_handle;
1517
1519 ni_device_handle_t blk_io_handle;
1520
1522 ni_device_handle_t sender_handle;
1523 ni_device_handle_t auto_dl_handle;
1524 uint8_t is_auto_dl;
1525
1528
1534 uint32_t session_id;
1538 uint32_t device_type;
1545
1546 int src_bit_depth; // 8 or 10 bits/pixel formats, default 8
1547 int src_endian; // encoding 0: little endian (default) 1: big
1548 int bit_depth_factor; // for YUV buffer allocation
1549 // for encoder roi metadata
1550 uint32_t roi_len;
1551 uint32_t roi_avg_qp;
1552
1555
1556 /* Overall resource use among namespaces */
1558
1560 uint8_t *p_leftover;
1562 uint32_t sent_size;
1563
1565 uint8_t *p_hdr_buf;
1567
1570
1573
1576
1580
1581 void *p_dump[2];
1582 char param_err_msg[512];
1583
1584 int keyframe_factor; // Unused
1585 uint64_t frame_num;
1586 uint64_t pkt_num;
1587 int rc_error_count; // Unused
1588
1590 uint32_t hwd_src_cpu;
1593 uint32_t hwd_Inst_ID;
1594
1595 // frame forcing: for encoding
1597
1598 uint32_t ready_to_close; //flag to indicate we are ready to close session
1599
1600 // session running state
1602 //Current video width. this is used to do sequence change
1604 //Current video height ,this is used to do sequence change
1606 //Actual video width (without stride + cropped)
1608 // Used to track sequence changes that require bigger bitstream buffers
1610 ni_pthread_t keep_alive_thread;
1614
1615 // original resolution this stream started with, this is used by encoder sequence change
1617
1618 // a mutex for Xcoder API, to keep the thread-safety.
1619 ni_pthread_mutex_t mutex;
1620
1621 // Xcoder running state
1623
1624 // only be used when regular-io
1625 void *p_all_zero_buf; //This is for sos, eos, flush and keep alive request
1626
1627 // these two event handle are only for Windows asynchronous read and write now
1628 ni_event_handle_t event_handle;
1629 ni_event_handle_t thread_event_handle;
1630
1631 // ROI data
1633 // last passed in ni_region_of_interest_t
1636 ni_enc_quad_roi_custom_map *roi_map; // actual AVC/HEVC QP map
1637
1638 // only for H.264 test roi buffer for up to 8k resolution H.264 - 32 x 32 sub CTUs
1640 // only for H.265 custom map buffer for up to 8k resolution - 64x64 CTU Regions
1642 // only for hevc actual ROI map is stored in individual session context !
1644
1645 // encoder reconfig parameters
1647 // decoder lowDelay mode for All I packets or IPPP packets
1650
1651 // wrapper API request data, to be sent out once with the next input frame
1652 // to encoder
1653 int32_t target_bitrate; // A target bitrate to reconfig, -1 if inactive
1654 int force_idr_frame; // force IDR frame type
1656 int32_t ltr_interval; // LTR interval to set
1657 int32_t ltr_frame_ref_invalid; // frame after which all ref to be invalid
1658 ni_framerate_t framerate; // framerate to reconfig, 0 if inactive
1659 ni_vui_hrd_t vui; // vui to reconfig
1660
1661 // path of decoder input pkt saving folder
1665
1666 // some parameters for decoder session
1667 // int hw_frame_extra_buffer; e.g. 3
1671 int32_t isP2P;
1673 unsigned short domain;
1674 unsigned short bus;
1675 unsigned short dev;
1676 unsigned short fn;
1677
1678 // the FW API version of device that opened
1679 uint8_t fw_rev[8];
1680 uint8_t ddr_config;
1681
1683
1685 uint32_t prev_fps;
1687 uint64_t prev_pts;
1691
1692 uint32_t meta_size;
1696
1697 // flags_array to save packet flags
1699
1700 // for decoder: store currently returned decoded frame's pkt offset
1703
1705
1706 uint32_t count_frame_num_in_sec; //used in the vfr mode, indicate the frame count in seconds
1707 uint32_t passed_time_in_timebase_unit; //used in the vfr mode, indicate how long it has passed
1708
1709 int32_t max_frame_size; // maxFrameSize (in bytes) to reconfig, 0 if inactive
1710
1711 // block device name requested by caller to open: when specified this block
1712 // device has priority over hw_id which is device specified by index.
1714
1715 // decoder low delay send/recv sync; async_mode = 0 by default, i.e.
1716 // codec send-to/recv-from FW is in synchrounous mode by default.
1719 ni_pthread_mutex_t low_delay_sync_mutex;
1720 ni_pthread_cond_t low_delay_sync_cond;
1721
1722 // muxtex default from source session
1723 // required pointer to external if used by hwdl
1724 ni_pthread_mutex_t* pext_mutex;
1726
1727 // required parameters for slow sequence change
1730
1731 // AI embedded network parameters data
1733
1736 //shared variable for main thread to read and keepalive thread to update
1737 volatile uint64_t last_access_time;
1738
1739 int reconfig_crf; // crf value to reconfig (range in [0..51]), -1 if inactive
1740 int reconfig_crf_decimal; // crf decimal fration value to reconfig
1741 // (range in [0..99]), -1 if inactive
1742 int reconfig_vbv_buffer_size; // vbv buffer size value to reconfig
1743 int reconfig_vbv_max_rate; // vbv max rate value to reconfig
1744
1749 uint64_t av1_pkt_num;
1750
1757 char E2EID[128];
1759 int pixel_format_changed; // only for decoder now
1761
1764 double psnr_y;
1765 double psnr_u;
1766 double psnr_v;
1771
1773
1774 // write packet/frame required buf size
1776
1777 // record the drop num
1779
1780 //for AI aio
1781 ni_aio_context_t aio_context;
1782 ni_iocb_t **iocbs;
1783 ni_io_event_t *io_event;
1785
1789
1791 void *mctf;
1795
1797{
1799 int w[3];
1800 int h[3];
1801 int f[3]; //planar format
1802 int f8b[3]; //forced 8bit
1803 //int crop_meta_data_rltb[3][4]; //crop rectangle
1805
1806/*!*
1807* \brief This is an enumeration for encoder reconfiguration test settings
1808*/
1809typedef enum _ni_reconfig
1810{
1816//XCODER_TEST_RECONF_RC = 5, // not required by customers
1817 XCODER_TEST_RECONF_RC_MIN_MAX_QP = 6, // reconfig min&max QP
1818#ifdef QUADRA
1823 XCODER_TEST_RECONF_RC_MIN_MAX_QP_REDUNDANT = 11, // reconfig min&max QP through libxcoder API (redundant demo mode index)
1829 XCODER_TEST_FORCE_IDR_FRAME = 100, // force IDR through libxcoder API
1830 XCODER_TEST_RECONF_BR_API = 101, // reconfig BR through libxcoder API
1831 XCODER_TEST_RECONF_INTRAPRD_API = 102, // reconfig intraperiod through libxcoder API
1832 XCODER_TEST_RECONF_VUI_HRD_API = 103, // reconfig VUI through libxcoder API
1833 XCODER_TEST_RECONF_LTR_API = 104, // reconfig LTR through libxcoder API
1834 XCODER_TEST_RECONF_RC_MIN_MAX_QP_API_REDUNDANT = 106, // reconfig min&max QP through libxcoder API (redundant demo mode index)
1835 XCODER_TEST_RECONF_LTR_INTERVAL_API = 107, // reconf LTR interval thru API
1836 XCODER_TEST_INVALID_REF_FRAME_API = 108, // invalidate ref frame thru API
1837 XCODER_TEST_RECONF_FRAMERATE_API = 109, // reconfig framerate through libxcoder API
1838 XCODER_TEST_RECONF_MAX_FRAME_SIZE_API = 110, // reconfig maxFrameSize through libxcoder API
1839 XCODER_TEST_RECONF_RC_MIN_MAX_QP_API = 111, // reconfig min&max QP through libxcoder API
1840 XCODER_TEST_CRF_API = 114, // reconfig crf through libxcoder API
1841 XCODER_TEST_CRF_FLOAT_API = 115, // reconfig crf float type through libxcoder API
1842 XCODER_TEST_RECONF_VBV_API = 116, // reconfig vbv buffer size and vbv max rate through libxcoder API
1843 XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO_API = 117, // reconfig maxFrameSize ratio through libxcoder API
1844 XCODER_TEST_RECONF_SLICE_ARG_API = 118, // reconfig sliceArg through libxcoder API
1846#endif
1848
1850{
1851 /* A float type of buffer data */
1853 /* A half float type of buffer data */
1855 /* A 8 bit unsigned integer type of buffer data */
1857 /* A 8 bit signed integer type of buffer data */
1859 /* A 16 bit unsigned integer type of buffer data */
1861 /* A 16 signed integer type of buffer data */
1863 /* A char type of data */
1865 /* A bfloat 16 type of data */
1867 /* A 32 bit integer type of data */
1869 /* A 32 bit unsigned signed integer type of buffer */
1871 /* A 64 bit signed integer type of data */
1873 /* A 64 bit unsigned integer type of data */
1875 /* A 64 bit float type of buffer data */
1878
1880{
1881 /* Not quantized format */
1883 /* A quantization data type which specifies the fixed point position for whole tensor. */
1885 /* A quantization data type which has scale value and zero point to match with TF and
1886 Android NN API for whole tensor. */
1888 /* A max vaule support quantize format */
1891
1893{
1894 NI_DDR_PRIORITY_NONE = -1, // Do not change DDR priorities
1895 NI_DDR_PRIORITY_RESET, // Reset DDR priorities to default
1896 NI_DDR_PRIORITY_DECENC, // DDR prioritize decoder and encoder
1897 NI_DDR_PRIORITY_FILT, // DDR prioritize filter
1898 NI_DDR_PRIORITY_AI, // DDR prioritize AI
1901
1914
1915#ifdef QUADRA
1916#define NI_ENC_GOP_PARAMS_G0_POC_OFFSET "g0pocOffset"
1917#define NI_ENC_GOP_PARAMS_G0_QP_OFFSET "g0QpOffset"
1918//#define NI_ENC_GOP_PARAMS_G0_QP_FACTOR "g0QpFactor"
1919#define NI_ENC_GOP_PARAMS_G0_TEMPORAL_ID "g0temporalId"
1920#define NI_ENC_GOP_PARAMS_G0_PIC_TYPE "g0picType"
1921#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PICS "g0numRefPics"
1922#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC0 "g0refPic0"
1923#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC0_USED "g0refPic0Used"
1924#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC1 "g0refPic1"
1925#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC1_USED "g0refPic1Used"
1926#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC2 "g0refPic2"
1927#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC2_USED "g0refPic2Used"
1928#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC3 "g0refPic3"
1929#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC3_USED "g0refPic3Used"
1930
1931#define NI_ENC_GOP_PARAMS_G1_POC_OFFSET "g1pocOffset"
1932#define NI_ENC_GOP_PARAMS_G1_QP_OFFSET "g1QpOffset"
1933//#define NI_ENC_GOP_PARAMS_G1_QP_FACTOR "g1QpFactor"
1934#define NI_ENC_GOP_PARAMS_G1_TEMPORAL_ID "g1temporalId"
1935#define NI_ENC_GOP_PARAMS_G1_PIC_TYPE "g1picType"
1936#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PICS "g1numRefPics"
1937#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC0 "g1refPic0"
1938#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC0_USED "g1refPic0Used"
1939#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC1 "g1refPic1"
1940#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC1_USED "g1refPic1Used"
1941#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC2 "g1refPic2"
1942#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC2_USED "g1refPic2Used"
1943#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC3 "g1refPic3"
1944#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC3_USED "g1refPic3Used"
1945
1946#define NI_ENC_GOP_PARAMS_G2_POC_OFFSET "g2pocOffset"
1947#define NI_ENC_GOP_PARAMS_G2_QP_OFFSET "g2QpOffset"
1948//#define NI_ENC_GOP_PARAMS_G2_QP_FACTOR "g2QpFactor"
1949#define NI_ENC_GOP_PARAMS_G2_TEMPORAL_ID "g2temporalId"
1950#define NI_ENC_GOP_PARAMS_G2_PIC_TYPE "g2picType"
1951#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PICS "g2numRefPics"
1952#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC0 "g2refPic0"
1953#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC0_USED "g2refPic0Used"
1954#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC1 "g2refPic1"
1955#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC1_USED "g2refPic1Used"
1956#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC2 "g2refPic2"
1957#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC2_USED "g2refPic2Used"
1958#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC3 "g2refPic3"
1959#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC3_USED "g2refPic3Used"
1960
1961#define NI_ENC_GOP_PARAMS_G3_POC_OFFSET "g3pocOffset"
1962#define NI_ENC_GOP_PARAMS_G3_QP_OFFSET "g3QpOffset"
1963//#define NI_ENC_GOP_PARAMS_G3_QP_FACTOR "g3QpFactor"
1964#define NI_ENC_GOP_PARAMS_G3_TEMPORAL_ID "g3temporalId"
1965#define NI_ENC_GOP_PARAMS_G3_PIC_TYPE "g3picType"
1966#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PICS "g3numRefPics"
1967#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC0 "g3refPic0"
1968#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC0_USED "g3refPic0Used"
1969#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC1 "g3refPic1"
1970#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC1_USED "g3refPic1Used"
1971#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC2 "g3refPic2"
1972#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC2_USED "g3refPic2Used"
1973#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC3 "g3refPic3"
1974#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC3_USED "g3refPic3Used"
1975
1976#define NI_ENC_GOP_PARAMS_G4_POC_OFFSET "g4pocOffset"
1977#define NI_ENC_GOP_PARAMS_G4_QP_OFFSET "g4QpOffset"
1978//#define NI_ENC_GOP_PARAMS_G4_QP_FACTOR "g4QpFactor"
1979#define NI_ENC_GOP_PARAMS_G4_TEMPORAL_ID "g4temporalId"
1980#define NI_ENC_GOP_PARAMS_G4_PIC_TYPE "g4picType"
1981#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PICS "g4numRefPics"
1982#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC0 "g4refPic0"
1983#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC0_USED "g4refPic0Used"
1984#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC1 "g4refPic1"
1985#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC1_USED "g4refPic1Used"
1986#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC2 "g4refPic2"
1987#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC2_USED "g4refPic2Used"
1988#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC3 "g4refPic3"
1989#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC3_USED "g4refPic3Used"
1990
1991#define NI_ENC_GOP_PARAMS_G5_POC_OFFSET "g5pocOffset"
1992#define NI_ENC_GOP_PARAMS_G5_QP_OFFSET "g5QpOffset"
1993//#define NI_ENC_GOP_PARAMS_G5_QP_FACTOR "g5QpFactor"
1994#define NI_ENC_GOP_PARAMS_G5_TEMPORAL_ID "g5temporalId"
1995#define NI_ENC_GOP_PARAMS_G5_PIC_TYPE "g5picType"
1996#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PICS "g5numRefPics"
1997#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC0 "g5refPic0"
1998#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC0_USED "g5refPic0Used"
1999#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC1 "g5refPic1"
2000#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC1_USED "g5refPic1Used"
2001#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC2 "g5refPic2"
2002#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC2_USED "g5refPic2Used"
2003#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC3 "g5refPic3"
2004#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC3_USED "g5refPic3Used"
2005
2006#define NI_ENC_GOP_PARAMS_G6_POC_OFFSET "g6pocOffset"
2007#define NI_ENC_GOP_PARAMS_G6_QP_OFFSET "g6QpOffset"
2008//#define NI_ENC_GOP_PARAMS_G6_QP_FACTOR "g6QpFactor"
2009#define NI_ENC_GOP_PARAMS_G6_TEMPORAL_ID "g6temporalId"
2010#define NI_ENC_GOP_PARAMS_G6_PIC_TYPE "g6picType"
2011#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PICS "g6numRefPics"
2012#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC0 "g6refPic0"
2013#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC0_USED "g6refPic0Used"
2014#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC1 "g6refPic1"
2015#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC1_USED "g6refPic1Used"
2016#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC2 "g6refPic2"
2017#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC2_USED "g6refPic2Used"
2018#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC3 "g6refPic3"
2019#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC3_USED "g6refPic3Used"
2020
2021#define NI_ENC_GOP_PARAMS_G7_POC_OFFSET "g7pocOffset"
2022#define NI_ENC_GOP_PARAMS_G7_QP_OFFSET "g7QpOffset"
2023//#define NI_ENC_GOP_PARAMS_G7_QP_FACTOR "g7QpFactor"
2024#define NI_ENC_GOP_PARAMS_G7_TEMPORAL_ID "g7temporalId"
2025#define NI_ENC_GOP_PARAMS_G7_PIC_TYPE "g7picType"
2026#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PICS "g7numRefPics"
2027#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC0 "g7refPic0"
2028#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC0_USED "g7refPic0Used"
2029#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC1 "g7refPic1"
2030#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC1_USED "g7refPic1Used"
2031#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC2 "g7refPic2"
2032#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC2_USED "g7refPic2Used"
2033#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC3 "g7refPic3"
2034#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC3_USED "g7refPic3Used"
2035
2036typedef struct _ni_gop_rps
2037{
2038 int ref_pic; /*!*< delta_poc of this short reference picture relative to the poc of current picture or index of LTR */
2039 int ref_pic_used; /*!*< whether this reference picture used by current picture */
2041
2042typedef struct _ni_gop_params
2043{
2044 int poc_offset; /*!*< A POC of Nth picture in the custom GOP */
2045 int qp_offset; /*!*< QP offset of Nth picture in the custom GOP */
2046 float qp_factor; /*!*< QP factor of Nth picture in the custom GOP */
2047 int temporal_id; /*!*< A temporal ID of Nth picture in the custom GOP */
2048 int pic_type; /*!*< A picture type of Nth picture in the custom GOP */
2049 int num_ref_pics; /*!*< the number of reference pictures kept for this picture, the value should be within [0, 4] */
2052#else
2053#define NI_ENC_GOP_PARAMS_G0_PIC_TYPE "g0picType"
2054#define NI_ENC_GOP_PARAMS_G0_POC_OFFSET "g0pocOffset"
2055#define NI_ENC_GOP_PARAMS_G0_PIC_QP "g0picQp"
2056#define NI_ENC_GOP_PARAMS_G0_NUM_REF_PIC_L0 "g0numRefPicL0"
2057#define NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L0 "g0refPocL0"
2058#define NI_ENC_GOP_PARAMS_G0_NUM_REF_POC_L1 "g0refPocL1"
2059#define NI_ENC_GOP_PARAMS_G0_TEMPORAL_ID "g0temporalId"
2060
2061#define NI_ENC_GOP_PARAMS_G1_PIC_TYPE "g1picType"
2062#define NI_ENC_GOP_PARAMS_G1_POC_OFFSET "g1pocOffset"
2063#define NI_ENC_GOP_PARAMS_G1_PIC_QP "g1picQp"
2064#define NI_ENC_GOP_PARAMS_G1_NUM_REF_PIC_L0 "g1numRefPicL0"
2065#define NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L0 "g1refPocL0"
2066#define NI_ENC_GOP_PARAMS_G1_NUM_REF_POC_L1 "g1refPocL1"
2067#define NI_ENC_GOP_PARAMS_G1_TEMPORAL_ID "g1temporalId"
2068
2069#define NI_ENC_GOP_PARAMS_G2_PIC_TYPE "g2picType"
2070#define NI_ENC_GOP_PARAMS_G2_POC_OFFSET "g2pocOffset"
2071#define NI_ENC_GOP_PARAMS_G2_PIC_QP "g2picQp"
2072#define NI_ENC_GOP_PARAMS_G2_NUM_REF_PIC_L0 "g2numRefPicL0"
2073#define NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L0 "g2refPocL0"
2074#define NI_ENC_GOP_PARAMS_G2_NUM_REF_POC_L1 "g2refPocL1"
2075#define NI_ENC_GOP_PARAMS_G2_TEMPORAL_ID "g2temporalId"
2076
2077#define NI_ENC_GOP_PARAMS_G3_PIC_TYPE "g3picType"
2078#define NI_ENC_GOP_PARAMS_G3_POC_OFFSET "g3pocOffset"
2079#define NI_ENC_GOP_PARAMS_G3_PIC_QP "g3picQp"
2080#define NI_ENC_GOP_PARAMS_G3_NUM_REF_PIC_L0 "g3numRefPicL0"
2081#define NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L0 "g3refPocL0"
2082#define NI_ENC_GOP_PARAMS_G3_NUM_REF_POC_L1 "g3refPocL1"
2083#define NI_ENC_GOP_PARAMS_G3_TEMPORAL_ID "g3temporalId"
2084
2085#define NI_ENC_GOP_PARAMS_G4_PIC_TYPE "g4picType"
2086#define NI_ENC_GOP_PARAMS_G4_POC_OFFSET "g4pocOffset"
2087#define NI_ENC_GOP_PARAMS_G4_PIC_QP "g4picQp"
2088#define NI_ENC_GOP_PARAMS_G4_NUM_REF_PIC_L0 "g4numRefPicL0"
2089#define NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L0 "g4refPocL0"
2090#define NI_ENC_GOP_PARAMS_G4_NUM_REF_POC_L1 "g4refPocL1"
2091#define NI_ENC_GOP_PARAMS_G4_TEMPORAL_ID "g4temporalId"
2092
2093#define NI_ENC_GOP_PARAMS_G5_PIC_TYPE "g5picType"
2094#define NI_ENC_GOP_PARAMS_G5_POC_OFFSET "g5pocOffset"
2095#define NI_ENC_GOP_PARAMS_G5_PIC_QP "g5picQp"
2096#define NI_ENC_GOP_PARAMS_G5_NUM_REF_PIC_L0 "g5numRefPicL0"
2097#define NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L0 "g5refPocL0"
2098#define NI_ENC_GOP_PARAMS_G5_NUM_REF_POC_L1 "g5refPocL1"
2099#define NI_ENC_GOP_PARAMS_G5_TEMPORAL_ID "g5temporalId"
2100
2101#define NI_ENC_GOP_PARAMS_G6_PIC_TYPE "g6picType"
2102#define NI_ENC_GOP_PARAMS_G6_POC_OFFSET "g6pocOffset"
2103#define NI_ENC_GOP_PARAMS_G6_PIC_QP "g6picQp"
2104#define NI_ENC_GOP_PARAMS_G6_NUM_REF_PIC_L0 "g6numRefPicL0"
2105#define NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L0 "g6refPocL0"
2106#define NI_ENC_GOP_PARAMS_G6_NUM_REF_POC_L1 "g6refPocL1"
2107#define NI_ENC_GOP_PARAMS_G6_TEMPORAL_ID "g6temporalId"
2108
2109#define NI_ENC_GOP_PARAMS_G7_PIC_TYPE "g7picType"
2110#define NI_ENC_GOP_PARAMS_G7_POC_OFFSET "g7pocOffset"
2111#define NI_ENC_GOP_PARAMS_G7_PIC_QP "g7picQp"
2112#define NI_ENC_GOP_PARAMS_G7_NUM_REF_PIC_L0 "g7numRefPicL0"
2113#define NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L0 "g7refPocL0"
2114#define NI_ENC_GOP_PARAMS_G7_NUM_REF_POC_L1 "g7refPocL1"
2115#define NI_ENC_GOP_PARAMS_G7_TEMPORAL_ID "g7temporalId"
2116
2117typedef struct _ni_gop_params
2118{
2119 int pic_type; /*!*< A picture type of Nth picture in the custom GOP */
2120 int poc_offset; /*!*< A POC of Nth picture in the custom GOP */
2121 int pic_qp; /*!*< A quantization parameter of Nth picture in the custom GOP */
2122 int num_ref_pic_L0; /*!*< The number of reference L0 of Nth picture in the custom GOP */
2123 int ref_poc_L0; /*!*< A POC of reference L0 of Nth picture in the custom GOP */
2124 int ref_poc_L1; /*!*< A POC of reference L1 of Nth picture in the custom GOP */
2125 int temporal_id; /*!*< A temporal ID of Nth picture in the custom GOP */
2127#endif
2128
2129
2130
2131#define NI_ENC_GOP_PARAMS_CUSTOM_GOP_SIZE "customGopSize"
2132
2134{
2135 int custom_gop_size; /*!*< The size of custom GOP (0~8) */
2136 ni_gop_params_t pic_param[NI_MAX_GOP_NUM]; /*!*< Picture parameters of Nth picture in custom GOP */
2138
2139#define NI_ENC_REPEAT_HEADERS_FIRST_IDR 0
2140#define NI_ENC_REPEAT_HEADERS_ALL_I_FRAMES 1
2141#define NI_KEEP_ALIVE_TIMEOUT "keepAliveTimeout"
2142
2144{
2145#define NI_ENC_PARAM_BITRATE "bitrate"
2146#define NI_ENC_PARAM_RECONF_DEMO_MODE "ReconfDemoMode"
2147#define NI_ENC_PARAM_RECONF_FILE "ReconfFile"
2148#define NI_ENC_PARAM_ROI_DEMO_MODE "RoiDemoMode"
2149#define NI_ENC_PARAM_CACHE_ROI "cacheRoi"
2150#define NI_ENC_PARAM_FORCE_PIC_QP_DEMO_MODE "ForcePicQpDemoMode"
2151
2152#ifndef DEPRECATION_AS_ERROR
2154#define NI_ENC_PARAM_GEN_HDRS NI_DEPRECATED_MACRO "GenHdrs"
2155#endif
2156#define NI_ENC_PARAM_PADDING "padding"
2157#define NI_ENC_PARAM_FORCE_FRAME_TYPE "forceFrameType"
2158#define NI_ENC_PARAM_PROFILE "profile"
2159#define NI_ENC_PARAM_LEVEL "level"
2160#define NI_ENC_PARAM_HIGH_TIER "high-tier"
2161#define NI_ENC_PARAM_LOG_LEVEL "log-level"
2162#define NI_ENC_PARAM_LOG "log"
2163#define NI_ENC_PARAM_GOP_PRESET_IDX "gopPresetIdx"
2164#define NI_ENC_PARAM_LOW_DELAY "lowDelay"
2165#define NI_ENC_PARAM_MIN_FRAMES_DELAY "minFramesDelay"
2166#define NI_ENC_PARAM_USE_RECOMMENDED_ENC_PARAMS "useRecommendEncParam"
2167#define NI_ENC_PARAM_USE_LOW_DELAY_POC_TYPE "useLowDelayPocType"
2168#define NI_ENC_PARAM_CU_SIZE_MODE "cuSizeMode"
2169#define NI_ENC_PARAM_MAX_NUM_MERGE "maxNumMerge"
2170#define NI_ENC_PARAM_ENABLE_DYNAMIC_8X8_MERGE "dynamicMerge8x8Enable"
2171#define NI_ENC_PARAM_ENABLE_DYNAMIC_16X16_MERGE "dynamicMerge16x16Enable"
2172#define NI_ENC_PARAM_ENABLE_DYNAMIC_32X32_MERGE "dynamicMerge32x32Enable"
2173#define NI_ENC_PARAM_ENABLE_RATE_CONTROL "RcEnable"
2174#define NI_ENC_PARAM_ENABLE_CU_LEVEL_RATE_CONTROL "cuLevelRCEnable"
2175#define NI_ENC_PARAM_ENABLE_HVS_QP "hvsQPEnable"
2176#define NI_ENC_PARAM_ENABLE_HVS_QP_SCALE "hvsQpScaleEnable"
2177#define NI_ENC_PARAM_HVS_QP_SCALE "hvsQpScale"
2178#define NI_ENC_PARAM_MIN_QP "minQp"
2179#define NI_ENC_PARAM_MAX_QP "maxQp"
2180#define NI_ENC_PARAM_MAX_DELTA_QP "maxDeltaQp"
2181#define NI_ENC_PARAM_FORCED_HEADER_ENABLE "repeatHeaders"
2182#define NI_ENC_PARAM_ROI_ENABLE "roiEnable"
2183#define NI_ENC_PARAM_CONF_WIN_TOP "confWinTop"
2184#define NI_ENC_PARAM_CONF_WIN_BOTTOM "confWinBot"
2185#define NI_ENC_PARAM_CONF_WIN_LEFT "confWinLeft"
2186#define NI_ENC_PARAM_CONF_WIN_RIGHT "confWinRight"
2187#define NI_ENC_PARAM_INTRA_PERIOD "intraPeriod"
2188#define NI_ENC_PARAM_TRANS_RATE "transRate"
2189#define NI_ENC_PARAM_FRAME_RATE "frameRate"
2190#define NI_ENC_PARAM_FRAME_RATE_DENOM "frameRateDenom"
2191#define NI_ENC_PARAM_INTRA_QP "intraQP"
2192#define NI_ENC_PARAM_DECODING_REFRESH_TYPE "decodingRefreshType"
2193#define NI_ENC_PARAM_INTRA_REFRESH_RESET "intraRefreshResetOnForceIDR"
2194// Rev. B: H.264 only parameters.
2195#define NI_ENC_PARAM_ENABLE_8X8_TRANSFORM "transform8x8Enable"
2196#define NI_ENC_PARAM_ENTROPY_CODING_MODE "entropyCodingMode"
2197// Rev. B: shared between HEVC and H.264
2198#define NI_ENC_PARAM_SLICE_MODE "sliceMode"
2199#define NI_ENC_PARAM_SLICE_ARG "sliceArg"
2200#define NI_ENC_PARAM_INTRA_MB_REFRESH_MODE "intraMbRefreshMode"
2201#define NI_ENC_PARAM_INTRA_MB_REFRESH_ARG "intraMbRefreshArg"
2202#define NI_ENC_PARAM_INTRA_REFRESH_MODE "intraRefreshMode"
2203#define NI_ENC_PARAM_INTRA_REFRESH_ARG "intraRefreshArg"
2204#define NI_ENC_PARAM_ENABLE_MB_LEVEL_RC "mbLevelRcEnable"
2205#define NI_ENC_PARAM_PREFERRED_TRANSFER_CHARACTERISTICS "prefTRC"
2206
2207// To be deprecated: RcInitDelay -> vbvBufferSize, cbr -> fillerEnable
2208#define NI_ENC_PARAM_RC_INIT_DELAY "RcInitDelay"
2209#define NI_ENC_PARAM_CBR "cbr"
2210#define NI_ENC_PARAM_INTRA_REFRESH_MIN_PERIOD "intraRefreshMinPeriod"
2211
2212#define NI_ENC_PARAM_USE_MCTF "useMCTF"
2213
2214//QUADRA
2215#ifndef DEPRECATION_AS_ERROR
2217#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR NI_DEPRECATED_MACRO "crf"
2218#endif
2219#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR_FLOAT "crfFloat"
2220#define NI_ENC_PARAM_RDO_LEVEL "rdoLevel"
2221#define NI_ENC_PARAM_RDO_QUANT "EnableRdoQuant"
2222#define NI_ENC_PARAM_MAX_CLL "maxCLL"
2223#define NI_ENC_PARAM_MASTER_DISPLAY "masterDisplay"
2224#define NI_ENC_PARAM_LOOK_AHEAD_DEPTH "lookAheadDepth"
2225#define NI_ENC_PARAM_ENABLE_AUD "enableAUD"
2226#define NI_ENC_PARAM_CTB_RC_MODE "ctbRcMode"
2227#define NI_ENC_PARAM_GOP_SIZE "gopSize"
2228#define NI_ENC_PARAM_GOP_LOW_DELAY "gopLowdelay"
2229#define NI_ENC_PARAM_GDR_DURATION "intraRefreshDuration"
2230#define NI_ENC_PARAM_HRD_ENABLE "hrdEnable"
2231#define NI_ENC_PARAM_DOLBY_VISION_PROFILE "dolbyVisionProfile"
2232#define NI_ENC_PARAM_VBV_BUFFER_SIZE "vbvBufferSize"
2233#define NI_ENC_PARAM_VBV_MAXRAE "vbvMaxRate"
2234#define NI_ENC_PARAM_ENABLE_FILLER "fillerEnable"
2235#define NI_ENC_PARAM_ENABLE_PIC_SKIP "picSkip"
2236#ifndef DEPRECATION_AS_ERROR
2238#define NI_ENC_PARAM_MAX_FRAME_SIZE_LOW_DELAY NI_DEPRECATED_MACRO "maxFrameSize"
2239#endif
2240#define NI_ENC_PARAM_MAX_FRAME_SIZE_BITS_LOW_DELAY "maxFrameSize-Bits"
2241#define NI_ENC_PARAM_MAX_FRAME_SIZE_BYTES_LOW_DELAY "maxFrameSize-Bytes"
2242#define NI_ENC_PARAM_LTR_REF_INTERVAL "ltrRefInterval"
2243#define NI_ENC_PARAM_LTR_REF_QPOFFSET "ltrRefQpOffset"
2244#define NI_ENC_PARAM_LTR_FIRST_GAP "ltrFirstGap"
2245#define NI_ENC_PARAM_LTR_NEXT_INTERVAL "ltrNextInterval"
2246#define NI_ENC_PARAM_MULTICORE_JOINT_MODE "multicoreJointMode"
2247#define NI_ENC_PARAM_JPEG_QLEVEL "qlevel"
2248#define NI_ENC_PARAM_CHROMA_QP_OFFSET "chromaQpOffset"
2249#define NI_ENC_PARAM_TOL_RC_INTER "tolCtbRcInter"
2250#define NI_ENC_PARAM_TOL_RC_INTRA "tolCtbRcIntra"
2251#define NI_ENC_PARAM_BITRATE_WINDOW "bitrateWindow"
2252#define NI_ENC_INLOOP_DS_RATIO "inLoopDSRatio"
2253#define NI_ENC_BLOCK_RC_SIZE "blockRCSize"
2254#define NI_ENC_RC_QP_DELTA_RANGE "rcQpDeltaRange"
2255#define NI_ENC_CTB_ROW_QP_STEP "ctbRowQpStep"
2256#define NI_ENC_NEW_RC_ENABLE "newRcEnable"
2257#define NI_ENC_PARAM_INTRA_QP_DELTA "intraQpDelta"
2258#define NI_ENC_PARAM_LONG_TERM_REFERENCE_ENABLE "longTermReferenceEnable"
2259#define NI_ENC_PARAM_LONG_TERM_REFERENCE_COUNT "longTermReferenceCount"
2260#define NI_ENC_PARAM_LONG_TERM_REFERENCE_INTERVAL "longTermReferenceInterval"
2261#define NI_ENC_PARAM_SKIP_FRAME_ENABLE "skipFrameEnable"
2262#define NI_ENC_PARAM_MAX_CONSUTIVE_SKIP_FRAME_NUMBER "maxConsecutiveSkipFrameNum"
2263#define NI_ENC_PARAM_SKIP_FRAME_INTERVAL "skipFrameInterVal"
2264#define NI_ENC_PARAM_IFRAME_SIZE_RATIO "iFrameSizeRatio"
2265#define NI_ENC_PARAM_STILL_IMAGE_DETECT_LEVEL "stillImageDetectLevel"
2266#define NI_ENC_PARAM_SCENE_CHANG_DETECT_LEVEL "sceneChangeDetectLevel"
2267#define NI_ENC_PARAM_ENABLE_SMOOTH_CRF "enableSmoothCRF"
2268#define NI_ENC_PARAM_ENABLE_COMPENSATE_QP "enableCompensateQp"
2269#define NI_ENC_PARAM_ADAPTIVE_LAMDA_MODE "adaptiveLamdaMode"
2270#define NI_ENC_PARAM_ADAPTIVE_CRF_MODE "adaptiveCrfMode"
2271#define NI_ENC_PARAM_INTRA_COMPENSATE_MODE "intraCompensateMode"
2272#define NI_ENC_PARAM_CUSTOM_MIN_COEFF_DIV "customMinCoeffDiv"
2273// stream color info
2274#define NI_ENC_PARAM_COLOR_PRIMARY "colorPri"
2275#define NI_ENC_PARAM_COLOR_TRANSFER_CHARACTERISTIC "colorTrc"
2276#define NI_ENC_PARAM_COLOR_SPACE "colorSpc"
2277// sample aspect ratio specified in numerator/denominator
2278#define NI_ENC_PARAM_SAR_NUM "sarNum"
2279#define NI_ENC_PARAM_SAR_DENOM "sarDenom"
2280// video_full_range_flag
2281#define NI_ENC_PARAM_VIDEO_FULL_RANGE_FLAG "videoFullRangeFlag"
2282// VFR related
2283#define NI_ENC_PARAM_ENABLE_VFR "enableVFR"
2284#define NI_ENC_ENABLE_SSIM "enableSSIM"
2285#define NI_ENC_PARAM_AVCC_HVCC "avccHvcc"
2286#define NI_ENC_PARAM_AV1_ERROR_RESILIENT_MODE "av1ErrorResilientMode"
2287// set memory allocation parameters, M_MMAP_THRESHOLD and M_TRIM_THRESHOLD
2288#define NI_ENC_PARAM_STATIC_MMAP_THRESHOLD "staticMmapThreshold"
2289#define NI_ENC_PARAM_TEMPORAL_LAYERS_ENABLE "temporalLayersEnable"
2290#define NI_ENC_PARAM_ENABLE_AI_ENHANCE "enableAIEnhance"
2291#define NI_ENC_PARAM_ENABLE_AI_HVSPLUS "enableHVSPlus"
2292#define NI_ENC_PARAM_ENABLE_2PASS_GOP "enable2PassGop"
2293#define NI_ENC_PARAM_ZEROCOPY_MODE "zeroCopyMode"
2294#define NI_ENC_PARAM_AI_ENHANCE_LEVEL "AIEnhanceLevel"
2295#define NI_ENC_PARAM_HVSPLUS_LEVEL "HVSPlusLevel"
2296#define NI_ENC_PARAM_CROP_WIDTH "cropWidth"
2297#define NI_ENC_PARAM_CROP_HEIGHT "cropHeight"
2298#define NI_ENC_PARAM_HORIZONTAL_OFFSET "horOffset"
2299#define NI_ENC_PARAM_VERTICAL_OFFSET "verOffset"
2300#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR_MAX "crfMax"
2301#define NI_ENC_PARAM_QCOMP "qcomp"
2302#define NI_ENC_PARAM_NO_MBTREE "noMbtree"
2303#define NI_ENC_PARAM_NO_HW_MULTIPASS_SUPPORT "noHWMultiPassSupport"
2304#define NI_ENC_PARAM_CU_TREE_FACTOR "cuTreeFactor"
2305#define NI_ENC_PARAM_IP_RATIO "ipRatio"
2306#define NI_ENC_PARAM_ENABLE_IP_RATIO "enableipRatio"
2307#define NI_ENC_PARAM_PB_RATIO "pbRatio"
2308#define NI_ENC_PARAM_CPLX_DECAY "cplxDecay"
2309#define NI_ENC_PARAM_PPS_INIT_QP "ppsInitQp"
2310#define NI_ENC_PARAM_DDR_PRIORITY_MODE "ddrPriorityMode"
2311#define NI_ENC_PARAM_BITRATE_MODE "bitrateMode"
2312#define NI_ENC_PARAM_PASS1_QP "pass1Qp"
2313#define NI_ENC_PARAM_HVS_BASE_MB_COMPLEXITY "hvsBaseMbComplexity"
2314#define NI_ENC_PARAM_STATISTIC_OUTPUT_LEVEL "statisticOutputLevel"
2315#define NI_ENC_PARAM_ENABLE_ALL_SEI_PASSTHRU "enableAllSeiPassthru"
2316#define NI_ENC_PARAM_CRF_MAX_IFRAME_ENABLE "crfMaxIframeEnable"
2317#define NI_ENC_PARAM_VBV_MINRATE "vbvMinRate"
2318#define NI_ENC_PARAM_DISABLE_ADAPTIVE_BUFFERS "disableAdaptiveBuffers"
2319#define NI_ENC_PARAM_DISABLE_BFRAME_RDOQ "disableBframeRDOQ"
2320#define NI_ENC_PARAM_FORCE_BFRAME_QPFACTOR "forceBframeQpfactor"
2321#define NI_ENC_PARAM_TUNE_BFRAME_VISUAL "tuneBframeVisual"
2322#define NI_ENC_PARAM_ENABLE_ACQUIRE_LIMIT "enableAcqLimit"
2323#define NI_ENC_PARAM_GET_PSNR_MODE "getPsnrMode"
2324#define NI_ENC_PARAM_PSNR_INTERVAL "intervalOfPsnr"
2325#define NI_ENC_PARAM_CUSTOMIZE_ROI_QP_LEVEL "customizeQpLevel"
2326#define NI_ENC_PARAM_CUSTOMIZE_ROI_QP_MAP "customizeQpMapFile"
2327#define NI_ENC_PARAM_MOTION_CONSTRAINED_MODE "motionConstrainedMode"
2328#define NI_ENC_PARAM_ALLOCATE_STRAEGY "encMemAllocateStrategy"
2329#define NI_ENC_PARAM_SPATIAL_LAYERS "spatialLayers"
2330#define NI_ENC_PARAM_ENABLE_TIMECODE "enableTimecode"
2331#define NI_ENC_PARAM_SPATIAL_LAYERS_REF_BASE_LAYER "spatialLayersRefBaseLayer"
2332#define NI_ENC_PARAM_GET_RECONSTRUCTED_MODE "getReconstructedMode"
2333#define NI_ENC_PARAM_VBV_BUFFER_REENCODE "vbvBufferReencode"
2334#define NI_ENC_PARAM_TOTAL_CUTREE_DEPTH "totalCuTreeDepth"
2335#define NI_ENC_PARAM_ADAPTIVE_CUTREE "adaptiveCuTree"
2336#define NI_ENC_PARAM_PRE_INTRA_HANDLING "preIntraHandling"
2337#define NI_ENC_PARAM_BASE_LAYER_ONLY "baseLayerOnly"
2338#define NI_ENC_PARAM_PAST_FRAME_MAX_INTRA_RATIO "pastFrameMaxIntraRatio"
2339#define NI_ENC_PARAM_LINK_FRAME_MAX_INTRA_RATIO "linkFrameMaxIntraRatio"
2340#define NI_ENC_PARAM_SPATIAL_LAYER_BITRATE "spatialLayerBitrate"
2341#define NI_ENC_PARAM_DISABLE_AV1_TIMING_INFO "disableAv1TimingInfo"
2342#define NI_ENC_PARAM_AV1_OP_LEVEL "av1OpLevel"
2343#define NI_ENC_PARAM_ENABLE_CPU_AFFINITY "enableCpuAffinity"
2344#define NI_ENC_PARAM_PRESET "preset"
2345#define NI_ENC_PARAM_QP_SCALE_ENABLE "qpScaleEnable"
2346#define NI_ENC_PARAM_GET_BITSTREAM_FEATURES "getBitstreamFeatures"
2347
2348 //----- Start supported by all codecs -----
2355 //----- End supported by all codecs -----
2356
2357 //----- Start supported by AV1, AVC, HEVC only -----
2360 //GOP Pattern
2362 /*!*< A GOP structure preset option (IPP, IBP, IBBP, IbBbP, use Custom GOP, etc) */ // 0-custom 1-I-only 2-IPPP 3-IBBB 4-IBP .....
2363
2364 // CUSTOM_GOP
2366
2373
2374 // HLG preferred transfer characteristics
2376
2379 int crf;
2403 //----- End supported by AV1, AVC, HEVC only -----
2404
2405 //----- Start supported by AVC, HEVC only -----
2406 //ConformanceWindowOffsets
2407 int conf_win_top; /*!*< A conformance window size of TOP */
2408 int conf_win_bottom; /*!*< A conformance window size of BOTTOM */
2409 int conf_win_left; /*!*< A conformance window size of LEFT */
2410 int conf_win_right; /*!*< A conformance window size of RIGHT */
2414 //----- End supported by AVC, HEVC only -----
2415
2416 //----- Start supported by AVC only -----
2418 //----- End supported by AVC only -----
2419
2420 //----- Start supported by HEVC only -----
2425 //----- End supported by HEVC only -----
2426
2427 //----- Start supported by JPEG only -----
2429 //----- End supported by JPEG only -----
2430
2431 //----- Start test use only -----
2435 //----- End test use only -----
2436
2437 //----- Start supported by AV1, AVC, HEVC only -----
2442 //----- End supported by AV1, AVC, HEVC only -----
2443
2444 //----- Start test use only -----
2447 //----- End test use only -----
2448
2449 //----- Start supported by AV1, AVC, HEVC only -----
2451 //----- End supported by AV1, AVC, HEVC only -----
2452
2453 //----- start DEPRECATED or for T408 -----
2455 //Preset Mode
2456 int use_recommend_enc_params; /*!*< 0: Custom, 1: Slow speed and best quality, 2: Normal Speed and quality, 3: Fast Speed and Low Quality */
2457 //Encode Options
2458 int cu_size_mode; /*!*< bit 0: enable 8x8 CU, bit 1: enable 16x16 CU, bit 2: enable 32x32 CU */
2459 int max_num_merge; /*!*< Maximum number of merge candidates (0~2) */
2460 int enable_dynamic_8x8_merge; /*!*< It enables dynamic merge 8x8 candidates. */
2461 int enable_dynamic_16x16_merge; /*!*< It enables dynamic merge 16x16 candidates. */
2462 int enable_dynamic_32x32_merge; /*!*< It enables dynamic merge 32x32 candidates. */
2463
2464 // Rev. B: H.264 only parameters, in ni_t408_config_t
2465 // - for H.264 on T408:
2469
2471 //----- end DEPRECATED or for T408 -----
2472
2473 struct //Rate control parameters
2474 {
2475 int enable_rate_control; /*!*< It enable rate control */
2476 int min_qp; /*!*< A minimum QP for rate control */ //8
2477 int max_qp; /*!*< A maximum QP for rate control */ //51
2481
2482 //no JPEG
2483 int enable_cu_level_rate_control; /*!*< It enable CU level rate control */
2484 int enable_hvs_qp; /*!*< It enable CU QP adjustment for subjective quality enhancement */
2485 int hvs_qp_scale; /*!*< A QP scaling factor for CU QP adjustment when hvcQpenable = 1 */
2489
2490 //deprecated
2491 int enable_hvs_qp_scale; /*!*< It enable QP scaling factor for CU QP adjustment when enable_hvs_qp = 1 */
2492 int max_delta_qp; /*!*< A maximum delta QP for rate control */ //10
2496 int keep_alive_timeout; /* keep alive timeout setting */
2510 float qcomp;
2514 float ipRatio;
2515 float pbRatio;
2522 // 0: no extra output encoder information
2523 // 1: Frame Level output encoder information
2524 // 2: Cu Level Output encoder information
2525 // 3: Frame&Cu Level encoder information
2526 // 6: 1-pass satd cost
2573
2575{
2576#define NI_DEC_PARAM_OUT "out"
2577#define NI_DEC_PARAM_ENABLE_OUT_1 "enableOut1"
2578#define NI_DEC_PARAM_ENABLE_OUT_2 "enableOut2"
2579#define NI_DEC_PARAM_FORCE_8BIT_0 "force8Bit0"
2580#define NI_DEC_PARAM_FORCE_8BIT_1 "force8Bit1"
2581#define NI_DEC_PARAM_FORCE_8BIT_2 "force8Bit2"
2582#define NI_DEC_PARAM_SEMI_PLANAR_0 "semiplanar0"
2583#define NI_DEC_PARAM_SEMI_PLANAR_1 "semiplanar1"
2584#define NI_DEC_PARAM_SEMI_PLANAR_2 "semiplanar2"
2585#define NI_DEC_PARAM_CROP_MODE_0 "cropMode0"
2586#define NI_DEC_PARAM_CROP_MODE_1 "cropMode1"
2587#define NI_DEC_PARAM_CROP_MODE_2 "cropMode2"
2588#define NI_DEC_PARAM_CROP_PARAM_0 "crop0"
2589#define NI_DEC_PARAM_CROP_PARAM_1 "crop1"
2590#define NI_DEC_PARAM_CROP_PARAM_2 "crop2"
2591#define NI_DEC_PARAM_SCALE_0 "scale0"
2592#define NI_DEC_PARAM_SCALE_1 "scale1"
2593#define NI_DEC_PARAM_SCALE_2 "scale2"
2594#define NI_DEC_PARAM_SCALE_0_W "scale0w"
2595#define NI_DEC_PARAM_SCALE_0_H "scale0h"
2596#define NI_DEC_PARAM_SCALE_1_W "scale1w"
2597#define NI_DEC_PARAM_SCALE_1_H "scale1h"
2598#define NI_DEC_PARAM_SCALE_2_W "scale2w"
2599#define NI_DEC_PARAM_SCALE_2_H "scale2h"
2600#define NI_DEC_PARAM_SCALE_0_LONG_SHORT_ADAPT "scale0LongShortAdapt"
2601#define NI_DEC_PARAM_SCALE_1_LONG_SHORT_ADAPT "scale1LongShortAdapt"
2602#define NI_DEC_PARAM_SCALE_2_LONG_SHORT_ADAPT "scale2LongShortAdapt"
2603#define NI_DEC_PARAM_SCALE_0_RES_CEIL "scale0ResCeil"
2604#define NI_DEC_PARAM_SCALE_1_RES_CEIL "scale1ResCeil"
2605#define NI_DEC_PARAM_SCALE_2_RES_CEIL "scale2ResCeil"
2606#define NI_DEC_PARAM_SCALE_0_ROUND "scale0Round"
2607#define NI_DEC_PARAM_SCALE_1_ROUND "scale1Round"
2608#define NI_DEC_PARAM_SCALE_2_ROUND "scale2Round"
2609#define NI_DEC_PARAM_MULTICORE_JOINT_MODE "multicoreJointMode"
2610#define NI_DEC_PARAM_SAVE_PKT "savePkt"
2611#define NI_DEC_PARAM_LOW_DELAY "lowDelay"
2612#define NI_DEC_PARAM_FORCE_LOW_DELAY "forceLowDelay"
2613#define NI_DEC_PARAM_MIN_PACKETS_DELAY "minPacketsDelay"
2614#define NI_DEC_PARAM_ENABLE_LOW_DELAY_CHECK "enableLowDelayCheck"
2615#define NI_DEC_PARAM_DISABLE_REORDER "disableReorder"
2616#define NI_DEC_PARAM_ENABLE_USR_DATA_SEI_PASSTHRU "enableUserDataSeiPassthru"
2617#define NI_DEC_PARAM_ENABLE_CUSTOM_SEI_PASSTHRU "customSeiPassthru"
2618#define NI_DEC_PARAM_SVC_T_DECODING_LAYER "svctDecodingLayer"
2619#define NI_DEC_PARAM_DDR_PRIORITY_MODE "ddrPriorityMode"
2620#define NI_DEC_PARAM_EC_POLICY "ecPolicy"
2621#define NI_DEC_PARAM_ENABLE_ADVANCED_EC "enableAdvancedEc"
2622#define NI_DEC_PARAM_ERROR_THRESHOLD "ecErrThreshold"
2623#define NI_DEC_PARAM_ENABLE_PPU_SCALE_ADAPT "enablePpuScaleAdapt"
2624#define NI_DEC_PARAM_ENABLE_PPU_SCALE_LIMIT "enablePpuScaleLimit"
2625#define NI_DEC_PARAM_MAX_EXTRA_HW_FRAME_CNT "maxExtraHwFrameCnt"
2626#define NI_DEC_PARAM_SKIP_PTS_GUESS "skipPtsGuess"
2627#define NI_DEC_PARAM_PKT_PTS_UNCHANGE "pktPtsUnchange"
2628#define NI_DEC_PARAM_ENABLE_ALL_SEI_PASSTHRU "enableAllSeiPassthru"
2629#define NI_DEC_PARAM_ENABLE_FOLLOW_IFRAME "enableFollowIFrame"
2630#define NI_DEC_PARAM_DISABLE_ADAPTIVE_BUFFERS "disableAdaptiveBuffers"
2631#define NI_DEC_PARAM_SURVIVE_STREAM_ERR "surviveStreamErr"
2632#define NI_DEC_PARAM_REDUCE_DPB_DELAY "reduceDpbDelay"
2633#define NI_DEC_PARAM_SKIP_EXTRA_HEADERS "skipExtraHeaders"
2634#define NI_DEC_PARAM_ENABLE_CPU_AFFINITY "enableCpuAffinity"
2635#define NI_DEC_PARAM_EXTEND_POOL_SIZE "extendPoolSize"
2636#define NI_DEC_PARAM_DECODER_MODE "decoderMode"
2637
2642 int nb_save_pkt; // number of decoder input packets to be saved
2649 1]; /*cut-out of expression to be parsed*/
2653 1]; /*cut-out of expression to be parsed*/
2654 int keep_alive_timeout; /* keep alive timeout setting */
2655 // decoder lowDelay mode for All I packets or IPPP packets
2664 int enable_ppu_scale_adapt; // 0: disabled; 1: adapt to long edge; 2: adapt to short edge.
2671 // 0: disabled; 1: adapt to long edge; 2: adapt to short edge.
2674 int scale_round[NI_MAX_NUM_OF_DECODER_OUTPUTS]; // 0 up align 1 dowm align
2685
2710
2711/*
2712 * Algorithm identifier for user-supplied Q14 kernel (N2D_FILTER_USER).
2713 * Must match SCALER_ALGORITHM_USER_KERNEL in firmware/fp/inc/scaler_manager.h
2714 * and NI_SCALER_ALGORITHM_USER_KERNEL in the 3rd_libs header copy.
2715 */
2716#define NI_SCALER_ALGORITHM_USER_KERNEL 6
2717
2718/* Kernel table geometry — must match firmware constants. */
2719#define NI_SCALER_KERNEL_POSITIONS 17 /* gcvSUBPIXELLOADCOUNT */
2720#define NI_SCALER_KERNEL_SLOTS 9 /* gcvMAXTAPSIZE (rows) */
2721#define NI_SCALER_MAX_KERNEL_TAPS 5 /* gcvMAXTAPSIZE_OPF */
2722#define NI_SCALER_KERNEL_BYTES (NI_SCALER_KERNEL_POSITIONS * \
2723 NI_SCALER_KERNEL_SLOTS * 2) /* 306 */
2724#define NI_SCALER_Q14_ONE 0x4000 /* 1.0 in Q14 fixed-point */
2725
2727{
2733 /* User-defined Q14 polyphase kernel (NI_SCALER_ALGORITHM_USER_KERNEL).
2734 *
2735 * Set kernel_taps to the number of active taps (1 .. NI_SCALER_MAX_KERNEL_TAPS).
2736 * Populate kernel_array via ni_scaler_build_kernel():
2737 * kernel_array[0] horizontal pass (17 positions × 9 slots × uint16_t)
2738 * kernel_array[1] vertical pass (same layout)
2739 * ni_scaler_set_params() will:
2740 * - validate that each of the 17 rows in kernel_array[0] sums to Q14_ONE
2741 * - override filterblit → NI_SCALER_ALGORITHM_USER_KERNEL
2742 * - forward kernel_array[0] to the firmware (firmware shares one table
2743 * for both H and V passes; kernel_array[1] is reserved for future use)
2744 *
2745 * Leave kernel_taps = 0 to disable (all other filter algorithms). */
2746 uint8_t kernel_taps; /* active taps: 1..5; 0 = disabled */
2747 uint16_t kernel_array[2][17 * 9]; /* Q14: [0]=H [1]=V, 17 pos × 9 slots */
2749
2751{
2752 uint32_t start_x;
2753 uint32_t start_y;
2754 uint32_t end_x;
2755 uint32_t end_y;
2756 uint32_t rgba_c;
2758
2766
2771
2775
2776typedef struct _ni_iovec {
2777 uint32_t size;
2778 void *ptr;
2780
2781typedef struct _ni_frame
2782{
2783 // codec of the source from which this frame is decoded
2785
2786 long long dts;
2787 long long pts;
2790 uint32_t video_width;
2792
2793 uint32_t crop_top;
2794 uint32_t crop_bottom;
2795 uint32_t crop_left;
2796 uint32_t crop_right;
2797
2798 // for encoder: force headers on this frame
2800 // for encoder: control long term reference picture feature
2803
2805 // for encoding: frame picture type sent to encoder
2806 // for decoding: frame picture type returned from decoder
2808 // total SEI size: used by encoder
2809 unsigned int sei_total_len;
2810
2811 // SEI info of closed caption: returned by decoder or set by encoder
2812 unsigned int sei_cc_offset;
2813 unsigned int sei_cc_len;
2814 // SEI info of HDR: returned by decoder
2819 // SEI info of HDR10+: returned by decoder
2821 unsigned int sei_hdr_plus_len;
2822 // SEI info of User Data Unregistered SEI: returned by decoder
2825 // SEI info of alternative transfer characteristics: returned by decoder
2828 // VUI info: returned by decoder
2829 unsigned int vui_offset;
2830 unsigned int vui_len;
2831
2832 // ROI data length: for encoder
2833 unsigned int roi_len;
2834 // reconfig data length: for encoder
2835 unsigned int reconf_len;
2836 // total extra data data length: for encoder
2837 unsigned int extra_data_len;
2838 // force pic qp value
2840 // frame chunk index
2842
2845
2846 uint8_t *p_buffer;
2847 uint32_t buffer_size;
2848
2849 ni_buf_t
2850 *dec_buf; // buffer pool entry (has memory pointed to by p_buffer)
2853
2855
2856 // frame auxiliary data
2859
2860 // the following info is of the source stream that is returned by decoder:
2861 // color info, sample aspect ratio, timing etc that are useful at encoding.
2863 uint8_t color_trc;
2867 uint16_t sar_width;
2868 uint16_t sar_height;
2871
2872 int flags; // flags of demuxed packet
2873
2874 // for encoder: metadata buffer info if not contiguous with YUV
2877 // for encoder: whether metadata should be sent separately for frame
2879 uint64_t pkt_pos;
2880
2881 // for encoder: non-4k-aligned part at the start of YUV data
2886 // for encoder: whether the start of non-4k-aligned YUV data should be sent separately for frame
2889 long long orignal_pts;
2890 uint32_t error_ratio;
2891
2892 //for AI non-4k-aligned memory buffer
2893 uint32_t iovec_num;
2895
2896 // offset to be adjusted in FW for zero copy - obtain from ni_encoder_frame_zerocopy_adjust
2898 // for encoder: indicates if raw timecode data is present in frame extra data
2901
2902typedef struct _ni_xcoder_params
2903{
2904 int log;
2906 /* Numerator and denominator of frame rate */
2907 uint32_t fps_number;
2909 /* Width (in pixels) of the source pictures. If this width is not an even
2910 * multiple of 4, the encoder will pad the pictures internally to meet this
2911 * minimum requirement. All valid HEVC widths are supported */
2913
2914 /* Height (in pixels) of the source pictures. If this height is not an even
2915 * multiple of 4, the encoder will pad the pictures internally to meet this
2916 * minimum requirement. All valid HEVC heights are supported */
2919 int roi_demo_mode; // for encoder ROI testing
2920 int reconf_demo_mode; // for encoder reconfiguration testing
2921 int force_pic_qp_demo_mode; // for force pic qp mode testing
2922 int low_delay_mode; // encoder low latency mode
2923 int padding; // encoder input padding setting
2924 int generate_enc_hdrs; // in libavcodec, open a dummy session to generate codec headers during init
2925 int use_low_delay_poc_type; // specifies the encoder to set
2926 // picture_order_count_type=2 in the H.264 SPS
2927
2929
2930 // 1: force on every frame with same input type; 0: no (except for I-frame)
2932
2935
2936 int cacheRoi; // enables caching of ROIs applied to subsequent frames
2937
2938#ifndef DEPRECATION_AS_ERROR
2940 NI_DEPRECATED uint32_t
2945#endif
2946
2953
2954 union
2955 {
2958 };
2959
2960 // for encoder reconfiguration testing, saving key:val1,val2,val3,...val9
2961 // (max 9 values) in the demo reconfig data file this supports max 50000
2962 // lines in reconfig file, max 10 key/values per line
2968
2969 int enable_vfr; //enable the vfr
2970
2985
2986typedef struct _niFrameSurface1
2987{
2988 uint16_t ui16FrameIdx; //frame location on device
2989 uint16_t ui16session_ID; //for instance tracking
2990 uint16_t ui16width; // width on device
2991 uint16_t ui16height; // height on device
2992 uint32_t ui32nodeAddress; //currently not in use, formerly offset
2993 int32_t device_handle; //handle to access device
2994 int8_t bit_depth; //1 == 8bit per pixel, 2 == 10bit
2995 int8_t encoding_type; //0 = semiplanar, 1 = planar, 2 = tiled4x4
2996 int8_t output_idx; // 0-2 for decoder output index
2997 int8_t src_cpu; // frame origin location
2998 int32_t dma_buf_fd; // P2P dma buffer file descriptor
3000
3001typedef struct _ni_frame_config
3002{
3006 uint16_t options;
3011 uint32_t rgba_color;
3012 uint16_t frame_index;
3013 uint16_t session_id;
3015 uint8_t orientation; // 0 <= n <= 3, (n * 90°) clockwise rotation
3017
3018
3019// bitstream features related definitions
3020typedef enum
3021{
3026 //NI_QUADRA_NOTCODED_FRAME = 3, /* Used just as a return value */
3028
3036
3044
3052
3060
3066
3072
3077
3078typedef enum
3079{
3082
3084{
3091 int analyzed_mbs; // intra 16x16, intra 8x8, intra 4x4 and inter blocks
3092 int num_intra_block_blocks; // intra 4x4 and 8x8 blocks (counted in 4x4)
3093 int num_intra_plane_blocks; // intra 16x16 blocks (counted in 4x4)
3094 int num_skip_blocks; // skip blocks (counted in 4x4)
3095 int num_forward_pred_blocks; // forward prediction blocks (counted in 4x4)
3097
3098
3099typedef struct _ni_packet
3100{
3101 long long dts;
3102 long long pts;
3103 long long pos;
3104 uint64_t pkt_pos;
3107 uint32_t video_width;
3109 uint32_t frame_type; // encoding only 0=I, 1=P, 2=B
3111 void* p_data;
3112 uint32_t data_len;
3114
3116 uint32_t buffer_size;
3117 uint32_t avg_frame_qp; // average frame QP reported by VPU
3124
3125 int flags; // flags of demuxed packet
3126
3128
3129 double psnr_y;
3130 double psnr_u;
3131 double psnr_v;
3133 double ssim_y;
3134 double ssim_u;
3135 double ssim_v;
3140
3150
3157typedef enum _ni_device_mode{
3158 NI_DEVICE_READ_ONLY = 0x0001, /* Read-only access */
3159 NI_DEVICE_WRITE_ONLY = 0x0002, /* Write-only access */
3160 NI_DEVICE_READ_WRITE = 0x0003 /* Read-write access */
3162
3163#define NI_XCODER_PRESET_NAMES_ARRAY_LEN 7
3164#define NI_XCODER_LOG_NAMES_ARRAY_LEN 7
3165
3166#define NI_XCODER_PRESET_NAME_NONE "none"
3167#define NI_XCODER_PRESET_NAME_VERYFAST "veryfast"
3168#define NI_XCODER_PRESET_NAME_FASTER "faster"
3169#define NI_XCODER_PRESET_NAME_FAST "fast"
3170#define NI_XCODER_PRESET_NAME_MEDIUM "medium"
3171#define NI_XCODER_PRESET_NAME_SLOW "slow"
3172#define NI_XCODER_PRESET_NAME_SLOWER "slower"
3173#define NI_XCODER_PRESET_NAME_VERYSLOW "veryslow"
3174
3175#define NI_XCODER_LOG_NAME_NONE "none"
3176#define NI_XCODER_LOG_NAME_ERROR "error"
3177#define NI_XCODER_LOG_NAME_WARN "warning"
3178#define NI_XCODER_LOG_NAME_INFO "info"
3179#define NI_XCODER_LOG_NAME_DEBUG "debug"
3180#define NI_XCODER_LOG_NAME_FULL "full"
3181
3184
3185/*!*****************************************************************************
3186 * \brief Allocate and initialize a new ni_session_context_t struct
3187 *
3188 *
3189 * \return On success returns a valid pointer to newly allocated context
3190 * On failure returns NULL
3191 ******************************************************************************/
3193
3194/*!*****************************************************************************
3195 * \brief Initialize already allocated session context to a known state
3196 *
3197 * \param[in] p_ctx Pointer to an already allocated ni_session_context_t
3198 * struct
3199 *
3200 * \return On success
3201 * NI_RETCODE_SUCCESS
3202 * On failure
3203 * NI_RETCODE_INVALID_PARAM
3204 * NI_RETCODE_FAILURE
3205 ******************************************************************************/
3208
3209/*!*****************************************************************************
3210 * \brief Clear already allocated session context
3211 *
3212 * \param[in] p_ctx Pointer to an already allocated ni_session_context_t
3213 *
3214 *
3215 ******************************************************************************/
3217
3218/*!*****************************************************************************
3219 * \brief Free previously allocated session context
3220 *
3221 * \param[in] p_ctx Pointer to an already allocated ni_session_context_t
3222 * struct
3223 *
3224 ******************************************************************************/
3226
3227/*!*****************************************************************************
3228 * \brief Create event and return event handle if successful (Windows only)
3229 *
3230 * \return On success returns a event handle
3231 * On failure returns NI_INVALID_EVENT_HANDLE
3232 ******************************************************************************/
3233LIB_API ni_event_handle_t ni_create_event(void);
3234
3235/*!*****************************************************************************
3236 * \brief Close event and release resources (Windows only)
3237 *
3238 * \return NONE
3239 *
3240 ******************************************************************************/
3241LIB_API void ni_close_event(ni_event_handle_t event_handle);
3242
3243#ifndef DEPRECATION_AS_ERROR
3244/*!*****************************************************************************
3245 * \brief Open device and return device device_handle if successful
3246 *
3247 * \param[in] p_dev Device name represented as c string. ex: "/dev/nvme0"
3248 * \param[out] p_max_io_size_out Maximum IO Transfer size supported
3249 *
3250 * \return On success returns a device device_handle
3251 * On failure returns NI_INVALID_DEVICE_HANDLE
3252 ******************************************************************************/
3253LIB_API NI_DEPRECATED ni_device_handle_t ni_device_open(const char *dev,
3254 uint32_t *p_max_io_size_out);
3255#endif
3256
3257/*!*****************************************************************************
3258 * \brief Open device and return device device_handle if successful
3259 *
3260 * \param[in] p_dev Device name represented as c string. ex: "/dev/nvme0"
3261 * \param[in] mode Device configuration parameters
3262 *
3263 * \return On success returns a device device_handle
3264 * On failure returns NI_INVALID_DEVICE_HANDLE
3265 ******************************************************************************/
3266LIB_API ni_device_handle_t ni_device_open2(const char *dev,
3267 ni_device_mode_t mode);
3268
3269/*!*****************************************************************************
3270 * \brief Close device and release resources
3271 *
3272 * \param[in] device_handle Device handle obtained by calling ni_device_open()
3273 *
3274 * \return NONE
3275 *
3276 ******************************************************************************/
3277LIB_API void ni_device_close(ni_device_handle_t dev);
3278
3279#ifndef DEPRECATION_AS_ERROR
3280/*!*****************************************************************************
3281 * \brief Query device and return device capability structure
3282 * This function had been replaced by ni_device_capability_query2
3283 * This function can't be callback in multi thread
3284 *
3285 * \param[in] device_handle Device handle obtained by calling ni_device_open
3286 * \param[in] p_cap Pointer to a caller allocated ni_device_capability_t
3287 * struct
3288 * \return On success
3289 * NI_RETCODE_SUCCESS
3290 * On failure
3291 * NI_RETCODE_INVALID_PARAM
3292 * NI_RETCODE_ERROR_MEM_ALOC
3293 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3294 ******************************************************************************/
3296 ni_device_handle_t device_handle, ni_device_capability_t *p_cap);
3297#endif
3298
3299/*!*****************************************************************************
3300 * \brief Query device and return device capability structure
3301 * This function had replaced ni_device_capability_query
3302 * This function can be callback with multi thread
3303 *
3304 * \param[in] device_handle Device handle obtained by calling ni_device_open
3305 * \param[in] p_cap Pointer to a caller allocated ni_device_capability_t
3306 * struct
3307 * \param[in] device_in_ctxt If device is in ctx
3308 * \return On success
3309 * NI_RETCODE_SUCCESS
3310 * On failure
3311 * NI_RETCODE_INVALID_PARAM
3312 * NI_RETCODE_ERROR_MEM_ALOC
3313 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3314 ******************************************************************************/
3315LIB_API ni_retcode_t ni_device_capability_query2(ni_device_handle_t device_handle,
3316 ni_device_capability_t *p_cap, bool device_in_ctxt);
3317
3318/*!*****************************************************************************
3319 * \brief Open a new device session depending on the device_type parameter
3320 * If device_type is NI_DEVICE_TYPE_DECODER opens decoding session
3321 * If device_type is NI_DEVICE_TYPE_ENCODER opens encoding session
3322 * If device_type is NI_DEVICE_TYPE_SCALER opens scaling session
3323 *
3324 * \param[in] p_ctx Pointer to a caller allocated
3325 * ni_session_context_t struct
3326 * \param[in] device_type NI_DEVICE_TYPE_DECODER, NI_DEVICE_TYPE_ENCODER,
3327 * or NI_DEVICE_TYPE_SCALER
3328 * \return On success
3329 * NI_RETCODE_SUCCESS
3330 * On failure
3331 * NI_RETCODE_INVALID_PARAM
3332 * NI_RETCODE_ERROR_MEM_ALOC
3333 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3334 * NI_RETCODE_ERROR_INVALID_SESSION
3335 ******************************************************************************/
3337 ni_device_type_t device_type);
3338
3339/*!*****************************************************************************
3340 * \brief Close device session that was previously opened by calling
3341 * ni_device_session_open()
3342 * If device_type is NI_DEVICE_TYPE_DECODER closes decoding session
3343 * If device_type is NI_DEVICE_TYPE_ENCODER closes encoding session
3344 * If device_type is NI_DEVICE_TYPE_SCALER closes scaling session
3345 *
3346 * \param[in] p_ctx Pointer to a caller allocated
3347 * ni_session_context_t struct
3348 * \param[in] eos_received Flag indicating if End Of Stream indicator was
3349 * received
3350 * \param[in] device_type NI_DEVICE_TYPE_DECODER, NI_DEVICE_TYPE_ENCODER,
3351 * or NI_DEVICE_TYPE_SCALER
3352 * \return On success
3353 * NI_RETCODE_SUCCESS
3354 * On failure
3355 * NI_RETCODE_INVALID_PARAM
3356 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3357 * NI_RETCODE_ERROR_INVALID_SESSION
3358 ******************************************************************************/
3360 int eos_received,
3361 ni_device_type_t device_type);
3362
3363/*!*****************************************************************************
3364 * \brief Send a flush command to the device
3365 * If device_type is NI_DEVICE_TYPE_DECODER sends EOS command to
3366 * decoder
3367 * If device_type is NI_DEVICE_TYPE_ENCODER sends EOS command to
3368 * encoder
3369 *
3370 * \param[in] p_ctx Pointer to a caller allocated
3371 * ni_session_context_t struct
3372 * \param[in] device_type NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER
3373 * \return On success
3374 * NI_RETCODE_SUCCESS
3375 * On failure
3376 * NI_RETCODE_INVALID_PARAM
3377 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3378 * NI_RETCODE_ERROR_INVALID_SESSION
3379 ******************************************************************************/
3381 ni_device_type_t device_type);
3382
3383/*!*****************************************************************************
3384 * \brief Save a stream's headers in a decoder session that can be used later
3385 * for continuous decoding from the same source.
3386 *
3387 * \param[in] p_ctx Pointer to a caller allocated
3388 * ni_session_context_t struct
3389 * \param[in] hdr_data Pointer to header data
3390 * \param[in] hdr_size Size of header data in bytes
3391 * \return On success
3392 * NI_RETCODE_SUCCESS
3393 * On failure
3394 * NI_RETCODE_INVALID_PARAM
3395 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3396 * NI_RETCODE_ERROR_INVALID_SESSION
3397 ******************************************************************************/
3399 ni_session_context_t *p_ctx, uint8_t *hdr_data, uint8_t hdr_size);
3400
3401/*!*****************************************************************************
3402 * \brief Flush a decoder session to get ready to continue decoding.
3403 * Note: this is different from ni_device_session_flush in that it closes the
3404 * current decode session and opens a new one for continuous decoding.
3405 *
3406 * \param[in] p_ctx Pointer to a caller allocated
3407 * ni_session_context_t struct
3408 * \return On success
3409 * NI_RETCODE_SUCCESS
3410 * On failure
3411 * NI_RETCODE_INVALID_PARAM
3412 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3413 * NI_RETCODE_ERROR_INVALID_SESSION
3414 ******************************************************************************/
3416
3417/*!*****************************************************************************
3418 * \brief Send data to the device
3419 * If device_type is NI_DEVICE_TYPE_DECODER sends data packet to
3420 * decoder
3421 * If device_type is NI_DEVICE_TYPE_ENCODER sends data frame to encoder
3422 * If device_type is NI_DEVICE_TYPE_AI sends data frame to AI engine
3423 *
3424 * \param[in] p_ctx Pointer to a caller allocated
3425 * ni_session_context_t struct
3426 * \param[in] p_data Pointer to a caller allocated
3427 * ni_session_data_io_t struct which contains either a
3428 * ni_frame_t data frame or ni_packet_t data packet to
3429 * send
3430 * \param[in] device_type NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER or
3431 * NI_DEVICE_TYPE_AI
3432 * If NI_DEVICE_TYPE_DECODER is specified, it is
3433 * expected that the ni_packet_t struct inside the
3434 * p_data pointer contains data to send.
3435 * If NI_DEVICE_TYPE_ENCODER or NI_DEVICE_TYPE_AI is
3436 * specified, it is expected that the ni_frame_t
3437 * struct inside the p_data pointer contains data to
3438 * send.
3439 * \return On success
3440 * Total number of bytes written
3441 * On failure
3442 * NI_RETCODE_INVALID_PARAM
3443 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3444 * NI_RETCODE_ERROR_INVALID_SESSION
3445 ******************************************************************************/
3447 ni_session_data_io_t *p_data,
3448 ni_device_type_t device_type);
3449
3450/*!*****************************************************************************
3451 * \brief Read data from the device
3452 * If device_type is NI_DEVICE_TYPE_DECODER reads data packet from
3453 * decoder
3454 * If device_type is NI_DEVICE_TYPE_ENCODER reads data frame from
3455 * encoder
3456 * If device_type is NI_DEVICE_TYPE_AI reads data frame from AI engine
3457 *
3458 * \param[in] p_ctx Pointer to a caller allocated
3459 * ni_session_context_t struct
3460 * \param[in] p_data Pointer to a caller allocated ni_session_data_io_t
3461 * struct which contains either a ni_frame_t data frame
3462 * or ni_packet_t data packet to send
3463 * \param[in] device_type NI_DEVICE_TYPE_DECODER, NI_DEVICE_TYPE_ENCODER, or
3464 * NI_DEVICE_TYPE_SCALER
3465 * If NI_DEVICE_TYPE_DECODER is specified, data that
3466 * was read will be placed into ni_frame_t struct
3467 * inside the p_data pointer
3468 * If NI_DEVICE_TYPE_ENCODER is specified, data that
3469 * was read will be placed into ni_packet_t struct
3470 * inside the p_data pointer
3471 * If NI_DEVICE_TYPE_AI is specified, data that was
3472 * read will be placed into ni_frame_t struct inside
3473 * the p_data pointer
3474 * \return On success
3475 * Total number of bytes read
3476 * On failure
3477 * NI_RETCODE_INVALID_PARAM
3478 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3479 * NI_RETCODE_ERROR_INVALID_SESSION
3480 ******************************************************************************/
3482 ni_session_data_io_t *p_data,
3483 ni_device_type_t device_type);
3484
3485/*!*****************************************************************************
3486 * \brief Query session data from the device -
3487 * If device_type is valid, will query session data
3488 * from specified device type
3489 *
3490 * \param[in] p_ctx Pointer to a caller allocated
3491 * ni_session_context_t struct
3492 * \param[in] device_type NI_DEVICE_TYPE_DECODER or
3493 * NI_DEVICE_TYPE_ENCODER or
3494 * NI_DEVICE_TYPE_SCALER or
3495 * NI_DEVICE_TYPE_AI or
3496 * NI_DEVICE_TYPE_UPLOADER
3497 *
3498 * \return On success
3499 * NI_RETCODE_SUCCESS
3500 * On failure
3501 * NI_RETCODE_INVALID_PARAM
3502 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3503 * NI_RETCODE_ERROR_INVALID_SESSION
3504 ******************************************************************************/
3506 ni_device_type_t device_type);
3507/*!*****************************************************************************
3508 * \brief Query detail session data from the device -
3509 * If device_type is valid, will query session data
3510 * from specified device type
3511 *
3512 * \param[in] p_ctx Pointer to a caller allocated
3513 * ni_session_context_t struct
3514 * \param[in] device_type NI_DEVICE_TYPE_DECODER or
3515 * NI_DEVICE_TYPE_ENCODER or
3516 *
3517 * \return On success
3518 * NI_RETCODE_SUCCESS
3519 * On failure
3520 * NI_RETCODE_INVALID_PARAM
3521 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3522 * NI_RETCODE_ERROR_INVALID_SESSION
3523 ******************************************************************************/
3525 ni_device_type_t device_type, ni_instance_mgr_detail_status_t *detail_data);
3526
3527/*!*****************************************************************************
3528 * \brief Query detail session data from the device -
3529 * If device_type is valid, will query session data
3530 * from specified device type
3531 *
3532 * \param[in] p_ctx Pointer to a caller allocated
3533 * ni_session_context_t struct
3534 * \param[in] device_type NI_DEVICE_TYPE_DECODER or
3535 * NI_DEVICE_TYPE_ENCODER or
3536 *
3537 * \return On success
3538 * NI_RETCODE_SUCCESS
3539 * On failure
3540 * NI_RETCODE_INVALID_PARAM
3541 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3542 * NI_RETCODE_ERROR_INVALID_SESSION
3543 ******************************************************************************/
3545
3546/*!*****************************************************************************
3547 * \brief Send namespace num and SRIOv index to the device with specified logic block
3548 * address.
3549 *
3550 * \param[in] device_handle Device handle obtained by calling ni_device_open
3551 * \param[in] namespace_num Set the namespace number with designated sriov
3552 * \param[in] sriov_index Identify which sriov need to be set
3553 *
3554 * \return On success
3555 * NI_RETCODE_SUCCESS
3556 * On failure
3557 * NI_RETCODE_ERROR_MEM_ALOC
3558 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3559 ******************************************************************************/
3560LIB_API ni_retcode_t ni_device_config_namespace_num(ni_device_handle_t device_handle,
3561 uint32_t namespace_num, uint32_t sriov_index);
3562
3563/*!*****************************************************************************
3564 * \brief Send qos mode to the device with specified logic block
3565 * address.
3566 *
3567 * \param[in] device_handle Device handle obtained by calling ni_device_open
3568 * \param[in] mode The requested qos mode
3569 *
3570 * \return On success
3571 * NI_RETCODE_SUCCESS
3572 * On failure
3573 * NI_RETCODE_ERROR_MEM_ALOC
3574 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3575 ******************************************************************************/
3576LIB_API ni_retcode_t ni_device_config_qos(ni_device_handle_t device_handle,
3577 uint32_t mode);
3578
3579 /*!*****************************************************************************
3580 * \brief Send qos over provisioning mode to target namespace with specified logic
3581 * block address.
3582 *
3583 * \param[in] device_handle Device handle obtained by calling ni_device_open
3584 * \param[in] device_handle_t Target device handle of namespace required for OP
3585 * \param[in] over_provision The request overprovision percent
3586 *
3587 * \return On success
3588 * NI_RETCODE_SUCCESS
3589 * On failure
3590 * NI_RETCODE_ERROR_MEM_ALOC
3591 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3592 ******************************************************************************/
3593LIB_API ni_retcode_t ni_device_config_qos_op(ni_device_handle_t device_handle,
3594 ni_device_handle_t device_handle_t,
3595 uint32_t over_provision);
3596/*!*****************************************************************************
3597 * \brief Set QoS allowance for a specific namespace
3598 *
3599 * \param[in] device_handle Device handle obtained by calling ni_device_open
3600 * \param[in] device_handle_t Target device handle of namespace required
3601 * \param[in] allowance Allowance percentage (0.0-100.0)
3602 *
3603 * \return On success
3604 * NI_RETCODE_SUCCESS
3605 * On failure
3606 * NI_RETCODE_ERROR_MEM_ALOC
3607 * NI_RETCODE_ERROR_NVME_CMD_FAILED
3608 ******************************************************************************/
3609LIB_API ni_retcode_t ni_device_config_qos_allowance(ni_device_handle_t device_handle,
3610 ni_device_handle_t device_handle_t,
3611 uint32_t allowance);
3612
3613
3614/*!*****************************************************************************
3615 * \brief Allocate preliminary memory for the frame buffer based on provided
3616 * parameters. Applicable to YUV420 Planar pixel (8 or 10 bit/pixel)
3617 * format or 32-bit RGBA.
3618 *
3619 * \param[in] p_frame Pointer to a caller allocated
3620 * ni_frame_t struct
3621 * \param[in] video_width Width of the video frame
3622 * \param[in] video_height Height of the video frame
3623 * \param[in] alignment Allignment requirement
3624 * \param[in] metadata_flag Flag indicating if space for additional metadata
3625 * should be allocated
3626 * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel,
3627 * 4 for 32 bits/pixel (RGBA)
3628 * \param[in] hw_frame_count Number of hw descriptors stored in lieu of raw YUV
3629 * \param[in] is_planar 0 if semiplanar else planar
3630 *
3631 * \return On success
3632 * NI_RETCODE_SUCCESS
3633 * On failure
3634 * NI_RETCODE_INVALID_PARAM
3635 * NI_RETCODE_ERROR_MEM_ALOC
3636 ******************************************************************************/
3637LIB_API ni_retcode_t ni_frame_buffer_alloc(ni_frame_t *p_frame, int video_width,
3638 int video_height, int alignment,
3639 int metadata_flag, int factor,
3640 int hw_frame_count, int is_planar);
3641
3642/*!*****************************************************************************
3643 * \brief Wrapper function for ni_frame_buffer_alloc. Meant to handle RGBA min.
3644 * resoulution considerations for encoder.
3645 *
3646 * \param[in] p_frame Pointer to a caller allocated
3647 * ni_frame_t struct
3648 * \param[in] video_width Width of the video frame
3649 * \param[in] video_height Height of the video frame
3650 * \param[in] alignment Allignment requirement
3651 * \param[in] metadata_flag Flag indicating if space for additional metadata
3652 * should be allocated
3653 * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel,
3654 * 4 for 32 bits/pixel (RGBA)
3655 * \param[in] hw_frame_count Number of hw descriptors stored
3656 * \param[in] is_planar 0 if semiplanar else planar
3657 * \param[in] pix_fmt pixel format to distinguish between planar types
3658 * and/or components
3659 *
3660 * \return On success
3661 * NI_RETCODE_SUCCESS
3662 * On failure
3663 * NI_RETCODE_INVALID_PARAM
3664 * NI_RETCODE_ERROR_MEM_ALOC
3665 ******************************************************************************/
3667 int video_height, int alignment,
3668 int metadata_flag, int factor,
3669 int hw_frame_count, int is_planar,
3670 ni_pix_fmt_t pix_fmt);
3671
3673 int video_width, int video_height,
3674 int pixel_format);
3675
3676/*!*****************************************************************************
3677 * \brief Allocate memory for decoder frame buffer based on provided
3678 * parameters; the memory is retrieved from a buffer pool and will be
3679 * returned to the same buffer pool by ni_decoder_frame_buffer_free.
3680 * Note: all attributes of ni_frame_t will be set up except for memory and
3681 * buffer, which rely on the pool being allocated; the pool will be
3682 * allocated only after the frame resolution is known.
3683 *
3684 * \param[in] p_pool Buffer pool to get the memory from
3685 * \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
3686 * \param[in] alloc_mem Whether to get memory from buffer pool
3687 * \param[in] video_width Width of the video frame
3688 * \param[in] video_height Height of the video frame
3689 * \param[in] alignment Alignment requirement
3690 * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel
3691 * \param[in] is_planar 0 if semiplanar else planar
3692 *
3693 * \return On success
3694 * NI_RETCODE_SUCCESS
3695 * On failure
3696 * NI_RETCODE_INVALID_PARAM
3697 * NI_RETCODE_ERROR_MEM_ALOC
3698 ******************************************************************************/
3700 ni_buf_pool_t *p_pool, ni_frame_t *pframe, int alloc_mem, int video_width,
3701 int video_height, int alignment, int factor, int is_planar);
3702
3703/*!*****************************************************************************
3704 * \brief Allocate memory for the frame buffer for encoding based on given
3705 * parameters, taking into account pic line size and extra data.
3706 * Applicable to YUV420p AVFrame only. 8 or 10 bit/pixel.
3707 * Cb/Cr size matches that of Y.
3708 *
3709 * \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
3710 *
3711 * \param[in] video_width Width of the video frame
3712 * \param[in] video_height Height of the video frame
3713 * \param[in] linesize Picture line size
3714 * \param[in] alignment Allignment requirement
3715 * \param[in] extra_len Extra data size (incl. meta data). < 0 means not
3716 * to allocate any buffer (zero-copy from existing)
3717 * \param[in] alignment_2pass_wa set alignment to work with 2pass encode
3718 *
3719 * \return On success
3720 * NI_RETCODE_SUCCESS
3721 * On failure
3722 * NI_RETCODE_INVALID_PARAM
3723 * NI_RETCODE_ERROR_MEM_ALOC
3724 *****************************************************************************/
3726 ni_frame_t *pframe, int video_width, int video_height, int linesize[],
3727 int alignment, int extra_len, bool alignment_2pass_wa);
3728
3730 ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params,
3731 niFrameSurface1_t *p_surface);
3732
3734 ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params,
3735 niFrameSurface1_t *p_src_surface);
3736
3738 ni_session_context_t *p_ctx, ni_scaler_input_params_t scaler_params);
3739
3740/*!*****************************************************************************
3741* \brief Allocate memory for the frame buffer based on provided parameters
3742* taking into account pic line size and extra data.
3743* Applicable to nv12 AVFrame only. Cb/Cr size matches that of Y.
3744*
3745* \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
3746*
3747* \param[in] video_width Width of the video frame
3748* \param[in] video_height Height of the video frame
3749* \param[in] linesize Picture line size
3750* \param[in] extra_len Extra data size (incl. meta data). < 0 means not
3751* to allocate any buffer (zero-copy from existing)
3752* \param[in] alignment_2pass_wa set alignment to work with 2pass encode
3753*
3754* \return On success
3755* NI_RETCODE_SUCCESS
3756* On failure
3757* NI_RETCODE_INVALID_PARAM
3758* NI_RETCODE_ERROR_MEM_ALOC
3759*****************************************************************************/
3761 int video_width, int video_height,
3762 int linesize[], int extra_len,
3763 bool alignment_2pass_wa);
3764
3765/*!*****************************************************************************
3766 * \brief This API is a wrapper for ni_encoder_frame_buffer_alloc(), used
3767 * for planar pixel formats, and ni_frame_buffer_alloc_nv(), used for
3768 * semi-planar pixel formats. This API is meant to combine the
3769 * functionality for both formats.
3770 * Allocate memory for the frame buffer for encoding based on given
3771 * parameters, taking into account pic line size and extra data.
3772 * Applicable to YUV420p(8 or 10 bit/pixel) or nv12 AVFrame.
3773 * Cb/Cr size matches that of Y.
3774 *
3775 * \param[in] planar true: if planar:
3776 * pixel_format == (NI_PIX_FMT_YUV420P ||
3777 * NI_PIX_FMT_YUV420P10LE ||NI_PIX_FMT_RGBA).
3778 * false: semi-planar:
3779 * pixel_format == (NI_PIX_FMT_NV12 ||
3780 * NI_PIX_FMT_P010LE).
3781 * \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
3782 * \param[in] video_width Width of the video frame
3783 * \param[in] video_height Height of the video frame
3784 * \param[in] linesize Picture line size
3785 * \param[in] alignment Allignment requirement. Only used for planar format.
3786 * \param[in] extra_len Extra data size (incl. meta data). < 0 means not
3787 * to allocate any buffer (zero-copy from existing)
3788 * \param[in] alignment_2pass_wa set alignment to work with 2pass encode
3789 *
3790 * \return On success
3791 * NI_RETCODE_SUCCESS
3792 * On failure
3793 * NI_RETCODE_INVALID_PARAM
3794 * NI_RETCODE_ERROR_MEM_ALOC
3795 *****************************************************************************/
3797 int video_width, int video_height,
3798 int linesize[], int alignment,
3799 int extra_len,
3800 bool alignment_2pass_wa);
3801
3802/*!*****************************************************************************
3803 * \brief Free frame buffer that was previously allocated with either
3804 * ni_frame_buffer_alloc or ni_encoder_frame_buffer_alloc or
3805 * ni_frame_buffer_alloc_nv
3806 *
3807 * \param[in] p_frame Pointer to a previously allocated ni_frame_t struct
3808 *
3809 * \return On success NI_RETCODE_SUCCESS
3810 * On failure NI_RETCODE_INVALID_PARAM
3811 ******************************************************************************/
3813
3814/*!*****************************************************************************
3815 * \brief Free decoder frame buffer that was previously allocated with
3816 * ni_decoder_frame_buffer_alloc, returning memory to a buffer pool.
3817 *
3818 * \param[in] p_frame Pointer to a previously allocated ni_frame_t struct
3819 *
3820 * \return On success NI_RETCODE_SUCCESS
3821 * On failure NI_RETCODE_INVALID_PARAM
3822 ******************************************************************************/
3824
3825/*!*****************************************************************************
3826 * \brief Return a memory buffer to memory buffer pool, for a decoder frame.
3827 *
3828 * \param[in] buf Buffer to be returned.
3829 * \param[in] p_buffer_pool Buffer pool to return buffer to.
3830 *
3831 * \return None
3832 ******************************************************************************/
3833LIB_API void
3835 ni_buf_pool_t *p_buffer_pool);
3836
3837/*!*****************************************************************************
3838 * \brief Allocate memory for the packet buffer based on provided packet size
3839 *
3840 * \param[in] p_packet Pointer to a caller allocated
3841 * ni_packet_t struct
3842 * \param[in] packet_size Required allocation size
3843 *
3844 * \return On success
3845 * NI_RETCODE_SUCCESS
3846 * On failure
3847 * NI_RETCODE_INVALID_PARAM
3848 * NI_RETCODE_ERROR_MEM_ALOC
3849 ******************************************************************************/
3851 int packet_size);
3852
3853/*!*****************************************************************************
3854 * \brief Allocate packet buffer using a user provided pointer, the memory
3855 * is expected to have already been allocated.
3856 *
3857 * For ideal performance memory should be 4k aligned. If it is not 4K aligned
3858 * then a temporary 4k aligned memory will be used to copy data to and from
3859 * when writing and reading. This will negatively impact performance.
3860 *
3861 * This API will overwrite p_packet->buffer_size, p_packet->p_buffer and
3862 * p_packet->p_data fields in p_packet.
3863 *
3864 * This API will not free any memory associated with p_packet->p_buffer and
3865 * p_packet->p_data fields in p_packet.
3866 * Common use case could be,
3867 * 1. Allocate memory to pointer
3868 * 2. Call ni_custom_packet_buffer_alloc() with allocated pointer.
3869 * 3. Use p_packet as required.
3870 * 4. Call ni_packet_buffer_free() to free up the memory.
3871 *
3872 * \param[in] p_buffer User provided pointer to be used for buffer
3873 * \param[in] p_packet Pointer to a caller allocated
3874 * ni_packet_t struct
3875 * \param[in] buffer_size Buffer size
3876 *
3877 * \return On success
3878 * NI_RETCODE_SUCCESS
3879 * On failure
3880 * NI_RETCODE_INVALID_PARAM
3881 * NI_RETCODE_ERROR_MEM_ALOC
3882 ******************************************************************************/
3884 ni_packet_t *p_packet,
3885 int buffer_size);
3886
3887/*!*****************************************************************************
3888 * \brief Free packet buffer that was previously allocated with
3889 * ni_packet_buffer_alloc
3890 *
3891 * \param[in] p_packet Pointer to a previously allocated ni_packet_t struct
3892 *
3893 * \return On success NI_RETCODE_SUCCESS
3894 * On failure NI_RETCODE_INVALID_PARAM
3895 ******************************************************************************/
3897
3898/*!*****************************************************************************
3899 * \brief Free packet buffer that was previously allocated with
3900 * ni_packet_buffer_alloc for AV1 packets merge
3901 *
3902 * \param[in] p_packet Pointer to a previously allocated ni_packet_t struct
3903 *
3904 * \return On success NI_RETCODE_SUCCESS
3905 * On failure NI_RETCODE_INVALID_PARAM
3906 ******************************************************************************/
3908
3909/*!*****************************************************************************
3910 * \brief Copy video packet accounting for alignment
3911 *
3912 * \param[in] p_destination Destination to where to copy to
3913 * \param[in] p_source Source from where to copy from
3914 * \param[in] cur_size current size
3915 * \param[out] p_leftover Pointer to the data that was left over
3916 * \param[out] p_prev_size Size of the data leftover
3917 *
3918 * \return On success Total number of bytes that were copied
3919 * On failure NI_RETCODE_FAILURE
3920 ******************************************************************************/
3921LIB_API int ni_packet_copy(void *p_destination, const void *const p_source,
3922 int cur_size, void *p_leftover, int *p_prev_size);
3923
3924/*!*****************************************************************************
3925 * \brief Add a new auxiliary data to a frame
3926 *
3927 * \param[in/out] frame a frame to which the auxiliary data should be added
3928 * \param[in] type type of the added auxiliary data
3929 * \param[in] data_size size of the added auxiliary data
3930 *
3931 * \return a pointer to the newly added aux data on success, NULL otherwise
3932 ******************************************************************************/
3934 ni_aux_data_type_t type,
3935 int data_size);
3936
3937/*!*****************************************************************************
3938 * \brief Add a new auxiliary data to a frame and copy in the raw data
3939 *
3940 * \param[in/out] frame a frame to which the auxiliary data should be added
3941 * \param[in] type type of the added auxiliary data
3942 * \param[in] raw_data the raw data of the aux data
3943 * \param[in] data_size size of the added auxiliary data
3944 *
3945 * \return a pointer to the newly added aux data on success, NULL otherwise
3946 ******************************************************************************/
3949 const uint8_t *raw_data, int data_size);
3950
3951/*!*****************************************************************************
3952 * \brief Retrieve from the frame auxiliary data of a given type if exists
3953 *
3954 * \param[in] frame a frame from which the auxiliary data should be retrieved
3955 * \param[in] type type of the auxiliary data to be retrieved
3956 *
3957 * \return a pointer to the aux data of a given type on success, NULL otherwise
3958 ******************************************************************************/
3960 ni_aux_data_type_t type);
3961
3962/*!*****************************************************************************
3963 * \brief If auxiliary data of the given type exists in the frame, free it
3964 * and remove it from the frame.
3965 *
3966 * \param[in/out] frame a frame from which the auxiliary data should be removed
3967 * \param[in] type type of the auxiliary data to be removed
3968 *
3969 * \return None
3970 ******************************************************************************/
3972
3973/*!*****************************************************************************
3974 * \brief Free and remove all auxiliary data from the frame.
3975 *
3976 * \param[in/out] frame a frame from which the auxiliary data should be removed
3977 *
3978 * \return None
3979 ******************************************************************************/
3981
3982/*!*****************************************************************************
3983 * \brief Initialize default encoder parameters
3984 *
3985 * \param[out] param Pointer to a user allocated ni_xcoder_params_t
3986 * to initialize to default parameters
3987 * \param[in] fps_num Frames per second
3988 * \param[in] fps_denom FPS denomination
3989 * \param[in] bit_rate bit rate
3990 * \param[in] width frame width
3991 * \param[in] height frame height
3992 * \param[in] codec_format codec from ni_codec_format_t
3993 *
3994 * \return On success
3995 * NI_RETCODE_SUCCESS
3996 * On failure
3997 * NI_RETCODE_FAILURE
3998 * NI_RETCODE_INVALID_PARAM
3999 ******************************************************************************/
4001 ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate,
4002 int width, int height, ni_codec_format_t codec_format);
4003
4004/*!*****************************************************************************
4005 * \brief Initialize default decoder parameters
4006 *
4007 * \param[out] param Pointer to a user allocated ni_xcoder_params_t
4008 * to initialize to default parameters
4009 * \param[in] fps_num Frames per second
4010 * \param[in] fps_denom FPS denomination
4011 * \param[in] bit_rate bit rate
4012 * \param[in] width frame width
4013 * \param[in] height frame height
4014 *
4015 * \return On success
4016 * NI_RETCODE_SUCCESS
4017 * On failure
4018 * NI_RETCODE_FAILURE
4019 * NI_RETCODE_INVALID_PARAM
4020 ******************************************************************************/
4022 int fps_num, int fps_denom,
4023 long bit_rate, int width,
4024 int height);
4025
4026/*!*****************************************************************************
4027 * \brief Set value referenced by name in encoder parameters structure
4028 *
4029 * \param[in] p_params Pointer to a user allocated ni_xcoder_params_t
4030 * to find and set a particular parameter
4031 * \param[in] name String represented parameter name to search
4032 * \param[in] value Parameter value to set
4033*
4034 * \return On success
4035 * NI_RETCODE_SUCCESS
4036 * On failure
4037 * NI_RETCODE_FAILURE
4038 * NI_RETCODE_INVALID_PARAM
4039 ******************************************************************************/
4041 const char *name,
4042 const char *value);
4043
4044/*!*****************************************************************************
4045* \brief Set value referenced by name in decoder parameters structure
4046*
4047* \param[in] p_params Pointer to a user allocated ni_xcoder_params_t (used
4048* for decoder too for now ) to find and set a particular
4049* parameter
4050* \param[in] name String represented parameter name to search
4051* \param[in] value Parameter value to set
4052*
4053* \return On success
4054* NI_RETCODE_SUCCESS
4055* On failure
4056* NI_RETCODE_FAILURE
4057* NI_RETCODE_INVALID_PARAM
4058******************************************************************************/
4060 const char *name, char *value);
4061
4062/*!*****************************************************************************
4063 * \brief Set GOP parameter value referenced by name in encoder parameters
4064 * structure
4065 *
4066 * \param[in] p_params Pointer to a user allocated ni_xcoder_params_t
4067 * to find and set a particular parameter
4068 * \param[in] name String represented parameter name to search
4069 * \param[in] value Parameter value to set
4070*
4071 * \return On success
4072 * NI_RETCODE_SUCCESS
4073 * On failure
4074 * NI_RETCODE_FAILURE
4075 * NI_RETCODE_INVALID_PARAM
4076 ******************************************************************************/
4078 ni_xcoder_params_t *p_params, const char *name, const char *value);
4079
4080/*!*****************************************************************************
4081* \brief Copy existing decoding session params for hw frame usage
4082*
4083* \param[in] src_p_ctx Pointer to a caller allocated source session context
4084* \param[in] dst_p_ctx Pointer to a caller allocated destination session
4085* context
4086* \return On success
4087* NI_RETCODE_SUCCESS
4088* On failure
4089* NI_RETCODE_INVALID_PARAM
4090******************************************************************************/
4092 ni_session_context_t *dst_p_ctx);
4093
4094/*!*****************************************************************************
4095* \brief Send frame pool setup info to device
4096*
4097* \param[in] p_ctx Pointer to a caller allocated
4098* ni_session_context_t struct
4099* \param[in] pool_size Upload session initial allocated frames count
4100* must be > 0,
4101* \param[in] pool 0 use the normal pool
4102* 1 use a dedicated P2P pool
4103*
4104* \return On success Return code
4105* On failure
4106* NI_RETCODE_INVALID_PARAM
4107* NI_RETCODE_ERROR_NVME_CMD_FAILED
4108* NI_RETCODE_ERROR_INVALID_SESSION
4109* NI_RETCODE_ERROR_MEM_ALOC
4110******************************************************************************/
4112 uint32_t pool_size, uint32_t pool);
4113
4114/*!*****************************************************************************
4115* \brief Sends frame pool change info to device
4116*
4117* \param[in] p_ctx Pointer to a caller allocated
4118* ni_session_context_t struct
4119* \param[in] pool_size if pool_size = 0, free allocated device memory buffers
4120* if pool_size > 0, expand device frame buffer pool of
4121* current instance with pool_size more frame buffers
4122*
4123* \return On success Return code
4124* On failure
4125* NI_RETCODE_FAILURE
4126* NI_RETCODE_INVALID_PARAM
4127* NI_RETCODE_ERROR_NVME_CMD_FAILED
4128* NI_RETCODE_ERROR_INVALID_SESSION
4129* NI_RETCODE_ERROR_MEM_ALOC
4130* NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4131*******************************************************************************/
4133 uint32_t pool_size);
4134
4135/*!*****************************************************************************
4136* \brief Read data from the device
4137* If device_type is NI_DEVICE_TYPE_DECODER reads data hwdesc from
4138* decoder
4139* If device_type is NI_DEVICE_TYPE_SCALER reads data hwdesc from
4140* scaler
4141*
4142* \param[in] p_ctx Pointer to a caller allocated
4143* ni_session_context_t struct
4144* \param[in] p_data Pointer to a caller allocated
4145* ni_session_data_io_t struct which contains either a
4146* ni_frame_t data frame or ni_packet_t data packet to
4147* send
4148* \param[in] device_type NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_SCALER
4149* If NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_SCALER is specified,
4150* hw descriptor info will be stored in p_data ni_frame
4151* \return On success
4152* Total number of bytes read
4153* On failure
4154* NI_RETCODE_INVALID_PARAM
4155* NI_RETCODE_ERROR_NVME_CMD_FAILED
4156* NI_RETCODE_ERROR_INVALID_SESSION
4157******************************************************************************/
4159 ni_session_data_io_t *p_data,
4160 ni_device_type_t device_type);
4161
4162/*!*****************************************************************************
4163* \brief Read YUV data from hw descriptor stored location on device
4164*
4165* \param[in] p_ctx Pointer to a caller allocated
4166* ni_session_context_t struct
4167* \param[in] p_data Pointer to a caller allocated
4168* ni_session_data_io_t struct which contains either a
4169* ni_frame_t data frame or ni_packet_t data packet to
4170* send
4171* \param[in] hwdesc HW descriptor to find frame in XCODER
4172* \return On success
4173* Total number of bytes read
4174* On failure
4175* NI_RETCODE_INVALID_PARAM
4176* NI_RETCODE_ERROR_NVME_CMD_FAILED
4177* NI_RETCODE_ERROR_INVALID_SESSION
4178******************************************************************************/
4180 ni_session_data_io_t *p_data,
4181 niFrameSurface1_t *hwdesc);
4182
4183/*!*****************************************************************************
4184* \brief Query the session if a buffer is available
4185*
4186* \param[in] p_ctx Pointer to a caller allocated
4187* ni_session_context_t struct
4188* \param[in] device_type Quadra device type
4189*
4190* \return On success
4191* NI_RETCODE_SUCCESS
4192* On failure
4193* NI_RETCODE_INVALID_PARAM
4194* NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4195* NI_RETCODE_ERROR_NVME_CMD_FAILED
4196* NI_RETCODE_ERROR_INVALID_SESSION
4197*******************************************************************************/
4199 ni_device_type_t device_type);
4200
4201
4202/*!*****************************************************************************
4203* \brief Send raw YUV input to uploader instance and retrieve a HW descriptor
4204* to represent it
4205*
4206* \param[in] p_ctx Pointer to a caller allocated
4207* ni_session_context_t struct
4208* \param[in] p_src_data Pointer to a caller allocated
4209* ni_session_data_io_t struct which contains a
4210* ni_frame_t data frame to send to uploader
4211* \param[out] hwdesc HW descriptor to find frame in XCODER
4212* \return On success
4213* Total number of bytes read
4214* On failure
4215* NI_RETCODE_INVALID_PARAM
4216* NI_RETCODE_ERROR_NVME_CMD_FAILED
4217* NI_RETCODE_ERROR_INVALID_SESSION
4218*******************************************************************************/
4220
4221/*!*****************************************************************************
4222* \brief Allocate memory for the hwDescriptor buffer based on provided
4223* parameters taking into account pic size and extra data.
4224*
4225* \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
4226*
4227* \param[in] video_width Width of the video frame
4228* \param[in] video_height Height of the video frame
4229* \param[in] extra_len Extra data size (incl. meta data)
4230*
4231* \return On success
4232* NI_RETCODE_SUCCESS
4233* On failure
4234* NI_RETCODE_INVALID_PARAM
4235* NI_RETCODE_ERROR_MEM_ALOC
4236*****************************************************************************/
4238 int video_width,
4239 int video_height,
4240 int extra_len);
4241
4242/*!*****************************************************************************
4243* \brief Recycle a hwframe buffer on card
4244*
4245* \param[in] surface Struct containing device and frame location to clear out
4246* \param[in] device_handle handle to access device memory buffer is stored in
4247*
4248* \return On success NI_RETCODE_SUCCESS
4249* On failure NI_RETCODE_INVALID_PARAM
4250*******************************************************************************/
4252 int32_t device_handle);
4253
4254
4255/*!*****************************************************************************
4256* \brief Recycle a hwframe buffer on card
4257*
4258* \param[in] surface Struct containing device and frame location to clear out
4259*
4260* \return On success NI_RETCODE_SUCCESS
4261* On failure NI_RETCODE_INVALID_PARAM
4262*******************************************************************************/
4264
4265/*!*****************************************************************************
4266 * \brief Set parameters on the device for the 2D engine
4267 *
4268 * \param[in] p_ctx pointer to session context
4269 * \param[in] p_params pointer to the scaler parameters
4270 *
4271 * \return NI_RETCODE_INVALID_PARAM
4272 * NI_RETCODE_ERROR_INVALID_SESSION
4273 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4274
4275 ******************************************************************************/
4277 ni_scaler_params_t *p_params);
4278
4279/*!*****************************************************************************
4280 * \brief Allocate a frame on the device for 2D engine or AI engine
4281 * to work on based on provided parameters
4282 *
4283 * \param[in] p_ctx pointer to session context
4284 * \param[in] width width, in pixels
4285 * \param[in] height height, in pixels
4286 * \param[in] format pixel format
4287 * \param[in] options options bitmap flags, bit 0 (NI_SCALER_FLAG_IO) is
4288 * 0=input frame or 1=output frame. Bit 1 (NI_SCALER_FLAG_PC) is
4289 * 0=single allocation, 1=create pool. Bit 2 (NI_SCALER_FLAG_PA) is
4290 * 0=straight alpha, 1=premultiplied alpha
4291 * \param[in] rectangle_width clipping rectangle width
4292 * \param[in] rectangle_height clipping rectangle height
4293 * \param[in] rectangle_x horizontal position of clipping rectangle
4294 * \param[in] rectangle_y vertical position of clipping rectangle
4295 * \param[in] rgba_color RGBA fill colour (for padding only)
4296 * \param[in] frame_index input hwdesc index
4297 * \param[in] device_type only NI_DEVICE_TYPE_SCALER
4298 * and NI_DEVICE_TYPE_AI (only needs p_ctx and frame_index)
4299 *
4300 * \return NI_RETCODE_INVALID_PARAM
4301 * NI_RETCODE_ERROR_INVALID_SESSION
4302 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4303 * NI_RETCODE_ERROR_MEM_ALOC
4304 ******************************************************************************/
4306 int width,
4307 int height,
4308 int format,
4309 int options,
4310 int rectangle_width,
4311 int rectangle_height,
4312 int rectangle_x,
4313 int rectangle_y,
4314 int rgba_color,
4315 int frame_index,
4316 ni_device_type_t device_type);
4317
4318/*!*****************************************************************************
4319 * \brief Allocate a frame on the device and return the frame index
4320 *
4321 * \param[in] p_ctx pointer to session context
4322 * \param[in] p_out_surface pointer to output frame surface
4323 * \param[in] device_type currently only NI_DEVICE_TYPE_AI
4324 *
4325 * \return NI_RETCODE_INVALID_PARAM
4326 * NI_RETCODE_ERROR_INVALID_SESSION
4327 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4328 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4329 * NI_RETCODE_ERROR_MEM_ALOC
4330 ******************************************************************************/
4332 niFrameSurface1_t *p_out_surface,
4333 ni_device_type_t device_type);
4334
4335/*!*****************************************************************************
4336 * \brief Copy the data of src hwframe to dst hwframe
4337 *
4338 * \param[in] p_ctx pointer to session context
4339 * \param[in] p_frameclone_desc pointer to the frameclone descriptor
4340 *
4341 * \return NI_RETCODE_INVALID_PARAM
4342 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4343 * NI_RETCODE_ERROR_INVALID_SESSION
4344 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4345 * NI_RETCODE_ERROR_MEM_ALOC
4346 ******************************************************************************/
4348 ni_frameclone_desc_t *p_frameclone_desc);
4349
4350/*!*****************************************************************************
4351 * \brief Config a frame on the device for 2D engined
4352 * to work on based on provided parameters
4353 *
4354 * \param[in] p_ctx pointer to session context
4355 * \param[in] p_cfg pointer to frame config
4356 *
4357 * \return NI_RETCODE_INVALID_PARAM
4358 * NI_RETCODE_ERROR_INVALID_SESSION
4359 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4360 * NI_RETCODE_ERROR_MEM_ALOC
4361 ******************************************************************************/
4363 ni_frame_config_t *p_cfg);
4364
4366 ni_scaler_drawbox_params_t *p_params);
4367
4370
4371/*!*****************************************************************************
4372 * \brief Config multiple frame on the device for 2D engined
4373 * to work on based on provided parameters
4374 *
4375 * \param[in] p_ctx pointer to session context
4376 * \param[in] p_cfg_in input frame config array
4377 * \param[in] numInCfgs number of frame config entries in the p_cfg_in array
4378 * \param[in] p_cfg_out output frame config
4379 *
4380 * \return NI_RETCODE_INVALID_PARAM
4381 * NI_RETCODE_ERROR_INVALID_SESSION
4382 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4383 * NI_RETCODE_ERROR_MEM_ALOC
4384 ******************************************************************************/
4386 ni_frame_config_t p_cfg_in[],
4387 int numInCfgs,
4388 ni_frame_config_t *p_cfg_out);
4389
4390/*!*****************************************************************************
4391 * \brief Allocate memory for the frame buffer based on provided parameters
4392 * taking into account the pixel format, width, height, stride,
4393 * alignment, and extra data
4394 * \param[in] p_frame Pointer to caller allocated ni_frame_t
4395 * \param[in] pixel_format a pixel format in ni_pix_fmt_t enum
4396 * \param[in] video_width width, in pixels
4397 * \param[in] video_height height, in pixels
4398 * \param[in] linesize horizontal stride
4399 * \param[in] alignment apply a 16 pixel height alignment (T408 only)
4400 * \param[in] extra_len meta data size
4401 *
4402 * \return NI_RETCODE_SUCCESS
4403 * NI_RETCODE_INVALID_PARAM
4404 * NI_RETCODE_ERROR_MEM_ALOC
4405 *
4406 ******************************************************************************/
4408 ni_frame_t *pframe, int pixel_format, int video_width, int video_height,
4409 int linesize[], int alignment, int extra_len);
4410
4411/*!*****************************************************************************
4412 * \brief configure a network context based with the network binary
4413 *
4414 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4415 * \param[in] file Pointer to caller network binary file path
4416 *
4417 * \return NI_RETCODE_SUCCESS
4418 * NI_RETCODE_INVALID_PARAM
4419 * NI_RETCODE_ERROR_MEM_ALOC
4420 * NI_RETCODE_ERROR_INVALID_SESSION
4421 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4422 * NI_RETCODE_FAILURE
4423 *
4424 ******************************************************************************/
4426 ni_network_data_t *p_network,
4427 const char *file);
4428
4429/*!*****************************************************************************
4430 * \brief configure a hvsplus filter
4431 *
4432 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4433 *
4434 * \return NI_RETCODE_SUCCESS
4435 * NI_RETCODE_FAILURE
4436 *
4437 ******************************************************************************/
4439 ni_network_data_t *p_network);
4440
4441/*!*****************************************************************************
4442 * \brief Allocate input layers memory for AI frame buffer based on provided parameters
4443 * taking into account width, height, format defined by network.
4444 *
4445 * \param[out] p_frame Pointer to caller allocated ni_frame_t
4446 * \param[in] p_network Pointer to caller allocated ni_network_data_t
4447 *
4448 * \return NI_RETCODE_SUCCESS
4449 * NI_RETCODE_INVALID_PARAM
4450 * NI_RETCODE_ERROR_MEM_ALOC
4451 *
4452 ******************************************************************************/
4454 ni_network_data_t *p_network);
4455
4456/*!*****************************************************************************
4457 * \brief Allocate output layers memory for the packet buffer based on provided network
4458 *
4459 * \param[out] p_packet Pointer to a caller allocated
4460 * ni_packet_t struct
4461 * \param[in] p_network Pointer to a caller allocated
4462 * ni_network_data_t struct
4463 *
4464 * \return On success
4465 * NI_RETCODE_SUCCESS
4466 * On failure
4467 * NI_RETCODE_INVALID_PARAM
4468 * NI_RETCODE_ERROR_MEM_ALOC
4469 ******************************************************************************/
4471 ni_network_data_t *p_network);
4472
4473// wrapper API request, dynamic encode configuration setting to be sent to the
4474// encoder with the next frame
4475
4476/*!*****************************************************************************
4477 * \brief Reconfigure bitrate dynamically during encoding.
4478 *
4479 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4480 * \param[in] bitrate Target bitrate to set
4481 *
4482 * \return On success NI_RETCODE_SUCCESS
4483 * On failure NI_RETCODE_INVALID_PARAM
4484 ******************************************************************************/
4486 int32_t bitrate);
4487
4488/*!*****************************************************************************
4489 * \brief Reconfigure intraPeriod dynamically during encoding.
4490 *
4491 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4492 * \param[in] intra_period Target intra period to set
4493 *
4494 * \return On success NI_RETCODE_SUCCESS
4495 * On failure NI_RETCODE_INVALID_PARAM
4496 *
4497 * NOTE - the frame upon which intra period is reconfigured is encoded as IDR frame
4498 * NOTE - reconfigure intra period is not allowed if intraRefreshMode is enabled or if gopPresetIdx is 1
4499 *
4500 ******************************************************************************/
4502 int32_t intra_period);
4503
4504/*!*****************************************************************************
4505 * \brief Reconfigure VUI dynamically during encoding.
4506 *
4507 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4508 * \param[in] bitrate Target bitrate to set
4509 *
4510 * \return On success NI_RETCODE_SUCCESS
4511 * On failure NI_RETCODE_INVALID_PARAM
4512 ******************************************************************************/
4514 ni_vui_hrd_t *vui);
4515
4516/*!*****************************************************************************
4517 * \brief Force next frame to be IDR frame during encoding.
4518 *
4519 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4520 *
4521 * \return On success NI_RETCODE_SUCCESS
4522 ******************************************************************************/
4524
4525/*!*****************************************************************************
4526 * \brief Set a frame's support of Long Term Reference frame during encoding.
4527 *
4528 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4529 * \param[in] ltr Pointer to struct specifying LTR support
4530 *
4531 * \return On success NI_RETCODE_SUCCESS
4532 * On failure NI_RETCODE_INVALID_PARAM
4533 ******************************************************************************/
4535 ni_long_term_ref_t *ltr);
4536
4537/*!*****************************************************************************
4538 * \brief Set Long Term Reference interval
4539 *
4540 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4541 * \param[in] ltr_interval the new long term reference inteval value
4542 *
4543 * \return On success NI_RETCODE_SUCCESS
4544 * On failure NI_RETCODE_INVALID_PARAM
4545 ******************************************************************************/
4547 int32_t ltr_interval);
4548
4549/*!*****************************************************************************
4550 * \brief Set frame reference invalidation
4551 *
4552 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4553 * \param[in] frame_num frame number after which all references shall be
4554 * invalidated
4555 *
4556 * \return On success NI_RETCODE_SUCCESS
4557 * On failure NI_RETCODE_INVALID_PARAM
4558 ******************************************************************************/
4560 int32_t frame_num);
4561
4562/*!*****************************************************************************
4563 * \brief Reconfigure framerate dynamically during encoding.
4564 *
4565 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4566 * \param[in] framerate Pointer to struct specifying framerate to set
4567 *
4568 * \return On success NI_RETCODE_SUCCESS
4569 * On failure NI_RETCODE_INVALID_PARAM
4570 ******************************************************************************/
4572 ni_framerate_t *framerate);
4573
4574/*!*****************************************************************************
4575 * \brief Reconfigure maxFrameSize dynamically during encoding.
4576 *
4577 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4578 * \param[in] max_frame_size the new maxFrameSize value
4579 *
4580 * \return On success NI_RETCODE_SUCCESS
4581 * On failure NI_RETCODE_INVALID_PARAM
4582 *
4583 * NOTE - maxFrameSize_Bytes value less than ((bitrate / 8) / framerate) will be rejected
4584 *
4585 ******************************************************************************/
4587 int32_t max_frame_size);
4588
4589/*!*****************************************************************************
4590 * \brief Reconfigure min&max qp dynamically during encoding.
4591 *
4592 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4593 * \param[in] ni_rc_min_max_qp Target min&max qp to set
4594 *
4595 * \return On success NI_RETCODE_SUCCESS
4596 * On failure NI_RETCODE_INVALID_PARAM
4597 ******************************************************************************/
4599 ni_rc_min_max_qp *p_min_max_qp);
4600
4601
4602/*!*****************************************************************************
4603 * \brief Reconfigure crf value dynamically during encoding.
4604 *
4605 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4606 * \param[in] crf crf value to reconfigure
4607 *
4608 * \return On success NI_RETCODE_SUCCESS
4609 * On failure NI_RETCODE_INVALID_PARAM
4610 ******************************************************************************/
4612 int32_t crf);
4613
4614/*!*****************************************************************************
4615 * \brief Reconfigure crf float point value dynamically during encoding.
4616 *
4617 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4618 * \param[in] crf crf float point value to reconfigure
4619 *
4620 * \return On success NI_RETCODE_SUCCESS
4621 * On failure NI_RETCODE_INVALID_PARAM
4622 ******************************************************************************/
4624 float crf);
4625
4626
4627/*!*****************************************************************************
4628 * \brief Reconfigure vbv buffer size and vbv max rate dynamically during encoding.
4629 *
4630 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4631 * \param[in] vbvBufferSize Target vbvBufferSize to set
4632 * \param[in] vbvMaxRate Target vbvMaxRate to set
4633 *
4634 * \return On success NI_RETCODE_SUCCESS
4635 * On failure NI_RETCODE_INVALID_PARAM
4636 ******************************************************************************/
4638 int32_t vbvMaxRate, int32_t vbvBufferSize);
4639
4640/*!*****************************************************************************
4641 * \brief Reconfigure maxFrameSizeRatio dynamically during encoding.
4642 *
4643 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4644 * \param[in] max_frame_size_ratio the new maxFrameSizeRatio value
4645 *
4646 * \return On success NI_RETCODE_SUCCESS
4647 * On failure NI_RETCODE_INVALID_PARAM
4648 ******************************************************************************/
4650 int32_t max_frame_size_ratio);
4651
4652/*!*****************************************************************************
4653 * \brief Reconfigure sliceArg dynamically during encoding.
4654 *
4655 * \param[in] p_ctx Pointer to caller allocated ni_session_context_t
4656 * \param[in] sliceArg the new sliceArg value
4657 *
4658 * \return On success NI_RETCODE_SUCCESS
4659 * On failure NI_RETCODE_INVALID_PARAM
4660 ******************************************************************************/
4662 int16_t sliceArg);
4663
4664#ifndef _WIN32
4665/*!*****************************************************************************
4666* \brief Acquire a P2P frame buffer from the hwupload session
4667*
4668* \param[in] p_upl_ctx Pointer to a caller allocated
4669* ni_session_context_t struct
4670* \param[out] p_frame Pointer to a caller allocated hw frame
4671*
4672* \return On success
4673* NI_RETCODE_SUCCESS
4674* On failure
4675* NI_RETCODE_INVALID_PARAM
4676* NI_RETCODE_ERROR_NVME_CMD_FAILED
4677* NI_RETCODE_ERROR_INVALID_SESSION
4678*******************************************************************************/
4680 ni_frame_t *p_frame);
4681
4682/*!*****************************************************************************
4683* \brief Acquire a P2P frame buffer from the hwupload session for P2P read
4684*
4685* \param[in] p_upl_ctx Pointer to a caller allocated
4686* ni_session_context_t struct
4687* \param[out] p_frame Pointer to a caller allocated hw frame
4688*
4689* \return On success
4690* NI_RETCODE_SUCCESS
4691* On failure
4692* NI_RETCODE_INVALID_PARAM
4693* NI_RETCODE_ERROR_NVME_CMD_FAILED
4694* NI_RETCODE_ERROR_INVALID_SESSION
4695*******************************************************************************/
4697 ni_frame_t *p_frame);
4698
4699/*!*****************************************************************************
4700 * \brief Lock a hardware P2P frame prior to encoding
4701 *
4702 * \param[in] p_upl_ctx pointer to caller allocated upload context
4703 * [in] p_frame pointer to caller allocated hardware P2P frame
4704 *
4705 * \return On success
4706 * NI_RETCODE_SUCCESS
4707 * On failure NI_RETCODE_FAILURE
4708 * NI_RETCODE_INVALID_PARAM
4709*******************************************************************************/
4711 ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame);
4712
4713/*!*****************************************************************************
4714 * \brief Unlock a hardware P2P frame after encoding
4715 *
4716 * \param[in] p_upl_ctx pointer to caller allocated upload context
4717 * [in] p_frame pointer to caller allocated hardware P2P frame
4718 *
4719 * \return On success
4720 * NI_RETCODE_SUCCESS
4721 * On failure NI_RETCODE_FAILURE
4722 * NI_RETCODE_INVALID_PARAM
4723*******************************************************************************/
4725 ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame);
4726
4727/*!*****************************************************************************
4728 * \brief Special P2P test API call. Copies YUV data from the software
4729 * frame to the hardware P2P frame on the Quadra device
4730 *
4731 * \param[in] p_upl_ctx pointer to caller allocated uploader session
4732 * context
4733 * [in] p_swframe pointer to a caller allocated software frame
4734 * [in] p_hwframe pointer to a caller allocated hardware frame
4735 *
4736 * \return On success
4737 * NI_RETCODE_SUCCESS
4738 * On failure
4739 * NI_RETCODE_FAILURE
4740 * NI_RETCODE_INVALID_PARAM
4741*******************************************************************************/
4743 uint8_t *p_data, uint32_t len,
4744 ni_frame_t *p_hwframe);
4745
4746
4748 uint8_t *p_data, uint32_t len,
4749 ni_frame_t *p_hwframe);
4750
4751/*!*****************************************************************************
4752 * \brief Set the incoming frame format for the encoder
4753 *
4754 * \param[in] p_enc_ctx pointer to encoder context
4755 * [in] p_enc_params pointer to encoder parameters
4756 * [in] width input width
4757 * [in] height input height
4758 * [in] bit_depth 8 for 8-bit YUV, 10 for 10-bit YUV
4759 * [in] src_endian NI_FRAME_LITTLE_ENDIAN or NI_FRAME_BIG_ENDIAN
4760 * [in] planar 0 for semi-planar YUV, 1 for planar YUV
4761 *
4762 * \return on success
4763 * NI_RETCODE_SUCCESS
4764 *
4765 * on failure
4766 * NI_RETCODE_INVALID_PARAM
4767*******************************************************************************/
4769 ni_session_context_t *p_enc_ctx, ni_xcoder_params_t *p_enc_params,
4770 int width, int height, int bit_depth, int src_endian, int planar);
4771
4772/*!*****************************************************************************
4773 * \brief Acquire the scaler P2P DMA buffer for read/write
4774 *
4775 * \param [in] p_ctx pointer to caller allocated upload context
4776 * [in] p_surface pointer to a caller allocated hardware frame
4777 * [in] data_len scaler frame buffer data length
4778 *
4779 * \return on success
4780 * NI_RETCODE_SUCCESS
4781 *
4782 * on failure
4783 * NI_RETCODE_FAILURE
4784*******************************************************************************/
4786 niFrameSurface1_t *p_surface,
4787 int data_len);
4788
4789/*!*****************************************************************************
4790 * \brief Recycle hw P2P frames
4791 *
4792 * \param [in] p_frame pointer to an acquired P2P hw frame
4793 *
4794 * \return on success
4795 * NI_RETCODE_SUCCESS
4796 *
4797 * on failure
4798 * NI_RETCODE_INVALID_PARAM
4799*******************************************************************************/
4801#endif
4802
4803/*!*****************************************************************************
4804 * \brief Set the frame format for the uploader
4805 *
4806 * \param[in] p_upl_ctx pointer to uploader context
4807 * [in] width width
4808 * [in] height height
4809 * [in] pixel_format pixel format
4810 * [in] isP2P 0 = normal, 1 = P2P
4811 *
4812 * \return on success
4813 * NI_RETCODE_SUCCESS
4814 *
4815 * on failure
4816 * NI_RETCODE_INVALID_PARAM
4817*******************************************************************************/
4820 int height, ni_pix_fmt_t pixel_format, int isP2P);
4821
4822/*!*****************************************************************************
4823 * \brief Read encoder stream header from the device
4824 *
4825 * \param[in] p_ctx Pointer to a caller allocated
4826 * ni_session_context_t struct from encoder
4827 * \param[in] p_data Pointer to a caller allocated ni_session_data_io_t
4828 * struct which contains a ni_packet_t data packet to
4829 * receive
4830 * \return On success
4831 * Total number of bytes read
4832 * On failure
4833 * NI_RETCODE_INVALID_PARAM
4834 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4835 * NI_RETCODE_ERROR_INVALID_SESSION
4836*******************************************************************************/
4838 ni_session_data_io_t *p_data);
4839
4840
4841/*!*****************************************************************************
4842 * \brief Get the DMA buffer file descriptor from the P2P frame
4843 *
4844 * \param[in] p_frame pointer to a P2P frame
4845 *
4846 * \return On success
4847 * DMA buffer file descriptor
4848 * On failure
4849 * NI_RETCODE_FAILURE
4850*******************************************************************************/
4851LIB_API int32_t ni_get_dma_buf_file_descriptor(const ni_frame_t* p_frame);
4852
4853
4854/*!*****************************************************************************
4855 * \brief Send sequence change information to device
4856 *
4857 * \param[in] p_ctx Pointer to a caller allocated
4858 * ni_session_context_t struct
4859 * \param[in] width input width
4860 * \param[in] height input height
4861 * \param[in] bit_depth_factor 1 for 8-bit YUV, 2 for 10-bit YUV
4862 * \param[in] device_type device type (must be encoder)
4863 * \return On success
4864 * NI_RETCODE_SUCCESS
4865 * On failure
4866 * NI_RETCODE_INVALID_PARAM
4867 * NI_RETCODE_ERROR_MEM_ALOC
4868 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4869 * NI_RETCODE_ERROR_INVALID_SESSION
4870 ******************************************************************************/
4872 int width, int height, int bit_depth_factor, ni_device_type_t device_type);
4873
4874/*!*****************************************************************************
4875 * \brief Fetch perf metrics of inferences from device
4876 *
4877 * \param[in] p_ctx Pointer to a caller allocated
4878 * ni_session_context_t struct
4879 * \param[in] p_metrics Pointer to network metrics
4880 * \return On success
4881 * NI_RETCODE_SUCCESS
4882 * On failure
4883 * NI_RETCODE_INVALID_PARAM
4884 * NI_RETCODE_ERROR_MEM_ALOC
4885 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4886 ******************************************************************************/
4889
4890/*!*****************************************************************************
4891 * \brief Query firmware loader and firmware versions from the device
4892 *
4893 * \param[in] device_handle Device handle obtained by calling ni_device_open()
4894 * \param[in] device_info
4895 *
4896 * \return On success
4897 * NI_RETCODE_SUCCESS
4898 * On failure
4899 * NI_RETCODE_INVALID_PARAM
4900 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4901 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4902 * NI_RETCODE_ERROR_MEM_ALOC
4903 ******************************************************************************/
4904LIB_API ni_retcode_t ni_query_fl_fw_versions(ni_device_handle_t device_handle,
4905 ni_device_info_t *p_dev_info);
4906
4907/*!*****************************************************************************
4908 * \brief Query NVMe load from the device
4909 *
4910 * \param[in] p_ctx Pointer to a caller allocated
4911 * ni_session_context_t struct
4912 * \param[in] p_load_query Pointer to a caller allocated
4913 * ni_load_query_t struct
4914 *
4915 * \return On success
4916 * NI_RETCODE_SUCCESS
4917 * On failure
4918 * NI_RETCODE_INVALID_PARAM
4919 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4920 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4921 * NI_RETCODE_ERROR_MEM_ALOC
4922 ******************************************************************************/
4924 ni_session_context_t *p_ctx, ni_load_query_t *p_load_query);
4925
4926/*!*****************************************************************************
4927 * \brief Query VF and NS id from device
4928 *
4929 * \param[in] device_handle Device handle obtained by calling ni_device_open()
4930 * \param[in] p_dev_ns_vf Pointer to a ni_device_vf_ns_id_t struct
4931 * \param[in] fw_rev[] Fw version to check if this function is supported
4932 *
4933 * \return On success
4934 * NI_RETCODE_SUCCESS
4935 * On failure
4936 * NI_RETCODE_INVALID_PARAM
4937 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4938 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4939 * NI_RETCODE_ERROR_MEM_ALOC
4940 ******************************************************************************/
4941LIB_API ni_retcode_t ni_query_vf_ns_id(ni_device_handle_t device_handle,
4942 ni_device_vf_ns_id_t *p_dev_ns_vf,
4943 uint8_t fw_rev[]);
4944
4945/*!*****************************************************************************
4946 * \brief Query CompositeTemp from device
4947 *
4948 * \param[in] device_handle Device handle obtained by calling ni_device_open()
4949 * \param[in] p_dev_temp Pointer to device temperature
4950 * \param[in] fw_rev[] Fw version to check if this function is supported
4951 *
4952 * \return On success
4953 * NI_RETCODE_SUCCESS
4954 * On failure
4955 * NI_RETCODE_INVALID_PARAM
4956 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4957 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4958 * NI_RETCODE_ERROR_MEM_ALOC
4959 ******************************************************************************/
4960LIB_API ni_retcode_t ni_query_temperature(ni_device_handle_t device_handle,
4961 ni_device_temp_t *p_dev_temp,
4962 uint8_t fw_rev[]);
4963
4964/*!*****************************************************************************
4965 * \brief Query CompositeTemp from device
4966 *
4967 * \param[in] device_handle Device handle obtained by calling ni_device_open()
4968 * \param[in] p_dev_extra_info Pointer to device extra info
4969 * \param[in] fw_rev[] Fw version to check if this function is supported
4970 *
4971 * \return On success
4972 * NI_RETCODE_SUCCESS
4973 * On failure
4974 * NI_RETCODE_INVALID_PARAM
4975 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4976 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4977 * NI_RETCODE_ERROR_MEM_ALOC
4978 ******************************************************************************/
4979LIB_API ni_retcode_t ni_query_extra_info(ni_device_handle_t device_handle,
4980 ni_device_extra_info_t *p_dev_extra_info,
4981 uint8_t fw_rev[]);
4982
4983/*!*****************************************************************************
4984 * \brief Query QoS information for the device
4985 *
4986 * \param[in] device_handle Device handle for the target namespace
4987 * \param[out] p_qos_ns_info Pointer to namespace QoS header info structure
4988 * \param[in] fw_rev[] Firmware version array
4989 *
4990 * \return On success
4991 * NI_RETCODE_SUCCESS
4992 * On failure
4993 * NI_RETCODE_INVALID_PARAM
4994 * NI_RETCODE_ERROR_NVME_CMD_FAILED
4995 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
4996 * NI_RETCODE_ERROR_MEM_ALOC
4997*******************************************************************************/
4998LIB_API ni_retcode_t ni_query_qos_info(ni_device_handle_t device_handle,
4999 ni_qos_header_info_log_page_t *p_dev_qos_header,
5000 uint8_t fw_rev[]);
5001
5002/*!*****************************************************************************
5003 * \brief Query QoS information for a specific namespace
5004 *
5005 * \param[in] device_handle Device handle for the target namespace
5006 * \param[out] p_qos_ns_info Pointer to namespace QoS namespace info structure
5007 * \param[in] fw_rev[] Firmware version array
5008 *
5009 * \return On success
5010 * NI_RETCODE_SUCCESS
5011 * On failure
5012 * NI_RETCODE_INVALID_PARAM
5013 * NI_RETCODE_ERROR_NVME_CMD_FAILED
5014 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5015 * NI_RETCODE_ERROR_MEM_ALOC
5016*******************************************************************************/
5017LIB_API ni_retcode_t ni_query_qos_namespace_info(ni_device_handle_t device_handle,
5019 uint8_t fw_rev[]);
5020
5021/*!*****************************************************************************
5022 * \brief Check if incoming frame is encoder zero copy compatible or not
5023 *
5024 * \param[in] p_enc_ctx pointer to encoder context
5025 * [in] p_enc_params pointer to encoder parameters
5026 * [in] width input width
5027 * [in] height input height
5028 * [in] linesize input linesizes (pointer to array)
5029 * [in] set_linesize setup linesizes 0 means not setup linesizes, 1 means setup linesizes (before encoder open)
5030 *
5031 * \return on success and can do zero copy
5032 * NI_RETCODE_SUCCESS
5033 *
5034 * cannot do zero copy
5035 * NI_RETCODE_ERROR_UNSUPPORTED_FEATURE
5036 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5037 * NI_RETCODE_INVALID_PARAM
5038 *
5039*******************************************************************************/
5041 ni_xcoder_params_t *p_enc_params,
5042 int width, int height,
5043 const int linesize[],
5044 bool set_linesize);
5045
5046/*!*****************************************************************************
5047 * \brief Check if the frame data transferred is within a frame boundary and
5048 * adjust with offset if it doesn't. EP will re-adjust the data pointer
5049 * to the correct start address.
5050 *
5051 * \param[in] video_height Height of the video frame
5052 * [in] linesize Picture line size after filtering (i.e. cropping)
5053 * [in] data Picture data pointers after filtering (for each of YUV planes)
5054 * [in] buf_size0 Y frame size before any filtering (original size)
5055 * [in] buf_size1 U frame size before any filtering (original)
5056 * [in] buf_size2 V frame size before any filtering (original)
5057 * [in] buf_data0 Y picture data pointer before any filtering (original)
5058 * [in] buf_data1 U picture data pointer before any filtering (original)
5059 * [in] buf_data2 V picture data pointer before any filtering (original)
5060 *
5061 * \return On success
5062 * NI_RETCODE_SUCCESS
5063 * On failure
5064 * NI_RETCODE_INVALID_PARAM
5065 *****************************************************************************/
5067 ni_frame_t *p_frame, int video_height,
5068 const int linesize[], const uint8_t *data[],
5069 int buf_size0, int buf_size1, int buf_size2,
5070 uint8_t *buf_data0, uint8_t *buf_data1, uint8_t *buf_data2);
5071
5072/*!*****************************************************************************
5073 * \brief Allocate memory for encoder zero copy (metadata, etc.)
5074 * for encoding based on given
5075 * parameters, taking into account pic linesize and extra data.
5076 * Applicable to YUV planr / semi-planar 8 or 10 bit and RGBA pixel formats.
5077 *
5078 *
5079 * \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
5080 * \param[in] video_width Width of the video frame
5081 * \param[in] video_height Height of the video frame
5082 * \param[in] linesize Picture line size
5083 * \param[in] data Picture data pointers (for each of YUV planes)
5084 * \param[in] extra_len Extra data size (incl. meta data)
5085 *
5086 * \return On success
5087 * NI_RETCODE_SUCCESS
5088 * On failure
5089 * NI_RETCODE_INVALID_PARAM
5090 * NI_RETCODE_ERROR_MEM_ALOC
5091 *****************************************************************************/
5093 int video_width, int video_height,
5094 const int linesize[], const uint8_t *data[],
5095 int extra_len);
5096
5097/*!*****************************************************************************
5098 * \brief Check if incoming frame is hwupload zero copy compatible or not
5099 *
5100 * \param[in] p_upl_ctx pointer to uploader context
5101 * [in] width input width
5102 * [in] height input height
5103 * [in] linesize input linesizes (pointer to array)
5104 * [in] pixel_format input pixel format
5105 *
5106 * \return on success and can do zero copy
5107 * NI_RETCODE_SUCCESS
5108 *
5109 * cannot do zero copy
5110 * NI_RETCODE_ERROR_UNSUPPORTED_FEATURE
5111 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5112 * NI_RETCODE_INVALID_PARAM
5113 *
5114*******************************************************************************/
5116 int width, int height,
5117 const int linesize[], int pixel_format);
5118
5119/*!*****************************************************************************
5120 * \brief Allocate log buffer if needed and retrieve firmware logs from device
5121 *
5122 * \param[in] p_ctx Pointer to a caller allocated
5123 * ni_session_context_t struct
5124 * \param[in] p_log_buffer Reference to pointer to a log buffer
5125 * If log buffer pointer is NULL, this function will allocate log buffer
5126 * NOTE caller is responsible for freeing log buffer after calling this function
5127 * \param[in] gen_log_file Indicating whether it is required to generate log files
5128 *
5129 *
5130 * \return on success
5131 * NI_RETCODE_SUCCESS
5132 *
5133 * on failure
5134 * NI_RETCODE_ERROR_MEM_ALOC
5135 * NI_RETCODE_INVALID_PARAM
5136*******************************************************************************/
5137LIB_API ni_retcode_t ni_device_alloc_and_get_firmware_logs(ni_session_context_t *p_ctx, void** p_log_buffer, bool gen_log_file);
5139
5140/*!*****************************************************************************
5141 * \brief Set up hard coded demo ROI map
5142 *
5143 * \param[in] p_enc_ctx Pointer to a caller allocated
5144 *
5145 * \return on success
5146 * NI_RETCODE_SUCCESS
5147 *
5148 * on failure
5149 * NI_RETCODE_ERROR_MEM_ALOC
5150*******************************************************************************/
5152
5153/*!*****************************************************************************
5154 * \brief Convert various reconfig and demo modes (stored in encoder configuration) to
5155 * aux data and store them in frame
5156 *
5157 * \param[in] p_enc_ctx Pointer to a caller allocated
5158 * ni_session_context_t struct
5159 * \param[in] p_frame Pointer to a caller allocated ni_frame_t struct
5160 *
5161 *
5162 * \return on success
5163 * NI_RETCODE_SUCCESS
5164 *
5165 * on failure
5166 * NI_RETCODE_ERROR_MEM_ALOC
5167*******************************************************************************/
5169 ni_frame_t *p_frame);
5170
5171/*!*****************************************************************************
5172 * \brief Set custom gop and prepare to check if success
5173 *
5174 * \param[in] p_param Pointer to a caller allocated ni_xcoder_params_t struct
5175 * \param[in] value Pointer to a caller allocated custom gop name
5176 *
5177 * \return none
5178 *
5179*******************************************************************************/
5180LIB_API void ni_gop_params_check_set(ni_xcoder_params_t *p_param, char *value);
5181
5182/*!*****************************************************************************
5183 * \brief Check custom gop params set.
5184 *
5185 * \param[in] p_param Pointer to a caller allocated ni_xcoder_params_t struct
5186 *
5187 *
5188 * \return on success
5189 * true
5190 *
5191 * on failure
5192 * false
5193*******************************************************************************/
5195
5196#ifndef DEPRECATION_AS_ERROR
5197/*!*****************************************************************************
5198 * \brief Initiate P2P transfer (P2P write) (deprecated)
5199 *
5200 * \param[in] pSession Pointer to source card destination
5201 * \param[in] source Pointer to source frame to transmit
5202 * \param[in] ui64DestAddr Destination address on target device
5203 * \param[in] ui32FrameSize Size of frame to transfer
5204 *
5205 * \return always returns
5206 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5207*******************************************************************************/
5209 niFrameSurface1_t *source,
5210 uint64_t ui64DestAddr,
5211 uint32_t ui32FrameSize);
5212#endif
5213
5214#ifndef DEPRECATION_AS_ERROR
5215/*!*****************************************************************************
5216 * \brief Initiate P2P transfer to another device (P2P write)
5217 *
5218 * \param[in] pSession Pointer to source card destination
5219 * \param[in] source Pointer to source frame to transmit
5220 * \param[in] ui64DestAddr Destination address on target device
5221 * \param[in] ui32FrameSize Size of frame to transfer
5222 *
5223 * \return on success
5224 * NI_RETCODE_SUCCESS
5225 * on failure
5226 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5227 * NI_RETCODE_INVALID_PARAM
5228 * NI_RETCODE_ERROR_INVALID_SESSION
5229 * NI_RETCODE_ERROR_MEM_ALOC
5230 * NI_RETCODE_ERROR_NVME_CMD_FAILED
5231*******************************************************************************/
5233 niFrameSurface1_t *source,
5234 uint64_t ui64DestAddr,
5235 uint32_t ui32FrameSize);
5236#endif
5237
5238/*!*****************************************************************************
5239 * \brief Initiate P2P transfer to another device (P2P write) with sgl list
5240 *
5241 * \param[in] pSession Pointer to source card upload session
5242 * \param[in] pSrcFrame Pointer to source P2P frame
5243 * \param[in] dmaAddrs Pointer to destination DMA addresses - sgl_list
5244 *
5245 * \return on success
5246 * NI_RETCODE_SUCCESS
5247 * on failure
5248 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5249 * NI_RETCODE_INVALID_PARAM
5250 * NI_RETCODE_ERROR_INVALID_SESSION
5251 * NI_RETCODE_ERROR_MEM_ALOC
5252 * NI_RETCODE_ERROR_NVME_CMD_FAILED
5253*******************************************************************************/
5255 ni_frame_t *pSrcFrame,
5256 const ni_p2p_sgl_t *dmaAddrs);
5257
5258/*!*****************************************************************************
5259 * \brief Calculate the total size of a frame based on the upload
5260 * context attributes and includes rounding up to the page size
5261 *
5262 * \param[in] p_upl_ctx pointer to an uploader session context
5263 * \param[in] linesize array of line stride
5264 *
5265 * \return size
5266 * NI_RETCODE_INVALID_PARAM
5267 *
5268 ******************************************************************************/
5270 const int linesize[]);
5271
5272
5273/*!*****************************************************************************
5274 * \brief Initiate a P2P transfer (P2P read)
5275 *
5276 * \param[in] pSession Pointer to destination upload session
5277 * \param[in] dmaAddrs Pointer to source DMA addresses
5278 * \param[in] pDstFrame Pointer to destination P2P frame
5279 *
5280 * \return on success
5281 * NI_RETCODE_SUCCESS
5282 * on failure
5283 * NI_RETCODE_ERROR_UNSUPPORTED_FW_VERSION
5284 * NI_RETCODE_INVALID_PARAM
5285 * NI_RETCODE_ERROR_INVALID_SESSION
5286 * NI_RETCODE_ERROR_MEM_ALOC
5287 * NI_RETCODE_ERROR_NVME_CMD_FAILED
5288*******************************************************************************/
5290 const ni_p2p_sgl_t *dmaAddrs,
5291 ni_frame_t *pDstFrame);
5292
5293/*!*****************************************************************************
5294 * \brief Send a restart command after flush command
5295 * Only support Encoder now
5296 *
5297 * \param[in] p_ctx Pointer to a caller allocated
5298 * ni_session_context_t struct
5299 * \param[in] width width, in pixels
5300 * \param[in] height height, in pixels
5301 * \param[in] device_type NI_DEVICE_TYPE_ENCODER
5302 * \return On success
5303 * NI_RETCODE_SUCCESS
5304 * On failure
5305 * NI_RETCODE_INVALID_PARAM
5306 * NI_RETCODE_ERROR_NVME_CMD_FAILED
5307 * NI_RETCODE_ERROR_INVALID_SESSION
5308 ******************************************************************************/
5310 int video_width,
5311 int video_height,
5312 ni_device_type_t device_type);
5313
5314/*!******************************************************************************
5315* \brief Send a p_config command to reconfigure decoding ppu params.
5316*
5317* \param ni_session_context_t p_session_ctx - xcoder Context
5318* \param ni_xcoder_params_t p_param - xcoder Params
5319* \param ni_ppu_config_t p_ppu_config - Struct ni_ppu_config
5320*
5321* \return - NI_RETCODE_SUCCESS on success, NI_RETCODE_ERROR_INVALID_SESSION, NI_RETCODE_ERROR_NVME_CMD_FAILED on failure
5322*******************************************************************************/
5324 ni_xcoder_params_t *p_param,
5325 ni_ppu_config_t *p_ppu_config);
5326/*!*****************************************************************************
5327 * \brief Replace the kernel coefficient callback.
5328 *
5329 * \param ni_session_context_t p_session_ctx - xcoder Context
5330 * \param ni_kernel_coeff_fn fn - ni_kernel_coeff_fn
5331 * Thread-safety: must be called before any concurrent use of
5332 * ni_scaler_build_kernel().
5333 *
5334 * \param[in] fn New callback, or NULL to restore ni_bicubic_coeff_default.
5335 *
5336 * \return - NI_RETCODE_SUCCESS on success, NI_RETCODE_INVALID_PARAM on failure
5337 ******************************************************************************/
5340
5341/*!******************************************************************************
5342* \brief Build scaler kernal array.
5343*
5344* \param ni_session_context_t p_session_ctx - xcoder Context
5345* \param uint16_t kernel_array - fw kernel array[17 * 9]
5346* \param int kernel_taps - kernel_taps
5347* \param double param_b - param_b
5348* \param double param_c - param_c
5349* \param int SrcSize - input frame size(x/y)
5350* \param int DstSize - output frame size(x/y)
5351*
5352* \return - NI_RETCODE_SUCCESS on success
5353*******************************************************************************/
5355 uint16_t kernel_array[], int kernel_taps, double param_b,
5356 double param_c, int SrcSize, int DstSize);
5357
5358#ifdef __cplusplus
5359}
5360#endif
Common NETINT definitions used by all modules.
#define NI_DEPRECATED
Definition ni_defs.h:80
#define NI_MAX_NUM_DATA_POINTERS
Definition ni_defs.h:244
#define NI_FIFO_SZ
Definition ni_defs.h:305
#define NI_MAX_DEVICE_NAME_LEN
Definition ni_defs.h:236
#define MAX_AV1_ENCODER_GOP_NUM
Definition ni_defs.h:327
#define NI_MAX_CUSTOM_SEI_CNT
Definition ni_defs.h:317
#define NI_MAX_CONTEXTS_PER_HW_INSTANCE
Definition ni_defs.h:248
#define NI_MAX_DEVICES_PER_HW_INSTANCE
Definition ni_defs.h:251
#define NI_MAX_NUM_OF_DECODER_OUTPUTS
Definition ni_defs.h:255
ni_device_type_t
Definition ni_defs.h:356
@ NI_DEVICE_TYPE_XCODER_MAX
Definition ni_defs.h:364
#define NI_DEPRECATE_MACRO(X)
Definition ni_defs.h:82
enum _ni_scaler_opcode ni_scaler_opcode_t
ni_retcode_t
Definition ni_defs.h:447
#define NI_MAX_PPU_PARAM_EXPR_CHAR
Definition ni_defs.h:259
LIB_API ni_retcode_t ni_query_nvme_status(ni_session_context_t *p_ctx, ni_load_query_t *p_load_query)
Query NVMe load from the device.
enum _ni_ddr_priority_mode_t ni_ddr_priority_mode_t
LIB_API ni_retcode_t ni_frame_buffer_alloc_dl(ni_frame_t *p_frame, int video_width, int video_height, int pixel_format)
Allocate preliminary memory for the frame buffer based on provided parameters.
struct _ni_iovec ni_iovec_t
LIB_API ni_retcode_t ni_device_config_namespace_num(ni_device_handle_t device_handle, uint32_t namespace_num, uint32_t sriov_index)
Send namespace num and SRIOv index to the device with specified logic block address.
enum _ni_frame_pool_type ni_frame_pool_type_t
Frame pool type.
_ni_session_run_state
Session running state type.
@ SESSION_RUN_STATE_NORMAL
@ SESSION_RUN_STATE_SEQ_CHANGE_OPENING
@ SESSION_RUN_STATE_SEQ_CHANGE_DRAINING
@ SESSION_RUN_STATE_FLUSHING
@ SESSION_RUN_STATE_RESETTING
struct _ni_scaler_multi_drawbox_params_t ni_scaler_multi_drawbox_params_t
LIB_API void ni_close_event(ni_event_handle_t event_handle)
Close event and release resources (Windows only)
LIB_API int ni_encoder_session_read_stream_header(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data)
Read encoder stream header from the device.
LIB_API ni_retcode_t ni_query_extra_info(ni_device_handle_t device_handle, ni_device_extra_info_t *p_dev_extra_info, uint8_t fw_rev[])
Query CompositeTemp from device.
LIB_API ni_retcode_t ni_encoder_params_set_value(ni_xcoder_params_t *p_params, const char *name, const char *value)
Set value referenced by name in encoder parameters structure.
enum _ni_param_change_flags ni_param_change_flags_t
This is an enumeration for encoder parameter change.
LIB_API ni_retcode_t ni_ai_frame_buffer_alloc(ni_frame_t *p_frame, ni_network_data_t *p_network)
Allocate input layers memory for AI frame buffer based on provided parameters taking into account wid...
LIB_API void ni_frame_free_aux_data(ni_frame_t *frame, ni_aux_data_type_t type)
If auxiliary data of the given type exists in the frame, free it and remove it from the frame.
av1_codec_profile
@ AV1_CODEC_PROFILE_MAIN
LIB_API ni_retcode_t ni_set_ltr_interval(ni_session_context_t *p_ctx, int32_t ltr_interval)
Set Long Term Reference interval.
LIB_API ni_retcode_t ni_reconfig_vui(ni_session_context_t *p_ctx, ni_vui_hrd_t *vui)
Reconfigure VUI dynamically during encoding.
LIB_API ni_retcode_t ni_device_session_query_detail(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_detail_status_t *detail_data)
Query detail session data from the device - If device_type is valid, will query session data from spe...
struct _ni_device_capability ni_device_capability_t
device capability type
struct _ni_enc_mastering_display_colour_volume ni_enc_mastering_display_colour_volume_t
encoded payload format of HDR SEI mastering display colour volume
LIB_API void ni_device_session_context_clear(ni_session_context_t *p_ctx)
Clear already allocated session context.
_ni_reconfig
This is an enumeration for encoder reconfiguration test settings.
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO
@ XCODER_TEST_RECONF_VBV_API
@ XCODER_TEST_RECONF_FRAMERATE_API
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_API
@ XCODER_TEST_RECONF_FRAMERATE
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE
@ XCODER_TEST_RECONF_CRF_FLOAT
@ XCODER_TEST_RECONF_LTR_INTERVAL_API
@ XCODER_TEST_RECONF_SLICE_ARG
@ XCODER_TEST_RECONF_VUI_HRD
@ XCODER_TEST_CRF_API
@ XCODER_TEST_RECONF_LTR_INTERVAL
@ XCODER_TEST_RECONF_LTR_API
@ XCODER_TEST_RECONF_INTRAPRD
@ XCODER_TEST_RECONF_SLICE_ARG_API
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP
@ XCODER_TEST_CRF_FLOAT_API
@ XCODER_TEST_RECONF_VUI_HRD_API
@ XCODER_TEST_FORCE_IDR_FRAME
@ XCODER_TEST_RECONF_BR_API
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_API
@ XCODER_TEST_RECONF_LONG_TERM_REF
@ XCODER_TEST_RECONF_MAX_FRAME_SIZE_RATIO_API
@ XCODER_TEST_RECONF_END
@ XCODER_TEST_RECONF_BR
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_REDUNDANT
@ XCODER_TEST_RECONF_CRF
@ XCODER_TEST_INVALID_REF_FRAME_API
@ XCODER_TEST_INVALID_REF_FRAME
@ XCODER_TEST_RECONF_VBV
@ XCODER_TEST_RECONF_INTRAPRD_API
@ XCODER_TEST_RECONF_RC_MIN_MAX_QP_API_REDUNDANT
@ XCODER_TEST_RECONF_OFF
ni_qos_modes
@ QOS_MODE_DISABLED
@ QOS_MODE_ENABLED_SHARE
@ QOS_MODE_ENABLED_NO_SHARE
struct _ni_aux_data ni_aux_data_t
_ni_frame_pool_type
Frame pool type.
@ NI_POOL_TYPE_NONE
@ NI_POOL_TYPE_NORMAL
@ NI_POOL_TYPE_P2P
struct _ni_buf_pool_t ni_buf_pool_t
union _ni_enc_avc_roi_custom_map ni_enc_avc_roi_custom_map_t
encoder AVC ROI custom map (1 MB = 8bits)
#define NI_BITRATE_RECONFIG_FILE_MAX_LINES
Max number of lines supported for the bitrate reconfig file.
_ni_custom_sei_location
This is an enumeration for illustrating the custom SEI locations.
@ NI_CUSTOM_SEI_LOC_AFTER_VCL
@ NI_CUSTOM_SEI_LOC_BEFORE_VCL
struct _ni_bitsream_features ni_bitstream_features_t
struct _ni_split_context_t ni_split_context_t
LIB_API ni_retcode_t ni_device_session_sequence_change(ni_session_context_t *p_ctx, int width, int height, int bit_depth_factor, ni_device_type_t device_type)
Send sequence change information to device.
LIB_API ni_retcode_t ni_uploader_frame_buffer_lock(ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame)
Lock a hardware P2P frame prior to encoding.
struct _ni_frame_config ni_frame_config_t
#define NI_XCODER_LOG_NAMES_ARRAY_LEN
LIB_API const char *const g_xcoder_preset_names[NI_XCODER_PRESET_NAMES_ARRAY_LEN]
LIB_API ni_retcode_t ni_encoder_frame_buffer_alloc(ni_frame_t *pframe, int video_width, int video_height, int linesize[], int alignment, int extra_len, bool alignment_2pass_wa)
Allocate memory for the frame buffer for encoding based on given parameters, taking into account pic ...
#define NI_CC_SEI_TRAILER_LEN
LIB_API 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...
struct _ni_framerate ni_framerate_t
ni_quadra_frame_type
@ NI_QUADRA_PREDICTED_FRAME
@ NI_QUADRA_PIC_TYPE_IDR
@ NI_QUADRA_BIDIR_PREDICTED_FRAME
@ NI_QUADRA_INTRA_FRAME
LIB_API ni_retcode_t ni_device_config_qos_op(ni_device_handle_t device_handle, ni_device_handle_t device_handle_t, uint32_t over_provision)
Send qos over provisioning mode to target namespace with specified logic block address.
struct _ni_custom_sei ni_custom_sei_t
custom sei payload passthrough
LIB_API void ni_decoder_frame_buffer_pool_return_buf(ni_buf_t *buf, ni_buf_pool_t *p_buffer_pool)
Return a memory buffer to memory buffer pool, for a decoder frame.
LIB_API int ni_device_session_read(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 packet from decoder If ...
LIB_API int ni_device_session_acquire_for_read(ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame)
Acquire a P2P frame buffer from the hwupload session for P2P read.
enum _ni_session_run_state ni_session_run_state_t
Session running state type.
struct _ni_network_layer_offset ni_network_layer_offset_t
struct _niFrameSurface1 niFrameSurface1_t
struct _ni_session_context ni_session_context_t
struct _ni_dec_h265_vui_param ni_dec_h265_vui_param_t
decoded payload format of H.265 VUI
LIB_API ni_retcode_t ni_device_session_query_buffer_avail(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Query the session if a buffer is available.
LIB_API ni_retcode_t ni_device_config_qos(ni_device_handle_t device_handle, uint32_t mode)
Send qos mode to the device with specified logic block address.
LIB_API ni_retcode_t ni_reconfig_bitrate(ni_session_context_t *p_ctx, int32_t bitrate)
Reconfigure bitrate dynamically during encoding.
_ni_pixel_planar_format
@ NI_PIXEL_PLANAR_FORMAT_SEMIPLANAR
@ NI_PIXEL_PLANAR_MAX
@ NI_PIXEL_PLANAR_FORMAT_TILED4X4
@ NI_PIXEL_PLANAR_FORMAT_PLANAR
struct _ni_queue_buffer_pool_t ni_queue_buffer_pool_t
struct _ni_network_layer_params_t ni_network_layer_params_t
LIB_API ni_retcode_t ni_device_session_query(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Query session data from the device - If device_type is valid, will query session data from specified ...
LIB_API ni_retcode_t ni_encoder_frame_zerocopy_check(ni_session_context_t *p_enc_ctx, ni_xcoder_params_t *p_enc_params, int width, int height, const int linesize[], bool set_linesize)
Check if incoming frame is encoder zero copy compatible or not.
enum _ni_dec_crop_mode ni_dec_crop_mode
LIB_API ni_retcode_t ni_encoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height, ni_codec_format_t codec_format)
Initialize default encoder parameters.
LIB_API int ni_device_session_hwup(ni_session_context_t *p_ctx, ni_session_data_io_t *p_src_data, niFrameSurface1_t *hwdesc)
Send raw YUV input to uploader instance and retrieve a HW descriptor to represent it.
LIB_API 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
LIB_API ni_retcode_t ni_reconfig_max_frame_size_ratio(ni_session_context_t *p_ctx, int32_t max_frame_size_ratio)
Reconfigure maxFrameSizeRatio dynamically during encoding.
LIB_API ni_retcode_t ni_ai_config_hvsplus(ni_session_context_t *p_ctx, ni_network_data_t *p_network)
configure a hvsplus filter
struct _ni_scaler_input_params_t ni_scaler_input_params_t
LIB_API NI_DEPRECATED ni_device_handle_t ni_device_open(const char *dev, uint32_t *p_max_io_size_out)
Open device and return device device_handle if successful.
LIB_API ni_retcode_t ni_uploader_p2p_test_send(ni_session_context_t *p_upl_ctx, uint8_t *p_data, uint32_t len, ni_frame_t *p_hwframe)
Special P2P test API call. Copies YUV data from the software frame to the hardware P2P frame on the Q...
LIB_API ni_retcode_t ni_packet_buffer_free(ni_packet_t *ppacket)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc.
struct _ni_category_classify ni_category_classify_t
LIB_API 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.
struct _ni_encoder_cfg_params ni_encoder_cfg_params_t
LIB_API ni_session_context_t * ni_device_session_context_alloc_init(void)
Allocate and initialize a new ni_session_context_t struct.
enum ni_qos_modes ni_qos_modes_t
struct _ni_decoder_input_params_t ni_decoder_input_params_t
LIB_API ni_retcode_t ni_enc_prep_reconf_demo_data(ni_session_context_t *p_enc_ctx, ni_frame_t *p_frame)
Convert various reconfig and demo modes (stored in encoder configuration) to aux data and store them ...
#define NI_CC_SEI_HDR_H264_LEN
LIB_API void ni_gop_params_check_set(ni_xcoder_params_t *p_param, char *value)
Set custom gop and prepare to check if success.
_ni_device_mode
Device access mode enumeration.
@ NI_DEVICE_READ_ONLY
@ NI_DEVICE_WRITE_ONLY
@ NI_DEVICE_READ_WRITE
_ni_ai_buffer_quantize_format_e
@ NI_AI_BUFFER_QUANTIZE_DYNAMIC_FIXED_POINT
@ NI_AI_BUFFER_QUANTIZE_MAX
@ NI_AI_BUFFER_QUANTIZE_NONE
@ NI_AI_BUFFER_QUANTIZE_TF_ASYMM
#define NI_MAX_GOP_NUM
LIB_API 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
float(* ni_kernel_coeff_fn)(int filtersize, double offset, double B, double C)
LIB_API ni_retcode_t ni_device_dec_session_save_hdrs(ni_session_context_t *p_ctx, uint8_t *hdr_data, uint8_t hdr_size)
Save a stream's headers in a decoder session that can be used later for continuous decoding from the ...
struct _ni_instance_mgr_detail_status_v1 ni_instance_mgr_detail_status_v1_t
#define NI_CUSTOMIZE_ROI_QP_NUM
Max number of entries per line supported for the qp number.
LIB_API ni_retcode_t ni_scaler_set_drawbox_params(ni_session_context_t *p_ctx, ni_scaler_drawbox_params_t *p_params)
Send a p_config command to configure scaling drawbox parameters.
LIB_API 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_MAX_CUSTOM_SEI_DATA
struct _ni_dec_h264_vui_param ni_dec_h264_vui_param_t
decoded payload format of H.264 VUI
LIB_API int ni_calculate_total_frame_size(const ni_session_context_t *p_upl_ctx, const int linesize[])
Calculate the total size of a frame based on the upload context attributes and includes rounding up t...
union _ni_enc_quad_roi_custom_map ni_enc_quad_roi_custom_map
encoder AVC ROI custom map (1 MB = 8bits)
struct _ni_thread_arg_struct_t ni_thread_arg_struct_t
LIB_API ni_retcode_t ni_p2p_recv(ni_session_context_t *pSession, const ni_p2p_sgl_t *dmaAddrs, ni_frame_t *pDstFrame)
Initiate a P2P transfer (P2P read)
struct _ni_instance_mgr_detail_status_append ni_instance_mgr_detail_status_append_t
LIB_API ni_retcode_t ni_encoder_set_input_frame_format(ni_session_context_t *p_enc_ctx, ni_xcoder_params_t *p_enc_params, int width, int height, int bit_depth, int src_endian, int planar)
Set the incoming frame format for the encoder.
struct _ni_long_term_ref ni_long_term_ref_t
LIB_API ni_retcode_t ni_encoder_frame_zerocopy_adjust(ni_session_context_t *p_enc_ctx, ni_frame_t *p_frame, int video_height, const int linesize[], const uint8_t *data[], int buf_size0, int buf_size1, int buf_size2, uint8_t *buf_data0, uint8_t *buf_data1, uint8_t *buf_data2)
Check if the frame data transferred is within a frame boundary and adjust with offset if it doesn't....
LIB_API ni_retcode_t ni_set_frame_ref_invalid(ni_session_context_t *p_ctx, int32_t frame_num)
Set frame reference invalidation.
struct _ni_content_light_level_info_bytes ni_content_light_level_info_bytes_t
payload format of HDR SEI content light level info
LIB_API int ni_device_session_hwdl(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, niFrameSurface1_t *hwdesc)
Read YUV data from hw descriptor stored location on device.
struct _ni_encoder_change_params_t ni_encoder_change_params_t
This is a data structure for encoding parameters that have changed.
_ni_dec_crop_mode
@ NI_DEC_CROP_MODE_AUTO
@ NI_DEC_CROP_MODE_MANUAL
@ NI_DEC_CROP_MODE_DISABLE
LIB_API ni_retcode_t ni_scaler_set_watermark_params(ni_session_context_t *p_ctx, ni_scaler_watermark_params_t *p_params)
Send a p_config command to configure scaling watermark parameters.
struct _ni_hw_capability ni_hw_capability_t
hardware capability type
LIB_API ni_retcode_t ni_device_session_close(ni_session_context_t *p_ctx, int eos_received, ni_device_type_t device_type)
Close device session that was previously opened by calling ni_device_session_open() If device_type is...
struct _ni_packet ni_packet_t
LIB_API ni_retcode_t ni_encoder_frame_zerocopy_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, const int linesize[], const uint8_t *data[], int extra_len)
Allocate memory for encoder zero copy (metadata, etc.) for encoding based on given parameters,...
ni_xcoder_state_t
@ NI_XCODER_HWDL_STATE
@ NI_XCODER_IDLE_STATE
@ NI_XCODER_READ_DESC_STATE
@ NI_XCODER_FLUSH_STATE
@ NI_XCODER_GENERAL_STATE
@ NI_XCODER_READ_STATE
@ NI_XCODER_INTER_FLUSH_STATE
@ NI_XCODER_CLOSE_STATE
@ NI_XCODER_HWUP_STATE
@ NI_XCODER_OPEN_STATE
@ NI_XCODER_WRITE_STATE
LIB_API ni_retcode_t ni_decoder_params_set_value(ni_xcoder_params_t *p_params, const char *name, char *value)
Set value referenced by name in decoder parameters structure.
_ni_frame_aux_data_type
@ NI_FRAME_AUX_DATA_MASTERING_DISPLAY_METADATA
@ NI_FRAME_AUX_DATA_BITRATE
@ NI_FRAME_AUX_DATA_SLICE_ARG
@ NI_FRAME_AUX_DATA_CRF_FLOAT
@ NI_FRAME_AUX_DATA_UDU_SEI
@ NI_FRAME_AUX_DATA_MAX_MIN_QP
@ NI_FRAME_AUX_DATA_CATEGORY_CLASSIFY
@ NI_FRAME_AUX_DATA_FRAMERATE
@ NI_FRAME_AUX_DATA_LTR_INTERVAL
@ NI_FRAME_AUX_DATA_HDR_PLUS
@ NI_FRAME_AUX_DATA_VBV_MAX_RATE
@ NI_FRAME_AUX_DATA_INTRAPRD
@ NI_FRAME_AUX_DATA_CUSTOM_SEI
@ NI_FRAME_AUX_DATA_CRF
@ NI_FRAME_AUX_DATA_MAX_FRAME_SIZE
@ NI_FRAME_AUX_DATA_VUI
@ NI_FRAME_AUX_DATA_NONE
@ NI_FRAME_AUX_DATA_INVALID_REF_FRAME
@ NI_FRAME_AUX_DATA_A53_CC
@ NI_FRAME_AUX_DATA_CONTENT_LIGHT_LEVEL
@ NI_FRAME_AUX_DATA_REGIONS_OF_INTEREST
@ NI_FRAME_AUX_DATA_LONG_TERM_REF
@ NI_FRAME_AUX_DATA_VBV_BUFFER_SIZE
struct _ni_load_query ni_load_query_t
LIB_API ni_retcode_t ni_packet_buffer_free_av1(ni_packet_t *ppacket)
Free packet buffer that was previously allocated with ni_packet_buffer_alloc for AV1 packets merge.
struct _ni_context_query ni_context_query_t
#define NI_HDR10P_SEI_HDR_AV1_LEN
LIB_API NI_DEPRECATED ni_retcode_t ni_device_capability_query(ni_device_handle_t device_handle, ni_device_capability_t *p_cap)
Query device and return device capability structure This function had been replaced by ni_device_capa...
LIB_API ni_retcode_t ni_device_multi_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t p_cfg_in[], int numInCfgs, ni_frame_config_t *p_cfg_out)
Config multiple frame on the device for 2D engined to work on based on provided parameters.
LIB_API ni_aux_data_t * ni_frame_new_aux_data(ni_frame_t *frame, ni_aux_data_type_t type, int data_size)
Add a new auxiliary data to a frame.
ni_h265_sei_user_data_type_t
@ NI_H265_USERDATA_FLAG_RESERVED_3
@ NI_H265_USERDATA_FLAG_UNREGISTERED_PRE
@ NI_H265_USERDATA_FLAG_ITU_T_T35_PRE
@ NI_H265_USERDATA_FLAG_ITU_T_T35_PRE_1
@ NI_H265_USERDATA_FLAG_ITU_T_T35_SUF
@ NI_H265_USERDATA_FLAG_RESERVED_1
@ NI_H265_USERDATA_FLAG_VUI
@ NI_H265_USERDATA_FLAG_ITU_T_T35_PRE_2
@ NI_H265_USERDATA_FLAG_RESERVED_9
@ NI_H265_USERDATA_FLAG_TONE_MAPPING_INFO
@ NI_H265_USERDATA_FLAG_PIC_TIMING
@ NI_H265_USERDATA_FLAG_RESERVED_0
@ NI_H265_USERDATA_FLAG_MASTERING_COLOR_VOL
@ NI_H265_USERDATA_FLAG_CHROMA_RESAMPLING_FILTER_HINT
@ NI_H265_USER_DATA_FLAG_COLOUR_REMAPPING_INFO
@ NI_H265_USERDATA_FLAG_ITU_T_T35_SUF_2
@ NI_H265_USER_DATA_FLAG_CONTENT_LIGHT_LEVEL_INFO
@ NI_H265_USERDATA_FLAG_ITU_T_T35_SUF_1
@ NI_H265_USERDATA_FLAG_KNEE_FUNCTION_INFO
@ NI_H265_USER_DATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO
@ NI_H265_USERDATA_FLAG_UNREGISTERED_SUF
LIB_API ni_retcode_t ni_reconfig_min_max_qp(ni_session_context_t *p_ctx, ni_rc_min_max_qp *p_min_max_qp)
Reconfigure min&max qp dynamically during encoding.
LIB_API ni_retcode_t ni_ai_packet_buffer_alloc(ni_packet_t *p_packet, ni_network_data_t *p_network)
Allocate output layers memory for the packet buffer based on provided network.
LIB_API ni_retcode_t ni_query_qos_namespace_info(ni_device_handle_t device_handle, ni_qos_namespace_info_log_page_t *p_dev_qos_ns, uint8_t fw_rev[])
Query QoS information for a specific namespace.
LIB_API ni_retcode_t ni_p2p_send_v2(ni_session_context_t *pSession, ni_frame_t *pSrcFrame, const ni_p2p_sgl_t *dmaAddrs)
Initiate P2P transfer to another device (P2P write) with sgl list.
LIB_API ni_retcode_t ni_reconfig_intraprd(ni_session_context_t *p_ctx, int32_t intra_period)
Reconfigure intraPeriod dynamically during encoding.
#define NI_ENC_PARAM_CONSTANT_RATE_FACTOR
LIB_API ni_event_handle_t ni_create_event(void)
Create event and return event handle if successful (Windows only)
LIB_API ni_retcode_t ni_hwframe_buffer_recycle2(niFrameSurface1_t *surface)
Recycle a hwframe buffer on card.
struct _ni_network_perf_metrics ni_network_perf_metrics_t
ni_qos_codes
@ QOS_ALLOW_CONFIG_CODE
@ QOS_OP_CONFIG_CODE
@ QOS_ALLOW_CONFIG_REC_ALLOW_CODE
@ QOS_OP_CONFIG_REC_OP_CODE
@ QOS_NAMESPACE_CODE
LIB_API ni_retcode_t ni_reconfig_vbv_value(ni_session_context_t *p_ctx, int32_t vbvMaxRate, int32_t vbvBufferSize)
Reconfigure vbv buffer size and vbv max rate dynamically during encoding.
LIB_API ni_retcode_t ni_frame_buffer_alloc_pixfmt(ni_frame_t *pframe, int pixel_format, int video_width, int video_height, int linesize[], int alignment, int extra_len)
Allocate memory for the frame buffer based on provided parameters taking into account the pixel forma...
LIB_API ni_retcode_t ni_ai_session_read_metrics(ni_session_context_t *p_ctx, ni_network_perf_metrics_t *p_metrics)
Fetch perf metrics of inferences from device.
union _ni_enc_hevc_roi_custom_map ni_enc_hevc_roi_custom_map_t
encoder HEVC ROI custom map (1 CTU = 64bits)
struct _ni_ppu_config ni_ppu_config_t
LIB_API void ni_device_close(ni_device_handle_t dev)
Close device and release resources.
LIB_API ni_retcode_t ni_hwframe_p2p_buffer_recycle(ni_frame_t *p_frame)
Recycle hw P2P frames.
#define NI_HDR10P_SEI_HDR_H264_LEN
LIB_API int32_t ni_get_dma_buf_file_descriptor(const ni_frame_t *p_frame)
Get the DMA buffer file descriptor from the P2P frame.
LIB_API 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
h264_codec_profile
@ H264_CODEC_PROFILE_EXTENDED
@ H264_CODEC_PROFILE_HIGH
@ H264_CODEC_PROFILE_BASELINE
@ H264_CODEC_PROFILE_MAIN
LIB_API ni_retcode_t ni_hwframe_buffer_recycle(niFrameSurface1_t *surface, int32_t device_handle)
Recycle a hwframe buffer on card.
#define NI_CC_SEI_HDR_AV1_LEN
LIB_API ni_retcode_t ni_force_idr_frame_type(ni_session_context_t *p_ctx)
Force next frame to be IDR frame during encoding.
LIB_API ni_retcode_t ni_uploader_frame_buffer_unlock(ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame)
Unlock a hardware P2P frame after encoding.
enum _ni_vq_presets_e ni_vq_presets_e
LIB_API int ni_device_session_write(ni_session_context_t *p_ctx, ni_session_data_io_t *p_data, ni_device_type_t device_type)
Send data to the device If device_type is NI_DEVICE_TYPE_DECODER sends data packet to decoder If devi...
LIB_API ni_retcode_t ni_reconfig_crf(ni_session_context_t *p_ctx, int32_t crf)
Reconfigure crf value dynamically during encoding.
struct _ni_vui_hrd ni_vui_hrd_t
struct _ni_session_data_io ni_session_data_io_t
LIB_API ni_retcode_t ni_device_session_update_framepool(ni_session_context_t *p_ctx, uint32_t pool_size)
Sends frame pool change info to device.
LIB_API ni_retcode_t ni_device_capability_query2(ni_device_handle_t device_handle, ni_device_capability_t *p_cap, bool device_in_ctxt)
Query device and return device capability structure This function had replaced ni_device_capability_q...
struct _ni_rc_min_max_qp ni_rc_min_max_qp
LIB_API ni_retcode_t ni_reconfig_slice_arg(ni_session_context_t *p_ctx, int16_t sliceArg)
Reconfigure sliceArg dynamically during encoding.
LIB_API ni_retcode_t ni_device_alloc_and_get_firmware_logs(ni_session_context_t *p_ctx, void **p_log_buffer, bool gen_log_file)
Allocate log buffer if needed and retrieve firmware logs from device.
LIB_API ni_retcode_t ni_decoder_frame_buffer_alloc(ni_buf_pool_t *p_pool, ni_frame_t *pframe, int alloc_mem, int video_width, int video_height, int alignment, int factor, int is_planar)
Allocate memory for decoder frame buffer based on provided parameters; the memory is retrieved from a...
LIB_API bool ni_gop_params_check(ni_xcoder_params_t *p_param)
Check custom gop params set.
LIB_API ni_retcode_t ni_encoder_gop_params_set_value(ni_xcoder_params_t *p_params, const char *name, const char *value)
Set GOP parameter value referenced by name in encoder parameters structure.
LIB_API ni_retcode_t ni_scaler_p2p_frame_acquire(ni_session_context_t *p_ctx, niFrameSurface1_t *p_surface, int data_len)
Acquire the scaler P2P DMA buffer for read/write.
LIB_API ni_retcode_t ni_frame_buffer_alloc_hwenc(ni_frame_t *pframe, int video_width, int video_height, int extra_len)
Allocate memory for the hwDescriptor buffer based on provided parameters taking into account pic size...
LIB_API ni_retcode_t ni_decoder_init_default_params(ni_xcoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default decoder parameters.
enum _ni_custom_sei_location ni_custom_sei_location_t
This is an enumeration for illustrating the custom SEI locations.
LIB_API ni_retcode_t ni_device_clone_hwframe(ni_session_context_t *p_ctx, ni_frameclone_desc_t *p_frameclone_desc)
Copy the data of src hwframe to dst hwframe.
#define NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL
Max number of lines supported for qpoffset level.
enum _ni_frame_aux_data_type ni_aux_data_type_t
struct _ni_gop_rps ni_gop_rps_t
hevc_codec_profile
@ HEVC_CODEC_PROFILE_MAIN10
@ HEVC_CODEC_PROFILE_MAIN
struct _ni_scaler_multi_watermark_params_t ni_scaler_multi_watermark_params_t
LIB_API ni_retcode_t ni_scaler_set_params(ni_session_context_t *p_ctx, ni_scaler_params_t *p_params)
Set parameters on the device for the 2D engine.
enum _ni_ai_buffer_format_e ni_ai_buffer_format_e
video_codec_identifier
@ VODEO_CODEC_ID_HEVC
@ VODEO_CODEC_ID_H264
@ VODEO_CODEC_ID_AV1
@ VODEO_CODEC_ID_VP9
LIB_API NI_DEPRECATED ni_retcode_t ni_p2p_send(ni_session_context_t *pSession, niFrameSurface1_t *source, uint64_t ui64DestAddr, uint32_t ui32FrameSize)
Initiate P2P transfer to another device (P2P write)
enum _ni_codec_format ni_codec_format_t
This is an enumeration for supported codec formats.
struct _ni_scaler_params_t ni_scaler_params_t
LIB_API int ni_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 alignment.
struct _ni_overall_load_query ni_overall_load_query_t
LIB_API ni_retcode_t ni_device_session_context_init(ni_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
#define NI_ENC_PARAM_MAX_FRAME_SIZE_LOW_DELAY
LIB_API ni_retcode_t ni_device_session_query_detail_v1(ni_session_context_t *p_ctx, ni_device_type_t device_type, ni_instance_mgr_detail_status_v1_t *detail_data)
Query detail session data from the device - If device_type is valid, will query session data from spe...
LIB_API ni_retcode_t ni_set_ltr(ni_session_context_t *p_ctx, ni_long_term_ref_t *ltr)
Set a frame's support of Long Term Reference frame during encoding.
ni_quadra_av1_profile
@ NI_QUADRA_AV1_PROFILE_MAIN
struct _ni_frame ni_frame_t
LIB_API void ni_frame_wipe_aux_data(ni_frame_t *frame)
Free and remove all auxiliary data from the frame.
LIB_API ni_retcode_t ni_device_alloc_dst_frame(ni_session_context_t *p_ctx, niFrameSurface1_t *p_out_surface, ni_device_type_t device_type)
Allocate a frame on the device and return the frame index.
_ni_ddr_priority_mode_t
@ NI_DDR_PRIORITY_AI
@ NI_DDR_PRIORITY_FILT
@ NI_DDR_PRIORITY_DECENC
@ NI_DDR_PRIORITY_NONE
@ NI_DDR_PRIORITY_RESET
@ NI_DDR_PRIORITY_MAX
LIB_API void ni_device_session_context_free(ni_session_context_t *p_ctx)
Free previously allocated session context.
LIB_API ni_retcode_t ni_frame_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, int alignment, int metadata_flag, int factor, int hw_frame_count, int is_planar)
Allocate preliminary memory for the frame buffer based on provided parameters. Applicable to YUV420 P...
struct _ni_input_frame ni_input_frame
LIB_API ni_retcode_t ni_uploader_p2p_test_load(ni_session_context_t *p_upl_ctx, uint8_t *p_data, uint32_t len, ni_frame_t *p_hwframe)
Special P2P test API function. Copies video data from the software frame to the hardware P2P frame on...
#define MAX_CHAR_IN_DEVICE_NAME
struct _ni_timestamp_table_t ni_timestamp_table_t
LIB_API ni_retcode_t ni_kernel_set_callback(ni_session_context_t *p_session_ctx, ni_kernel_coeff_fn fn)
Replace the kernel coefficient callback.
LIB_API NI_DEPRECATED ni_retcode_t ni_p2p_xfer(ni_session_context_t *pSession, niFrameSurface1_t *source, uint64_t ui64DestAddr, uint32_t ui32FrameSize)
Initiate P2P transfer (P2P write) (deprecated)
LIB_API ni_retcode_t ni_device_session_restart(ni_session_context_t *p_ctx, int video_width, int video_height, ni_device_type_t device_type)
Send a restart command after flush command Only support Encoder now.
#define NI_MAX_SUPPORT_DRAWBOX_NUM
LIB_API ni_retcode_t ni_encoder_sw_frame_buffer_alloc(bool planar, ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int alignment, int extra_len, bool alignment_2pass_wa)
This API is a wrapper for ni_encoder_frame_buffer_alloc(), used for planar pixel formats,...
struct _ni_network_data ni_network_data_t
LIB_API ni_retcode_t ni_set_demo_roi_map(ni_session_context_t *p_enc_ctx)
Set up hard coded demo ROI map.
LIB_API ni_retcode_t ni_device_session_copy(ni_session_context_t *src_p_ctx, ni_session_context_t *dst_p_ctx)
Copy existing decoding session params for hw frame usage.
LIB_API ni_retcode_t ni_query_fl_fw_versions(ni_device_handle_t device_handle, ni_device_info_t *p_dev_info)
Query firmware loader and firmware versions from the device.
struct _ni_custom_sei_set ni_custom_sei_set_t
#define NI_MAX_SPATIAL_LAYERS
LIB_API int ni_device_session_acquire(ni_session_context_t *p_upl_ctx, ni_frame_t *p_frame)
Acquire a P2P frame buffer from the hwupload session.
#define NI_HDR10P_SEI_HDR_HEVC_LEN
#define NI_NAMESPACE_MAX_NUM
LIB_API ni_retcode_t ni_device_dec_session_flush(ni_session_context_t *p_ctx)
Flush a decoder session to get ready to continue decoding. Note: this is different from ni_device_ses...
LIB_API ni_retcode_t ni_query_vf_ns_id(ni_device_handle_t device_handle, ni_device_vf_ns_id_t *p_dev_ns_vf, uint8_t fw_rev[])
Query VF and NS id from device.
ni_codec_hw_actions
This is an enumeration for hw actions.
@ NI_CODEC_HW_UPLOAD
@ NI_CODEC_HW_NONE
@ NI_CODEC_HW_DOWNLOAD
@ NI_CODEC_HW_ENABLE
@ NI_CODEC_HW_PAYLOAD_OFFSET
@ NI_CODEC_HW_RSVD
_ni_codec_format
This is an enumeration for supported codec formats.
@ NI_CODEC_FORMAT_H265
@ NI_CODEC_FORMAT_AV1
@ NI_CODEC_FORMAT_H264
@ NI_CODEC_FORMAT_JPEG
@ NI_CODEC_FORMAT_VP9
LIB_API 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_pix_fmt_t
@ NI_PIX_FMT_ARGB
@ NI_PIX_FMT_P010LE
@ NI_PIX_FMT_YUV420P
@ NI_PIX_FMT_ABGR
@ NI_PIX_FMT_NONE
@ NI_PIX_FMT_10_TILED4X4
@ NI_PIX_FMT_BGRP
@ NI_PIX_FMT_BGR0
@ NI_PIX_FMT_YUYV422
@ NI_PIX_FMT_RGBA
@ NI_PIX_FMT_NV12
@ NI_PIX_FMT_8_TILED4X4
@ NI_PIX_FMT_BGRA
@ NI_PIX_FMT_NV16
@ NI_PIX_FMT_UYVY422
@ NI_PIX_FMT_YUV420P10LE
LIB_API ni_retcode_t ni_device_config_qos_allowance(ni_device_handle_t device_handle, ni_device_handle_t device_handle_t, uint32_t allowance)
Set QoS allowance for a specific namespace.
enum _ni_reconfig ni_reconfig_t
This is an enumeration for encoder reconfiguration test settings.
LIB_API ni_retcode_t ni_reconfig_framerate(ni_session_context_t *p_ctx, ni_framerate_t *framerate)
Reconfigure framerate dynamically during encoding.
struct _ni_scaler_drawbox_params_t ni_scaler_drawbox_params_t
LIB_API int ni_device_session_init_framepool(ni_session_context_t *p_ctx, uint32_t pool_size, uint32_t pool)
Send frame pool setup info to device.
struct _ni_extended_dec_metadata ni_extended_dec_metadata_t
_ni_ai_buffer_format_e
@ NI_AI_BUFFER_FORMAT_INT8
@ NI_AI_BUFFER_FORMAT_FP64
@ NI_AI_BUFFER_FORMAT_FP32
@ NI_AI_BUFFER_FORMAT_CHAR
@ NI_AI_BUFFER_FORMAT_UINT16
@ NI_AI_BUFFER_FORMAT_UINT8
@ NI_AI_BUFFER_FORMAT_BFP16
@ NI_AI_BUFFER_FORMAT_FP16
@ NI_AI_BUFFER_FORMAT_INT64
@ NI_AI_BUFFER_FORMAT_UINT32
@ NI_AI_BUFFER_FORMAT_INT32
@ NI_AI_BUFFER_FORMAT_INT16
@ NI_AI_BUFFER_FORMAT_UINT64
struct _ni_rational ni_rational_t
#define NI_ENC_PARAM_GEN_HDRS
LIB_API ni_retcode_t ni_frame_buffer_alloc_nv(ni_frame_t *p_frame, int video_width, int video_height, int linesize[], int extra_len, bool alignment_2pass_wa)
Allocate memory for the frame buffer based on provided parameters taking into account pic line size a...
LIB_API ni_retcode_t ni_packet_buffer_alloc(ni_packet_t *ppacket, int packet_size)
Allocate memory for the packet buffer based on provided packet size.
struct _ni_dec_mastering_display_colour_volume_bytes ni_dec_mastering_display_colour_volume_bytes_t
decoded payload format of HDR SEI mastering display colour volume
LIB_API ni_retcode_t ni_frame_buffer_free(ni_frame_t *pframe)
Free frame buffer that was previously allocated with either ni_frame_buffer_alloc or ni_encoder_frame...
#define NI_MAX_SUPPORT_WATERMARK_NUM
struct _ni_queue_t ni_queue_t
enum ni_codec_hw_actions ni_codec_hw_actions_t
This is an enumeration for hw actions.
#define NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE
ni_pic_type_t
@ PIC_TYPE_B
@ PIC_TYPE_NIDR
@ PIC_TYPE_IDR
@ DECODER_PIC_TYPE_IDR
@ PIC_TYPE_P
@ PIC_NOT_CODED
@ PIC_TYPE_MAX
@ PIC_TYPE_CRA
@ PIC_TYPE_I
LIB_API ni_retcode_t ni_decoder_frame_buffer_free(ni_frame_t *pframe)
Free decoder frame buffer that was previously allocated with ni_decoder_frame_buffer_alloc,...
struct _ni_network_layer_info ni_network_layer_info_t
struct _ni_pkt_info ni_pkt_info
itu_frame_type
@ ITU_FRAME_TYPE_NONE
@ ITU_FRAME_TYPE_B
@ ITU_FRAME_TYPE_P
@ ITU_FRAME_TYPE_I
struct _ni_sei_header ni_sei_header_t
LIB_API ni_retcode_t ni_reconfig_crf2(ni_session_context_t *p_ctx, float crf)
Reconfigure crf float point value dynamically during encoding.
LIB_API ni_retcode_t ni_device_session_flush(ni_session_context_t *p_ctx, ni_device_type_t device_type)
Send a flush command to the device If device_type is NI_DEVICE_TYPE_DECODER sends EOS command to deco...
LIB_API ni_device_handle_t ni_device_open2(const char *dev, ni_device_mode_t mode)
Open device and return device device_handle if successful.
LIB_API ni_retcode_t ni_scaler_build_kernel(ni_session_context_t *p_session_ctx, uint16_t kernel_array[], int kernel_taps, double param_b, double param_c, int SrcSize, int DstSize)
Build scaler kernal array.
ni_enc_allocate_strategy_t
@ NI_ENC_MEM_ALLOCATE_STRATEGY_INVALID_MAX
@ NI_ENC_MEM_ALLOCATE_STRATEGY_REGION_1_FIRST
@ NI_ENC_MEM_ALLOCATE_STRATEGY_REGION_0_FIRST
@ NI_ENC_MEM_ALLOCATE_STRATEGY_DEFAULT
@ NI_ENC_MEM_ALLOCATE_STRATEGY_INVALID_MIN
#define NI_XCODER_PRESET_NAMES_ARRAY_LEN
_ni_vq_presets_e
@ NI_PRESETS_NONE
@ NI_NUM_PRESETS_MAX
@ NI_VQ_FASTER
@ NI_VQ_SLOWER
@ NI_VQ_FAST
@ NI_VQ_SLOW
@ NI_VQ_MEDIUM
@ NI_VQ_VERYSLOW
@ NI_VQ_VERYFAST
#define NI_MAX_NUM_AUX_DATA_PER_FRAME
enum _ni_ai_buffer_quantize_format_e ni_ai_buffer_quantize_format_e
ni_customize_roi_level_t
@ NI_CUS_ROI_OVERWRITE
@ NI_CUS_ROI_MERGE
@ NI_CUS_ROI_DISABLE
@ NI_CUS_ROI_MAPFILE
@ NI_CUS_ROI_REPLACE
enum _ni_device_mode ni_device_mode_t
Device access mode enumeration.
struct _ni_gop_params ni_gop_params_t
struct _ni_region_of_interest ni_region_of_interest_t
ni_quadra_hevc_profile
@ NI_QUADRA_HEVC_PROFILE_MAIN
@ NI_QUADRA_HEVC_PROFILE_MAIN10
LIB_API ni_retcode_t ni_device_alloc_and_get_fw_log_artifacts(ni_session_context_t *p_ctx, bool gen_artifacts_file)
Read log artifacts from the device and save to disk.
LIB_API ni_retcode_t ni_custom_packet_buffer_alloc(void *p_buffer, ni_packet_t *p_packet, int buffer_size)
Allocate packet buffer using a user provided pointer, the memory is expected to have already been all...
#define NI_MAX_REF_PIC
#define NI_MAX_VUI_SIZE
LIB_API ni_retcode_t ni_uploader_set_frame_format(ni_session_context_t *p_upl_ctx, int width, int height, ni_pix_fmt_t pixel_format, int isP2P)
Set the frame format for the uploader.
LIB_API ni_retcode_t ni_query_temperature(ni_device_handle_t device_handle, ni_device_temp_t *p_dev_temp, uint8_t fw_rev[])
Query CompositeTemp from device.
struct _ni_buf_t ni_buf_t
enum _ni_pixel_planar_format ni_pixel_planar_format
_ni_param_change_flags
This is an enumeration for encoder parameter change.
@ NI_SET_CHANGE_PARAM_INVALID_REF_FRAME
@ NI_SET_CHANGE_PARAM_RC_TARGET_RATE
@ NI_SET_CHANGE_PARAM_RC_FRAMERATE
@ NI_SET_CHANGE_PARAM_CRF
@ NI_SET_CHANGE_PARAM_LTR_INTERVAL
@ NI_SET_CHANGE_PARAM_RC_BIT_RATIO_LAYER
@ NI_SET_CHANGE_PARAM_CUSTOM_LAMBDA
@ NI_SET_CHANGE_PARAM_VBV
@ NI_SET_CHANGE_PARAM_RC2
@ NI_SET_CHANGE_PARAM_VUI_HRD_PARAM
@ NI_SET_CHANGE_PARAM_RC_MIN_MAX_QP
@ NI_SET_CHANGE_PARAM_NR
@ NI_SET_CHANGE_PARAM_DEPEND_SLICE
@ NI_SET_CHANGE_PARAM_SLICE_ARG
@ NI_SET_CHANGE_PARAM_INTRA_PERIOD
@ NI_SET_CHANGE_PARAM_BG
@ NI_SET_CHANGE_PARAM_PPS
@ NI_SET_CHANGE_PARAM_CUSTOM_MD
@ NI_SET_CHANGE_PARAM_MAX_FRAME_SIZE
@ NI_SET_CHANGE_PARAM_RDO
@ NI_SET_CHANGE_PARAM_INDEPEND_SLICE
LIB_API const char *const g_xcoder_log_names[NI_XCODER_LOG_NAMES_ARRAY_LEN]
LIB_API ni_retcode_t ni_reconfig_max_frame_size(ni_session_context_t *p_ctx, int32_t max_frame_size)
Reconfigure maxFrameSize dynamically during encoding.
enum ni_qos_codes ni_qos_codes_t
LIB_API ni_retcode_t ni_dec_reconfig_ppu_params(ni_session_context_t *p_session_ctx, ni_xcoder_params_t *p_param, ni_ppu_config_t *p_ppu_config)
Send a p_config command to reconfigure decoding ppu params.
LIB_API ni_retcode_t ni_uploader_frame_zerocopy_check(ni_session_context_t *p_upl_ctx, int width, int height, const int linesize[], int pixel_format)
Check if incoming frame is hwupload zero copy compatible or not.
ni_quadra_h264_profile
@ NI_QUADRA_H264_PROFILE_BASELINE
@ NI_QUADRA_H264_PROFILE_HIGH
@ NI_QUADRA_H264_PROFILE_MAIN
@ NI_QUADRA_H264_PROFILE_EXTENDED
struct _ni_queue_node_t ni_queue_node_t
struct _ni_xcoder_params ni_xcoder_params_t
LIB_API ni_retcode_t ni_query_qos_info(ni_device_handle_t device_handle, ni_qos_header_info_log_page_t *p_dev_qos_header, uint8_t fw_rev[])
Query QoS information for the device.
struct _ni_instance_mgr_detail_status ni_instance_mgr_detail_status_t
#define NI_CC_SEI_HDR_HEVC_LEN
struct _ni_custom_gop_params ni_custom_gop_params_t
LIB_API ni_aux_data_t * ni_frame_get_aux_data(const ni_frame_t *frame, ni_aux_data_type_t type)
Retrieve from the frame auxiliary data of a given type if exists.
LIB_API ni_retcode_t ni_enc_frame_buffer_alloc(ni_frame_t *p_frame, int video_width, int video_height, int alignment, int metadata_flag, int factor, int hw_frame_count, int is_planar, ni_pix_fmt_t pix_fmt)
Wrapper function for ni_frame_buffer_alloc. Meant to handle RGBA min. resoulution considerations for ...
LIB_API ni_retcode_t ni_device_config_frame(ni_session_context_t *p_ctx, ni_frame_config_t *p_cfg)
Config a frame on the device for 2D engined to work on based on provided parameters.
struct _ni_scaler_watermark_params_t ni_scaler_watermark_params_t
struct _ni_frameclone_desc ni_frameclone_desc_t
struct _ni_dec_win ni_dec_win_t
LIB_API ni_aux_data_t * ni_frame_new_aux_data_from_raw_data(ni_frame_t *frame, ni_aux_data_type_t type, const uint8_t *raw_data, int data_size)
Add a new auxiliary data to a frame and copy in the raw data.
Public definitions for managing NETINT video processing devices.
ni_aux_data_type_t type
ni_pthread_mutex_t mutex
ni_buf_t * p_free_tail
ni_buf_t * p_used_head
ni_buf_t * p_used_tail
uint32_t number_of_buffers
ni_buf_t * p_free_head
struct _ni_buf_t * p_previous_buffer
struct _ni_buf_pool_t * pool
struct _ni_buf_t * p_next
struct _ni_buf_t * p_prev
struct _ni_buf_t * p_next_buffer
payload format of HDR SEI content light level info
ni_gop_params_t pic_param[NI_MAX_GOP_NUM]
ni_custom_sei_t custom_sei[NI_MAX_CUSTOM_SEI_CNT]
custom sei payload passthrough
uint8_t data[NI_MAX_CUSTOM_SEI_DATA]
ni_custom_sei_location_t location
decoded payload format of H.264 VUI
int8_t chroma_sample_loc_type_bottom_field
uint8_t vcl_hrd_parameters_present_flag
uint8_t motion_vectors_over_pic_boundaries_flag
uint8_t aspect_ratio_info_present_flag
int8_t chroma_sample_loc_type_top_field
uint8_t colour_description_present_flag
uint8_t nal_hrd_parameters_present_flag
uint8_t video_signal_type_present_flag
decoded payload format of H.265 VUI
uint8_t vui_poc_proportional_to_timing_flag
uint8_t restricted_ref_pic_lists_flag
int8_t chroma_sample_loc_type_bottom_field
uint8_t motion_vectors_over_pic_boundaries_flag
uint8_t aspect_ratio_info_present_flag
uint8_t vui_hrd_parameters_present_flag
int8_t chroma_sample_loc_type_top_field
uint8_t neutral_chroma_indication_flag
int16_t vui_num_ticks_poc_diff_one_minus1
uint8_t colour_description_present_flag
uint8_t frame_field_info_present_flag
uint8_t video_signal_type_present_flag
decoded payload format of HDR SEI mastering display colour volume
char cr_expr[NI_MAX_NUM_OF_DECODER_OUTPUTS][4][NI_MAX_PPU_PARAM_EXPR_CHAR+1]
int scale_wh[NI_MAX_NUM_OF_DECODER_OUTPUTS][2]
int scale_resolution_ceil[NI_MAX_NUM_OF_DECODER_OUTPUTS]
int semi_planar[NI_MAX_NUM_OF_DECODER_OUTPUTS]
int scale_round[NI_MAX_NUM_OF_DECODER_OUTPUTS]
int scale_long_short_edge[NI_MAX_NUM_OF_DECODER_OUTPUTS]
int force_8_bit[NI_MAX_NUM_OF_DECODER_OUTPUTS]
int crop_mode[NI_MAX_NUM_OF_DECODER_OUTPUTS]
int crop_whxy[NI_MAX_NUM_OF_DECODER_OUTPUTS][4]
char sc_expr[NI_MAX_NUM_OF_DECODER_OUTPUTS][2][NI_MAX_PPU_PARAM_EXPR_CHAR+1]
device capability type
uint8_t xcoder_cnt[NI_DEVICE_TYPE_XCODER_MAX]
ni_hw_capability_t xcoder_devices[NI_MAX_DEVICES_PER_HW_INSTANCE]
uint8_t fw_branch_name[256]
encoded payload format of HDR SEI mastering display colour volume
ni_custom_gop_params_t custom_gop_params
struct _ni_encoder_cfg_params::@16 rc
int spatialLayerBitrate[NI_MAX_SPATIAL_LAYERS]
int av1OpLevel[NI_MAX_SPATIAL_LAYERS]
This is a data structure for encoding parameters that have changed.
uint16_t rectangle_height
uint16_t force_pic_qp
uint8_t color_trc
uint8_t inconsecutive_transfer
uint32_t data_len[NI_MAX_NUM_DATA_POINTERS]
unsigned int sei_hdr_mastering_display_color_vol_offset
uint8_t * p_buffer
uint32_t crop_top
uint32_t error_ratio
uint32_t vui_time_scale
uint32_t start_of_stream
unsigned int sei_hdr_content_light_level_info_offset
uint16_t sar_width
ni_codec_format_t src_codec
uint8_t color_primaries
unsigned int vui_len
ni_iovec_t * iovec
unsigned int reconf_len
uint8_t preferred_characteristics_data_len
long long dts
uint32_t vui_num_units_in_tick
uint32_t start_len[NI_MAX_NUM_DATA_POINTERS]
uint32_t start_buffer_size
uint8_t aspect_ratio_idc
uint32_t end_of_stream
uint16_t sar_height
uint8_t separate_metadata
unsigned int sei_hdr_plus_len
ni_buf_t * dec_buf
uint64_t pkt_pos
uint32_t metadata_buffer_size
uint32_t crop_right
unsigned int vui_offset
uint32_t crop_bottom
uint32_t video_width
unsigned int sei_hdr_plus_offset
uint8_t timecode_present
long long pts
uint8_t * p_data[NI_MAX_NUM_DATA_POINTERS]
uint32_t total_start_len
uint8_t color_space
uint32_t frame_chunk_idx
unsigned int extra_data_len
uint8_t * p_start_buffer
uint32_t buffer_size
unsigned int sei_total_len
uint8_t separate_start
unsigned int sei_cc_len
unsigned int sei_cc_offset
unsigned int sei_user_data_unreg_len
uint32_t crop_left
ni_pic_type_t ni_pict_type
long long orignal_pts
uint16_t force_headers
uint8_t use_cur_src_as_long_term_pic
ni_custom_sei_set_t * p_custom_sei_set
uint16_t hor_adjust_offset
unsigned int sei_hdr_content_light_level_info_len
uint32_t iovec_num
ni_aux_data_t * aux_data[NI_MAX_NUM_AUX_DATA_PER_FRAME]
uint8_t * p_metadata_buffer
unsigned int sei_hdr_mastering_display_color_vol_len
int video_full_range_flag
unsigned int sei_user_data_unreg_offset
uint8_t use_long_term_ref
uint32_t video_height
unsigned int roi_len
unsigned int sei_alt_transfer_characteristics_len
unsigned int sei_alt_transfer_characteristics_offset
int32_t framerate_denom
int32_t framerate_num
ni_gop_rps_t rps[NI_MAX_REF_PIC]
hardware capability type
uint8_t max_number_of_contexts
uint8_t * p_input_buffer
ni_instance_mgr_detail_status_append_t sInstDetailStatusAppend[NI_MAX_CONTEXTS_PER_HW_INSTANCE]
ni_instance_mgr_detail_status_t sInstDetailStatus[NI_MAX_CONTEXTS_PER_HW_INSTANCE]
uint32_t size
uint32_t fw_share_mem_usage
uint32_t total_pixel_load
ni_context_query_t context_status[NI_MAX_CONTEXTS_PER_HW_INSTANCE]
uint32_t fw_model_load
uint32_t fw_p2p_mem_usage
uint32_t fw_video_shared_mem_usage
uint32_t pcie_throughput
uint32_t current_load
uint32_t total_contexts
uint32_t active_hwuploaders
uint32_t fw_video_mem_usage
uint8_t use_cur_src_as_long_term_pic
ni_network_layer_offset_t * inset
ni_network_layer_info_t linfo
ni_network_layer_offset_t * outset
ni_network_layer_params_t * in_param
ni_network_layer_params_t * out_param
union _ni_network_layer_params_t::@13 quant_data
struct _ni_network_layer_params_t::@13::@15 affine
struct _ni_network_layer_params_t::@13::@14 dfp
uint32_t data_len
uint32_t start_of_stream
long long dts
uint32_t av1_data_len[MAX_AV1_ENCODER_GOP_NUM]
uint32_t end_of_stream
uint64_t pkt_pos
uint8_t scene_change_detected
uint32_t video_width
uint8_t still_image_detected
long long pts
ni_bitstream_features_t bitstream_features
uint8_t * av1_p_buffer[MAX_AV1_ENCODER_GOP_NUM]
uint32_t buffer_size
double average_psnr
uint32_t avg_frame_qp
uint32_t frame_type
ni_custom_sei_set_t * p_custom_sei_set
long long pos
uint8_t * av1_p_data[MAX_AV1_ENCODER_GOP_NUM]
uint32_t video_height
uint32_t av1_buffer_size[MAX_AV1_ENCODER_GOP_NUM]
double reserved[1]
uint16_t ppu_h[NI_MAX_NUM_OF_DECODER_OUTPUTS]
uint16_t ppu_w[NI_MAX_NUM_OF_DECODER_OUTPUTS]
ni_queue_node_t * p_used_tail
ni_queue_node_t * p_free_head
ni_queue_node_t * p_used_head
ni_queue_node_t * p_free_tail
struct _ni_queue_node_t * p_previous_buffer
struct _ni_queue_node_t * p_next_buffer
struct _ni_queue_node_t * p_next
struct _ni_queue_node_t * p_prev
ni_queue_node_t * p_last
ni_queue_node_t * p_first
ni_scaler_drawbox_params_t multi_drawbox_params[NI_MAX_SUPPORT_DRAWBOX_NUM]
ni_scaler_watermark_params_t multi_watermark_params[NI_MAX_SUPPORT_WATERMARK_NUM]
uint16_t kernel_array[2][17 *9]
ni_io_event_t * io_event
uint64_t pkt_offsets_index_min[NI_FIFO_SZ]
char blk_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
uint8_t itu_t_t35_hdr10p_sei_hdr_hevc[NI_HDR10P_SEI_HDR_HEVC_LEN]
ni_pthread_mutex_t mutex
uint32_t count_frame_num_in_sec
NI_DEPRECATED uint64_t prev_read_frame_time
ni_pthread_cond_t low_delay_sync_cond
ni_event_handle_t thread_event_handle
uint8_t itu_t_t35_hdr10p_sei_hdr_av1[NI_HDR10P_SEI_HDR_AV1_LEN]
ni_queue_buffer_pool_t * buffer_pool
ni_thread_arg_struct_t * keep_alive_thread_args
ni_session_statistic_t session_statistic
uint8_t preferred_characteristics_data
uint8_t ui8_light_level_data[5]
char blk_dev_name[NI_MAX_DEVICE_NAME_LEN]
ni_device_handle_t sender_handle
ni_device_handle_t device_handle
uint32_t fps_change_detect_count
int flags_array[NI_FIFO_SZ]
ni_load_query_t load_query
ni_pthread_mutex_t * pext_mutex
uint8_t itu_t_t35_cc_sei_hdr_av1[NI_CC_SEI_HDR_AV1_LEN]
ni_custom_sei_set_t * pkt_custom_sei_set[NI_FIFO_SZ]
int sei_hdr_mastering_display_color_vol_len
ni_device_handle_t auto_dl_handle
uint8_t sei_trailer[NI_CC_SEI_TRAILER_LEN]
ni_aio_context_t aio_context
ni_network_data_t * network_data
ni_framerate_t framerate
uint64_t pkt_offsets_index[NI_FIFO_SZ]
uint32_t prev_fps
Params used in VFR mode Start///.
uint8_t ui8_mdcv_max_min_lum_data[9]
uint8_t itu_t_t35_cc_sei_hdr_hevc[NI_CC_SEI_HDR_HEVC_LEN]
volatile uint64_t last_access_time
ni_enc_avc_roi_custom_map_t * avc_roi_map
char dev_xcoder_name[MAX_CHAR_IN_DEVICE_NAME]
ni_pthread_t keep_alive_thread
uint8_t itu_t_t35_cc_sei_hdr_h264[NI_CC_SEI_HDR_H264_LEN]
unsigned short domain
ni_event_handle_t event_handle
ni_input_frame input_frame_fifo[120]
encoder:calculate PSNR start
ni_framerate_t last_framerate
uint32_t meta_size
Params used in VFR mode Done///.
uint8_t pending_bitstream_buffer_realloc
ni_device_handle_t blk_io_handle
uint32_t force_idr_intra_offset
uint32_t biggest_bitstream_buffer_allocated
int hvsplus_level
encoder:calculate PSNR end
ni_overall_load_query_t overall_load_query
uint64_t pkt_pos[NI_FIFO_SZ]
ni_enc_hevc_roi_custom_map_t * hevc_roi_map
int64_t enc_pts_list[NI_FIFO_SZ]
ni_long_term_ref_t ltr_to_set
ni_timestamp_table_t * pts_table
ni_session_run_state_t session_run_state
ni_encoder_change_params_t * enc_change_params
ni_pthread_mutex_t low_delay_sync_mutex
uint8_t itu_t_t35_hdr10p_sei_hdr_h264[NI_HDR10P_SEI_HDR_H264_LEN]
ni_kernel_coeff_fn scaler_coeff_fn
ni_enc_quad_roi_custom_map * roi_map
int64_t pts_offsets[NI_FIFO_SZ]
ni_timestamp_table_t * dts_queue
ni_region_of_interest_t * av_rois
NI_DEPRECATED int64_t start_dts_offset
uint32_t decoder_last_drop_frame_num
uint8_t * hevc_sub_ctu_roi_buf
ni_frame_pool_type_t pool_type
uint32_t passed_time_in_timebase_unit
ni_buf_pool_t * dec_fme_buf_pool
union _ni_session_data_io::@19 data
ni_event_handle_t thread_event_handle
ni_pthread_mutex_t * p_mutex
ni_device_handle_t device_handle
volatile uint64_t * plast_access_time
int32_t videoFullRange
int32_t colorDescPresent
int32_t colorPrimaries
int32_t aspectRatioHeight
int32_t colorSpace
int32_t colorTrc
int32_t aspectRatioWidth
ni_encoder_cfg_params_t cfg_enc_params
int8_t customize_roi_qp_map[NI_CUSTOMIZE_ROI_QPOFFSET_LEVEL][NI_CUSTOMIZE_ROI_QP_NUM]
ni_ddr_priority_mode_t ddr_priority_mode
ni_frame_t * p_first_frame
NI_DEPRECATED uint32_t pos_time_scale
ni_decoder_input_params_t dec_input_params
NI_DEPRECATED uint8_t ui8VuiRbsp[NI_MAX_VUI_SIZE]
NI_DEPRECATED uint32_t pos_num_units_in_tick
NI_DEPRECATED uint32_t ui32VuiDataSizeBytes
NI_DEPRECATED uint32_t ui32VuiDataSizeBits
int reconf_hash[NI_BITRATE_RECONFIG_FILE_MAX_LINES][NI_BITRATE_RECONFIG_FILE_MAX_ENTRIES_PER_LINE]
encoder AVC ROI custom map (1 MB = 8bits)
struct _ni_enc_avc_roi_custom_map::@5 field
encoder HEVC ROI custom map (1 CTU = 64bits)
struct _ni_enc_hevc_roi_custom_map::@4 field
encoder AVC ROI custom map (1 MB = 8bits)
struct _ni_enc_quad_roi_custom_map::@6 field