libxcoder  3.5.4
ni_device_api_logan.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_logan.h
24 *
25 * \brief Main NETINT device API header file
26 * provides the ability to communicate with NI T-408 type hardware
27 * transcoder devices
28 *
29 *******************************************************************************/
30 
31 #pragma once
32 
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39 #include "ni_defs_logan.h"
40 
41 #define NI_LOGAN_DATA_FORMAT_VIDEO_PACKET 0
42 #define NI_LOGAN_DATA_FORMAT_YUV_FRAME 1
43 #define NI_LOGAN_DATA_FORMAT_Y_FRAME 2
44 #define NI_LOGAN_DATA_FORMAT_CB_FRAME 3
45 #define NI_LOGAN_DATA_FORMAT_CR_FRAME 4
46 
47 #define NI_LOGAN_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
48 
49 // the following are the default values from FFmpeg
50 #define LOGAN_AV_CODEC_DEFAULT_BITRATE 200 * 1000
51 
52 #define NI_LOGAN_MAX_GOP_NUM 8
53 
54 #define NI_LOGAN_MAX_VUI_SIZE 32
55 
56 #define LOGAN_FRAME_CHUNK_INDEX_SIZE 4096
57 #define NI_LOGAN_SIGNATURE_SIZE 256
58 
59 #define NI_LOGAN_MAX_RESOLUTION_WIDTH 8192
60 #define NI_LOGAN_MAX_RESOLUTION_HEIGHT 8192
61 #define NI_LOGAN_MAX_RESOLUTION_AREA 8192*5120
62 
63 #define NI_LOGAN_FRAME_LITTLE_ENDIAN 0
64 #define NI_LOGAN_FRAME_BIG_ENDIAN 1
65 
66 #define NI_LOGAN_INVALID_SESSION_ID (-1)
67 #define NI_LOGAN_INVALID_HW_FRAME_IDX (-3) // fw default invalid value
68 #define NI_LOGAN_INVALID_HW_META_IDX (-5) // fw hw meta index
69 
70 #define NI_LOGAN_MAX_BITRATE 700000000
71 #define NI_LOGAN_MIN_BITRATE 64000
72 
73 #define NI_LOGAN_MAX_INTRA_PERIOD 1024
74 #define NI_LOGAN_MIN_INTRA_PERIOD 0
75 
76 /*Values below used for timeout checking*/
77 #define NI_LOGAN_MAX_SESSION_OPEN_RETRIES 20
78 #define NI_LOGAN_SESSION_OPEN_RETRY_INTERVAL_US 200
79 
80 #define NI_LOGAN_MAX_ENC_SESSION_OPEN_QUERY_RETRIES 3000
81 #define NI_LOGAN_ENC_SESSION_OPEN_RETRY_INTERVAL_US 1000
82 
83 #define NI_LOGAN_MAX_ENC_SESSION_WRITE_QUERY_RETRIES 2000
84 #define NI_LOGAN_MAX_ENC_SESSION_READ_QUERY_RETRIES 3000
85 
86 #define NI_LOGAN_MAX_DEC_SESSION_WRITE_QUERY_RETRIES 100
87 #define NI_LOGAN_MAX_DEC_SESSION_READ_QUERY_RETRIES 3000
88 #define NI_LOGAN_MAX_DEC_SESSION_READ_QUERY_EOS_RETRIES 15000
89 
90 #define NI_LOGAN_MAX_SESSION_CLOSE_RETRIES 10
91 #define NI_LOGAN_SESSION_CLOSE_RETRY_INTERVAL_US 500000
92 
93 #define NI_LOGAN_RETRY_INTERVAL_100US 100
94 #define NI_LOGAN_RETRY_INTERVAL_200US 200
95 
96 // Number of pixels for main stream resolutions
97 #define NI_LOGAN_NUM_OF_PIXELS_720P (1280*720)
98 
99 /*Values below used for VPU resolution range checking*/
100 #define NI_LOGAN_MAX_WIDTH 8192
101 #define NI_LOGAN_MIN_WIDTH 256
102 #define NI_LOGAN_MAX_HEIGHT 8192
103 #define NI_LOGAN_MIN_HEIGHT 128
104 
105 /*Values below used for parameter resolution range checking*/
106 #define NI_LOGAN_PARAM_MAX_WIDTH 8192
107 #define NI_LOGAN_PARAM_MIN_WIDTH 32
108 #define NI_LOGAN_PARAM_MAX_HEIGHT 8192
109 #define NI_LOGAN_PARAM_MIN_HEIGHT 32
110 
111 #define NI_LOGAN_MAX_GOP_SIZE 8
112 #define NI_LOGAN_MIN_GOP_SIZE 1
113 #define NI_LOGAN_MAX_GOP_PRESET_IDX 9
114 #define NI_LOGAN_MIN_GOP_PRESET_IDX 0
115 #define NI_LOGAN_MAX_DECODING_REFRESH_TYPE 2
116 #define NI_LOGAN_MIN_DECODING_REFRESH_TYPE 0
117 #define NI_LOGAN_DEFAULT_CU_SIZE_MODE 7
118 #define NI_LOGAN_MAX_DYNAMIC_MERGE 1
119 #define NI_LOGAN_MIN_DYNAMIC_MERGE 0
120 #define NI_LOGAN_MAX_USE_RECOMMENDED_ENC_PARAMS 3
121 #define NI_LOGAN_MIN_USE_RECOMMENDED_ENC_PARAMS 0
122 #define NI_LOGAN_MAX_MAX_NUM_MERGE 3
123 #define NI_LOGAN_MIN_MAX_NUM_MERGE 0
124 #define NI_LOGAN_MAX_INTRA_QP 51
125 #define NI_LOGAN_MIN_INTRA_QP 0
126 #define NI_LOGAN_DEFAULT_INTRA_QP 22
127 #define NI_LOGAN_INTRA_QP_RANGE 25
128 #define NI_LOGAN_QP_MID_POINT 26
129 #define NI_LOGAN_MAX_MAX_QP 51
130 #define NI_LOGAN_MIN_MAX_QP 0
131 #define NI_LOGAN_MAX_MIN_QP 51
132 #define NI_LOGAN_MIN_MIN_QP 0
133 #define NI_LOGAN_DEFAULT_MAX_QP 51
134 #define NI_LOGAN_DEFAULT_MIN_QP 8
135 #define NI_LOGAN_MAX_MAX_DELTA_QP 51
136 #define NI_LOGAN_MIN_MAX_DELTA_QP 0
137 #define NI_LOGAN_DEFAULT_MAX_DELTA_QP 10
138 #define NI_LOGAN_MAX_BIN 1
139 #define NI_LOGAN_MIN_BIN 0
140 #define NI_LOGAN_MAX_NUM_SESSIONS 32
141 #define NI_LOGAN_MAX_CRF 51
142 #define NI_LOGAN_MIN_CRF 0
143 #define NI_LOGAN_MIN_INTRA_REFRESH_MIN_PERIOD 0
144 #define NI_LOGAN_MAX_INTRA_REFRESH_MIN_PERIOD 8191
145 #define NI_LOGAN_MAX_KEEP_ALIVE_TIMEOUT 100
146 #define NI_LOGAN_MIN_KEEP_ALIVE_TIMEOUT 1
147 #define NI_LOGAN_DEFAULT_KEEP_ALIVE_TIMEOUT 3
148 #define NI_LOGAN_MIN_CUSTOM_SEI_PASSTHRU (-1)
149 #define NI_LOGAN_MAX_CUSTOM_SEI_PASSTHRU 1000
150 #define NI_LOGAN_MIN_PRIORITY 0
151 #define NI_LOGAN_MAX_PRIORITY 1
152 #define NI_LOGAN_DISABLE_USR_DATA_SEI_PASSTHRU 0
153 #define NI_LOGAN_ENABLE_USR_DATA_SEI_PASSTHRU 1
154 #define NI_LOGAN_DISABLE_CHECK_PACKET 0
155 #define NI_LOGAN_ENABLE_CHECK_PACKET 1
156 
157 #define RC_SUCCESS true
158 #define RC_ERROR false
159 
160 #define NI_LOGAN_INVALID_HWID (-1)
161 
162 #define BEST_LOAD_STR "bestload"
163 #define BEST_DEVICE_INST_STR "bestinst"
164 #define BEST_MODEL_LOAD_STR "bestmodelload"
165 #define LIST_DEVICES_STR "list"
166 #define LOGAN_MAX_CHAR_IN_DEVICE_NAME 32
167 
168 #define LOGAN_MAX_NUM_FRAMEPOOL_HWAVFRAME 64
169 #define LOGAN_MAX_FIFO_CAPACITY 120
170 
171 // Picked from the xcoder firmware, commit e3b882e7
172 #define NI_LOGAN_VPU_CEIL(_data, _align) (((_data)+(_align-1))&~(_align-1))
173 #define NI_LOGAN_VPU_ALIGN4(_x) (((_x)+0x03)&~0x03)
174 #define NI_LOGAN_VPU_ALIGN8(_x) (((_x)+0x07)&~0x07)
175 #define NI_LOGAN_VPU_ALIGN16(_x) (((_x)+0x0f)&~0x0f)
176 #define NI_LOGAN_VPU_ALIGN32(_x) (((_x)+0x1f)&~0x1f)
177 #define NI_LOGAN_VPU_ALIGN64(_x) (((_x)+0x3f)&~0x3f)
178 #define NI_LOGAN_VPU_ALIGN128(_x) (((_x)+0x7f)&~0x7f)
179 #define NI_LOGAN_VPU_ALIGN256(_x) (((_x)+0xff)&~0xff)
180 #define NI_LOGAN_VPU_ALIGN512(_x) (((_x)+0x1ff)&~0x1ff)
181 #define NI_LOGAN_VPU_ALIGN2048(_x) (((_x)+0x7ff)&~0x7ff)
182 #define NI_LOGAN_VPU_ALIGN4096(_x) (((_x)+0xfff)&~0xfff)
183 #define NI_LOGAN_VPU_ALIGN16384(_x) (((_x)+0x3fff)&~0x3fff)
184 
186 {
187  uint32_t offset;
188  uint32_t size;
190 
191 typedef enum
192 {
198  NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_PRE = 5, /* SEI Prefix: user_data_registered_itu_t_t35 */
199  NI_LOGAN_H265_USERDATA_FLAG_UNREGISTERED_PRE = 6, /* SEI Prefix: user_data_unregistered */
200  NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_SUF = 7, /* SEI Suffix: user_data_registered_itu_t_t35 */
201  NI_LOGAN_H265_USERDATA_FLAG_UNREGISTERED_SUF = 8, /* SEI Suffix: user_data_unregistered */
203  NI_LOGAN_H265_USERDATA_FLAG_MASTERING_COLOR_VOL = 10, /* SEI Prefix: mastering_display_color_volume */
204  NI_LOGAN_H265_USERDATA_FLAG_CHROMA_RESAMPLING_FILTER_HINT = 11, /* SEI Prefix: chroma_resampling_filter_hint */
205  NI_LOGAN_H265_USERDATA_FLAG_KNEE_FUNCTION_INFO = 12, /* SEI Prefix: knee_function_info */
206  NI_LOGAN_H265_USERDATA_FLAG_TONE_MAPPING_INFO = 13, /* SEI Prefix: tone_mapping_info */
207  NI_LOGAN_H265_USER_DATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO = 14, /* SEI Prefix: film_grain_characteristics_info */
208  NI_LOGAN_H265_USER_DATA_FLAG_CONTENT_LIGHT_LEVEL_INFO = 15, /* SEI Prefix: content_light_level_info */
209  NI_LOGAN_H265_USER_DATA_FLAG_COLOUR_REMAPPING_INFO = 16, /* SEI Prefix: content_light_level_info */
210  NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_PRE_1 = 28, /* SEI Prefix: additional user_data_registered_itu_t_t35 */
211  NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_PRE_2 = 29, /* SEI Prefix: additional user_data_registered_itu_t_t35 */
212  NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_SUF_1 = 30, /* SEI Suffix: additional user_data_registered_itu_t_t35 */
213  NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_SUF_2 = 31, /* SEI Suffix: additional user_data_registered_itu_t_t35 */
215 
216 typedef enum
217 {
218  LOGAN_PIC_TYPE_I = 0, /*!*< I picture */
219  LOGAN_PIC_TYPE_P = 1, /*!*< P picture */
220  LOGAN_PIC_TYPE_B = 2, /*!*< B picture (except VC1) */
221  LOGAN_PIC_TYPE_FORCE_IDR = 3, /*!*< force IDR frame when encoding */
222 
223  LOGAN_PIC_TYPE_IDR = 5, /*!*< H.264/H.265 IDR picture */
224  LOGAN_PIC_TYPE_CRA = 6, /*!*< H.265 CRA picture */
225  LOGAN_PIC_TYPE_MAX /*!*< No Meaning */
227 
228 typedef enum
229 {
230  NI_LOGAN_PIX_FMT_YUV420P = 0, /* 8-bit YUV420 planar */
231  NI_LOGAN_PIX_FMT_YUVJ420P = 1, /* 8-bit YUV420 planar (JPEG)*/
232  NI_LOGAN_PIX_FMT_YUV420P10BE = 2, /* 10-bit YUV420 planar, big-endian */
233  NI_LOGAN_PIX_FMT_YUV420P10LE = 3, /* 10-bit YUV420 planar, little-endian */
235 
236 // Maximum SEI sizes for supported types for encoder and decoder
237 #define NI_LOGAN_ENC_MAX_SEI_BUF_SIZE NI_LOGAN_VPU_ALIGN16(1024) //1024
238 #define NI_LOGAN_MAX_SEI_ENTRIES 32
239 // 32 user_data_entry_t records + various SEI messages sizes
240 #define NI_LOGAN_MAX_SEI_DATA NI_LOGAN_VPU_ALIGN8(NI_LOGAN_MAX_SEI_ENTRIES * sizeof(ni_logan_sei_user_data_entry_t) + 1024) // 1280
241 
242 #define NI_LOGAN_DEC_MAX_CC_BUF_SIZE 93 // max 31 CC entries of 3 bytes each
243 
244 #ifndef QUADRA
245 
246 #define NI_CC_SEI_BYTE0 0xB5 // itu_t_t35_country_code =181 (North America)
247 #define NI_CC_SEI_BYTE1 0x00
248 #define NI_CC_SEI_BYTE2 0x31 // itu_t_t35_provider_code = 49
249 #define NI_CC_SEI_BYTE3 0x47 // ATSC_user_identifier = "GA94"
250 #define NI_CC_SEI_BYTE4 0x41
251 #define NI_CC_SEI_BYTE5 0x39
252 #define NI_CC_SEI_BYTE6 0x34
253 #define NI_CC_SEI_BYTE7 0x03 // cc_data = 0x03
254 
255 #define NI_HDR10P_SEI_BYTE0 0xB5 // itu_t_t35_country_code =181 (North America
256 #define NI_HDR10P_SEI_BYTE1 0x00
257 #define NI_HDR10P_SEI_BYTE2 0x3c // itu_t_t35_provider_code = 0x003c
258 #define NI_HDR10P_SEI_BYTE3 0x00
259 #define NI_HDR10P_SEI_BYTE4 0x01 // u16 itu_t_t35_provider_oriented_code = 0x0001
260 #define NI_HDR10P_SEI_BYTE5 0x04 // u8 application_identifier = 0x04
261 #define NI_HDR10P_SEI_BYTE6 0x00 // u8 application version = 0x00
262 
263 #define NI_CC_SEI_HDR_HEVC_LEN 18
264 #define NI_HDR10P_SEI_HDR_HEVC_LEN 9
265 #define NI_HDR10P_SEI_HDR_H264_LEN 8
266 #define NI_CC_SEI_HDR_H264_LEN 17
267 #define NI_CC_SEI_TRAILER_LEN 2
268 #define NI_RBSP_TRAILING_BITS_LEN 1
269 
270 #define NI_MAX_NUM_AUX_DATA_PER_FRAME 16
271 
272 
273 // frame auxiliary data; mostly used for SEI data associated with frame
275 {
277 
278  // ATSC A53 Part 4 Closed Captions
280 
281  // HDR10 mastering display metadata associated with a video frame
283 
284  // HDR10 content light level (based on CTA-861.3). This payload contains
285  // data in the form of ni_content_light_level_t struct.
287 
288  // HDR10+ dynamic metadata associated with a video frame. The payload is
289  // a ni_dynamic_hdr_plus_t struct that contains information for color volume
290  // transform - application 4 of SMPTE 2094-40:2016 standard.
292 
293  // Regions of Interest, the payload is an array of ni_region_of_interest_t,
294  // the number of array element is implied by:
295  // ni_logan_frame_aux_data.size / sizeof(ni_region_of_interest_t)
297 
298  // NETINT: user data unregistered SEI data, which takes SEI payload type
299  // USER_DATA_UNREGISTERED.
300  // There will be no byte reordering.
301  // Usually this payload would be: 16B UUID + other payload Bytes.
303 
304  // NETINT: custom SEI data, which takes SEI payload custom types.
305  // There will be no byte reordering.
306  // Usually this payload would be: 1B Custom SEI type + 16B UUID + other
307  // payload Bytes.
309 
310  // NETINT: custom bitrate adjustment, which takes int32_t type data as
311  // payload that indicates the new target bitrate value.
313 
314  // NETINT: custom min max qp adjustment. This side data is a struct of
315  // AVNetintMinMaxQP that indicates the new target qp value.
317 
318  // NETINT: long term reference frame support, which is a struct of
319  // ni_long_term_ref_t that specifies a frame's support of long term
320  // reference frame.
322 
323  // NETINT: vui data frame support, which is a struct of
324  // ni_long_term_ref_t that specifies a frame's support of long term
325  // reference frame.
327 
329 
330 // rational number (pair of numerator and denominator)
331 typedef struct _ni_logan_rational
332 {
333  int num; // numerator
334  int den; // denominator
336 
337 // create an ni_rational_t
338 static inline ni_rational_t ni_make_q(int num, int den)
339 {
340  ni_rational_t ret = {num, den};
341  return ret;
342 }
343 
344 // convert an ni_rational_t to a double
345 static inline double ni_q2d(ni_rational_t a)
346 {
347  return a.num / (double) a.den;
348 }
349 
350 // struct to hold auxiliary data for ni_logan_frame_t
351 typedef struct _ni_logan_aux_data
352 {
354  uint8_t *data;
355  int size;
357 
358 // struct describing a Region Of Interest (ROI)
360 {
361  // self size: must be set to: sizeof(ni_region_of_interest_t)
362  uint32_t self_size;
363 
364  // ROI rectangle: pixels from the frame's top edge to the top and bottom edges
365  // of the rectangle, from the frame's left edge to the left and right edges
366  // of the rectangle.
367  int top;
368  int bottom;
369  int left;
370  int right;
371 
372  // quantisation offset: [-1, +1], 0 means no quality change; < 0 value asks
373  // for better quality (less quantisation), > 0 value asks for worse quality
374  // (greater quantisation).
377 
378 // struct describing long term reference frame support.
380 {
381  // A flag for the current picture to be used as a long term reference
382  // picture later at other pictures' encoding
384 
385  // A flag to use a long term reference picture in DPB when encoding the
386  // current picture
389 
391 {
392  // NI_LOGAN_SET_CHANGE_PARAM_RC_MIN_MAX_QP
393  int32_t minQpI;
394  int32_t maxQpI;
395  int32_t maxDeltaQp;
396  int32_t minQpP;
397  int32_t minQpB;
398  int32_t maxQpP;
399  int32_t maxQpB;
401 
402 #endif // #ifndef QUADRA
403 
404 /*!*
405 * \brief encoder HEVC ROI custom map (1 CTU = 64bits)
406 */
408 {
409  struct
410  {
411  uint32_t ctu_force_mode : 2; //[ 1: 0]
412  uint32_t ctu_coeff_drop : 1; //[ 2]
413  uint32_t reserved : 5; //[ 7: 3]
414  uint32_t sub_ctu_qp_0 : 6; //[13: 8]
415  uint32_t sub_ctu_qp_1 : 6; //[19:14]
416  uint32_t sub_ctu_qp_2 : 6; //[25:20]
417  uint32_t sub_ctu_qp_3 : 6; //[31:26]
418 
419  uint32_t lambda_sad_0 : 8; //[39:32]
420  uint32_t lambda_sad_1 : 8; //[47:40]
421  uint32_t lambda_sad_2 : 8; //[55:48]
422  uint32_t lambda_sad_3 : 8; //[63:56]
423  } field;
425 
426 /*!*
427 * \brief encoder AVC ROI custom map (1 MB = 8bits)
428 */
430 {
431  struct
432  {
433  uint8_t mb_force_mode : 2; // [ 1: 0]
434  uint8_t mb_qp : 6; // [ 7: 2]
435  } field;
437 
438 /*!*
439 * \brief This is an enumeration for supported codec formats.
440 */
442 {
445 
447 
448 /*!*
449 * \brief This is an enumeration for hw actions
450 */
452 {
457  NI_LOGAN_CODEC_HW_RSVD = (1 << 3)
459 
460 /*!*
461 * \brief This is an enumeration for encoder parameter change.
462 */
464 {
465  // COMMON parameters which can be changed frame by frame.
483 
488 {
489  uint32_t enable_option;
490 
491  // NI_LOGAN_SET_CHANGE_PARAM_RC_TARGET_RATE
492  int32_t bitRate;
495  // NI_LOGAN_SET_CHANGE_PARAM_RC
496 // (rcEnable, cuLevelRc, bitAllocMode, RoiEnable, RcInitQp can't be changed while encoding)
497  int32_t hvsQPEnable;
498  int32_t hvsQpScale;
499  int32_t vbvBufferSize;
503  int32_t mbLevelRcEnable;
504  int32_t fillerEnable;
506  // NI_LOGAN_SET_CHANGE_PARAM_RC_MIN_MAX_QP
507  int32_t minQpI;
508  int32_t maxQpI;
509  int32_t maxDeltaQp;
512  int32_t minQpP;
513  int32_t minQpB;
514  int32_t maxQpP;
515  int32_t maxQpB;
517  // NI_LOGAN_SET_CHANGE_PARAM_INTRA_PARAM
518  int32_t intraQP;
519  int32_t intraPeriod;
520  int32_t repeatHeaders;
522  // NI_LOGAN_SET_CHANGE_PARAM_VUI_HRD_PARAM
523  uint32_t encodeVuiRbsp;
524  uint32_t vuiDataSizeBits;
525  uint32_t vuiDataSizeBytes;
528  int32_t maxFrameMode;
529  int32_t maxFrameArg;
530 
531  int32_t crfQpInt;
532  int32_t crfQpFraction;
533  int32_t crfIpRatioInt;
535  int32_t crfPbRatioInt;
537  int32_t reserved[8]; // reserved bytes to make struct size 8-align
538 } ni_logan_encoder_change_params_t; // 176 bytes (has to be 8 byte aligned)
539 
540 /*!*
541 * \brief decoded payload format of HDR SEI mastering display colour volume
542 *
543 */
545 {
546  uint32_t display_primaries_x[3];
547  uint32_t display_primaries_y[3];
548  uint32_t white_point_x : 16;
549  uint32_t white_point_y : 16;
553 
554 typedef struct _ni_logan_dec_win
555 {
556  int16_t left;
557  int16_t right;
558  int16_t top;
559  int16_t bottom;
561 
562 /*!*
563 * \brief decoded payload format of H.265 VUI
564 *
565 */
567 {
572 
574  int8_t video_format;
575 
578 
579  uint16_t sar_width;
580  uint16_t sar_height;
581 
585 
589 
591 
592  uint8_t field_seq_flag;
593 
598 
600  uint32_t vui_time_scale;
601 
604 
611 
615 
617 
619 
620 /*!*
621 * \brief decoded payload format of H.264 VUI
622 *
623 */
625 {
630 
632  int8_t video_format;
635 
636  uint16_t sar_width;
637  uint16_t sar_height;
638 
643 
646 
649 
651  uint32_t vui_time_scale;
652 
657 
662 
668 
669 /*!*
670 * \brief payload format of HDR SEI content light level info
671 *
672 */
674 {
678 
679 /*!*
680 * \brief encoded payload format of HDR SEI mastering display colour volume
681 *
682 */
684 {
685  uint16_t display_primaries[3][2];
686  uint16_t white_point_x;
687  uint16_t white_point_y;
691 
692 /*!*
693 * \brief This is an enumeration for illustrating the custom SEI locations.
694 */
696 {
700 
701 /*!*
702 * \brief custom sei payload passthrough
703 *
704 */
705 typedef struct _ni_logan_custom_sei
706 {
709  uint32_t custom_sei_size;
712 
714 {
715  uint8_t custom_sei_cnt;
718 
719 /*!*
720 * \brief hardware capability type
721 */
723 {
724  uint8_t reserved; //alignment
725  uint8_t hw_id;
727  uint8_t max_1080p_fps;
728  uint8_t codec_format;
729  uint8_t codec_type;
730  uint16_t max_video_width;
732  uint16_t min_video_width;
734  uint8_t video_profile;
735  uint8_t video_level;
737 
738 /*!*
739 * \brief device capability type
740 */
742 {
749  // firmware revision, a space right filled ASCII array, not a string
750  uint8_t fw_rev[8];
752  uint8_t fw_commit_hash[41];
753  uint8_t fw_commit_time[26];
754  uint8_t fw_branch_name[256];
756 
757 /*!*
758 * \brief Session running state type.
759 */
761 {
767 
768 
770 {
771  uint32_t context_id : 8; //07:00 SW Instance ID (0 to Max number of instances)
772  uint32_t context_status : 8; //15:08 Instance Status (0-Idle, 1-Active)
773  uint32_t codec_format : 8; //23:16 Codec Format (0-H264, 1-H265)
774  uint32_t video_width : 16; //39:24 Video Width (0 to Max Width)
775  uint32_t video_height : 16; //55:40 Video Height (0 to Max Height)
776  uint32_t fps : 8; //63:56 FPS (0 to 255)
777  uint32_t reserved : 8; //Alignment
779 
780 typedef struct _ni_logan_load_query
781 {
782  uint32_t current_load;
783  uint32_t fw_model_load;
785  uint32_t total_contexts;
788 
790 {
791  int hw_id; // Codec ID
792  uint32_t session_id; // session id
793  uint64_t session_timestamp; // Session Start Timestamp
794  bool close_thread; // a flag that the keep alive thread is closed or need to be closed
795  uint32_t device_type; // Device Type, Either NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
796  ni_device_handle_t device_handle; // block device handler
797  ni_event_handle_t thread_event_handle; // only for Windows asynchronous read and write
798  void *p_buffer; // only be used when regular i/o
799  uint32_t keep_alive_timeout; // keep alive timeout setting
801 
802 
803 typedef struct _ni_logan_buf_t
804 {
805  void* buf;
812 
813 typedef struct _ni_logan_buf_pool_t
814 {
815  ni_pthread_mutex_t mutex;
817  uint32_t buf_size;
823 
825 {
826  uint8_t ai8Sn[20];
828 
830 {
831  uint64_t timestamp;
832  uint64_t frame_info;
839 
841 {
842  uint32_t number_of_buffers; // total number of buffers
848 
849 // Assume that each buffer is the same size
850 typedef struct _ni_logan_fifo_buffer_t {
851  ni_pthread_mutex_t mutex;
852  uint32_t number_of_buffers; // total number of buffers
853  uint32_t buffer_size; // the size of every buffer
855  uint8_t *buffer;
856  uint32_t rndx, wndx;
858 
859 // HRD parameters
860 typedef struct _ni_hrd_params
861 {
869 
871 {
875 
881 
883 
894 
897  int64_t last_pts;
898  int64_t last_dts;
901  int64_t enc_pts_r_idx;
902  int64_t enc_pts_w_idx;
907  /* store pts values to create an accurate pts offset */
911  uint64_t pkt_index;
915 
917  ni_device_handle_t device_handle;
919  ni_device_handle_t blk_io_handle;
920 
922  // sender_handle is device handle of uploader or decoder.
923  ni_device_handle_t sender_handle;
924  // default is invalid, if need download back yuv, equals to sender_handle
925  ni_device_handle_t auto_dl_handle;
926 
929 
933  int hw_id;
935  const char *hw_name;
937  uint32_t session_id;
941  uint32_t device_type;
943  uint32_t codec_format;
950 
951  ni_logan_serial_num_t d_serial_number; /*Serial number of card (dec or uploader) in use*/
952  ni_logan_serial_num_t e_serial_number; /*Serial number of card (enc) in use*/
953 
954  int src_bit_depth; // 8 or 10 bits/pixel formats, default 8
955  int src_endian; // encoding 0: little endian (default) 1: big
956  int bit_depth_factor; // for YUV buffer allocation
957  // for encoder roi metadata
958  uint32_t roi_len;
959  uint32_t roi_avg_qp;
960 
965 
967  void *p_leftover;
969  uint32_t sent_size;
970 
972  uint8_t *p_hdr_buf;
973  uint8_t hdr_buf_size;
974 
979 
981  void *pts_table;
982 
984  void *dts_queue;
985 
990  int status;
992 
993  void *p_dump[2];
994  char param_err_msg[512];
995 
997  uint64_t frame_num;
998  uint64_t pkt_num;
1000 
1001  // write packet/frame required buf size
1003 
1004  // frame forcing: for encoding
1009 
1010  uint32_t ready_to_close; //flag to indicate we are ready to close session
1011  uint32_t ready_to_flush; //flag to indicate we are ready to flush decode
1012 
1013  // session running state
1015  uint32_t active_video_width; //Current video width. this is used to do sequence change
1016  uint32_t active_video_height; //Current video height ,this is used to do sequence change
1017  uint32_t active_bit_depth; //Current bit depth, this is used to do sequence change
1018  ni_pthread_t keep_alive_thread;
1022  uint32_t needs_dealoc; //This is set to indicate that the context was dynamically allocated and needs to be freed
1023 
1026 
1027  // only be used when regular i/o
1028  void *p_all_zero_buf; //This is for sos, eos, flush and keep alive request
1030 
1031  // these two event handle are only for Windows asynchronous read and write now
1032  ni_event_handle_t event_handle;
1033  ni_event_handle_t thread_event_handle;
1034 
1035  // decoder lowDelay mode
1037  // decoder lowDelay mode drop frame number
1039  // the number of decoder delayed frames caused by reorder
1041 
1043 
1044  // ROI data
1046  ni_region_of_interest_t *av_rois; // last passed in ni_region_of_interest_t
1047  int nb_rois;
1051 
1052  // encoder reconfig parameters
1054 
1055  // path of decoder input pkt saving folder
1056  char stream_dir_name[128];
1057  // hw yuvbypass
1060  int isP2P;
1062  unsigned short domain;
1063  unsigned short bus;
1064  unsigned short dev;
1065  unsigned short fn;
1066 
1068 
1070  uint32_t prev_fps;
1074  uint64_t prev_pts;
1079 
1080  uint32_t ui32timing_scale; // only used for the vfr, initialize the vui
1081  uint32_t ui32num_unit_in_tick;// only used for the vfr, initialize the vui
1083 
1084  // for decoder: store currently returned decoded frame's pkt offset
1086 
1087  // device session open/close/read/write session mutex
1088  ni_pthread_mutex_t mutex;
1089 
1090  // HRD parameters
1092 
1093  // FW revision
1094  uint8_t fw_rev[8];
1095 
1096  // extra info temperature
1098 
1099  // record the drop num
1102 
1103 /*!*
1104 * \brief This is an enumeration for encoder reconfiguration test settings
1105 */
1107 {
1117 
1118 #define NI_LOGAN_ENC_GOP_PARAMS_G0_PIC_TYPE "g0picType"
1119 #define NI_LOGAN_ENC_GOP_PARAMS_G0_POC_OFFSET "g0pocOffset"
1120 #define NI_LOGAN_ENC_GOP_PARAMS_G0_PIC_QP "g0picQp"
1121 #define NI_LOGAN_ENC_GOP_PARAMS_G0_NUM_REF_PIC_L0 "g0numRefPicL0"
1122 #define NI_LOGAN_ENC_GOP_PARAMS_G0_NUM_REF_POC_L0 "g0refPocL0"
1123 #define NI_LOGAN_ENC_GOP_PARAMS_G0_NUM_REF_POC_L1 "g0refPocL1"
1124 #define NI_LOGAN_ENC_GOP_PARAMS_G0_TEMPORAL_ID "g0temporalId"
1125 
1126 #define NI_LOGAN_ENC_GOP_PARAMS_G1_PIC_TYPE "g1picType"
1127 #define NI_LOGAN_ENC_GOP_PARAMS_G1_POC_OFFSET "g1pocOffset"
1128 #define NI_LOGAN_ENC_GOP_PARAMS_G1_PIC_QP "g1picQp"
1129 #define NI_LOGAN_ENC_GOP_PARAMS_G1_NUM_REF_PIC_L0 "g1numRefPicL0"
1130 #define NI_LOGAN_ENC_GOP_PARAMS_G1_NUM_REF_POC_L0 "g1refPocL0"
1131 #define NI_LOGAN_ENC_GOP_PARAMS_G1_NUM_REF_POC_L1 "g1refPocL1"
1132 #define NI_LOGAN_ENC_GOP_PARAMS_G1_TEMPORAL_ID "g1temporalId"
1133 
1134 #define NI_LOGAN_ENC_GOP_PARAMS_G2_PIC_TYPE "g2picType"
1135 #define NI_LOGAN_ENC_GOP_PARAMS_G2_POC_OFFSET "g2pocOffset"
1136 #define NI_LOGAN_ENC_GOP_PARAMS_G2_PIC_QP "g2picQp"
1137 #define NI_LOGAN_ENC_GOP_PARAMS_G2_NUM_REF_PIC_L0 "g2numRefPicL0"
1138 #define NI_LOGAN_ENC_GOP_PARAMS_G2_NUM_REF_POC_L0 "g2refPocL0"
1139 #define NI_LOGAN_ENC_GOP_PARAMS_G2_NUM_REF_POC_L1 "g2refPocL1"
1140 #define NI_LOGAN_ENC_GOP_PARAMS_G2_TEMPORAL_ID "g2temporalId"
1141 
1142 #define NI_LOGAN_ENC_GOP_PARAMS_G3_PIC_TYPE "g3picType"
1143 #define NI_LOGAN_ENC_GOP_PARAMS_G3_POC_OFFSET "g3pocOffset"
1144 #define NI_LOGAN_ENC_GOP_PARAMS_G3_PIC_QP "g3picQp"
1145 #define NI_LOGAN_ENC_GOP_PARAMS_G3_NUM_REF_PIC_L0 "g3numRefPicL0"
1146 #define NI_LOGAN_ENC_GOP_PARAMS_G3_NUM_REF_POC_L0 "g3refPocL0"
1147 #define NI_LOGAN_ENC_GOP_PARAMS_G3_NUM_REF_POC_L1 "g3refPocL1"
1148 #define NI_LOGAN_ENC_GOP_PARAMS_G3_TEMPORAL_ID "g3temporalId"
1149 
1150 #define NI_LOGAN_ENC_GOP_PARAMS_G4_PIC_TYPE "g4picType"
1151 #define NI_LOGAN_ENC_GOP_PARAMS_G4_POC_OFFSET "g4pocOffset"
1152 #define NI_LOGAN_ENC_GOP_PARAMS_G4_PIC_QP "g4picQp"
1153 #define NI_LOGAN_ENC_GOP_PARAMS_G4_NUM_REF_PIC_L0 "g4numRefPicL0"
1154 #define NI_LOGAN_ENC_GOP_PARAMS_G4_NUM_REF_POC_L0 "g4refPocL0"
1155 #define NI_LOGAN_ENC_GOP_PARAMS_G4_NUM_REF_POC_L1 "g4refPocL1"
1156 #define NI_LOGAN_ENC_GOP_PARAMS_G4_TEMPORAL_ID "g4temporalId"
1157 
1158 #define NI_LOGAN_ENC_GOP_PARAMS_G5_PIC_TYPE "g5picType"
1159 #define NI_LOGAN_ENC_GOP_PARAMS_G5_POC_OFFSET "g5pocOffset"
1160 #define NI_LOGAN_ENC_GOP_PARAMS_G5_PIC_QP "g5picQp"
1161 #define NI_LOGAN_ENC_GOP_PARAMS_G5_NUM_REF_PIC_L0 "g5numRefPicL0"
1162 #define NI_LOGAN_ENC_GOP_PARAMS_G5_NUM_REF_POC_L0 "g5refPocL0"
1163 #define NI_LOGAN_ENC_GOP_PARAMS_G5_NUM_REF_POC_L1 "g5refPocL1"
1164 #define NI_LOGAN_ENC_GOP_PARAMS_G5_TEMPORAL_ID "g5temporalId"
1165 
1166 #define NI_LOGAN_ENC_GOP_PARAMS_G6_PIC_TYPE "g6picType"
1167 #define NI_LOGAN_ENC_GOP_PARAMS_G6_POC_OFFSET "g6pocOffset"
1168 #define NI_LOGAN_ENC_GOP_PARAMS_G6_PIC_QP "g6picQp"
1169 #define NI_LOGAN_ENC_GOP_PARAMS_G6_NUM_REF_PIC_L0 "g6numRefPicL0"
1170 #define NI_LOGAN_ENC_GOP_PARAMS_G6_NUM_REF_POC_L0 "g6refPocL0"
1171 #define NI_LOGAN_ENC_GOP_PARAMS_G6_NUM_REF_POC_L1 "g6refPocL1"
1172 #define NI_LOGAN_ENC_GOP_PARAMS_G6_TEMPORAL_ID "g6temporalId"
1173 
1174 #define NI_LOGAN_ENC_GOP_PARAMS_G7_PIC_TYPE "g7picType"
1175 #define NI_LOGAN_ENC_GOP_PARAMS_G7_POC_OFFSET "g7pocOffset"
1176 #define NI_LOGAN_ENC_GOP_PARAMS_G7_PIC_QP "g7picQp"
1177 #define NI_LOGAN_ENC_GOP_PARAMS_G7_NUM_REF_PIC_L0 "g7numRefPicL0"
1178 #define NI_LOGAN_ENC_GOP_PARAMS_G7_NUM_REF_POC_L0 "g7refPocL0"
1179 #define NI_LOGAN_ENC_GOP_PARAMS_G7_NUM_REF_POC_L1 "g7refPocL1"
1180 #define NI_LOGAN_ENC_GOP_PARAMS_G7_TEMPORAL_ID "g7temporalId"
1181 
1182 typedef struct _ni_logan_gop_params
1183 {
1184  int pic_type; /*!*< A picture type of Nth picture in the custom GOP */
1185  int poc_offset; /*!*< A POC of Nth picture in the custom GOP */
1186  int pic_qp; /*!*< A quantization parameter of Nth picture in the custom GOP */
1187  int num_ref_pic_L0; /*!*< The number of reference L0 of Nth picture in the custom GOP */
1188  int ref_poc_L0; /*!*< A POC of reference L0 of Nth picture in the custom GOP */
1189  int ref_poc_L1; /*!*< A POC of reference L1 of Nth picture in the custom GOP */
1190  int temporal_id; /*!*< A temporal ID of Nth picture in the custom GOP */
1192 
1193 #define NI_LOGAN_ENC_GOP_PARAMS_CUSTOM_GOP_SIZE "customGopSize"
1194 
1196 {
1197  int custom_gop_size; /*!*< The size of custom GOP (0~8) */
1198  ni_logan_gop_params_t pic_param[NI_LOGAN_MAX_GOP_NUM]; /*!*< Picture parameters of Nth picture in custom GOP */
1200 
1201 #define NI_LOGAN_ENC_REPEAT_HEADERS_FIRST_IDR 0
1202 #define NI_LOGAN_ENC_REPEAT_HEADERS_ALL_KEY_FRAMES 1 // repeat headers for all I frames and intra refreshed key frames
1203 #define NI_LOGAN_ENC_REPEAT_HEADERS_ALL_I_FRAMES 2 // repeat headers for all I frames
1204 
1205 //ni_logan_h265_encoder_params defs
1206 #define NI_LOGAN_ENC_PARAM_BITRATE "bitrate"
1207 #define NI_LOGAN_ENC_PARAM_RECONF_DEMO_MODE "ReconfDemoMode"
1208 #define NI_LOGAN_ENC_PARAM_RECONF_FILE "ReconfFile"
1209 #define NI_LOGAN_ENC_PARAM_ROI_DEMO_MODE "RoiDemoMode"
1210 #define NI_LOGAN_ENC_PARAM_CACHE_ROI "cacheRoi"
1211 #define NI_LOGAN_ENC_PARAM_FORCE_PIC_QP_DEMO_MODE "ForcePicQpDemoMode"
1212 #define NI_LOGAN_ENC_PARAM_GEN_HDRS "GenHdrs"
1213 #define NI_LOGAN_ENC_PARAM_PADDING "padding"
1214 #define NI_LOGAN_ENC_PARAM_FORCE_FRAME_TYPE "forceFrameType"
1215 #define NI_LOGAN_ENC_PARAM_PROFILE "profile"
1216 #define NI_LOGAN_ENC_PARAM_LEVEL "level"
1217 #define NI_LOGAN_ENC_PARAM_HIGH_TIER "high-tier"
1218 #define NI_LOGAN_ENC_PARAM_LOG_LEVEL "log-level"
1219 #define NI_LOGAN_ENC_PARAM_LOG "log"
1220 #define NI_LOGAN_ENC_PARAM_GOP_PRESET_IDX "gopPresetIdx"
1221 #define NI_LOGAN_ENC_PARAM_LOW_DELAY "lowDelay"
1222 #define NI_LOGAN_ENC_PARAM_USE_RECOMMENDED_ENC_PARAMS "useRecommendEncParam"
1223 #define NI_LOGAN_ENC_PARAM_USE_LOW_DELAY_POC_TYPE "useLowDelayPocType"
1224 #define NI_LOGAN_ENC_PARAM_ENABLE_RATE_CONTROL "RcEnable"
1225 #define NI_LOGAN_ENC_PARAM_ENABLE_CU_LEVEL_RATE_CONTROL "cuLevelRCEnable"
1226 #define NI_LOGAN_ENC_PARAM_ENABLE_HVS_QP "hvsQPEnable"
1227 #define NI_LOGAN_ENC_PARAM_ENABLE_HVS_QP_SCALE "hvsQpScaleEnable"
1228 #define NI_LOGAN_ENC_PARAM_HVS_QP_SCALE "hvsQpScale"
1229 #define NI_LOGAN_ENC_PARAM_MIN_QP "minQp"
1230 #define NI_LOGAN_ENC_PARAM_MAX_QP "maxQp"
1231 #define NI_LOGAN_ENC_PARAM_MAX_DELTA_QP "maxDeltaQp"
1232 #define NI_LOGAN_ENC_PARAM_RC_INIT_DELAY "RcInitDelay"
1233 #define NI_LOGAN_ENC_PARAM_FORCED_HEADER_ENABLE "repeatHeaders"
1234 #define NI_LOGAN_ENC_PARAM_ROI_ENABLE "roiEnable"
1235 #define NI_LOGAN_ENC_PARAM_CONF_WIN_TOP "confWinTop"
1236 #define NI_LOGAN_ENC_PARAM_CONF_WIN_BOTTOM "confWinBot"
1237 #define NI_LOGAN_ENC_PARAM_CONF_WIN_LEFT "confWinLeft"
1238 #define NI_LOGAN_ENC_PARAM_CONF_WIN_RIGHT "confWinRight"
1239 #define NI_LOGAN_ENC_PARAM_INTRA_PERIOD "intraPeriod"
1240 #define NI_LOGAN_ENC_PARAM_TRANS_RATE "transRate"
1241 #define NI_LOGAN_ENC_PARAM_FRAME_RATE "frameRate"
1242 #define NI_LOGAN_ENC_PARAM_FRAME_RATE_DENOM "frameRateDenom"
1243 #define NI_LOGAN_ENC_PARAM_INTRA_QP "intraQP"
1244 #define NI_LOGAN_ENC_PARAM_DECODING_REFRESH_TYPE "decodingRefreshType"
1245 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_RESET "intraRefreshResetOnForceIDR"
1246 #define NI_LOGAN_ENC_PARAM_CHROMA_QP_OffSET "chromaQpOffset"
1247 // only for HEVC
1248 #define NI_LOGAN_ENC_PARAM_MAX_FRAME_SIZE "maxFrameSize"
1249 #define NI_LOGAN_ENC_PARAM_MAX_FRAME_SIZE_BITS "maxFrameSize-Bits"
1250 #define NI_LOGAN_ENC_PARAM_MAX_FRAME_SIZE_BYTES "maxFrameSize-Bytes"
1251 
1252 // Rev. B: H.264 only parameters.
1253 #define NI_LOGAN_ENC_PARAM_ENABLE_8X8_TRANSFORM "transform8x8Enable"
1254 #define NI_LOGAN_ENC_PARAM_AVC_SLICE_MODE "avcSliceMode"
1255 #define NI_LOGAN_ENC_PARAM_AVC_SLICE_ARG "avcSliceArg"
1256 #define NI_LOGAN_ENC_PARAM_ENTROPY_CODING_MODE "entropyCodingMode"
1257 #define NI_LOGAN_ENC_PARAM_INTRA_MB_REFRESH_MODE "intraMbRefreshMode"
1258 #define NI_LOGAN_ENC_PARAM_INTRA_MB_REFRESH_ARG "intraMbRefreshArg"
1259 // Rev. B: shared between HEVC and H.264
1260 #define NI_LOGAN_ENC_PARAM_SLICE_MODE "sliceMode"
1261 #define NI_LOGAN_ENC_PARAM_SLICE_ARG "sliceArg"
1262 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_MODE "intraRefreshMode"
1263 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_ARG "intraRefreshArg"
1264 // TBD Rev. B: could be shared for HEVC and H.264
1265 #define NI_LOGAN_ENC_PARAM_ENABLE_MB_LEVEL_RC "mbLevelRcEnable"
1266 #define NI_LOGAN_ENC_PARAM_PREFERRED_TRANSFER_CHARACTERISTICS "prefTRC"
1267 // HRD and AUD features related
1268 #define NI_LOGAN_ENC_PARAM_DOLBY_VISION_PROFILE "dolbyVisionProfile"
1269 #define NI_LOGAN_ENC_PARAM_HRD_ENABLE "hrdEnable"
1270 #define NI_LOGAN_ENC_PARAM_ENABLE_AUD "enableAUD"
1271 #define NI_LOGAN_ENC_PARAM_CRF "crf"
1272 #define NI_LOGAN_ENC_PARAM_CRF_IP_RATIO "ipRatio"
1273 #define NI_LOGAN_ENC_PARAM_CRF_PB_RATIO "pbRatio"
1274 #define NI_LOGAN_ENC_PARAM_CBR "cbr"
1275 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_MIN_PERIOD "intraRefreshMinPeriod"
1276 #define NI_LOGAN_ENC_PARAM_LONG_TERM_REFERENCE_ENABLE "longTermReferenceEnable"
1277 // stricter timeout detection enable
1278 #define NI_LOGAN_ENC_PARAM_STRICT_TIMEOUT_MODE "strictTimeout"
1279 #define NI_LOGAN_ENC_PARAM_LOSSLESS_ENABLE "losslessEnable"
1280 #define NI_LOGAN_ENC_PARAM_FLUSH_GOP "flushGop"
1281 // stream color info
1282 #define NI_LOGAN_ENC_PARAM_COLOR_PRIMARY "colorPri"
1283 #define NI_LOGAN_ENC_PARAM_COLOR_TRANSFER_CHARACTERISTIC "colorTrc"
1284 #define NI_LOGAN_ENC_PARAM_COLOR_SPACE "colorSpc"
1285 // sample aspect ratio specified in numerator/denominator
1286 #define NI_LOGAN_ENC_PARAM_SAR_NUM "sarNum"
1287 #define NI_LOGAN_ENC_PARAM_SAR_DENOM "sarDenom"
1288 // video_full_range_flag
1289 #define NI_LOGAN_ENC_PARAM_VIDEO_FULL_RANGE_FLAG "videoFullRangeFlag"
1290 // VFR related
1291 #define NI_LOGAN_ENC_PARAM_ENABLE_VFR "enableVFR"
1292 // HEVC explicit reference picture list
1293 #define NI_LOGAN_ENC_PARAM_ENABLE_EXPLICIT_RPL "enableExplicitRPL"
1294 // disable timing_info_preset_flag in VUI/VPS
1295 #define NI_LOGAN_ENC_PARAM_DISABLE_TIMING_INFO "disableTimingInfo"
1296 
1297 /* Decoder parameters */
1298 #define NI_LOGAN_DEC_PARAM_USR_DATA_SEI_PASSTHRU "enableUserDataSeiPassthru"
1299 #define NI_LOGAN_DEC_PARAM_CHECK_PACKET "checkPacket"
1300 #define NI_LOGAN_DEC_PARAM_CUSTOM_SEI_PASSTHRU "customSeiPassthru"
1301 #define NI_LOGAN_DEC_PARAM_LOW_DELAY "lowDelay"
1302 #define NI_LOGAN_DEC_PARAM_LOW_DELAY_MODE "lowDelayMode"
1303 #define NI_LOGAN_DEC_PARAM_ENABLE_FOLLOW_IFRAME "enableFollowIFrame"
1304 #define NI_LOGAN_DEC_PARAM_ENABLE_VUI_INFO_PASSTHRU "enableVuiInfoPassthru"
1305 #define NI_LOGAN_DEC_PARAM_ENABLE_SKIP_FMT_NONE_CHECK "enableSkipFmtNoneCheck"
1306 
1307 // data exchange save options
1308 #define NI_LOGAN_DEC_PARAM_SAVE_PKT "savePkt"
1309 
1310 /* General parameters */
1311 #define NI_LOGAN_SET_HIGH_PRIORITY "setHighPriority"
1312 #define NI_LOGAN_KEEP_ALIVE_TIMEOUT "keepAliveTimeout"
1313 
1315 {
1316  int profile;
1322  //GOP Pattern
1323  int gop_preset_index; /*!*< A GOP structure preset option (IPP, IBP, IBBP, IbBbP, use Custom GOP, etc)
1324  0-custom 1-I-only 2-IPPP 3-IBBB 4-IBP ..... */
1325 
1326  // CUSTOM_GOP
1328 
1329  //Preset Mode
1330  int use_recommend_enc_params; /*!*< 0: Custom, 1: Slow speed and best quality,
1331  2: Normal Speed and quality, 3: Fast Speed and Low Quality */
1332 
1333  //Encode Options
1334 
1335  struct
1336  {
1337  //Rate control parameters
1338  int enable_rate_control; /*!*< It enable rate control */
1339  int enable_cu_level_rate_control; /*!*< It enable CU level rate control */
1340  int enable_hvs_qp; /*!*< It enable CU QP adjustment for subjective quality enhancement */
1341  int enable_hvs_qp_scale; /*!*< It enable QP scaling factor for CU QP adjustment when enable_hvs_qp = 1 */
1342  int hvs_qp_scale; /*!*< A QP scaling factor for CU QP adjustment when hvcQpenable = 1 */
1343  int min_qp; /*!*< A minimum QP for rate control */ //8
1344  int max_qp; /*!*< A maximum QP for rate control */ //51
1345  int max_delta_qp; /*!*< A maximum delta QP for rate control */ //10
1346  int trans_rate; /*!*< trans_rate */
1349 
1350  int max_frame_size; /*!*< limiting max frame in bits */
1351  int max_frame_ratio; /*!*< limiting max frame in ratio * avg_pic_size */
1352 
1353  // TBD Rev. B: could be shared for HEVC and H.264 ?
1355  } rc;
1356 
1358 
1360 
1362 
1364 
1365  //ConformanceWindowOffsets
1366  int conf_win_top; /*!*< A conformance window size of TOP */
1367  int conf_win_bottom; /*!*< A conformance window size of BOTTOM */
1368  int conf_win_left; /*!*< A conformance window size of LEFT */
1369  int conf_win_right; /*!*< A conformance window size of RIGHT */
1370 
1373 
1374  // Rev. B: H.264 only parameters, in ni_logan_t408_config_t
1375  // - for H.264 on T408:
1380 
1381  // - shared between HEVC and H.264
1386  // HLG preferred transfer characteristics
1388 
1390 
1391 typedef struct _ni_logan_frame
1392 {
1393  // codec of the source from which this frame is decoded
1395  long long dts;
1396  long long pts;
1397  uint32_t end_of_stream;
1399  uint32_t video_width;
1400  uint32_t video_height;
1403 
1404  uint32_t crop_top;
1405  uint32_t crop_bottom;
1406  uint32_t crop_left;
1407  uint32_t crop_right;
1408 
1409  // for encoder: force headers on this frame
1410  uint16_t force_headers;
1411  // for encoder: control long term reference picture feature
1414 
1416  // for encoding: frame picture type sent to encoder
1417  // for decoding: frame picture type returned from decoder
1419  // total SEI size: used by encoder
1420  unsigned int sei_total_len;
1421 
1422  // SEI info of closed caption: returned by decoder or set by encoder
1423  unsigned int sei_cc_offset;
1424  unsigned int sei_cc_len;
1425  // SEI info of HDR: returned by decoder
1430  // SEI info of HDR10+: returned by decoder
1431  unsigned int sei_hdr_plus_offset;
1432  unsigned int sei_hdr_plus_len;
1433  // SEI info of User Data Unregistered SEI: returned by decoder
1436  // SEI info of alternative transfer characteristics: returned by decoder
1439  // VUI info: returned by decoder
1440  unsigned int vui_offset;
1441  unsigned int vui_len;
1442 
1443  // ROI data length: for encoder
1444  unsigned int roi_len;
1445  // reconfig data length: for encoder
1446  unsigned int reconf_len;
1447  // total extra data data length: for encoder
1448  unsigned int extra_data_len;
1449  // force pic qp value
1450  uint16_t force_pic_qp;
1451  // frame chunk index
1453 
1456 
1457  void* p_buffer;
1458  uint32_t buffer_size;
1459 
1460  ni_logan_buf_t *dec_buf; // buffer pool entry (has memory pointed to by p_buffer)
1462 
1463  uint8_t *p_custom_sei;
1464  uint16_t bit_depth;
1465  int flags;
1466 
1467  // frame auxiliary data
1470 
1471  // the following info is of the source stream that is returned by decoder:
1472  // color info, sample aspect ratio, timing etc that are useful at encoding.
1474  uint8_t color_trc;
1475  uint8_t color_space;
1478  uint16_t sar_width;
1479  uint16_t sar_height;
1481  uint32_t vui_time_scale;
1482  // for encoder: whether metadata should be sent separately for frame
1485 
1487 {
1488  int log;
1489  int preset;
1491  uint32_t fps_number;
1493 
1498 
1503  int bitrate;
1504  int roi_demo_mode; // demo ROI support - for internal testing
1505  int reconf_demo_mode; // NETINT_INTERNAL - currently only for internal testing
1506  int force_pic_qp_demo_mode; // demo force pic qp mode - for internal testing
1507  int low_delay_mode; // encoder low latency mode
1508  int padding; // encoder input padding setting
1509  int generate_enc_hdrs; // generate encoder headers in advance of encoding
1510  int use_low_delay_poc_type; // specifies the encoder to set
1511  // picture_order_count_type=2 in the H.264 SPS
1512  int strict_timeout_mode; // encoder stricter timeout detection mode
1513 
1514  // HRD and AUD features related
1518 
1519  // 1: force on every frame with same input type; 0: no (except for I-frame)
1521  int intra_refresh_reset; // reset intra refresh on force IDR frame
1522 
1525 
1526  float crf; /*!*< Constant Rate Factor setting */
1527  float crfIpRatio;
1528  float crfPbRatio;
1529  int cbr; //It enables filler data for strict rate control
1530  int cacheRoi; // enables caching of ROIs applied to subsequent frames
1531  int enable_vfr; // enable the vfr
1532  int enable_explicit_rpl; // enable HEVC reference picture list
1533  int disable_timing_info; // disable timing_info_preset_flag in VPS/VUI
1535 
1536  uint32_t ui32flushGop;
1544  uint32_t pos_time_scale;
1545 
1549  int sar_num;
1552 
1554 
1555  // NETINT_INTERNAL - currently only for internal testing of reconfig, saving
1556  // key:val1,val2,val3,...val9 (max 9 values) in the demo reconfig data file
1557  // this supports max 100 lines in reconfig file, max 10 key/values per line
1558  int reconf_hash[100][10];
1559 
1560  // NETINT INTERNAL - save exchanged data between host and fw; the data is
1561  // saved in a circular buffer by packets in a folder uniquely identified
1562  // by process id and session id; 0 is to not save.
1563  unsigned int nb_save_pkt; // number of decoder-in packets to save
1564 
1565  uint8_t hwframes;
1567 
1568  int32_t chromaQpOffset; /*!*< The value of chroma QP offset */
1570 
1571 //ni_logan_decoder_input_params defs
1572 #define NI_LOGAN_DEC_PARAM_OUT "out"
1573 
1575 {
1588 
1590 {
1591  int log;
1592 
1594  uint32_t fps_number;
1596 
1601 
1606  int bitrate;
1607 
1609 
1610  // NETINT INTERNAL - save exchanged data between host and fw; the data is
1611  // saved in a circular buffer by packets in a folder uniquely identified
1612  // by process id and session id; 0 is to not save.
1613  unsigned int nb_save_pkt; // number of decoder-in packets to save
1614 
1615  uint8_t hwframes;
1617 
1618 typedef struct _ni_logan_packet
1619 {
1620 
1621  long long dts;
1622  long long pts;
1623  long long pos;
1624  uint32_t end_of_stream;
1626  uint32_t video_width;
1627  uint32_t video_height;
1628  uint32_t frame_type; // encoding result only 0=I, 1=P, 2=B, 5=IDR, 6=CRA
1630 
1631  void* p_data;
1632  uint32_t data_len;
1634 
1635  void* p_buffer;
1636  uint32_t buffer_size;
1637  uint32_t avg_frame_qp; // average frame QP reported by VPU
1638 
1640  //The length of SEI data which is located after slice payload in the same packet.
1641  //Skip these SEI data when send the packet to the FW
1643  int flags;
1645 
1646 // 24 bytes
1648 {
1649  int32_t device_handle;
1650 
1651  int8_t i8FrameIdx;
1652  int8_t i8InstID;
1653  uint16_t ui16SessionID;
1654 
1655  uint16_t ui16width;
1656  uint16_t ui16height;
1657 
1658  int8_t bit_depth; //1 ==8bit per pixel, 2 ==10
1659  int8_t encoding_type; //h264/265
1660  int8_t seq_change;
1661  int8_t rsvd;
1662  int32_t device_handle_ext; // high 32-bit device handle
1663  int32_t dma_buf_fd;
1665 
1667 {
1668  union
1669  {
1673 
1675 
1676 
1677 
1678 #define NI_LOGAN_XCODER_PRESET_NAMES_ARRAY_LEN 3
1679 #define NI_LOGAN_XCODER_LOG_NAMES_ARRAY_LEN 7
1680 
1681 #define NI_LOGAN_XCODER_PRESET_NAME_DEFAULT "default"
1682 #define NI_LOGAN_XCODER_PRESET_NAME_CUSTOM "custom"
1683 
1684 #define NI_LOGAN_XCODER_LOG_NAME_NONE "none"
1685 #define NI_LOGAN_XCODER_LOG_NAME_ERROR "error"
1686 #define NI_LOGAN_XCODER_LOG_NAME_WARN "warning"
1687 #define NI_LOGAN_XCODER_LOG_NAME_INFO "info"
1688 #define NI_LOGAN_XCODER_LOG_NAME_DEBUG "debug"
1689 #define NI_LOGAN_XCODER_LOG_NAME_FULL "full"
1690 
1692 extern LIB_API const char* const g_logan_xcoder_log_names[NI_LOGAN_XCODER_LOG_NAMES_ARRAY_LEN];
1693 
1694 /*!*****************************************************************************
1695  * \brief Convert error numver into error messages
1696  *
1697  *
1698  * \return the string of error message
1699  ******************************************************************************/
1700 LIB_API const char* ni_logan_err2str(int err);
1701 
1702 /*!*****************************************************************************
1703  * \brief Allocate and initialize a new ni_logan_session_context_t struct
1704  *
1705  *
1706  * \return On success returns a valid pointer to newly allocated context
1707  * On failure returns NULL
1708  ******************************************************************************/
1710 
1711 /*!*****************************************************************************
1712  * \brief Initialize already allocated session context to a known state
1713  *
1714  * \param[in] p_ctx Pointer to an already allocated ni_logan_session_context_t struct
1715  *
1716  *
1717  ******************************************************************************/
1719 
1720 /*!****************************************************************************
1721  * \brief Frees previously allocated session context
1722  *
1723  * \param[in] p_ctx Pointer to an already allocated ni_logan_session_context_t struct
1724  *
1725  ******************************************************************************/
1727 
1728 /*!******************************************************************************
1729  * \brief Clear already allocated session context to all zeros buffer
1730  *
1731  * \param[in] p_ctx Pointer to an already allocated ni_logan_session_context_t struct
1732  *
1733  *
1734  *******************************************************************************/
1736 
1737 /*!****************************************************************************
1738  * \brief Create event and returnes event handle if successful
1739  *
1740  * \return On success returns a event handle
1741  * On failure returns NI_INVALID_EVENT_HANDLE
1742  *****************************************************************************/
1743 LIB_API ni_event_handle_t ni_logan_create_event();
1744 
1745 /*!****************************************************************************
1746  * \brief Closes event and releases resources
1747  *
1748  * \return NONE
1749  *
1750  ******************************************************************************/
1751 LIB_API void ni_logan_close_event(ni_event_handle_t event_handle);
1752 
1753 /*!*****************************************************************************
1754  * \brief Opens device and returnes device device_handle if successful
1755  *
1756  * \param[in] p_dev Device name represented as c string. ex: "/dev/nvme0"
1757  * \param[out] p_max_io_size_out Maximum IO Transfer size supported
1758  *
1759  * \return On success returns a device device_handle
1760  * On failure returns NI_INVALID_DEVICE_HANDLE
1761  ******************************************************************************/
1762 LIB_API ni_device_handle_t ni_logan_device_open(const char* dev, uint32_t * p_max_io_size_out);
1763 
1764 /*!*****************************************************************************
1765  * \brief Closes device and releases resources
1766  *
1767  * \param[in] device_handle Device handle obtained by calling ni_logan_device_open()
1768  *
1769  * \return NONE
1770  *
1771  ******************************************************************************/
1772 LIB_API void ni_logan_device_close(ni_device_handle_t dev);
1773 
1774 /*!*****************************************************************************
1775  * \brief Queries device and returns device capability structure
1776  *
1777  * \param[in] device_handle Device handle obtained by calling ni_logan_device_open()
1778  * \param[in] p_cap Pointer to a caller allocated ni_logan_device_capability_t struct
1779  * \return On success
1780  * NI_LOGAN_RETCODE_SUCCESS
1781  * On failure
1782  NI_LOGAN_RETCODE_INVALID_PARAM
1783  NI_LOGAN_RETCODE_ERROR_MEM_ALOC
1784  NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1785  ******************************************************************************/
1786 LIB_API ni_logan_retcode_t ni_logan_device_capability_query(ni_device_handle_t device_handle,
1788 
1789 /*!*****************************************************************************
1790  * \brief Opens a new device session depending on the device_type parameter
1791  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER opens decoding session
1792  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER opens encoding session
1793  *
1794  * \param[in] p_ctx Pointer to a caller allocated
1795  * ni_logan_session_context_t struct
1796  * ni_logan_session_config_t struct
1797  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1798  * \return On success
1799  * NI_LOGAN_RETCODE_SUCCESS
1800  * On failure
1801  * NI_LOGAN_RETCODE_INVALID_PARAM
1802  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
1803  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1804  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1805  ******************************************************************************/
1807  ni_logan_device_type_t device_type);
1808 
1809 /*!*****************************************************************************
1810  * \brief Closes device session that was previously opened by calling
1811  * ni_logan_device_session_open()
1812  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER closes decoding session
1813  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER closes encoding session
1814  *
1815  * \param[in] p_ctx Pointer to a caller allocated
1816  * ni_logan_session_context_t struct
1817  * \param[in] eos_recieved Flag indicating if End Of Stream indicator was recieved
1818  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1819  * \return On success
1820  * NI_LOGAN_RETCODE_SUCCESS
1821  * On failure
1822  * NI_LOGAN_RETCODE_INVALID_PARAM
1823  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1824  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1825  ******************************************************************************/
1827  int eos_recieved,
1828  ni_logan_device_type_t device_type);
1829 
1830 /*!*****************************************************************************
1831  * \brief Sends a flush command to the device
1832  * ni_logan_device_session_open()
1833  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER sends flush command to decoder
1834  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER sends flush command to decoder
1835  *
1836  * \param[in] p_ctx Pointer to a caller allocated
1837  * ni_logan_session_context_t struct
1838  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1839  * \return On success
1840  * NI_LOGAN_RETCODE_SUCCESS
1841  * On failure
1842  * NI_LOGAN_RETCODE_INVALID_PARAM
1843  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1844  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1845  ******************************************************************************/
1847  ni_logan_device_type_t device_type);
1848 
1849 /*!*****************************************************************************
1850  * \brief Sends a flush command to the decoder
1851  * ni_logan_device_session_open()
1852  *
1853  * \param[in] p_ctx Pointer to a caller allocated
1854  * ni_logan_session_context_t struct
1855  * \return On success
1856  * NI_LOGAN_RETCODE_SUCCESS
1857  * On failure
1858  * NI_LOGAN_RETCODE_INVALID_PARAM
1859  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1860  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1861  ******************************************************************************/
1863 
1864 /*!*****************************************************************************
1865  * \brief Save a stream's headers in a decoder session that can be used later
1866  * for continuous decoding from the same source.
1867  *
1868  * \param[in] p_ctx Pointer to a caller allocated
1869  * ni_logan_session_context_t struct
1870  * \param[in] hdr_data Pointer to header data
1871  * \param[in] hdr_size Size of header data in bytes
1872  * \return On success
1873  * NI_LOGAN_RETCODE_SUCCESS
1874  * On failure
1875  * NI_LOGAN_RETCODE_INVALID_PARAM
1876  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1877  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1878  ******************************************************************************/
1880  ni_logan_session_context_t *p_ctx, uint8_t *hdr_data, uint8_t hdr_size);
1881 
1882 /*!*****************************************************************************
1883  * \brief Flush a decoder session to get ready to continue decoding.
1884  * Note: this is different from ni_logan_device_session_flush in that it closes the
1885  * current decode session and opens a new one for continuous decoding.
1886  *
1887  * \param[in] p_ctx Pointer to a caller allocated
1888  * ni_logan_session_context_t struct
1889  * \return On success
1890  * NI_LOGAN_RETCODE_SUCCESS
1891  * On failure
1892  * NI_LOGAN_RETCODE_INVALID_PARAM
1893  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1894  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1895  ******************************************************************************/
1897 
1898 /*!*****************************************************************************
1899  * \brief Sends data the device
1900  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER sends data packet to decoder
1901  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER sends data frame to encoder
1902  *
1903  * \param[in] p_ctx Pointer to a caller allocated
1904  * ni_logan_session_context_t struct
1905  * \param[in] p_data Pointer to a caller allocated
1906  * ni_logan_session_data_io_t struct which contains either a
1907  * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
1908  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1909  * If NI_LOGAN_DEVICE_TYPE_DECODER is specified, it is expected
1910  * that the ni_logan_packet_t struct inside the p_data pointer
1911  * contains data to send.
1912  * If NI_LOGAN_DEVICE_TYPE_ENCODER is specified, it is expected
1913  * that the ni_logan_frame_t struct inside the p_data pointer
1914  * contains data to send.
1915  * \return On success
1916  * Total number of bytes written
1917  * On failure
1918  * NI_LOGAN_RETCODE_INVALID_PARAM
1919  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1920  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1921  ******************************************************************************/
1924  ni_logan_device_type_t device_type);
1925 
1926 /*!*****************************************************************************
1927  * \brief Reads data the device
1928  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER reads data packet from decoder
1929  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER reads data frame from encoder
1930  *
1931  * \param[in] p_ctx Pointer to a caller allocated
1932  * ni_logan_session_context_t struct
1933  * \param[in] p_data Pointer to a caller allocated
1934  * ni_logan_session_data_io_t struct which contains either a
1935  * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
1936  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1937  * If NI_LOGAN_DEVICE_TYPE_DECODER is specified, data that was
1938  * read will be placed into ni_logan_frame_t struct inside the p_data pointer
1939  * If NI_LOGAN_DEVICE_TYPE_ENCODER is specified, data that was
1940  * read will be placed into ni_logan_packet_t struct inside the p_data pointer
1941  * \return On success
1942  * Total number of bytes read
1943  * On failure
1944  * NI_LOGAN_RETCODE_INVALID_PARAM
1945  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1946  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1947  ******************************************************************************/
1950  ni_logan_device_type_t device_type);
1951 
1952 /*!*****************************************************************************
1953  * \brief Query session data from the device - Currently not implemented
1954  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER query session data
1955  * from decoder
1956  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER query session data
1957  * from encoder
1958  *
1959  * \param[in] p_ctx Pointer to a caller allocated
1960  * ni_logan_session_context_t struct
1961  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1962  *
1963  * \return On success
1964  * NI_LOGAN_RETCODE_SUCCESS
1965  * On failure
1966  * NI_LOGAN_RETCODE_INVALID_PARAM
1967  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1968  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1969  ******************************************************************************/
1971  ni_logan_device_type_t device_type);
1972 
1973 /*!*****************************************************************************
1974  * \brief Allocate preliminary memory for the frame buffer for encoding
1975  * based on provided parameters. Applicable to YUV420 Planar pixel
1976  * format only, 8 or 10 bit/pixel.
1977  *
1978  * \param[in] p_frame Pointer to a caller allocated
1979  * ni_logan_frame_t struct
1980  * \param[in] video_width Width of the video frame
1981  * \param[in] video_height Height of the video frame
1982  * \param[in] alignment Allignment requirement
1983  * \param[in] metadata_flag Flag indicating if space for additional metadata
1984  * should be allocated
1985  * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel
1986  *
1987  * \return On success
1988  * NI_LOGAN_RETCODE_SUCCESS
1989  * On failure
1990  * NI_LOGAN_RETCODE_INVALID_PARAM
1991  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
1992  ******************************************************************************/
1994  int video_width,
1995  int video_height,
1996  int alignment,
1997  int metadata_flag,
1998  int factor,
1999  int hw_frame_count);
2000 
2001 /*!*****************************************************************************
2002  * \brief Allocate memory for decoder frame buffer based on provided
2003  * parameters; the memory is retrieved from a buffer pool and will be
2004  * returned to the same buffer pool by ni_logan_decoder_frame_buffer_free.
2005  * Note: all attributes of ni_logan_frame_t will be set up except for memory and
2006  * buffer, which rely on the pool being allocated; the pool will be
2007  * allocated only after the frame resolution is known.
2008  *
2009  * \param[in] p_pool Buffer pool to get the memory from
2010  * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2011  * \param[in] alloc_mem Whether to get memory from buffer pool
2012  * \param[in] video_width Width of the video frame
2013  * \param[in] video_height Height of the video frame
2014  * \param[in] alignment Allignment requirement
2015  * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel
2016  *
2017  * \return On success
2018  * NI_LOGAN_RETCODE_SUCCESS
2019  * On failure
2020  * NI_LOGAN_RETCODE_INVALID_PARAM
2021  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2022  ******************************************************************************/
2024  ni_logan_frame_t *pframe,
2025  int alloc_mem,
2026  int video_width,
2027  int video_height,
2028  int alignment,
2029  int factor);
2030 
2031 /*!*****************************************************************************
2032  * \brief Allocate memory for the frame buffer for encoding based on given
2033  * parameters, taking into account pic line size and extra data.
2034  * Applicable to YUV420p AVFrame only. 8 or 10 bit/pixel.
2035  * Cb/Cr size matches that of Y.
2036  *
2037  * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2038  *
2039  * \param[in] video_width Width of the video frame
2040  * \param[in] video_height Height of the video frame
2041  * \param[in] linesize Picture line size
2042  * \param[in] alignment Allignment requirement
2043  * \param[in] extra_len Extra data size (incl. meta data)
2044  *
2045  * \return On success
2046  * NI_LOGAN_RETCODE_SUCCESS
2047  * On failure
2048  * NI_LOGAN_RETCODE_INVALID_PARAM
2049  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2050  *****************************************************************************/
2052  int video_width,
2053  int video_height,
2054  int linesize[],
2055  int alignment,
2056  int extra_len,
2057  int factor);
2058 
2059 /*!*****************************************************************************
2060  * \brief Free frame buffer that was previously allocated with either
2061  * ni_logan_frame_buffer_alloc or ni_logan_encoder_frame_buffer_alloc
2062  *
2063  * \param[in] p_frame Pointer to a previously allocated ni_logan_frame_t struct
2064  *
2065  * \return On success NI_LOGAN_RETCODE_SUCCESS
2066  * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2067  ******************************************************************************/
2069 
2070 /*!*****************************************************************************
2071  * \brief Free decoder frame buffer that was previously allocated with
2072  * ni_logan_decoder_frame_buffer_alloc, returning memory to a buffer pool.
2073  *
2074  * \param[in] p_frame Pointer to a previously allocated ni_logan_frame_t struct
2075  *
2076  * \return On success NI_LOGAN_RETCODE_SUCCESS
2077  * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2078  ******************************************************************************/
2080 
2081 /*!*****************************************************************************
2082  * \brief Return a memory buffer to memory buffer pool, for a decoder frame.
2083  *
2084  * \param[in] buf Buffer to be returned.
2085  * \param[in] p_buffer_pool Buffer pool to return buffer to.
2086  *
2087  * \return None
2088  ******************************************************************************/
2090  ni_logan_buf_pool_t *p_buffer_pool);
2091 
2092 /*!*****************************************************************************
2093  * \brief Allocate memory for the packet buffer based on provided packet size
2094  *
2095  * \param[in] p_packet Pointer to a caller allocated
2096  * ni_logan_packet_t struct
2097  * \param[in] packet_size Required allocation size
2098  *
2099  * \return On success
2100  * NI_LOGAN_RETCODE_SUCCESS
2101  * On failure
2102  * NI_LOGAN_RETCODE_INVALID_PARAM
2103  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2104  ******************************************************************************/
2106  int packet_size);
2107 
2108 /*!*****************************************************************************
2109  * \brief Free packet buffer that was previously allocated with either
2110  * ni_logan_packet_buffer_alloc
2111  *
2112  * \param[in] p_packet Pointer to a previously allocated ni_logan_packet_t struct
2113  *
2114  * \return On success NI_LOGAN_RETCODE_SUCCESS
2115  * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2116  ******************************************************************************/
2118 
2119 /*!*****************************************************************************
2120  * \brief Copy video packet accounting for allighment
2121  *
2122  * \param[in] p_destination Destination to where to copy to
2123  * \param[in] p_source Source from where to copy from
2124  * \param[in] cur_size current size
2125  * \param[out] p_leftover Pointer to the data that was left over
2126  * \param[out] p_prev_size Size of the data leftover ??
2127  *
2128  * \return On success Total number of bytes that were copied
2129  * On failure NI_LOGAN_RETCODE_FAILURE
2130  ******************************************************************************/
2131 LIB_API int ni_logan_packet_copy(void* p_destination,
2132  const void* const p_source,
2133  int cur_size,
2134  void* p_leftover,
2135  int* p_prev_size);
2136 
2137 /*!*****************************************************************************
2138  * \brief Initialize default encoder parameters
2139  *
2140  * \param[out] param Pointer to a user allocated ni_logan_encoder_params_t
2141  * to initialize to default parameters
2142  * \param[in] fps_num Frames per second
2143  * \param[in] fps_denom FPS denomination
2144  * \param[in] bit_rate bit rate
2145  * \param[in] width width
2146  * \param[in] height height
2147  *
2148  * \return On success
2149  * NI_LOGAN_RETCODE_SUCCESS
2150  * On failure
2151  * NI_LOGAN_RETCODE_FAILURE
2152  * NI_LOGAN_RETCODE_INVALID_PARAM
2153  ******************************************************************************/
2155  int fps_num,
2156  int fps_denom,
2157  long bit_rate,
2158  int width,
2159  int height);
2160 
2161 
2162 /*!*****************************************************************************
2163  * \brief Initialize default decoder parameters
2164  *
2165  * \param[out] param Pointer to a user allocated ni_logan_decoder_params_t
2166  * to initialize to default parameters
2167  * \param[in] fps_num Frames per second
2168  * \param[in] fps_denom FPS denomination
2169  * \param[in] bit_rate bit rate
2170  * \param[in] width width
2171  * \param[in] height height
2172  *
2173  * \return On success
2174  * NI_LOGAN_RETCODE_SUCCESS
2175  * On failure
2176  * NI_LOGAN_RETCODE_FAILURE
2177  * NI_LOGAN_RETCODE_INVALID_PARAM
2178  ******************************************************************************/
2180  int fps_num,
2181  int fps_denom,
2182  long bit_rate,
2183  int width,
2184  int height);
2185 
2186 /*!******************************************************************************
2187 * \brief Set value referenced by name in decoder parameters structure
2188 *
2189 * \param[in] p_params Pointer to a user allocated ni_logan_decoder_params_t
2190 * to find and set a particular parameter
2191 * \param[in] name String represented parameter name to search
2192 * \param[in] value Parameter value to set
2193 *
2194 * \return On success
2195 * NI_LOGAN_RETCODE_SUCCESS
2196 * On failure
2197 * NI_LOGAN_RETCODE_FAILURE
2198 * NI_LOGAN_RETCODE_INVALID_PARAM
2199 *******************************************************************************/
2201  const char* name,
2202  char* value);
2203 
2204 /*!******************************************************************************
2205 * \brief Set value referenced by name in encoder parameters structure
2206 *
2207 * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2208 * to find and set a particular parameter
2209 * \param[in] name String represented parameter name to search
2210 * \param[in] value Parameter value to set
2211 *
2212 * \return On success
2213 * NI_LOGAN_RETCODE_SUCCESS
2214 * On failure
2215 * NI_LOGAN_RETCODE_FAILURE
2216 * NI_LOGAN_RETCODE_INVALID_PARAM
2217 ******************************************************************************/
2219  const char *name,
2220  const char *value,
2222 
2223 /*!*****************************************************************************
2224 * \brief Validate relationship of some params in encoder parameters structure
2225 *
2226 * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2227 * \param[in] codec encoding codec
2228 *
2229 * \return On success
2230 * NI_LOGAN_RETCODE_SUCCESS
2231 * On failure
2232 * NI_LOGAN_RETCODE_FAILURE
2233 * NI_LOGAN_RETCODE_PARAM_ERROR_OOR and other error rc
2234 *******************************************************************************/
2236  ni_logan_codec_format_t codec);
2237 
2238 
2239 /*!*****************************************************************************
2240  * \brief Set gop parameter value referenced by name in encoder parameters
2241  * structure
2242  *
2243  * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2244  * to find and set a particular parameter
2245  * \param[in] name String represented parameter name to search
2246  * \param[in] value Parameter value to set
2247 *
2248  * \return On success
2249  * NI_LOGAN_RETCODE_SUCCESS
2250  * On failure
2251  * NI_LOGAN_RETCODE_FAILURE
2252  * NI_LOGAN_RETCODE_INVALID_PARAM
2253  ******************************************************************************/
2255  const char *name,
2256  const char *value);
2257 
2258 /*!*****************************************************************************
2259  * \brief Get GOP's max number of reorder frames
2260  *
2261  * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2262  *
2263  * \return max number of reorder frames of the GOP
2264  ******************************************************************************/
2266 
2267 /*!*****************************************************************************
2268  * \brief Get GOP's number of reference frames
2269  *
2270  * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2271  *
2272  * \return number of reference frames of the GOP
2273  ******************************************************************************/
2275 
2276 /*!*****************************************************************************
2277  * \brief Add a new auxiliary data to a frame
2278  *
2279  * \param[in/out] frame a frame to which the auxiliary data should be added
2280  * \param[in] type type of the added auxiliary data
2281  * \param[in] data_size size of the added auxiliary data
2282  *
2283  * \return a pointer to the newly added aux data on success, NULL otherwise
2284  ******************************************************************************/
2286  ni_aux_data_type_t type,
2287  int data_size);
2288 
2289 /*!*****************************************************************************
2290  * \brief Add a new auxiliary data to a frame and copy in the raw data
2291  *
2292  * \param[in/out] frame a frame to which the auxiliary data should be added
2293  * \param[in] type type of the added auxiliary data
2294  * \param[in] raw_data the raw data of the aux data
2295  * \param[in] data_size size of the added auxiliary data
2296  *
2297  * \return a pointer to the newly added aux data on success, NULL otherwise
2298  ******************************************************************************/
2300  ni_logan_frame_t *frame,
2301  ni_aux_data_type_t type,
2302  const uint8_t* raw_data,
2303  int data_size);
2304 
2305 /*!*****************************************************************************
2306  * \brief Retrieve from the frame auxiliary data of a given type if exists
2307  *
2308  * \param[in] frame a frame from which the auxiliary data should be retrieved
2309  * \param[in] type type of the auxiliary data to be retrieved
2310  *
2311  * \return a pointer to the aux data of a given type on success, NULL otherwise
2312  ******************************************************************************/
2314  ni_aux_data_type_t type);
2315 
2316 /*!*****************************************************************************
2317  * \brief If auxiliary data of the given type exists in the frame, free it
2318  * and remove it from the frame.
2319  *
2320  * \param[in/out] frame a frame from which the auxiliary data should be removed
2321  * \param[in] type type of the auxiliary data to be removed
2322  *
2323  * \return None
2324  ******************************************************************************/
2326  ni_aux_data_type_t type);
2327 
2328 /*!*****************************************************************************
2329  * \brief Free and remove all auxiliary data from the frame.
2330  *
2331  * \param[in/out] frame a frame from which the auxiliary data should be removed
2332  *
2333  * \return None
2334  ******************************************************************************/
2335 LIB_API void ni_logan_frame_wipe_aux_data(ni_logan_frame_t *frame);
2336 
2337 /*!******************************************************************************
2338 * \brief Queries device Serial number
2339 *
2340 * \param[in] device_handle Device handle used to backtrace serial Num
2341 * \param[in] p_serial_num Pointer to a caller allocated ni_logan_serial_num_t struct
2342 * \return On success
2343 * NI_LOGAN_RETCODE_SUCCESS
2344 * On failure
2345 * NI_LOGAN_RETCODE_INVALID_PARAM
2346 * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2347 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2348 *******************************************************************************/
2349 LIB_API ni_logan_retcode_t ni_logan_device_handle_map_SN(ni_device_handle_t device_handle,
2350  ni_logan_serial_num_t *p_serial_num);
2351 
2352 /*!******************************************************************************
2353 * \brief Copies existing decoding session params for hw frame usage
2354 *
2355 * \param[in] src_p_ctx Pointer to a caller allocated source
2356 * ni_logan_session_context_t struct
2357 * \param[in] dst_p_ctx Pointer to a caller allocated destination
2358 * ni_logan_session_context_t struct
2359 * \return On success
2360 * NI_LOGAN_RETCODE_SUCCESS
2361 * On failure
2362 * NI_LOGAN_RETCODE_INVALID_PARAM
2363 * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2364 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2365 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2366 *******************************************************************************/
2368  ni_logan_session_context_t *dst_p_ctx);
2369 
2370 /*!******************************************************************************
2371 * \brief Sends frame pool setup info to device
2372 *
2373 * \param[in] p_ctx Pointer to a caller allocated
2374 * ni_logan_session_context_t struct
2375 * \param[in] p_data Pointer to a caller allocated
2376 * ni_logan_session_data_io_t struct which contains either a
2377 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2378 * \return On success Return code
2379 * On failure
2380 * NI_LOGAN_RETCODE_INVALID_PARAM
2381 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2382 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2383 *******************************************************************************/
2385  uint32_t pool_size, uint32_t p2p_pool);
2386 
2387 /*!******************************************************************************
2388 * \brief Reads data from the device
2389 * device_type should be NI_LOGAN_DEVICE_TYPE_DECODER,
2390 * and reads data hwdesc from decoder when hw transcoding
2391 *
2392 * \param[in] p_ctx Pointer to a caller allocated
2393 * ni_logan_session_context_t struct
2394 * \param[in] p_data Pointer to a caller allocated
2395 * ni_logan_session_data_io_t struct which contains either a
2396 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2397 * \return On success
2398 * Total number of bytes read
2399 * On failure
2400 * NI_LOGAN_RETCODE_INVALID_PARAM
2401 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2402 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2403 *******************************************************************************/
2405  ni_logan_session_data_io_t *p_data);
2406 
2407 /*!******************************************************************************
2408 * \brief Reads data from hw descriptor from decoder output buffer
2409 *
2410 * \param[in] p_data Pointer to a caller allocated
2411 * ni_logan_session_data_io_t struct which contains either a
2412 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2413 * \param[in] hwdesc HW descriptor to find frame in XCODER
2414 * \return On success
2415 * Total number of bytes read
2416 * On failure
2417 * NI_LOGAN_RETCODE_INVALID_PARAM
2418 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2419 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2420 *******************************************************************************/
2423  ni_logan_hwframe_surface_t* hwdesc);
2424 
2425 /*!******************************************************************************
2426 * \brief Writes data and reads back hw descriptor from decoder output buffer
2427 *
2428 * \param[in] p_src_data Pointer to a caller allocated
2429 * ni_logan_session_data_io_t struct which contains either a
2430 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2431 * \param[in] hwdesc HW descriptor to find frame in XCODER
2432 * \return On success
2433 * Total number of bytes read
2434 * On failure
2435 * NI_LOGAN_RETCODE_INVALID_PARAM
2436 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2437 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2438 *******************************************************************************/
2440  ni_logan_session_data_io_t *p_src_data,
2441  ni_logan_hwframe_surface_t* hwdesc);
2442 
2443 #ifndef _WIN32
2444  /*!*****************************************************************************
2445  * \brief Acquire a P2P frame buffer from the hwupload session
2446  *
2447  * \param[in] p_ctx Pointer to a caller allocated
2448  * ni_session_context_t struct
2449  * \param[out] p_frame Pointer to a caller allocated hw frame
2450  *
2451  * \return On success
2452  * NI_RETCODE_SUCCESS
2453  * On failure
2454  * NI_RETCODE_INVALID_PARAM
2455  * NI_RETCODE_ERROR_NVME_CMD_FAILED
2456  * NI_RETCODE_ERROR_INVALID_SESSION
2457  *******************************************************************************/
2459 
2460  /*!*****************************************************************************
2461  * \brief Lock a hardware P2P frame prior to encoding
2462  *
2463  * \param[in] p_upl_ctx pointer to caller allocated upload context
2464  * [in] p_frame pointer to caller allocated hardware P2P frame
2465  *
2466  * \return On success
2467  * NI_RETCODE_SUCCESS
2468  * On failure NI_RETCODE_FAILURE
2469  * NI_RETCODE_INVALID_PARAM
2470  *******************************************************************************/
2472  ni_logan_frame_t *p_frame);
2473 
2474 /*!*****************************************************************************
2475 * \brief Unlock a hardware P2P frame after encoding
2476 *
2477 * \param[in] p_upl_ctx pointer to caller allocated upload context
2478 * [in] p_frame pointer to caller allocated hardware P2P frame
2479 *
2480 * \return On success
2481 * NI_RETCODE_SUCCESS
2482 * On failure NI_RETCODE_FAILURE
2483 * NI_RETCODE_INVALID_PARAM
2484 *******************************************************************************/
2486  ni_logan_frame_t *p_frame);
2487 
2488  /*!*****************************************************************************
2489  * \brief Special P2P test API call. Copies YUV data from the software
2490  * frame to the hardware P2P frame on the Quadra device
2491  *
2492  * \param[in] p_upl_ctx pointer to caller allocated uploader session
2493  * context
2494  * [in] p_swframe pointer to a caller allocated software frame
2495  * [in] p_hwframe pointer to a caller allocated hardware frame
2496  *
2497  * \return On success
2498  * NI_RETCODE_SUCCESS
2499  * On failure
2500  * NI_RETCODE_FAILURE
2501  * NI_RETCODE_INVALID_PARAM
2502  *******************************************************************************/
2504  uint8_t *p_data, uint32_t len,
2505  ni_logan_frame_t *p_hwframe);
2506  #endif
2507 
2508  /*!*****************************************************************************
2509  * \brief Set the incoming frame format for the encoder
2510  *
2511  * \param[in] p_enc_ctx pointer to encoder context
2512  * [in] p_enc_params pointer to encoder parameters
2513  * [in] width input width
2514  * [in] height input height
2515  * [in] bit_depth 8 for 8-bit YUV, 10 for 10-bit YUV
2516  * [in] src_endian NI_FRAME_LITTLE_ENDIAN or NI_FRAME_BIG_ENDIAN
2517  *
2518  * \return on success
2519  * NI_RETCODE_SUCCESS
2520  *
2521  * on failure
2522  * NI_RETCODE_INVALID_PARAM
2523 *******************************************************************************/
2525  ni_logan_session_context_t *p_enc_ctx, ni_logan_encoder_params_t *p_enc_params,
2526  int width, int height, int bit_depth, int src_endian);
2527 
2528 /*!*****************************************************************************
2529 * \brief Allocate memory for the frame buffer based on provided parameters
2530 * taking into account pic line size and extra data.
2531 * Applicable to YUV420p AVFrame only. Cb/Cr size matches that of Y.
2532 *
2533 * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2534 *
2535 * \param[in] video_width Width of the video frame
2536 * \param[in] video_height Height of the video frame
2537 * \param[in] linesize Picture line size
2538 * \param[in] alignment Allignment requirement
2539 * \param[in] extra_len Extra data size (incl. meta data)
2540 *
2541 * \return On success
2542 * NI_LOGAN_RETCODE_SUCCESS
2543 * On failure
2544 * NI_LOGAN_RETCODE_INVALID_PARAM
2545 * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2546 *****************************************************************************/
2548  int video_width,
2549  int video_height,
2550  int extra_len);
2551 
2552 /*!******************************************************************************
2553 * \brief POPULATE ME LATER
2554 *
2555 * \param[in] p_packet Pointer to a previously allocated ni_logan_packet_t struct
2556 * \param[in] device_handle device handle
2557 * \param[in] event_handle event handle
2558 *
2559 * \return On success NI_LOGAN_RETCODE_SUCCESS
2560 * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2561 *******************************************************************************/
2563  ni_device_handle_t device_handle,
2564  ni_event_handle_t event_handle);
2565 
2566 /*!******************************************************************************
2567  * \brief Allocate a frame on the device based on provided parameters
2568  *
2569  * \param[in] p_ctx pointer to session context
2570  * \param[in] width width, in pixels
2571  * \param[in] height height, in pixels
2572  * \param[in] format pixel format
2573  * \param[in] options options flags
2574  * \param[in] rectangle_width clipping rectangle width
2575  * \param[in] rectangle_height clipping rectangle height
2576  * \param[in] rectangle_x horizontal position of clipping rectangle
2577  * \param[in] rectangle_y vertical position of clipping rectangle
2578  * \param[in] rgba_color RGBA fill colour (for padding only)
2579  * \param[in] frame_index frame index (only applicable for hw frame)
2580  * \param[in] device_type only NI_LOGAN_DEVICE_TYPE_SCALER supported now
2581  *
2582  * \return NI_LOGAN_RETCODE_INVALID_PARAM
2583  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2584  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2585  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2586  *******************************************************************************/
2588  int width,
2589  int height,
2590  int format,
2591  int options,
2592  int rectangle_width,
2593  int rectangle_height,
2594  int rectangle_x,
2595  int rectangle_y,
2596  int rgba_color,
2597  int frame_index,
2598  ni_logan_device_type_t device_type);
2599 
2600 /*!******************************************************************************
2601  * \brief Allocate memory for the frame buffer based on provided parameters
2602  * taking into account width, height, format, stride, alignment, and
2603  * extra data
2604  *
2605  * \param[in] p_frame Pointer to caller allocated ni_logan_frame_t
2606  * \param[in] pixel_format pixel format
2607  * \param[in] video_width width, in pixels
2608  * \param[in] video_height height, in pixels
2609  * \param[in] linesize horizontal stride
2610  * \param[in] alignment apply a 16 pixel height alignment (T408 only)
2611  * \param[in] extra_len meta data size
2612  *
2613  * \return NI_LOGAN_RETCODE_SUCCESS
2614  * NI_LOGAN_RETCODE_INVALID_PARAM
2615  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2616  *
2617  *******************************************************************************/
2619  int pixel_format,
2620  int video_width,
2621  int video_height,
2622  int linesize[],
2623  int alignment,
2624  int extra_len);
2625 
2626 /*!*****************************************************************************
2627  * \brief Allocate memory for the frame buffer for encoding based on given
2628  * parameters, taking into account pic line size and extra data.
2629  * Applicable to YUV420p AVFrame only. 8 or 10 bit/pixel.
2630  * Cb/Cr size matches that of Y.
2631  *
2632  * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2633  *
2634  * \param[in] video_width Width of the video frame
2635  * \param[in] video_height Height of the video frame
2636  * \param[in] linesize Picture line size
2637  * \param[in] extra_len Extra data size (incl. meta data)
2638  * \param[in] buffer[] Buffer address of video frame.
2639  *
2640  * \return On success
2641  * NI_LOGAN_RETCODE_SUCCESS
2642  * On failure
2643  * NI_LOGAN_RETCODE_INVALID_PARAM
2644  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2645  *****************************************************************************/
2647  int video_width,
2648  int video_height,
2649  int linesize[],
2650  int extra_len,
2651  int factor,
2652  uint8_t* buffer[]);
2653 
2654 /*!*****************************************************************************
2655  * \brief Check if incoming frame is encoder zero copy compatible or not
2656  *
2657  * \param[in] width width of encoder frame.
2658  * \param[in] height height of encoder frame.
2659  * \param[in] linesize linesizes (pointer to array).
2660  * \param[in] dst_stride dst_stride (produced by ni_logan_get_hw_yuv420p_dim).
2661  * \param[in] src_height src height of every planar.
2662  * \param[in] dst_height dst_height_aligned(produced by ni_logan_get_hw_yuv420p_dim).
2663  * \param[in] bit_depth_factor bit_depth of frame.
2664  * \param[in] data CPU address of frame planar.
2665  *
2666  * \return on success
2667  * NI_LOGAN_RETCODE_SUCCESS
2668  *
2669  * on failure
2670  * NI_LOGAN_RETCODE_FAILURE
2671  *
2672 *******************************************************************************/
2673 LIB_API ni_logan_retcode_t ni_logan_frame_zerocopy_check(const int width,
2674  const int height,
2675  const int linesize[],
2676  const int dst_stride[],
2677  const int src_height[],
2678  const int dst_height[],
2679  const int bit_depth_factor,
2680  const uint8_t * data[]);
2681 
2682 /*!*****************************************************************************
2683  * \brief Check if logan firmware version is higher than expected api flavor and version
2684  *
2685  * \param[in] p_ctx Pointer to a caller allocated
2686  * ni_logan_session_context_t struct
2687  * \param[in] fw_api_fla expected firmware api flavor
2688  * \param[in] fw_api_ver expected firmware api version
2689  *
2690  * \return on success
2691  * NI_LOGAN_RETCODE_SUCCESS
2692  * On failure
2693  * NI_LOGAN_RETCODE_FAILURE
2694  *
2695 *******************************************************************************/
2696 LIB_API ni_logan_retcode_t is_logan_fw_rev_higher(ni_logan_session_context_t* p_ctx, int fw_api_fla, int fw_api_ver);
2697 
2698 /*!*****************************************************************************
2699  * \brief Allocate log buffer if needed and retrieve firmware logs from device
2700  *
2701  * \param[in] p_ctx Pointer to a caller allocated
2702  * ni_logan_session_context_t struct
2703  * \param[in] p_log_buffer Reference to pointer to a log buffer.
2704  * If log buffer pointer is NULL, this function will
2705  * allocate log buffer.
2706  * NOTE - caller is responsible for freeing log buffer
2707  * after calling this function.
2708  * \param[in] gen_log_file Indicating whether it is required to generate log files
2709  *
2710  *
2711  * \return on success
2712  * NI_LOGAN_RETCODE_SUCCESS
2713  *
2714  * on failure
2715  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2716  * NI_LOGAN_RETCODE_INVALID_PARAM
2717 *******************************************************************************/
2719  void** p_log_buffer,
2720  bool gen_log_file);
2721 #ifdef __cplusplus
2722 }
2723 #endif
Common NETINT definitions used by all modules.
#define NI_LOGAN_LIGHT_LEVEL_DATA_SZ
ni_logan_retcode_t
#define NI_LOGAN_MAX_NUM_DATA_POINTERS
#define NI_LOGAN_MAX_CONTEXTS_PER_HW_INSTANCE
#define NI_LOGAN_MAX_CUSTOM_SEI_CNT
#define NI_LOGAN_MAX_CUSTOM_SEI_SZ
#define NI_LOGAN_FIFO_SZ
#define NI_LOGAN_MAX_FORCE_FRAME_TABLE_SIZE
ni_logan_device_type_t
#define NI_LOGAN_MAX_DEVICES_PER_HW_INSTANCE
#define NI_LOGAN_MDCV_LUM_DATA_SZ
struct _ni_logan_rational ni_rational_t
ni_logan_retcode_t ni_logan_uploader_frame_buffer_unlock(ni_logan_session_context_t *p_upl_ctx, ni_logan_frame_t *p_frame)
Unlock a hardware P2P frame after encoding.
struct _ni_hrd_params ni_hrd_params_t
struct _ni_logan_enc_mastering_display_colour_volume ni_logan_enc_mastering_display_colour_volume_t
encoded payload format of HDR SEI mastering display colour volume
LIB_API ni_aux_data_t * ni_logan_frame_new_aux_data(ni_logan_frame_t *frame, ni_aux_data_type_t type, int data_size)
Add a new auxiliary data to a frame.
struct _ni_logan_all_custom_sei ni_logan_all_custom_sei_t
LIB_API ni_event_handle_t ni_logan_create_event()
Create event and returnes event handle if successful.
enum _ni_logan_codec_hw_actions ni_logan_codec_hw_actions_t
This is an enumeration for hw actions.
LIB_API int ni_logan_device_session_hwdl(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_data, ni_logan_hwframe_surface_t *hwdesc)
Reads data from hw descriptor from decoder output buffer.
enum _ni_logan_session_run_state ni_logan_session_run_state_t
Session running state type.
struct _ni_logan_dec_h265_vui_param ni_logan_dec_h265_vui_param_t
decoded payload format of H.265 VUI
struct _ni_logan_context_query ni_logan_context_query_t
LIB_API ni_logan_retcode_t ni_logan_frame_buffer_alloc(ni_logan_frame_t *pframe, int video_width, int video_height, int alignment, int metadata_flag, int factor, int hw_frame_count)
Allocate preliminary memory for the frame buffer for encoding based on provided parameters....
LIB_API ni_logan_retcode_t ni_logan_decoder_frame_buffer_free(ni_logan_frame_t *pframe)
Free decoder frame buffer that was previously allocated with ni_logan_decoder_frame_buffer_alloc,...
struct _ni_logan_custom_gop_params ni_logan_custom_gop_params_t
LIB_API ni_logan_retcode_t ni_logan_frame_zerocopy_check(const int width, const int height, const int linesize[], const int dst_stride[], const int src_height[], const int dst_height[], const int bit_depth_factor, const uint8_t *data[])
Check if incoming frame is encoder zero copy compatible or not.
LIB_API ni_logan_retcode_t ni_logan_device_dec_session_save_hdrs(ni_logan_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 ...
LIB_API int ni_logan_get_num_ref_frame_of_gop_structure(ni_logan_encoder_params_t *p_params)
Get GOP's number of reference frames.
struct _ni_logan_encoder_change_params_t ni_logan_encoder_change_params_t
This is a data structure for encoding parameters that have changed.
_ni_logan_frame_aux_data_type
@ NI_FRAME_AUX_DATA_MASTERING_DISPLAY_METADATA
@ NI_FRAME_AUX_DATA_BITRATE
@ NI_FRAME_AUX_DATA_VUI_INFO
@ NI_FRAME_AUX_DATA_UDU_SEI
@ NI_FRAME_AUX_DATA_MIN_MAX_QP
@ NI_FRAME_AUX_DATA_HDR_PLUS
@ NI_FRAME_AUX_DATA_CUSTOM_SEI
@ NI_FRAME_AUX_DATA_NONE
@ 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
struct _ni_logan_aux_data ni_aux_data_t
#define LOGAN_MAX_CHAR_IN_DEVICE_NAME
struct _ni_logan_hwframe_surface ni_logan_hwframe_surface_t
#define NI_CC_SEI_TRAILER_LEN
struct _ni_logan_session_data_io ni_logan_session_data_io_t
LIB_API ni_logan_session_context_t * ni_logan_device_session_context_alloc_init(void)
Allocate and initialize a new ni_logan_session_context_t struct.
ni_logan_retcode_t ni_logan_uploader_frame_buffer_lock(ni_logan_session_context_t *p_upl_ctx, ni_logan_frame_t *p_frame)
Lock a hardware P2P frame prior to encoding.
struct _ni_logan_encoder_input_params ni_logan_encoder_input_params_t
LIB_API ni_logan_retcode_t ni_logan_device_session_open(ni_logan_session_context_t *p_ctx, ni_logan_device_type_t device_type)
Opens a new device session depending on the device_type parameter If device_type is NI_LOGAN_DEVICE_T...
int ni_logan_device_session_acquire(ni_logan_session_context_t *p_ctx, ni_logan_frame_t *p_frame)
Acquire a P2P frame buffer from the hwupload session.
LIB_API ni_logan_retcode_t ni_logan_device_handle_map_SN(ni_device_handle_t device_handle, ni_logan_serial_num_t *p_serial_num)
Queries device Serial number.
struct _ni_logan_serial_num_t ni_logan_serial_num_t
#define NI_LOGAN_MAX_VUI_SIZE
LIB_API ni_logan_retcode_t ni_logan_encoder_init_default_params(ni_logan_encoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default encoder parameters.
LIB_API void ni_logan_decoder_frame_buffer_pool_return_buf(ni_logan_buf_t *buf, ni_logan_buf_pool_t *p_buffer_pool)
Return a memory buffer to memory buffer pool, for a decoder frame.
LIB_API ni_logan_retcode_t ni_logan_encoder_frame_buffer_alloc(ni_logan_frame_t *pframe, int video_width, int video_height, int linesize[], int alignment, int extra_len, int factor)
Allocate memory for the frame buffer for encoding based on given parameters, taking into account pic ...
struct _ni_logan_queue_node_t ni_logan_queue_node_t
LIB_API void ni_logan_device_close(ni_device_handle_t dev)
Closes device and releases resources.
_ni_logan_reconfig
This is an enumeration for encoder reconfiguration test settings.
@ LOGAN_XCODER_TEST_RECONF_BR
@ LOGAN_XCODER_TEST_RECONF_VUI_HRD
@ LOGAN_XCODER_TEST_RECONF_CRF
@ LOGAN_XCODER_TEST_RECONF_RC
@ LOGAN_XCODER_TEST_RECONF_INTRAPRD
@ LOGAN_XCODER_TEST_RECONF_RC_MIN_MAX_QP
@ LOGAN_XCODER_TEST_RECONF_OFF
@ LOGAN_XCODER_TEST_RECONF_LONG_TERM_REF
LIB_API ni_aux_data_t * ni_logan_frame_get_aux_data(const ni_logan_frame_t *frame, ni_aux_data_type_t type)
Retrieve from the frame auxiliary data of a given type if exists.
LIB_API int ni_logan_device_session_read(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_data, ni_logan_device_type_t device_type)
Reads data the device If device_type is NI_LOGAN_DEVICE_TYPE_DECODER reads data packet from decoder I...
_ni_logan_codec_hw_actions
This is an enumeration for hw actions.
@ NI_LOGAN_CODEC_HW_UPLOAD
@ NI_LOGAN_CODEC_HW_ENABLE
@ NI_LOGAN_CODEC_HW_RSVD
@ NI_LOGAN_CODEC_HW_DOWNLOAD
@ NI_LOGAN_CODEC_HW_NONE
LIB_API ni_logan_retcode_t ni_logan_device_dec_session_flush(ni_logan_session_context_t *p_ctx)
Flush a decoder session to get ready to continue decoding. Note: this is different from ni_logan_devi...
LIB_API int ni_logan_device_session_read_hwdesc(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_data)
Reads data from the device device_type should be NI_LOGAN_DEVICE_TYPE_DECODER, and reads data hwdesc ...
#define NI_CC_SEI_HDR_H264_LEN
LIB_API ni_aux_data_t * ni_logan_frame_new_aux_data_from_raw_data(ni_logan_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.
LIB_API const char * ni_logan_err2str(int err)
Convert error numver into error messages.
struct _ni_logan_fifo_buffer_t ni_logan_fifo_buffer_t
struct _ni_logan_frame ni_logan_frame_t
LIB_API ni_logan_retcode_t ni_logan_device_session_copy(ni_logan_session_context_t *src_p_ctx, ni_logan_session_context_t *dst_p_ctx)
Copies existing decoding session params for hw frame usage.
ni_logan_h265_sei_user_data_type_t
@ NI_LOGAN_H265_USERDATA_FLAG_RESERVED_0
@ NI_LOGAN_H265_USER_DATA_FLAG_FILM_GRAIN_CHARACTERISTICS_INFO
@ NI_LOGAN_H265_USERDATA_FLAG_UNREGISTERED_SUF
@ NI_LOGAN_H265_USERDATA_FLAG_CHROMA_RESAMPLING_FILTER_HINT
@ NI_LOGAN_H265_USERDATA_FLAG_TONE_MAPPING_INFO
@ NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_SUF_1
@ NI_LOGAN_H265_USERDATA_FLAG_MASTERING_COLOR_VOL
@ NI_LOGAN_H265_USERDATA_FLAG_VUI
@ NI_LOGAN_H265_USERDATA_FLAG_RESERVED_9
@ NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_SUF_2
@ NI_LOGAN_H265_USERDATA_FLAG_UNREGISTERED_PRE
@ NI_LOGAN_H265_USERDATA_FLAG_KNEE_FUNCTION_INFO
@ NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_PRE_2
@ NI_LOGAN_H265_USERDATA_FLAG_ALTERNATIVE_TRANSFER_CHARACTERISTICS
@ NI_LOGAN_H265_USERDATA_FLAG_PIC_TIMING
@ NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_SUF
@ NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_PRE_1
@ NI_LOGAN_H265_USER_DATA_FLAG_COLOUR_REMAPPING_INFO
@ NI_LOGAN_H265_USERDATA_FLAG_RESERVED_1
@ NI_LOGAN_H265_USERDATA_FLAG_ITU_T_T35_PRE
@ NI_LOGAN_H265_USER_DATA_FLAG_CONTENT_LIGHT_LEVEL_INFO
struct _ni_logan_encoder_params ni_logan_encoder_params_t
LIB_API ni_logan_retcode_t ni_logan_frame_buffer_free(ni_logan_frame_t *pframe)
Free frame buffer that was previously allocated with either ni_logan_frame_buffer_alloc or ni_logan_e...
_ni_logan_param_change_flags
This is an enumeration for encoder parameter change.
@ NI_LOGAN_SET_CHANGE_PARAM_VUI_HRD_PARAM
@ NI_LOGAN_SET_CHANGE_PARAM_CRF
@ NI_LOGAN_SET_CHANGE_PARAM_RDO
@ NI_LOGAN_SET_CHANGE_PARAM_CUSTOM_LAMBDA
@ NI_LOGAN_SET_CHANGE_PARAM_NR
@ NI_LOGAN_SET_CHANGE_PARAM_RC_BIT_RATIO_LAYER
@ NI_LOGAN_SET_CHANGE_PARAM_CUSTOM_MD
@ NI_LOGAN_SET_CHANGE_PARAM_RC2
@ NI_LOGAN_SET_CHANGE_PARAM_RC_TARGET_RATE
@ NI_LOGAN_SET_CHANGE_PARAM_PPS
@ NI_LOGAN_SET_CHANGE_PARAM_RC_MIN_MAX_QP
@ NI_LOGAN_SET_CHANGE_PARAM_BG
@ NI_LOGAN_SET_CHANGE_PARAM_DEPEND_SLICE
@ NI_LOGAN_SET_CHANGE_PARAM_INDEPEND_SLICE
@ NI_LOGAN_SET_CHANGE_PARAM_INTRA_PARAM
@ NI_LOGAN_SET_CHANGE_PARAM_RC
struct _ni_logan_decoder_params ni_logan_decoder_params_t
union _ni_logan_enc_hevc_roi_custom_map ni_logan_enc_hevc_roi_custom_map_t
encoder HEVC ROI custom map (1 CTU = 64bits)
LIB_API ni_logan_retcode_t ni_logan_frame_zerocopy_buffer_alloc(ni_logan_frame_t *pframe, int video_width, int video_height, int linesize[], int extra_len, int factor, uint8_t *buffer[])
Allocate memory for the frame buffer for encoding based on given parameters, taking into account pic ...
enum _ni_logan_param_change_flags ni_logan_param_change_flags_t
This is an enumeration for encoder parameter change.
_ni_logan_custom_sei_location
This is an enumeration for illustrating the custom SEI locations.
@ NI_LOGAN_CUSTOM_SEI_LOC_BEFORE_VCL
@ NI_LOGAN_CUSTOM_SEI_LOC_AFTER_VCL
struct _ni_logan_session_context ni_logan_session_context_t
struct _ni_logan_dec_mastering_display_colour_volume ni_logan_dec_mastering_display_colour_volume_t
decoded payload format of HDR SEI mastering display colour volume
LIB_API int ni_logan_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 allighment.
struct _ni_logan_load_query ni_logan_load_query_t
LIB_API ni_logan_retcode_t ni_logan_alloc_and_get_fw_logs(ni_logan_session_context_t *p_ctx, void **p_log_buffer, bool gen_log_file)
Allocate log buffer if needed and retrieve firmware logs from device.
enum _ni_logan_reconfig ni_logan_reconfig_t
This is an enumeration for encoder reconfiguration test settings.
LIB_API ni_logan_retcode_t ni_logan_decode_buffer_free(ni_logan_hwframe_surface_t *surface, ni_device_handle_t device_handle, ni_event_handle_t event_handle)
POPULATE ME LATER.
LIB_API ni_logan_retcode_t ni_logan_decoder_frame_buffer_alloc(ni_logan_buf_pool_t *p_pool, ni_logan_frame_t *pframe, int alloc_mem, int video_width, int video_height, int alignment, int factor)
Allocate memory for decoder frame buffer based on provided parameters; the memory is retrieved from a...
LIB_API ni_logan_retcode_t ni_logan_encoder_params_set_value(ni_logan_encoder_params_t *p_params, const char *name, const char *value, ni_logan_session_context_t *ctx)
Set value referenced by name in encoder parameters structure.
struct _ni_logan_gop_params ni_logan_gop_params_t
LIB_API void ni_logan_device_session_context_clear(ni_logan_session_context_t *p_ctx)
Clear already allocated session context to all zeros buffer.
LIB_API ni_logan_retcode_t ni_logan_device_session_query(ni_logan_session_context_t *p_ctx, ni_logan_device_type_t device_type)
Query session data from the device - Currently not implemented If device_type is NI_LOGAN_DEVICE_TYPE...
#define NI_HDR10P_SEI_HDR_H264_LEN
LIB_API ni_logan_retcode_t ni_logan_decoder_init_default_params(ni_logan_decoder_params_t *p_param, int fps_num, int fps_denom, long bit_rate, int width, int height)
Initialize default decoder parameters.
LIB_API void ni_logan_close_event(ni_event_handle_t event_handle)
Closes event and releases resources.
union _ni_logan_enc_avc_roi_custom_map ni_logan_enc_avc_roi_custom_map_t
encoder AVC ROI custom map (1 MB = 8bits)
struct _ni_logan_custom_sei ni_logan_custom_sei_t
custom sei payload passthrough
LIB_API ni_logan_retcode_t ni_logan_decoder_session_send_flush(ni_logan_session_context_t *p_ctx)
Sends a flush command to the decoder ni_logan_device_session_open()
struct _ni_logan_dec_win ni_logan_dec_win_t
ni_logan_pic_type_t
@ LOGAN_PIC_TYPE_P
@ LOGAN_PIC_TYPE_CRA
@ LOGAN_PIC_TYPE_I
@ LOGAN_PIC_TYPE_IDR
@ LOGAN_PIC_TYPE_B
@ LOGAN_PIC_TYPE_MAX
@ LOGAN_PIC_TYPE_FORCE_IDR
struct _ni_logan_region_of_interest ni_region_of_interest_t
LIB_API ni_logan_retcode_t ni_logan_encoder_gop_params_set_value(ni_logan_encoder_params_t *p_params, const char *name, const char *value)
Set gop parameter value referenced by name in encoder parameters structure.
LIB_API void ni_logan_frame_wipe_aux_data(ni_logan_frame_t *frame)
Free and remove all auxiliary data from the frame.
LIB_API void ni_logan_frame_free_aux_data(ni_logan_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.
LIB_API ni_logan_retcode_t ni_logan_uploader_p2p_test_send(ni_logan_session_context_t *p_upl_ctx, uint8_t *p_data, uint32_t len, ni_logan_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_logan_retcode_t ni_logan_packet_buffer_free(ni_logan_packet_t *ppacket)
Free packet buffer that was previously allocated with either ni_logan_packet_buffer_alloc.
struct _ni_logan_buf_t ni_logan_buf_t
LIB_API const char *const g_logan_xcoder_log_names[NI_LOGAN_XCODER_LOG_NAMES_ARRAY_LEN]
#define NI_LOGAN_MAX_SEI_DATA
LIB_API ni_logan_retcode_t ni_logan_encoder_set_input_frame_format(ni_logan_session_context_t *p_enc_ctx, ni_logan_encoder_params_t *p_enc_params, int width, int height, int bit_depth, int src_endian)
Set the incoming frame format for the encoder.
struct _ni_logan_packet ni_logan_packet_t
LIB_API ni_logan_retcode_t ni_logan_frame_buffer_alloc_v4(ni_logan_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 width,...
LIB_API ni_logan_retcode_t ni_logan_device_session_flush(ni_logan_session_context_t *p_ctx, ni_logan_device_type_t device_type)
Sends a flush command to the device ni_logan_device_session_open() If device_type is NI_LOGAN_DEVICE_...
LIB_API void ni_logan_device_session_context_free(ni_logan_session_context_t *p_ctx)
Frees previously allocated session context.
enum _ni_logan_frame_aux_data_type ni_aux_data_type_t
struct _ni_logan_hw_capability ni_logan_hw_capability_t
hardware capability type
LIB_API int ni_logan_get_num_reorder_of_gop_structure(ni_logan_encoder_params_t *p_params)
Get GOP's max number of reorder frames.
struct _ni_logan_content_light_level_info ni_logan_content_light_level_info_t
payload format of HDR SEI content light level info
LIB_API ni_device_handle_t ni_logan_device_open(const char *dev, uint32_t *p_max_io_size_out)
Opens device and returnes device device_handle if successful.
LIB_API void ni_logan_device_session_context_init(ni_logan_session_context_t *p_ctx)
Initialize already allocated session context to a known state.
LIB_API int ni_logan_device_session_write(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_data, ni_logan_device_type_t device_type)
Sends data the device If device_type is NI_LOGAN_DEVICE_TYPE_DECODER sends data packet to decoder If ...
#define NI_LOGAN_XCODER_PRESET_NAMES_ARRAY_LEN
LIB_API ni_logan_retcode_t is_logan_fw_rev_higher(ni_logan_session_context_t *p_ctx, int fw_api_fla, int fw_api_ver)
Check if logan firmware version is higher than expected api flavor and version.
struct _ni_logan_dec_h264_vui_param ni_logan_dec_h264_vui_param_t
decoded payload format of H.264 VUI
LIB_API ni_logan_retcode_t ni_logan_packet_buffer_alloc(ni_logan_packet_t *ppacket, int packet_size)
Allocate memory for the packet buffer based on provided packet size.
#define NI_HDR10P_SEI_HDR_HEVC_LEN
struct _ni_logan_sei_user_data_entry ni_logan_sei_user_data_entry_t
LIB_API int ni_logan_device_session_hwup(ni_logan_session_context_t *p_ctx, ni_logan_session_data_io_t *p_src_data, ni_logan_hwframe_surface_t *hwdesc)
Writes data and reads back hw descriptor from decoder output buffer.
LIB_API ni_logan_retcode_t ni_logan_device_alloc_frame(ni_logan_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_logan_device_type_t device_type)
Allocate a frame on the device based on provided parameters.
#define NI_LOGAN_MAX_GOP_NUM
_ni_logan_session_run_state
Session running state type.
@ LOGAN_SESSION_RUN_STATE_RESETTING
@ LOGAN_SESSION_RUN_STATE_QUEUED_FRAME_DRAINING
@ LOGAN_SESSION_RUN_STATE_SEQ_CHANGE_DRAINING
@ LOGAN_SESSION_RUN_STATE_NORMAL
LIB_API ni_logan_retcode_t ni_logan_decoder_params_set_value(ni_logan_decoder_params_t *p_params, const char *name, char *value)
Set value referenced by name in decoder parameters structure.
struct _ni_logan_long_term_ref ni_long_term_ref_t
LIB_API ni_logan_retcode_t ni_logan_frame_buffer_alloc_hwenc(ni_logan_frame_t *pframe, int video_width, int video_height, int extra_len)
Allocate memory for the frame buffer based on provided parameters taking into account pic line size a...
enum _ni_logan_codec_format ni_logan_codec_format_t
This is an enumeration for supported codec formats.
#define NI_MAX_NUM_AUX_DATA_PER_FRAME
LIB_API ni_logan_retcode_t ni_logan_device_capability_query(ni_device_handle_t device_handle, ni_logan_device_capability_t *p_cap)
Queries device and returns device capability structure.
struct _ni_logan_decoder_input_params ni_logan_decoder_input_params_t
struct _ni_logan_queue_buffer_pool_t ni_logan_queue_buffer_pool_t
LIB_API int ni_logan_device_session_init_framepool(ni_logan_session_context_t *p_ctx, uint32_t pool_size, uint32_t p2p_pool)
Sends frame pool setup info to device.
_ni_logan_codec_format
This is an enumeration for supported codec formats.
@ NI_LOGAN_CODEC_FORMAT_H265
@ NI_LOGAN_CODEC_FORMAT_H264
ni_logan_pix_fmt_t
@ NI_LOGAN_PIX_FMT_YUV420P
@ NI_LOGAN_PIX_FMT_YUV420P10BE
@ NI_LOGAN_PIX_FMT_YUV420P10LE
@ NI_LOGAN_PIX_FMT_YUVJ420P
LIB_API ni_logan_retcode_t ni_logan_encoder_params_check(ni_logan_encoder_params_t *p_params, ni_logan_codec_format_t codec)
Validate relationship of some params in encoder parameters structure.
struct _ni_logan_device_capability ni_logan_device_capability_t
device capability type
struct _ni_logan_buf_pool_t ni_logan_buf_pool_t
struct _ni_logan_thread_arg_struct_t ni_logan_thread_arg_struct_t
enum _ni_logan_custom_sei_location ni_logan_custom_sei_location_t
This is an enumeration for illustrating the custom SEI locations.
LIB_API ni_logan_retcode_t ni_logan_device_session_close(ni_logan_session_context_t *p_ctx, int eos_recieved, ni_logan_device_type_t device_type)
Closes device session that was previously opened by calling ni_logan_device_session_open() If device_...
#define NI_LOGAN_XCODER_LOG_NAMES_ARRAY_LEN
LIB_API const char *const g_logan_xcoder_preset_names[NI_LOGAN_XCODER_PRESET_NAMES_ARRAY_LEN]
struct ni_logan_rc_min_max_qp ni_logan_rc_min_max_qp
#define NI_CC_SEI_HDR_HEVC_LEN
uint32_t initial_cpb_removal_delay_length_minus1
uint32_t au_cpb_removal_delay_minus1
uint32_t dpb_output_delay_length_minus1
uint32_t au_cpb_removal_delay_length_minus1
ni_logan_custom_sei_t ni_custom_sei[NI_LOGAN_MAX_CUSTOM_SEI_CNT]
ni_aux_data_type_t type
ni_pthread_mutex_t mutex
ni_logan_buf_t * p_free_head
ni_logan_buf_t * p_free_tail
ni_logan_buf_t * p_used_head
ni_logan_buf_t * p_used_tail
struct _ni_logan_buf_pool_t * pool
struct _ni_logan_buf_t * p_next
struct _ni_logan_buf_t * p_previous_buffer
struct _ni_logan_buf_t * p_prev
struct _ni_logan_buf_t * p_next_buffer
payload format of HDR SEI content light level info
ni_logan_gop_params_t pic_param[NI_LOGAN_MAX_GOP_NUM]
custom sei payload passthrough
ni_logan_custom_sei_location_t custom_sei_loc
uint8_t custom_sei_data[NI_LOGAN_MAX_CUSTOM_SEI_SZ]
decoded payload format of H.264 VUI
decoded payload format of H.265 VUI
decoded payload format of HDR SEI mastering display colour volume
ni_logan_decoder_input_params_t dec_input_params
ni_logan_hw_capability_t xcoder_devices[NI_LOGAN_MAX_DEVICES_PER_HW_INSTANCE]
encoded payload format of HDR SEI mastering display colour volume
This is a data structure for encoding parameters that have changed.
uint8_t vuiRbsp[NI_LOGAN_MAX_VUI_SIZE]
struct _ni_logan_encoder_input_params::@3 rc
ni_logan_custom_gop_params_t custom_gop_params
ni_logan_encoder_input_params_t enc_input_params
uint8_t ui8VuiRbsp[NI_LOGAN_MAX_VUI_SIZE]
ni_logan_frame_t * p_first_frame
uint8_t ui8LastVuiRbsp[NI_LOGAN_MAX_VUI_SIZE]
unsigned int sei_hdr_mastering_display_color_vol_offset
unsigned int sei_hdr_content_light_level_info_offset
uint8_t preferred_characteristics_data_len
ni_logan_buf_t * dec_buf
unsigned int sei_hdr_plus_len
uint32_t data_len[NI_LOGAN_MAX_NUM_DATA_POINTERS]
unsigned int sei_hdr_plus_offset
unsigned int extra_data_len
unsigned int sei_total_len
unsigned int sei_cc_offset
unsigned int sei_user_data_unreg_len
ni_logan_pic_type_t ni_logan_pict_type
uint8_t use_cur_src_as_long_term_pic
ni_logan_codec_format_t src_codec
unsigned int sei_hdr_content_light_level_info_len
ni_aux_data_t * aux_data[NI_MAX_NUM_AUX_DATA_PER_FRAME]
void * p_data[NI_LOGAN_MAX_NUM_DATA_POINTERS]
unsigned int sei_hdr_mastering_display_color_vol_len
unsigned int sei_user_data_unreg_offset
unsigned int sei_alt_transfer_characteristics_len
unsigned int sei_alt_transfer_characteristics_offset
hardware capability type
ni_logan_context_query_t context_status[NI_LOGAN_MAX_CONTEXTS_PER_HW_INSTANCE]
ni_logan_all_custom_sei_t * p_all_custom_sei
ni_logan_queue_node_t * p_used_head
ni_logan_queue_node_t * p_used_tail
ni_logan_queue_node_t * p_free_tail
ni_logan_queue_node_t * p_free_head
struct _ni_logan_queue_node_t * p_previous_buffer
struct _ni_logan_queue_node_t * p_next_buffer
struct _ni_logan_queue_node_t * p_next
struct _ni_logan_queue_node_t * p_prev
uint32_t offset
uint32_t size
uint8_t itu_t_t35_hdr10p_sei_hdr_hevc[NI_HDR10P_SEI_HDR_HEVC_LEN]
ni_logan_encoder_change_params_t * enc_change_params
int64_t pts_offsets[NI_LOGAN_FIFO_SZ]
ni_logan_load_query_t load_query
uint8_t ui8_light_level_data[NI_LOGAN_LIGHT_LEVEL_DATA_SZ]
ni_event_handle_t thread_event_handle
uint8_t ui8_mdcv_max_min_lum_data[NI_LOGAN_MDCV_LUM_DATA_SZ]
uint8_t buf_lone_sei[NI_LOGAN_MAX_SEI_DATA]
ni_logan_enc_avc_roi_custom_map_t * avc_roi_map
ni_logan_serial_num_t d_serial_number
ni_device_handle_t sender_handle
ni_device_handle_t device_handle
uint64_t pkt_offsets_index_min[NI_LOGAN_FIFO_SZ]
ni_logan_lat_meas_q_t * frame_time_q
ni_device_handle_t auto_dl_handle
uint64_t pkt_offsets_index[NI_LOGAN_FIFO_SZ]
uint8_t sei_trailer[NI_CC_SEI_TRAILER_LEN]
int64_t enc_pts_list[NI_LOGAN_FIFO_SZ]
ni_logan_thread_arg_struct_t * keep_alive_thread_args
uint32_t prev_fps
Params used in VFR mode Start///.
int flags_array[NI_LOGAN_FIFO_SZ]
uint8_t itu_t_t35_cc_sei_hdr_hevc[NI_CC_SEI_HDR_HEVC_LEN]
ni_logan_session_run_state_t session_run_state
uint8_t itu_t_t35_cc_sei_hdr_h264[NI_CC_SEI_HDR_H264_LEN]
char blk_xcoder_name[LOGAN_MAX_CHAR_IN_DEVICE_NAME]
ni_device_handle_t blk_io_handle
ni_logan_enc_hevc_roi_custom_map_t * hevc_roi_map
ni_logan_queue_buffer_pool_t * buffer_pool
uint64_t frame_pkt_offset
Params used in VFR mode Done///.
ni_logan_buf_pool_t * dec_fme_buf_pool
int64_t force_frame_pts_table[NI_LOGAN_MAX_FORCE_FRAME_TABLE_SIZE]
uint8_t itu_t_t35_hdr10p_sei_hdr_h264[NI_HDR10P_SEI_HDR_H264_LEN]
char dev_xcoder[LOGAN_MAX_CHAR_IN_DEVICE_NAME]
ni_logan_instance_status_info_t session_stats
ni_region_of_interest_t * av_rois
ni_logan_all_custom_sei_t * pkt_custom_sei[NI_LOGAN_FIFO_SZ]
char dev_xcoder_name[LOGAN_MAX_CHAR_IN_DEVICE_NAME]
ni_logan_serial_num_t e_serial_number
union _ni_logan_session_data_io::@4 data
encoder AVC ROI custom map (1 MB = 8bits)
struct _ni_logan_enc_avc_roi_custom_map::@2 field
encoder HEVC ROI custom map (1 CTU = 64bits)
struct _ni_logan_enc_hevc_roi_custom_map::@1 field