libxcoder  3.5.1
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
1099 
1100 /*!*
1101 * \brief This is an enumeration for encoder reconfiguration test settings
1102 */
1104 {
1114 
1115 #define NI_LOGAN_ENC_GOP_PARAMS_G0_PIC_TYPE "g0picType"
1116 #define NI_LOGAN_ENC_GOP_PARAMS_G0_POC_OFFSET "g0pocOffset"
1117 #define NI_LOGAN_ENC_GOP_PARAMS_G0_PIC_QP "g0picQp"
1118 #define NI_LOGAN_ENC_GOP_PARAMS_G0_NUM_REF_PIC_L0 "g0numRefPicL0"
1119 #define NI_LOGAN_ENC_GOP_PARAMS_G0_NUM_REF_POC_L0 "g0refPocL0"
1120 #define NI_LOGAN_ENC_GOP_PARAMS_G0_NUM_REF_POC_L1 "g0refPocL1"
1121 #define NI_LOGAN_ENC_GOP_PARAMS_G0_TEMPORAL_ID "g0temporalId"
1122 
1123 #define NI_LOGAN_ENC_GOP_PARAMS_G1_PIC_TYPE "g1picType"
1124 #define NI_LOGAN_ENC_GOP_PARAMS_G1_POC_OFFSET "g1pocOffset"
1125 #define NI_LOGAN_ENC_GOP_PARAMS_G1_PIC_QP "g1picQp"
1126 #define NI_LOGAN_ENC_GOP_PARAMS_G1_NUM_REF_PIC_L0 "g1numRefPicL0"
1127 #define NI_LOGAN_ENC_GOP_PARAMS_G1_NUM_REF_POC_L0 "g1refPocL0"
1128 #define NI_LOGAN_ENC_GOP_PARAMS_G1_NUM_REF_POC_L1 "g1refPocL1"
1129 #define NI_LOGAN_ENC_GOP_PARAMS_G1_TEMPORAL_ID "g1temporalId"
1130 
1131 #define NI_LOGAN_ENC_GOP_PARAMS_G2_PIC_TYPE "g2picType"
1132 #define NI_LOGAN_ENC_GOP_PARAMS_G2_POC_OFFSET "g2pocOffset"
1133 #define NI_LOGAN_ENC_GOP_PARAMS_G2_PIC_QP "g2picQp"
1134 #define NI_LOGAN_ENC_GOP_PARAMS_G2_NUM_REF_PIC_L0 "g2numRefPicL0"
1135 #define NI_LOGAN_ENC_GOP_PARAMS_G2_NUM_REF_POC_L0 "g2refPocL0"
1136 #define NI_LOGAN_ENC_GOP_PARAMS_G2_NUM_REF_POC_L1 "g2refPocL1"
1137 #define NI_LOGAN_ENC_GOP_PARAMS_G2_TEMPORAL_ID "g2temporalId"
1138 
1139 #define NI_LOGAN_ENC_GOP_PARAMS_G3_PIC_TYPE "g3picType"
1140 #define NI_LOGAN_ENC_GOP_PARAMS_G3_POC_OFFSET "g3pocOffset"
1141 #define NI_LOGAN_ENC_GOP_PARAMS_G3_PIC_QP "g3picQp"
1142 #define NI_LOGAN_ENC_GOP_PARAMS_G3_NUM_REF_PIC_L0 "g3numRefPicL0"
1143 #define NI_LOGAN_ENC_GOP_PARAMS_G3_NUM_REF_POC_L0 "g3refPocL0"
1144 #define NI_LOGAN_ENC_GOP_PARAMS_G3_NUM_REF_POC_L1 "g3refPocL1"
1145 #define NI_LOGAN_ENC_GOP_PARAMS_G3_TEMPORAL_ID "g3temporalId"
1146 
1147 #define NI_LOGAN_ENC_GOP_PARAMS_G4_PIC_TYPE "g4picType"
1148 #define NI_LOGAN_ENC_GOP_PARAMS_G4_POC_OFFSET "g4pocOffset"
1149 #define NI_LOGAN_ENC_GOP_PARAMS_G4_PIC_QP "g4picQp"
1150 #define NI_LOGAN_ENC_GOP_PARAMS_G4_NUM_REF_PIC_L0 "g4numRefPicL0"
1151 #define NI_LOGAN_ENC_GOP_PARAMS_G4_NUM_REF_POC_L0 "g4refPocL0"
1152 #define NI_LOGAN_ENC_GOP_PARAMS_G4_NUM_REF_POC_L1 "g4refPocL1"
1153 #define NI_LOGAN_ENC_GOP_PARAMS_G4_TEMPORAL_ID "g4temporalId"
1154 
1155 #define NI_LOGAN_ENC_GOP_PARAMS_G5_PIC_TYPE "g5picType"
1156 #define NI_LOGAN_ENC_GOP_PARAMS_G5_POC_OFFSET "g5pocOffset"
1157 #define NI_LOGAN_ENC_GOP_PARAMS_G5_PIC_QP "g5picQp"
1158 #define NI_LOGAN_ENC_GOP_PARAMS_G5_NUM_REF_PIC_L0 "g5numRefPicL0"
1159 #define NI_LOGAN_ENC_GOP_PARAMS_G5_NUM_REF_POC_L0 "g5refPocL0"
1160 #define NI_LOGAN_ENC_GOP_PARAMS_G5_NUM_REF_POC_L1 "g5refPocL1"
1161 #define NI_LOGAN_ENC_GOP_PARAMS_G5_TEMPORAL_ID "g5temporalId"
1162 
1163 #define NI_LOGAN_ENC_GOP_PARAMS_G6_PIC_TYPE "g6picType"
1164 #define NI_LOGAN_ENC_GOP_PARAMS_G6_POC_OFFSET "g6pocOffset"
1165 #define NI_LOGAN_ENC_GOP_PARAMS_G6_PIC_QP "g6picQp"
1166 #define NI_LOGAN_ENC_GOP_PARAMS_G6_NUM_REF_PIC_L0 "g6numRefPicL0"
1167 #define NI_LOGAN_ENC_GOP_PARAMS_G6_NUM_REF_POC_L0 "g6refPocL0"
1168 #define NI_LOGAN_ENC_GOP_PARAMS_G6_NUM_REF_POC_L1 "g6refPocL1"
1169 #define NI_LOGAN_ENC_GOP_PARAMS_G6_TEMPORAL_ID "g6temporalId"
1170 
1171 #define NI_LOGAN_ENC_GOP_PARAMS_G7_PIC_TYPE "g7picType"
1172 #define NI_LOGAN_ENC_GOP_PARAMS_G7_POC_OFFSET "g7pocOffset"
1173 #define NI_LOGAN_ENC_GOP_PARAMS_G7_PIC_QP "g7picQp"
1174 #define NI_LOGAN_ENC_GOP_PARAMS_G7_NUM_REF_PIC_L0 "g7numRefPicL0"
1175 #define NI_LOGAN_ENC_GOP_PARAMS_G7_NUM_REF_POC_L0 "g7refPocL0"
1176 #define NI_LOGAN_ENC_GOP_PARAMS_G7_NUM_REF_POC_L1 "g7refPocL1"
1177 #define NI_LOGAN_ENC_GOP_PARAMS_G7_TEMPORAL_ID "g7temporalId"
1178 
1179 typedef struct _ni_logan_gop_params
1180 {
1181  int pic_type; /*!*< A picture type of Nth picture in the custom GOP */
1182  int poc_offset; /*!*< A POC of Nth picture in the custom GOP */
1183  int pic_qp; /*!*< A quantization parameter of Nth picture in the custom GOP */
1184  int num_ref_pic_L0; /*!*< The number of reference L0 of Nth picture in the custom GOP */
1185  int ref_poc_L0; /*!*< A POC of reference L0 of Nth picture in the custom GOP */
1186  int ref_poc_L1; /*!*< A POC of reference L1 of Nth picture in the custom GOP */
1187  int temporal_id; /*!*< A temporal ID of Nth picture in the custom GOP */
1189 
1190 #define NI_LOGAN_ENC_GOP_PARAMS_CUSTOM_GOP_SIZE "customGopSize"
1191 
1193 {
1194  int custom_gop_size; /*!*< The size of custom GOP (0~8) */
1195  ni_logan_gop_params_t pic_param[NI_LOGAN_MAX_GOP_NUM]; /*!*< Picture parameters of Nth picture in custom GOP */
1197 
1198 #define NI_LOGAN_ENC_REPEAT_HEADERS_FIRST_IDR 0
1199 #define NI_LOGAN_ENC_REPEAT_HEADERS_ALL_KEY_FRAMES 1 // repeat headers for all I frames and intra refreshed key frames
1200 #define NI_LOGAN_ENC_REPEAT_HEADERS_ALL_I_FRAMES 2 // repeat headers for all I frames
1201 
1202 //ni_logan_h265_encoder_params defs
1203 #define NI_LOGAN_ENC_PARAM_BITRATE "bitrate"
1204 #define NI_LOGAN_ENC_PARAM_RECONF_DEMO_MODE "ReconfDemoMode"
1205 #define NI_LOGAN_ENC_PARAM_RECONF_FILE "ReconfFile"
1206 #define NI_LOGAN_ENC_PARAM_ROI_DEMO_MODE "RoiDemoMode"
1207 #define NI_LOGAN_ENC_PARAM_CACHE_ROI "cacheRoi"
1208 #define NI_LOGAN_ENC_PARAM_FORCE_PIC_QP_DEMO_MODE "ForcePicQpDemoMode"
1209 #define NI_LOGAN_ENC_PARAM_GEN_HDRS "GenHdrs"
1210 #define NI_LOGAN_ENC_PARAM_PADDING "padding"
1211 #define NI_LOGAN_ENC_PARAM_FORCE_FRAME_TYPE "forceFrameType"
1212 #define NI_LOGAN_ENC_PARAM_PROFILE "profile"
1213 #define NI_LOGAN_ENC_PARAM_LEVEL "level"
1214 #define NI_LOGAN_ENC_PARAM_HIGH_TIER "high-tier"
1215 #define NI_LOGAN_ENC_PARAM_LOG_LEVEL "log-level"
1216 #define NI_LOGAN_ENC_PARAM_LOG "log"
1217 #define NI_LOGAN_ENC_PARAM_GOP_PRESET_IDX "gopPresetIdx"
1218 #define NI_LOGAN_ENC_PARAM_LOW_DELAY "lowDelay"
1219 #define NI_LOGAN_ENC_PARAM_USE_RECOMMENDED_ENC_PARAMS "useRecommendEncParam"
1220 #define NI_LOGAN_ENC_PARAM_USE_LOW_DELAY_POC_TYPE "useLowDelayPocType"
1221 #define NI_LOGAN_ENC_PARAM_ENABLE_RATE_CONTROL "RcEnable"
1222 #define NI_LOGAN_ENC_PARAM_ENABLE_CU_LEVEL_RATE_CONTROL "cuLevelRCEnable"
1223 #define NI_LOGAN_ENC_PARAM_ENABLE_HVS_QP "hvsQPEnable"
1224 #define NI_LOGAN_ENC_PARAM_ENABLE_HVS_QP_SCALE "hvsQpScaleEnable"
1225 #define NI_LOGAN_ENC_PARAM_HVS_QP_SCALE "hvsQpScale"
1226 #define NI_LOGAN_ENC_PARAM_MIN_QP "minQp"
1227 #define NI_LOGAN_ENC_PARAM_MAX_QP "maxQp"
1228 #define NI_LOGAN_ENC_PARAM_MAX_DELTA_QP "maxDeltaQp"
1229 #define NI_LOGAN_ENC_PARAM_RC_INIT_DELAY "RcInitDelay"
1230 #define NI_LOGAN_ENC_PARAM_FORCED_HEADER_ENABLE "repeatHeaders"
1231 #define NI_LOGAN_ENC_PARAM_ROI_ENABLE "roiEnable"
1232 #define NI_LOGAN_ENC_PARAM_CONF_WIN_TOP "confWinTop"
1233 #define NI_LOGAN_ENC_PARAM_CONF_WIN_BOTTOM "confWinBot"
1234 #define NI_LOGAN_ENC_PARAM_CONF_WIN_LEFT "confWinLeft"
1235 #define NI_LOGAN_ENC_PARAM_CONF_WIN_RIGHT "confWinRight"
1236 #define NI_LOGAN_ENC_PARAM_INTRA_PERIOD "intraPeriod"
1237 #define NI_LOGAN_ENC_PARAM_TRANS_RATE "transRate"
1238 #define NI_LOGAN_ENC_PARAM_FRAME_RATE "frameRate"
1239 #define NI_LOGAN_ENC_PARAM_FRAME_RATE_DENOM "frameRateDenom"
1240 #define NI_LOGAN_ENC_PARAM_INTRA_QP "intraQP"
1241 #define NI_LOGAN_ENC_PARAM_DECODING_REFRESH_TYPE "decodingRefreshType"
1242 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_RESET "intraRefreshResetOnForceIDR"
1243 #define NI_LOGAN_ENC_PARAM_CHROMA_QP_OffSET "chromaQpOffset"
1244 // only for HEVC
1245 #define NI_LOGAN_ENC_PARAM_MAX_FRAME_SIZE "maxFrameSize"
1246 #define NI_LOGAN_ENC_PARAM_MAX_FRAME_SIZE_BITS "maxFrameSize-Bits"
1247 #define NI_LOGAN_ENC_PARAM_MAX_FRAME_SIZE_BYTES "maxFrameSize-Bytes"
1248 
1249 // Rev. B: H.264 only parameters.
1250 #define NI_LOGAN_ENC_PARAM_ENABLE_8X8_TRANSFORM "transform8x8Enable"
1251 #define NI_LOGAN_ENC_PARAM_AVC_SLICE_MODE "avcSliceMode"
1252 #define NI_LOGAN_ENC_PARAM_AVC_SLICE_ARG "avcSliceArg"
1253 #define NI_LOGAN_ENC_PARAM_ENTROPY_CODING_MODE "entropyCodingMode"
1254 #define NI_LOGAN_ENC_PARAM_INTRA_MB_REFRESH_MODE "intraMbRefreshMode"
1255 #define NI_LOGAN_ENC_PARAM_INTRA_MB_REFRESH_ARG "intraMbRefreshArg"
1256 // Rev. B: shared between HEVC and H.264
1257 #define NI_LOGAN_ENC_PARAM_SLICE_MODE "sliceMode"
1258 #define NI_LOGAN_ENC_PARAM_SLICE_ARG "sliceArg"
1259 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_MODE "intraRefreshMode"
1260 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_ARG "intraRefreshArg"
1261 // TBD Rev. B: could be shared for HEVC and H.264
1262 #define NI_LOGAN_ENC_PARAM_ENABLE_MB_LEVEL_RC "mbLevelRcEnable"
1263 #define NI_LOGAN_ENC_PARAM_PREFERRED_TRANSFER_CHARACTERISTICS "prefTRC"
1264 // HRD and AUD features related
1265 #define NI_LOGAN_ENC_PARAM_DOLBY_VISION_PROFILE "dolbyVisionProfile"
1266 #define NI_LOGAN_ENC_PARAM_HRD_ENABLE "hrdEnable"
1267 #define NI_LOGAN_ENC_PARAM_ENABLE_AUD "enableAUD"
1268 #define NI_LOGAN_ENC_PARAM_CRF "crf"
1269 #define NI_LOGAN_ENC_PARAM_CRF_IP_RATIO "ipRatio"
1270 #define NI_LOGAN_ENC_PARAM_CRF_PB_RATIO "pbRatio"
1271 #define NI_LOGAN_ENC_PARAM_CBR "cbr"
1272 #define NI_LOGAN_ENC_PARAM_INTRA_REFRESH_MIN_PERIOD "intraRefreshMinPeriod"
1273 #define NI_LOGAN_ENC_PARAM_LONG_TERM_REFERENCE_ENABLE "longTermReferenceEnable"
1274 // stricter timeout detection enable
1275 #define NI_LOGAN_ENC_PARAM_STRICT_TIMEOUT_MODE "strictTimeout"
1276 #define NI_LOGAN_ENC_PARAM_LOSSLESS_ENABLE "losslessEnable"
1277 #define NI_LOGAN_ENC_PARAM_FLUSH_GOP "flushGop"
1278 // stream color info
1279 #define NI_LOGAN_ENC_PARAM_COLOR_PRIMARY "colorPri"
1280 #define NI_LOGAN_ENC_PARAM_COLOR_TRANSFER_CHARACTERISTIC "colorTrc"
1281 #define NI_LOGAN_ENC_PARAM_COLOR_SPACE "colorSpc"
1282 // sample aspect ratio specified in numerator/denominator
1283 #define NI_LOGAN_ENC_PARAM_SAR_NUM "sarNum"
1284 #define NI_LOGAN_ENC_PARAM_SAR_DENOM "sarDenom"
1285 // video_full_range_flag
1286 #define NI_LOGAN_ENC_PARAM_VIDEO_FULL_RANGE_FLAG "videoFullRangeFlag"
1287 // VFR related
1288 #define NI_LOGAN_ENC_PARAM_ENABLE_VFR "enableVFR"
1289 // HEVC explicit reference picture list
1290 #define NI_LOGAN_ENC_PARAM_ENABLE_EXPLICIT_RPL "enableExplicitRPL"
1291 // disable timing_info_preset_flag in VUI/VPS
1292 #define NI_LOGAN_ENC_PARAM_DISABLE_TIMING_INFO "disableTimingInfo"
1293 
1294 /* Decoder parameters */
1295 #define NI_LOGAN_DEC_PARAM_USR_DATA_SEI_PASSTHRU "enableUserDataSeiPassthru"
1296 #define NI_LOGAN_DEC_PARAM_CHECK_PACKET "checkPacket"
1297 #define NI_LOGAN_DEC_PARAM_CUSTOM_SEI_PASSTHRU "customSeiPassthru"
1298 #define NI_LOGAN_DEC_PARAM_LOW_DELAY "lowDelay"
1299 #define NI_LOGAN_DEC_PARAM_LOW_DELAY_MODE "lowDelayMode"
1300 #define NI_LOGAN_DEC_PARAM_ENABLE_FOLLOW_IFRAME "enableFollowIFrame"
1301 #define NI_LOGAN_DEC_PARAM_ENABLE_VUI_INFO_PASSTHRU "enableVuiInfoPassthru"
1302 
1303 // data exchange save options
1304 #define NI_LOGAN_DEC_PARAM_SAVE_PKT "savePkt"
1305 
1306 /* General parameters */
1307 #define NI_LOGAN_SET_HIGH_PRIORITY "setHighPriority"
1308 #define NI_LOGAN_KEEP_ALIVE_TIMEOUT "keepAliveTimeout"
1309 
1311 {
1312  int profile;
1318  //GOP Pattern
1319  int gop_preset_index; /*!*< A GOP structure preset option (IPP, IBP, IBBP, IbBbP, use Custom GOP, etc)
1320  0-custom 1-I-only 2-IPPP 3-IBBB 4-IBP ..... */
1321 
1322  // CUSTOM_GOP
1324 
1325  //Preset Mode
1326  int use_recommend_enc_params; /*!*< 0: Custom, 1: Slow speed and best quality,
1327  2: Normal Speed and quality, 3: Fast Speed and Low Quality */
1328 
1329  //Encode Options
1330 
1331  struct
1332  {
1333  //Rate control parameters
1334  int enable_rate_control; /*!*< It enable rate control */
1335  int enable_cu_level_rate_control; /*!*< It enable CU level rate control */
1336  int enable_hvs_qp; /*!*< It enable CU QP adjustment for subjective quality enhancement */
1337  int enable_hvs_qp_scale; /*!*< It enable QP scaling factor for CU QP adjustment when enable_hvs_qp = 1 */
1338  int hvs_qp_scale; /*!*< A QP scaling factor for CU QP adjustment when hvcQpenable = 1 */
1339  int min_qp; /*!*< A minimum QP for rate control */ //8
1340  int max_qp; /*!*< A maximum QP for rate control */ //51
1341  int max_delta_qp; /*!*< A maximum delta QP for rate control */ //10
1342  int trans_rate; /*!*< trans_rate */
1345 
1346  int max_frame_size; /*!*< limiting max frame in bits */
1347  int max_frame_ratio; /*!*< limiting max frame in ratio * avg_pic_size */
1348 
1349  // TBD Rev. B: could be shared for HEVC and H.264 ?
1351  } rc;
1352 
1354 
1356 
1358 
1360 
1361  //ConformanceWindowOffsets
1362  int conf_win_top; /*!*< A conformance window size of TOP */
1363  int conf_win_bottom; /*!*< A conformance window size of BOTTOM */
1364  int conf_win_left; /*!*< A conformance window size of LEFT */
1365  int conf_win_right; /*!*< A conformance window size of RIGHT */
1366 
1369 
1370  // Rev. B: H.264 only parameters, in ni_logan_t408_config_t
1371  // - for H.264 on T408:
1376 
1377  // - shared between HEVC and H.264
1382  // HLG preferred transfer characteristics
1384 
1386 
1387 typedef struct _ni_logan_frame
1388 {
1389  // codec of the source from which this frame is decoded
1391  long long dts;
1392  long long pts;
1393  uint32_t end_of_stream;
1395  uint32_t video_width;
1396  uint32_t video_height;
1399 
1400  uint32_t crop_top;
1401  uint32_t crop_bottom;
1402  uint32_t crop_left;
1403  uint32_t crop_right;
1404 
1405  // for encoder: force headers on this frame
1406  uint16_t force_headers;
1407  // for encoder: control long term reference picture feature
1410 
1412  // for encoding: frame picture type sent to encoder
1413  // for decoding: frame picture type returned from decoder
1415  // total SEI size: used by encoder
1416  unsigned int sei_total_len;
1417 
1418  // SEI info of closed caption: returned by decoder or set by encoder
1419  unsigned int sei_cc_offset;
1420  unsigned int sei_cc_len;
1421  // SEI info of HDR: returned by decoder
1426  // SEI info of HDR10+: returned by decoder
1427  unsigned int sei_hdr_plus_offset;
1428  unsigned int sei_hdr_plus_len;
1429  // SEI info of User Data Unregistered SEI: returned by decoder
1432  // SEI info of alternative transfer characteristics: returned by decoder
1435  // VUI info: returned by decoder
1436  unsigned int vui_offset;
1437  unsigned int vui_len;
1438 
1439  // ROI data length: for encoder
1440  unsigned int roi_len;
1441  // reconfig data length: for encoder
1442  unsigned int reconf_len;
1443  // total extra data data length: for encoder
1444  unsigned int extra_data_len;
1445  // force pic qp value
1446  uint16_t force_pic_qp;
1447  // frame chunk index
1449 
1452 
1453  void* p_buffer;
1454  uint32_t buffer_size;
1455 
1456  ni_logan_buf_t *dec_buf; // buffer pool entry (has memory pointed to by p_buffer)
1458 
1459  uint8_t *p_custom_sei;
1460  uint16_t bit_depth;
1461  int flags;
1462 
1463  // frame auxiliary data
1466 
1467  // the following info is of the source stream that is returned by decoder:
1468  // color info, sample aspect ratio, timing etc that are useful at encoding.
1470  uint8_t color_trc;
1471  uint8_t color_space;
1474  uint16_t sar_width;
1475  uint16_t sar_height;
1477  uint32_t vui_time_scale;
1478  // for encoder: whether metadata should be sent separately for frame
1481 
1483 {
1484  int log;
1485  int preset;
1487  uint32_t fps_number;
1489 
1494 
1499  int bitrate;
1500  int roi_demo_mode; // demo ROI support - for internal testing
1501  int reconf_demo_mode; // NETINT_INTERNAL - currently only for internal testing
1502  int force_pic_qp_demo_mode; // demo force pic qp mode - for internal testing
1503  int low_delay_mode; // encoder low latency mode
1504  int padding; // encoder input padding setting
1505  int generate_enc_hdrs; // generate encoder headers in advance of encoding
1506  int use_low_delay_poc_type; // specifies the encoder to set
1507  // picture_order_count_type=2 in the H.264 SPS
1508  int strict_timeout_mode; // encoder stricter timeout detection mode
1509 
1510  // HRD and AUD features related
1514 
1515  // 1: force on every frame with same input type; 0: no (except for I-frame)
1517  int intra_refresh_reset; // reset intra refresh on force IDR frame
1518 
1521 
1522  float crf; /*!*< Constant Rate Factor setting */
1523  float crfIpRatio;
1524  float crfPbRatio;
1525  int cbr; //It enables filler data for strict rate control
1526  int cacheRoi; // enables caching of ROIs applied to subsequent frames
1527  int enable_vfr; // enable the vfr
1528  int enable_explicit_rpl; // enable HEVC reference picture list
1529  int disable_timing_info; // disable timing_info_preset_flag in VPS/VUI
1531 
1532  uint32_t ui32flushGop;
1540  uint32_t pos_time_scale;
1541 
1545  int sar_num;
1548 
1550 
1551  // NETINT_INTERNAL - currently only for internal testing of reconfig, saving
1552  // key:val1,val2,val3,...val9 (max 9 values) in the demo reconfig data file
1553  // this supports max 100 lines in reconfig file, max 10 key/values per line
1554  int reconf_hash[100][10];
1555 
1556  // NETINT INTERNAL - save exchanged data between host and fw; the data is
1557  // saved in a circular buffer by packets in a folder uniquely identified
1558  // by process id and session id; 0 is to not save.
1559  unsigned int nb_save_pkt; // number of decoder-in packets to save
1560 
1561  uint8_t hwframes;
1563 
1564  int32_t chromaQpOffset; /*!*< The value of chroma QP offset */
1566 
1567 //ni_logan_decoder_input_params defs
1568 #define NI_LOGAN_DEC_PARAM_OUT "out"
1569 
1571 {
1583 
1585 {
1586  int log;
1587 
1589  uint32_t fps_number;
1591 
1596 
1601  int bitrate;
1602 
1604 
1605  // NETINT INTERNAL - save exchanged data between host and fw; the data is
1606  // saved in a circular buffer by packets in a folder uniquely identified
1607  // by process id and session id; 0 is to not save.
1608  unsigned int nb_save_pkt; // number of decoder-in packets to save
1609 
1610  uint8_t hwframes;
1612 
1613 typedef struct _ni_logan_packet
1614 {
1615 
1616  long long dts;
1617  long long pts;
1618  long long pos;
1619  uint32_t end_of_stream;
1621  uint32_t video_width;
1622  uint32_t video_height;
1623  uint32_t frame_type; // encoding result only 0=I, 1=P, 2=B, 5=IDR, 6=CRA
1625 
1626  void* p_data;
1627  uint32_t data_len;
1629 
1630  void* p_buffer;
1631  uint32_t buffer_size;
1632  uint32_t avg_frame_qp; // average frame QP reported by VPU
1633 
1635  //The length of SEI data which is located after slice payload in the same packet.
1636  //Skip these SEI data when send the packet to the FW
1638  int flags;
1640 
1641 // 24 bytes
1643 {
1644  int32_t device_handle;
1645 
1646  int8_t i8FrameIdx;
1647  int8_t i8InstID;
1648  uint16_t ui16SessionID;
1649 
1650  uint16_t ui16width;
1651  uint16_t ui16height;
1652 
1653  int8_t bit_depth; //1 ==8bit per pixel, 2 ==10
1654  int8_t encoding_type; //h264/265
1655  int8_t seq_change;
1656  int8_t rsvd;
1657  int32_t device_handle_ext; // high 32-bit device handle
1658  int32_t dma_buf_fd;
1660 
1662 {
1663  union
1664  {
1668 
1670 
1671 
1672 
1673 #define NI_LOGAN_XCODER_PRESET_NAMES_ARRAY_LEN 3
1674 #define NI_LOGAN_XCODER_LOG_NAMES_ARRAY_LEN 7
1675 
1676 #define NI_LOGAN_XCODER_PRESET_NAME_DEFAULT "default"
1677 #define NI_LOGAN_XCODER_PRESET_NAME_CUSTOM "custom"
1678 
1679 #define NI_LOGAN_XCODER_LOG_NAME_NONE "none"
1680 #define NI_LOGAN_XCODER_LOG_NAME_ERROR "error"
1681 #define NI_LOGAN_XCODER_LOG_NAME_WARN "warning"
1682 #define NI_LOGAN_XCODER_LOG_NAME_INFO "info"
1683 #define NI_LOGAN_XCODER_LOG_NAME_DEBUG "debug"
1684 #define NI_LOGAN_XCODER_LOG_NAME_FULL "full"
1685 
1687 extern LIB_API const char* const g_logan_xcoder_log_names[NI_LOGAN_XCODER_LOG_NAMES_ARRAY_LEN];
1688 
1689 /*!*****************************************************************************
1690  * \brief Convert error numver into error messages
1691  *
1692  *
1693  * \return the string of error message
1694  ******************************************************************************/
1695 LIB_API const char* ni_logan_err2str(int err);
1696 
1697 /*!*****************************************************************************
1698  * \brief Allocate and initialize a new ni_logan_session_context_t struct
1699  *
1700  *
1701  * \return On success returns a valid pointer to newly allocated context
1702  * On failure returns NULL
1703  ******************************************************************************/
1705 
1706 /*!*****************************************************************************
1707  * \brief Initialize already allocated session context to a known state
1708  *
1709  * \param[in] p_ctx Pointer to an already allocated ni_logan_session_context_t struct
1710  *
1711  *
1712  ******************************************************************************/
1714 
1715 /*!****************************************************************************
1716  * \brief Frees previously allocated session context
1717  *
1718  * \param[in] p_ctx Pointer to an already allocated ni_logan_session_context_t struct
1719  *
1720  ******************************************************************************/
1722 
1723 /*!******************************************************************************
1724  * \brief Clear already allocated session context to all zeros buffer
1725  *
1726  * \param[in] p_ctx Pointer to an already allocated ni_logan_session_context_t struct
1727  *
1728  *
1729  *******************************************************************************/
1731 
1732 /*!****************************************************************************
1733  * \brief Create event and returnes event handle if successful
1734  *
1735  * \return On success returns a event handle
1736  * On failure returns NI_INVALID_EVENT_HANDLE
1737  *****************************************************************************/
1738 LIB_API ni_event_handle_t ni_logan_create_event();
1739 
1740 /*!****************************************************************************
1741  * \brief Closes event and releases resources
1742  *
1743  * \return NONE
1744  *
1745  ******************************************************************************/
1746 LIB_API void ni_logan_close_event(ni_event_handle_t event_handle);
1747 
1748 /*!*****************************************************************************
1749  * \brief Opens device and returnes device device_handle if successful
1750  *
1751  * \param[in] p_dev Device name represented as c string. ex: "/dev/nvme0"
1752  * \param[out] p_max_io_size_out Maximum IO Transfer size supported
1753  *
1754  * \return On success returns a device device_handle
1755  * On failure returns NI_INVALID_DEVICE_HANDLE
1756  ******************************************************************************/
1757 LIB_API ni_device_handle_t ni_logan_device_open(const char* dev, uint32_t * p_max_io_size_out);
1758 
1759 /*!*****************************************************************************
1760  * \brief Closes device and releases resources
1761  *
1762  * \param[in] device_handle Device handle obtained by calling ni_logan_device_open()
1763  *
1764  * \return NONE
1765  *
1766  ******************************************************************************/
1767 LIB_API void ni_logan_device_close(ni_device_handle_t dev);
1768 
1769 /*!*****************************************************************************
1770  * \brief Queries device and returns device capability structure
1771  *
1772  * \param[in] device_handle Device handle obtained by calling ni_logan_device_open()
1773  * \param[in] p_cap Pointer to a caller allocated ni_logan_device_capability_t struct
1774  * \return On success
1775  * NI_LOGAN_RETCODE_SUCCESS
1776  * On failure
1777  NI_LOGAN_RETCODE_INVALID_PARAM
1778  NI_LOGAN_RETCODE_ERROR_MEM_ALOC
1779  NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1780  ******************************************************************************/
1781 LIB_API ni_logan_retcode_t ni_logan_device_capability_query(ni_device_handle_t device_handle,
1783 
1784 /*!*****************************************************************************
1785  * \brief Opens a new device session depending on the device_type parameter
1786  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER opens decoding session
1787  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER opens encoding session
1788  *
1789  * \param[in] p_ctx Pointer to a caller allocated
1790  * ni_logan_session_context_t struct
1791  * ni_logan_session_config_t struct
1792  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1793  * \return On success
1794  * NI_LOGAN_RETCODE_SUCCESS
1795  * On failure
1796  * NI_LOGAN_RETCODE_INVALID_PARAM
1797  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
1798  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1799  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1800  ******************************************************************************/
1802  ni_logan_device_type_t device_type);
1803 
1804 /*!*****************************************************************************
1805  * \brief Closes device session that was previously opened by calling
1806  * ni_logan_device_session_open()
1807  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER closes decoding session
1808  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER closes encoding session
1809  *
1810  * \param[in] p_ctx Pointer to a caller allocated
1811  * ni_logan_session_context_t struct
1812  * \param[in] eos_recieved Flag indicating if End Of Stream indicator was recieved
1813  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1814  * \return On success
1815  * NI_LOGAN_RETCODE_SUCCESS
1816  * On failure
1817  * NI_LOGAN_RETCODE_INVALID_PARAM
1818  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1819  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1820  ******************************************************************************/
1822  int eos_recieved,
1823  ni_logan_device_type_t device_type);
1824 
1825 /*!*****************************************************************************
1826  * \brief Sends a flush command to the device
1827  * ni_logan_device_session_open()
1828  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER sends flush command to decoder
1829  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER sends flush command to decoder
1830  *
1831  * \param[in] p_ctx Pointer to a caller allocated
1832  * ni_logan_session_context_t struct
1833  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1834  * \return On success
1835  * NI_LOGAN_RETCODE_SUCCESS
1836  * On failure
1837  * NI_LOGAN_RETCODE_INVALID_PARAM
1838  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1839  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1840  ******************************************************************************/
1842  ni_logan_device_type_t device_type);
1843 
1844 /*!*****************************************************************************
1845  * \brief Sends a flush command to the decoder
1846  * ni_logan_device_session_open()
1847  *
1848  * \param[in] p_ctx Pointer to a caller allocated
1849  * ni_logan_session_context_t struct
1850  * \return On success
1851  * NI_LOGAN_RETCODE_SUCCESS
1852  * On failure
1853  * NI_LOGAN_RETCODE_INVALID_PARAM
1854  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1855  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1856  ******************************************************************************/
1858 
1859 /*!*****************************************************************************
1860  * \brief Save a stream's headers in a decoder session that can be used later
1861  * for continuous decoding from the same source.
1862  *
1863  * \param[in] p_ctx Pointer to a caller allocated
1864  * ni_logan_session_context_t struct
1865  * \param[in] hdr_data Pointer to header data
1866  * \param[in] hdr_size Size of header data in bytes
1867  * \return On success
1868  * NI_LOGAN_RETCODE_SUCCESS
1869  * On failure
1870  * NI_LOGAN_RETCODE_INVALID_PARAM
1871  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1872  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1873  ******************************************************************************/
1875  ni_logan_session_context_t *p_ctx, uint8_t *hdr_data, uint8_t hdr_size);
1876 
1877 /*!*****************************************************************************
1878  * \brief Flush a decoder session to get ready to continue decoding.
1879  * Note: this is different from ni_logan_device_session_flush in that it closes the
1880  * current decode session and opens a new one for continuous decoding.
1881  *
1882  * \param[in] p_ctx Pointer to a caller allocated
1883  * ni_logan_session_context_t struct
1884  * \return On success
1885  * NI_LOGAN_RETCODE_SUCCESS
1886  * On failure
1887  * NI_LOGAN_RETCODE_INVALID_PARAM
1888  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1889  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1890  ******************************************************************************/
1892 
1893 /*!*****************************************************************************
1894  * \brief Sends data the device
1895  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER sends data packet to decoder
1896  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER sends data frame to encoder
1897  *
1898  * \param[in] p_ctx Pointer to a caller allocated
1899  * ni_logan_session_context_t struct
1900  * \param[in] p_data Pointer to a caller allocated
1901  * ni_logan_session_data_io_t struct which contains either a
1902  * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
1903  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1904  * If NI_LOGAN_DEVICE_TYPE_DECODER is specified, it is expected
1905  * that the ni_logan_packet_t struct inside the p_data pointer
1906  * contains data to send.
1907  * If NI_LOGAN_DEVICE_TYPE_ENCODER is specified, it is expected
1908  * that the ni_logan_frame_t struct inside the p_data pointer
1909  * contains data to send.
1910  * \return On success
1911  * Total number of bytes written
1912  * On failure
1913  * NI_LOGAN_RETCODE_INVALID_PARAM
1914  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1915  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1916  ******************************************************************************/
1919  ni_logan_device_type_t device_type);
1920 
1921 /*!*****************************************************************************
1922  * \brief Reads data the device
1923  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER reads data packet from decoder
1924  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER reads data frame from encoder
1925  *
1926  * \param[in] p_ctx Pointer to a caller allocated
1927  * ni_logan_session_context_t struct
1928  * \param[in] p_data Pointer to a caller allocated
1929  * ni_logan_session_data_io_t struct which contains either a
1930  * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
1931  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1932  * If NI_LOGAN_DEVICE_TYPE_DECODER is specified, data that was
1933  * read will be placed into ni_logan_frame_t struct inside the p_data pointer
1934  * If NI_LOGAN_DEVICE_TYPE_ENCODER is specified, data that was
1935  * read will be placed into ni_logan_packet_t struct inside the p_data pointer
1936  * \return On success
1937  * Total number of bytes read
1938  * On failure
1939  * NI_LOGAN_RETCODE_INVALID_PARAM
1940  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1941  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1942  ******************************************************************************/
1945  ni_logan_device_type_t device_type);
1946 
1947 /*!*****************************************************************************
1948  * \brief Query session data from the device - Currently not implemented
1949  * If device_type is NI_LOGAN_DEVICE_TYPE_DECODER query session data
1950  * from decoder
1951  * If device_type is NI_LOGAN_DEVICE_TYPE_EECODER query session data
1952  * from encoder
1953  *
1954  * \param[in] p_ctx Pointer to a caller allocated
1955  * ni_logan_session_context_t struct
1956  * \param[in] device_type NI_LOGAN_DEVICE_TYPE_DECODER or NI_LOGAN_DEVICE_TYPE_ENCODER
1957  *
1958  * \return On success
1959  * NI_LOGAN_RETCODE_SUCCESS
1960  * On failure
1961  * NI_LOGAN_RETCODE_INVALID_PARAM
1962  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
1963  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
1964  ******************************************************************************/
1966  ni_logan_device_type_t device_type);
1967 
1968 /*!*****************************************************************************
1969  * \brief Allocate preliminary memory for the frame buffer for encoding
1970  * based on provided parameters. Applicable to YUV420 Planar pixel
1971  * format only, 8 or 10 bit/pixel.
1972  *
1973  * \param[in] p_frame Pointer to a caller allocated
1974  * ni_logan_frame_t struct
1975  * \param[in] video_width Width of the video frame
1976  * \param[in] video_height Height of the video frame
1977  * \param[in] alignment Allignment requirement
1978  * \param[in] metadata_flag Flag indicating if space for additional metadata
1979  * should be allocated
1980  * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel
1981  *
1982  * \return On success
1983  * NI_LOGAN_RETCODE_SUCCESS
1984  * On failure
1985  * NI_LOGAN_RETCODE_INVALID_PARAM
1986  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
1987  ******************************************************************************/
1989  int video_width,
1990  int video_height,
1991  int alignment,
1992  int metadata_flag,
1993  int factor,
1994  int hw_frame_count);
1995 
1996 /*!*****************************************************************************
1997  * \brief Allocate memory for decoder frame buffer based on provided
1998  * parameters; the memory is retrieved from a buffer pool and will be
1999  * returned to the same buffer pool by ni_logan_decoder_frame_buffer_free.
2000  * Note: all attributes of ni_logan_frame_t will be set up except for memory and
2001  * buffer, which rely on the pool being allocated; the pool will be
2002  * allocated only after the frame resolution is known.
2003  *
2004  * \param[in] p_pool Buffer pool to get the memory from
2005  * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2006  * \param[in] alloc_mem Whether to get memory from buffer pool
2007  * \param[in] video_width Width of the video frame
2008  * \param[in] video_height Height of the video frame
2009  * \param[in] alignment Allignment requirement
2010  * \param[in] factor 1 for 8 bits/pixel format, 2 for 10 bits/pixel
2011  *
2012  * \return On success
2013  * NI_LOGAN_RETCODE_SUCCESS
2014  * On failure
2015  * NI_LOGAN_RETCODE_INVALID_PARAM
2016  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2017  ******************************************************************************/
2019  ni_logan_frame_t *pframe,
2020  int alloc_mem,
2021  int video_width,
2022  int video_height,
2023  int alignment,
2024  int factor);
2025 
2026 /*!*****************************************************************************
2027  * \brief Allocate memory for the frame buffer for encoding based on given
2028  * parameters, taking into account pic line size and extra data.
2029  * Applicable to YUV420p AVFrame only. 8 or 10 bit/pixel.
2030  * Cb/Cr size matches that of Y.
2031  *
2032  * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2033  *
2034  * \param[in] video_width Width of the video frame
2035  * \param[in] video_height Height of the video frame
2036  * \param[in] linesize Picture line size
2037  * \param[in] alignment Allignment requirement
2038  * \param[in] extra_len Extra data size (incl. meta data)
2039  *
2040  * \return On success
2041  * NI_LOGAN_RETCODE_SUCCESS
2042  * On failure
2043  * NI_LOGAN_RETCODE_INVALID_PARAM
2044  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2045  *****************************************************************************/
2047  int video_width,
2048  int video_height,
2049  int linesize[],
2050  int alignment,
2051  int extra_len,
2052  int factor);
2053 
2054 /*!*****************************************************************************
2055  * \brief Free frame buffer that was previously allocated with either
2056  * ni_logan_frame_buffer_alloc or ni_logan_encoder_frame_buffer_alloc
2057  *
2058  * \param[in] p_frame Pointer to a previously allocated ni_logan_frame_t struct
2059  *
2060  * \return On success NI_LOGAN_RETCODE_SUCCESS
2061  * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2062  ******************************************************************************/
2064 
2065 /*!*****************************************************************************
2066  * \brief Free decoder frame buffer that was previously allocated with
2067  * ni_logan_decoder_frame_buffer_alloc, returning memory to a buffer pool.
2068  *
2069  * \param[in] p_frame Pointer to a previously allocated ni_logan_frame_t struct
2070  *
2071  * \return On success NI_LOGAN_RETCODE_SUCCESS
2072  * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2073  ******************************************************************************/
2075 
2076 /*!*****************************************************************************
2077  * \brief Return a memory buffer to memory buffer pool, for a decoder frame.
2078  *
2079  * \param[in] buf Buffer to be returned.
2080  * \param[in] p_buffer_pool Buffer pool to return buffer to.
2081  *
2082  * \return None
2083  ******************************************************************************/
2085  ni_logan_buf_pool_t *p_buffer_pool);
2086 
2087 /*!*****************************************************************************
2088  * \brief Allocate memory for the packet buffer based on provided packet size
2089  *
2090  * \param[in] p_packet Pointer to a caller allocated
2091  * ni_logan_packet_t struct
2092  * \param[in] packet_size Required allocation size
2093  *
2094  * \return On success
2095  * NI_LOGAN_RETCODE_SUCCESS
2096  * On failure
2097  * NI_LOGAN_RETCODE_INVALID_PARAM
2098  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2099  ******************************************************************************/
2101  int packet_size);
2102 
2103 /*!*****************************************************************************
2104  * \brief Free packet buffer that was previously allocated with either
2105  * ni_logan_packet_buffer_alloc
2106  *
2107  * \param[in] p_packet Pointer to a previously allocated ni_logan_packet_t struct
2108  *
2109  * \return On success NI_LOGAN_RETCODE_SUCCESS
2110  * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2111  ******************************************************************************/
2113 
2114 /*!*****************************************************************************
2115  * \brief Copy video packet accounting for allighment
2116  *
2117  * \param[in] p_destination Destination to where to copy to
2118  * \param[in] p_source Source from where to copy from
2119  * \param[in] cur_size current size
2120  * \param[out] p_leftover Pointer to the data that was left over
2121  * \param[out] p_prev_size Size of the data leftover ??
2122  *
2123  * \return On success Total number of bytes that were copied
2124  * On failure NI_LOGAN_RETCODE_FAILURE
2125  ******************************************************************************/
2126 LIB_API int ni_logan_packet_copy(void* p_destination,
2127  const void* const p_source,
2128  int cur_size,
2129  void* p_leftover,
2130  int* p_prev_size);
2131 
2132 /*!*****************************************************************************
2133  * \brief Initialize default encoder parameters
2134  *
2135  * \param[out] param Pointer to a user allocated ni_logan_encoder_params_t
2136  * to initialize to default parameters
2137  * \param[in] fps_num Frames per second
2138  * \param[in] fps_denom FPS denomination
2139  * \param[in] bit_rate bit rate
2140  * \param[in] width width
2141  * \param[in] height height
2142  *
2143  * \return On success
2144  * NI_LOGAN_RETCODE_SUCCESS
2145  * On failure
2146  * NI_LOGAN_RETCODE_FAILURE
2147  * NI_LOGAN_RETCODE_INVALID_PARAM
2148  ******************************************************************************/
2150  int fps_num,
2151  int fps_denom,
2152  long bit_rate,
2153  int width,
2154  int height);
2155 
2156 
2157 /*!*****************************************************************************
2158  * \brief Initialize default decoder parameters
2159  *
2160  * \param[out] param Pointer to a user allocated ni_logan_decoder_params_t
2161  * to initialize to default parameters
2162  * \param[in] fps_num Frames per second
2163  * \param[in] fps_denom FPS denomination
2164  * \param[in] bit_rate bit rate
2165  * \param[in] width width
2166  * \param[in] height height
2167  *
2168  * \return On success
2169  * NI_LOGAN_RETCODE_SUCCESS
2170  * On failure
2171  * NI_LOGAN_RETCODE_FAILURE
2172  * NI_LOGAN_RETCODE_INVALID_PARAM
2173  ******************************************************************************/
2175  int fps_num,
2176  int fps_denom,
2177  long bit_rate,
2178  int width,
2179  int height);
2180 
2181 /*!******************************************************************************
2182 * \brief Set value referenced by name in decoder parameters structure
2183 *
2184 * \param[in] p_params Pointer to a user allocated ni_logan_decoder_params_t
2185 * to find and set a particular parameter
2186 * \param[in] name String represented parameter name to search
2187 * \param[in] value Parameter value to set
2188 *
2189 * \return On success
2190 * NI_LOGAN_RETCODE_SUCCESS
2191 * On failure
2192 * NI_LOGAN_RETCODE_FAILURE
2193 * NI_LOGAN_RETCODE_INVALID_PARAM
2194 *******************************************************************************/
2196  const char* name,
2197  char* value);
2198 
2199 /*!******************************************************************************
2200 * \brief Set value referenced by name in encoder parameters structure
2201 *
2202 * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2203 * to find and set a particular parameter
2204 * \param[in] name String represented parameter name to search
2205 * \param[in] value Parameter value to set
2206 *
2207 * \return On success
2208 * NI_LOGAN_RETCODE_SUCCESS
2209 * On failure
2210 * NI_LOGAN_RETCODE_FAILURE
2211 * NI_LOGAN_RETCODE_INVALID_PARAM
2212 ******************************************************************************/
2214  const char *name,
2215  const char *value,
2217 
2218 /*!*****************************************************************************
2219 * \brief Validate relationship of some params in encoder parameters structure
2220 *
2221 * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2222 * \param[in] codec encoding codec
2223 *
2224 * \return On success
2225 * NI_LOGAN_RETCODE_SUCCESS
2226 * On failure
2227 * NI_LOGAN_RETCODE_FAILURE
2228 * NI_LOGAN_RETCODE_PARAM_ERROR_OOR and other error rc
2229 *******************************************************************************/
2231  ni_logan_codec_format_t codec);
2232 
2233 
2234 /*!*****************************************************************************
2235  * \brief Set gop parameter value referenced by name in encoder parameters
2236  * structure
2237  *
2238  * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2239  * to find and set a particular parameter
2240  * \param[in] name String represented parameter name to search
2241  * \param[in] value Parameter value to set
2242 *
2243  * \return On success
2244  * NI_LOGAN_RETCODE_SUCCESS
2245  * On failure
2246  * NI_LOGAN_RETCODE_FAILURE
2247  * NI_LOGAN_RETCODE_INVALID_PARAM
2248  ******************************************************************************/
2250  const char *name,
2251  const char *value);
2252 
2253 /*!*****************************************************************************
2254  * \brief Get GOP's max number of reorder frames
2255  *
2256  * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2257  *
2258  * \return max number of reorder frames of the GOP
2259  ******************************************************************************/
2261 
2262 /*!*****************************************************************************
2263  * \brief Get GOP's number of reference frames
2264  *
2265  * \param[in] p_params Pointer to a user allocated ni_logan_encoder_params_t
2266  *
2267  * \return number of reference frames of the GOP
2268  ******************************************************************************/
2270 
2271 /*!*****************************************************************************
2272  * \brief Add a new auxiliary data to a frame
2273  *
2274  * \param[in/out] frame a frame to which the auxiliary data should be added
2275  * \param[in] type type of the added auxiliary data
2276  * \param[in] data_size size of the added auxiliary data
2277  *
2278  * \return a pointer to the newly added aux data on success, NULL otherwise
2279  ******************************************************************************/
2281  ni_aux_data_type_t type,
2282  int data_size);
2283 
2284 /*!*****************************************************************************
2285  * \brief Add a new auxiliary data to a frame and copy in the raw data
2286  *
2287  * \param[in/out] frame a frame to which the auxiliary data should be added
2288  * \param[in] type type of the added auxiliary data
2289  * \param[in] raw_data the raw data of the aux data
2290  * \param[in] data_size size of the added auxiliary data
2291  *
2292  * \return a pointer to the newly added aux data on success, NULL otherwise
2293  ******************************************************************************/
2295  ni_logan_frame_t *frame,
2296  ni_aux_data_type_t type,
2297  const uint8_t* raw_data,
2298  int data_size);
2299 
2300 /*!*****************************************************************************
2301  * \brief Retrieve from the frame auxiliary data of a given type if exists
2302  *
2303  * \param[in] frame a frame from which the auxiliary data should be retrieved
2304  * \param[in] type type of the auxiliary data to be retrieved
2305  *
2306  * \return a pointer to the aux data of a given type on success, NULL otherwise
2307  ******************************************************************************/
2309  ni_aux_data_type_t type);
2310 
2311 /*!*****************************************************************************
2312  * \brief If auxiliary data of the given type exists in the frame, free it
2313  * and remove it from the frame.
2314  *
2315  * \param[in/out] frame a frame from which the auxiliary data should be removed
2316  * \param[in] type type of the auxiliary data to be removed
2317  *
2318  * \return None
2319  ******************************************************************************/
2321  ni_aux_data_type_t type);
2322 
2323 /*!*****************************************************************************
2324  * \brief Free and remove all auxiliary data from the frame.
2325  *
2326  * \param[in/out] frame a frame from which the auxiliary data should be removed
2327  *
2328  * \return None
2329  ******************************************************************************/
2330 LIB_API void ni_logan_frame_wipe_aux_data(ni_logan_frame_t *frame);
2331 
2332 /*!******************************************************************************
2333 * \brief Queries device Serial number
2334 *
2335 * \param[in] device_handle Device handle used to backtrace serial Num
2336 * \param[in] p_serial_num Pointer to a caller allocated ni_logan_serial_num_t struct
2337 * \return On success
2338 * NI_LOGAN_RETCODE_SUCCESS
2339 * On failure
2340 * NI_LOGAN_RETCODE_INVALID_PARAM
2341 * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2342 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2343 *******************************************************************************/
2344 LIB_API ni_logan_retcode_t ni_logan_device_handle_map_SN(ni_device_handle_t device_handle,
2345  ni_logan_serial_num_t *p_serial_num);
2346 
2347 /*!******************************************************************************
2348 * \brief Copies existing decoding session params for hw frame usage
2349 *
2350 * \param[in] src_p_ctx Pointer to a caller allocated source
2351 * ni_logan_session_context_t struct
2352 * \param[in] dst_p_ctx Pointer to a caller allocated destination
2353 * ni_logan_session_context_t struct
2354 * \return On success
2355 * NI_LOGAN_RETCODE_SUCCESS
2356 * On failure
2357 * NI_LOGAN_RETCODE_INVALID_PARAM
2358 * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2359 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2360 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2361 *******************************************************************************/
2363  ni_logan_session_context_t *dst_p_ctx);
2364 
2365 /*!******************************************************************************
2366 * \brief Sends frame pool setup info to device
2367 *
2368 * \param[in] p_ctx Pointer to a caller allocated
2369 * ni_logan_session_context_t struct
2370 * \param[in] p_data Pointer to a caller allocated
2371 * ni_logan_session_data_io_t struct which contains either a
2372 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2373 * \return On success Return code
2374 * On failure
2375 * NI_LOGAN_RETCODE_INVALID_PARAM
2376 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2377 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2378 *******************************************************************************/
2380  uint32_t pool_size, uint32_t p2p_pool);
2381 
2382 /*!******************************************************************************
2383 * \brief Reads data from the device
2384 * device_type should be NI_LOGAN_DEVICE_TYPE_DECODER,
2385 * and reads data hwdesc from decoder when hw transcoding
2386 *
2387 * \param[in] p_ctx Pointer to a caller allocated
2388 * ni_logan_session_context_t struct
2389 * \param[in] p_data Pointer to a caller allocated
2390 * ni_logan_session_data_io_t struct which contains either a
2391 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2392 * \return On success
2393 * Total number of bytes read
2394 * On failure
2395 * NI_LOGAN_RETCODE_INVALID_PARAM
2396 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2397 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2398 *******************************************************************************/
2400  ni_logan_session_data_io_t *p_data);
2401 
2402 /*!******************************************************************************
2403 * \brief Reads data from hw descriptor from decoder output buffer
2404 *
2405 * \param[in] p_data Pointer to a caller allocated
2406 * ni_logan_session_data_io_t struct which contains either a
2407 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2408 * \param[in] hwdesc HW descriptor to find frame in XCODER
2409 * \return On success
2410 * Total number of bytes read
2411 * On failure
2412 * NI_LOGAN_RETCODE_INVALID_PARAM
2413 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2414 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2415 *******************************************************************************/
2418  ni_logan_hwframe_surface_t* hwdesc);
2419 
2420 /*!******************************************************************************
2421 * \brief Writes data and reads back hw descriptor from decoder output buffer
2422 *
2423 * \param[in] p_src_data Pointer to a caller allocated
2424 * ni_logan_session_data_io_t struct which contains either a
2425 * ni_logan_frame_t data frame or ni_logan_packet_t data packet to send
2426 * \param[in] hwdesc HW descriptor to find frame in XCODER
2427 * \return On success
2428 * Total number of bytes read
2429 * On failure
2430 * NI_LOGAN_RETCODE_INVALID_PARAM
2431 * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2432 * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2433 *******************************************************************************/
2435  ni_logan_session_data_io_t *p_src_data,
2436  ni_logan_hwframe_surface_t* hwdesc);
2437 
2438 #ifndef _WIN32
2439  /*!*****************************************************************************
2440  * \brief Acquire a P2P frame buffer from the hwupload session
2441  *
2442  * \param[in] p_ctx Pointer to a caller allocated
2443  * ni_session_context_t struct
2444  * \param[out] p_frame Pointer to a caller allocated hw frame
2445  *
2446  * \return On success
2447  * NI_RETCODE_SUCCESS
2448  * On failure
2449  * NI_RETCODE_INVALID_PARAM
2450  * NI_RETCODE_ERROR_NVME_CMD_FAILED
2451  * NI_RETCODE_ERROR_INVALID_SESSION
2452  *******************************************************************************/
2454 
2455  /*!*****************************************************************************
2456  * \brief Lock a hardware P2P frame prior to encoding
2457  *
2458  * \param[in] p_upl_ctx pointer to caller allocated upload context
2459  * [in] p_frame pointer to caller allocated hardware P2P frame
2460  *
2461  * \return On success
2462  * NI_RETCODE_SUCCESS
2463  * On failure NI_RETCODE_FAILURE
2464  * NI_RETCODE_INVALID_PARAM
2465  *******************************************************************************/
2467  ni_logan_frame_t *p_frame);
2468 
2469 /*!*****************************************************************************
2470 * \brief Unlock a hardware P2P frame after encoding
2471 *
2472 * \param[in] p_upl_ctx pointer to caller allocated upload context
2473 * [in] p_frame pointer to caller allocated hardware P2P frame
2474 *
2475 * \return On success
2476 * NI_RETCODE_SUCCESS
2477 * On failure NI_RETCODE_FAILURE
2478 * NI_RETCODE_INVALID_PARAM
2479 *******************************************************************************/
2481  ni_logan_frame_t *p_frame);
2482 
2483  /*!*****************************************************************************
2484  * \brief Special P2P test API call. Copies YUV data from the software
2485  * frame to the hardware P2P frame on the Quadra device
2486  *
2487  * \param[in] p_upl_ctx pointer to caller allocated uploader session
2488  * context
2489  * [in] p_swframe pointer to a caller allocated software frame
2490  * [in] p_hwframe pointer to a caller allocated hardware frame
2491  *
2492  * \return On success
2493  * NI_RETCODE_SUCCESS
2494  * On failure
2495  * NI_RETCODE_FAILURE
2496  * NI_RETCODE_INVALID_PARAM
2497  *******************************************************************************/
2499  uint8_t *p_data, uint32_t len,
2500  ni_logan_frame_t *p_hwframe);
2501  #endif
2502 
2503  /*!*****************************************************************************
2504  * \brief Set the incoming frame format for the encoder
2505  *
2506  * \param[in] p_enc_ctx pointer to encoder context
2507  * [in] p_enc_params pointer to encoder parameters
2508  * [in] width input width
2509  * [in] height input height
2510  * [in] bit_depth 8 for 8-bit YUV, 10 for 10-bit YUV
2511  * [in] src_endian NI_FRAME_LITTLE_ENDIAN or NI_FRAME_BIG_ENDIAN
2512  *
2513  * \return on success
2514  * NI_RETCODE_SUCCESS
2515  *
2516  * on failure
2517  * NI_RETCODE_INVALID_PARAM
2518 *******************************************************************************/
2520  ni_logan_session_context_t *p_enc_ctx, ni_logan_encoder_params_t *p_enc_params,
2521  int width, int height, int bit_depth, int src_endian);
2522 
2523 /*!*****************************************************************************
2524 * \brief Allocate memory for the frame buffer based on provided parameters
2525 * taking into account pic line size and extra data.
2526 * Applicable to YUV420p AVFrame only. Cb/Cr size matches that of Y.
2527 *
2528 * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2529 *
2530 * \param[in] video_width Width of the video frame
2531 * \param[in] video_height Height of the video frame
2532 * \param[in] linesize Picture line size
2533 * \param[in] alignment Allignment requirement
2534 * \param[in] extra_len Extra data size (incl. meta data)
2535 *
2536 * \return On success
2537 * NI_LOGAN_RETCODE_SUCCESS
2538 * On failure
2539 * NI_LOGAN_RETCODE_INVALID_PARAM
2540 * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2541 *****************************************************************************/
2543  int video_width,
2544  int video_height,
2545  int extra_len);
2546 
2547 /*!******************************************************************************
2548 * \brief POPULATE ME LATER
2549 *
2550 * \param[in] p_packet Pointer to a previously allocated ni_logan_packet_t struct
2551 * \param[in] device_handle device handle
2552 * \param[in] event_handle event handle
2553 *
2554 * \return On success NI_LOGAN_RETCODE_SUCCESS
2555 * On failure NI_LOGAN_RETCODE_INVALID_PARAM
2556 *******************************************************************************/
2558  ni_device_handle_t device_handle,
2559  ni_event_handle_t event_handle);
2560 
2561 /*!******************************************************************************
2562  * \brief Allocate a frame on the device based on provided parameters
2563  *
2564  * \param[in] p_ctx pointer to session context
2565  * \param[in] width width, in pixels
2566  * \param[in] height height, in pixels
2567  * \param[in] format pixel format
2568  * \param[in] options options flags
2569  * \param[in] rectangle_width clipping rectangle width
2570  * \param[in] rectangle_height clipping rectangle height
2571  * \param[in] rectangle_x horizontal position of clipping rectangle
2572  * \param[in] rectangle_y vertical position of clipping rectangle
2573  * \param[in] rgba_color RGBA fill colour (for padding only)
2574  * \param[in] frame_index frame index (only applicable for hw frame)
2575  * \param[in] device_type only NI_LOGAN_DEVICE_TYPE_SCALER supported now
2576  *
2577  * \return NI_LOGAN_RETCODE_INVALID_PARAM
2578  * NI_LOGAN_RETCODE_ERROR_INVALID_SESSION
2579  * NI_LOGAN_RETCODE_ERROR_NVME_CMD_FAILED
2580  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2581  *******************************************************************************/
2583  int width,
2584  int height,
2585  int format,
2586  int options,
2587  int rectangle_width,
2588  int rectangle_height,
2589  int rectangle_x,
2590  int rectangle_y,
2591  int rgba_color,
2592  int frame_index,
2593  ni_logan_device_type_t device_type);
2594 
2595 /*!******************************************************************************
2596  * \brief Allocate memory for the frame buffer based on provided parameters
2597  * taking into account width, height, format, stride, alignment, and
2598  * extra data
2599  *
2600  * \param[in] p_frame Pointer to caller allocated ni_logan_frame_t
2601  * \param[in] pixel_format pixel format
2602  * \param[in] video_width width, in pixels
2603  * \param[in] video_height height, in pixels
2604  * \param[in] linesize horizontal stride
2605  * \param[in] alignment apply a 16 pixel height alignment (T408 only)
2606  * \param[in] extra_len meta data size
2607  *
2608  * \return NI_LOGAN_RETCODE_SUCCESS
2609  * NI_LOGAN_RETCODE_INVALID_PARAM
2610  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2611  *
2612  *******************************************************************************/
2614  int pixel_format,
2615  int video_width,
2616  int video_height,
2617  int linesize[],
2618  int alignment,
2619  int extra_len);
2620 
2621 /*!*****************************************************************************
2622  * \brief Allocate memory for the frame buffer for encoding based on given
2623  * parameters, taking into account pic line size and extra data.
2624  * Applicable to YUV420p AVFrame only. 8 or 10 bit/pixel.
2625  * Cb/Cr size matches that of Y.
2626  *
2627  * \param[in] p_frame Pointer to a caller allocated ni_logan_frame_t struct
2628  *
2629  * \param[in] video_width Width of the video frame
2630  * \param[in] video_height Height of the video frame
2631  * \param[in] linesize Picture line size
2632  * \param[in] extra_len Extra data size (incl. meta data)
2633  * \param[in] buffer[] Buffer address of video frame.
2634  *
2635  * \return On success
2636  * NI_LOGAN_RETCODE_SUCCESS
2637  * On failure
2638  * NI_LOGAN_RETCODE_INVALID_PARAM
2639  * NI_LOGAN_RETCODE_ERROR_MEM_ALOC
2640  *****************************************************************************/
2642  int video_width,
2643  int video_height,
2644  int linesize[],
2645  int extra_len,
2646  int factor,
2647  uint8_t* buffer[]);
2648 
2649 /*!*****************************************************************************
2650  * \brief Check if incoming frame is encoder zero copy compatible or not
2651  *
2652  * \param[in] width width of encoder frame.
2653  * \param[in] height height of encoder frame.
2654  * \param[in] linesize linesizes (pointer to array).
2655  * \param[in] dst_stride dst_stride (produced by ni_logan_get_hw_yuv420p_dim).
2656  * \param[in] src_height src height of every planar.
2657  * \param[in] dst_height dst_height_aligned(produced by ni_logan_get_hw_yuv420p_dim).
2658  * \param[in] bit_depth_factor bit_depth of frame.
2659  * \param[in] data CPU address of frame planar.
2660  *
2661  * \return on success
2662  * NI_LOGAN_RETCODE_SUCCESS
2663  *
2664  * on failure
2665  * NI_LOGAN_RETCODE_FAILURE
2666  *
2667 *******************************************************************************/
2668 LIB_API ni_logan_retcode_t ni_logan_frame_zerocopy_check(const int width,
2669  const int height,
2670  const int linesize[],
2671  const int dst_stride[],
2672  const int src_height[],
2673  const int dst_height[],
2674  const int bit_depth_factor,
2675  const uint8_t * data[]);
2676 
2677 /*!*****************************************************************************
2678  * \brief Check if logan firmware version is higher than expected api flavor and version
2679  *
2680  * \param[in] p_ctx Pointer to a caller allocated
2681  * ni_logan_session_context_t struct
2682  * \param[in] fw_api_fla expected firmware api flavor
2683  * \param[in] fw_api_ver expected firmware api version
2684  *
2685  * \return on success
2686  * NI_LOGAN_RETCODE_SUCCESS
2687  * On failure
2688  * NI_LOGAN_RETCODE_FAILURE
2689  *
2690 *******************************************************************************/
2691 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);
2692 #ifdef __cplusplus
2693 }
2694 #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
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