1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef __HI_COMM_VENC_H__ 16 #define __HI_COMM_VENC_H__ 17 18 #include "hi_type.h" 19 #include "hi_common.h" 20 #include "hi_errno.h" 21 #include "hi_comm_video.h" 22 #include "hi_comm_rc.h" 23 #include "hi_comm_vb.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif /* __cplusplus */ 28 29 /* invlalid channel ID */ 30 #define HI_ERR_VENC_INVALID_CHNID HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID) 31 /* at lease one parameter is illagal, eg, an illegal enumeration value */ 32 #define HI_ERR_VENC_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM) 33 /* channel exists */ 34 #define HI_ERR_VENC_EXIST HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST) 35 /* channel exists */ 36 #define HI_ERR_VENC_UNEXIST HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST) 37 /* using a NULL point */ 38 #define HI_ERR_VENC_NULL_PTR HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR) 39 /* try to enable or initialize system, device or channel, before configing attribute */ 40 #define HI_ERR_VENC_NOT_CONFIG HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG) 41 /* operation is not supported by NOW */ 42 #define HI_ERR_VENC_NOT_SUPPORT HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT) 43 /* operation is not permitted, eg, try to change stati attribute */ 44 #define HI_ERR_VENC_NOT_PERM HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM) 45 /* failure caused by malloc memory */ 46 #define HI_ERR_VENC_NOMEM HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM) 47 /* failure caused by malloc buffer */ 48 #define HI_ERR_VENC_NOBUF HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF) 49 /* no data in buffer */ 50 #define HI_ERR_VENC_BUF_EMPTY HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY) 51 /* no buffer for new data */ 52 #define HI_ERR_VENC_BUF_FULL HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL) 53 /* system is not ready, had not initialed or loaded */ 54 #define HI_ERR_VENC_SYS_NOTREADY HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY) 55 /* system is busy */ 56 #define HI_ERR_VENC_BUSY HI_DEF_ERR(HI_ID_VENC, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY) 57 58 #define HI_VENC_MAX_PACK_INFO_NUM 8 59 #define HI_VENC_MAX_SSE_NUM 8 60 #define HI_VENC_MAX_MPF_NUM 2 61 #define HI_VENC_MAX_HIERARCHY_NUM 4 62 #define HI_VENC_SCALING_DIMENSION_NUM 2 63 #define HI_VENC_SCALING_LIST_SIZE_16 16 64 #define HI_VENC_SCALING_LIST_SIZE_64 64 65 #define HI_VENC_JPEG_QT_COEF_NUM 64 66 #define HI_VENC_MJPEG_QT_COEF_NUM HI_VENC_JPEG_QT_COEF_NUM 67 #define HI_VENC_PRORES_QT_COEF_NUM 64 68 #define HI_VENC_PRORES_MAX_ID_CHAR_NUM 4 69 #define HI_VENC_PRORES_MAX_VENDOR_NUM 4 70 #define HI_VENC_MAX_MOSAIC_RECT_NUM 200 71 #define HI_VENC_MAX_FRAME_NUM 2 72 #define HI_VENC_MAX_SVC_RECT_NUM 32 73 74 /* the nalu type of H264E */ 75 typedef enum hiH264E_NALU_TYPE_E { 76 H264E_NALU_BSLICE = 0, /* B SLICE types */ 77 H264E_NALU_PSLICE = 1, /* P SLICE types */ 78 H264E_NALU_ISLICE = 2, /* I SLICE types */ 79 H264E_NALU_IDRSLICE = 5, /* IDR SLICE types */ 80 H264E_NALU_SEI = 6, /* SEI types */ 81 H264E_NALU_SPS = 7, /* SPS types */ 82 H264E_NALU_PPS = 8, /* PPS types */ 83 H264E_NALU_BUTT 84 } H264E_NALU_TYPE_E; 85 86 /* the nalu type of H265E */ 87 typedef enum hiH265E_NALU_TYPE_E { 88 H265E_NALU_BSLICE = 0, /* B SLICE types */ 89 H265E_NALU_PSLICE = 1, /* P SLICE types */ 90 H265E_NALU_ISLICE = 2, /* I SLICE types */ 91 H265E_NALU_IDRSLICE = 19, /* IDR SLICE types */ 92 H265E_NALU_VPS = 32, /* VPS types */ 93 H265E_NALU_SPS = 33, /* SPS types */ 94 H265E_NALU_PPS = 34, /* PPS types */ 95 H265E_NALU_SEI = 39, /* SEI types */ 96 H265E_NALU_ENHANCE = 64, /* ENHANCE types */ 97 H265E_NALU_BUTT 98 } H265E_NALU_TYPE_E; 99 100 /* the reference type of H264E slice */ 101 typedef enum hiH264E_REFSLICE_TYPE_E { 102 H264E_REFSLICE_FOR_1X = 1, /* Reference slice for H264E_REF_MODE_1X */ 103 H264E_REFSLICE_FOR_2X = 2, /* Reference slice for H264E_REF_MODE_2X */ 104 H264E_REFSLICE_FOR_4X = 5, /* Reference slice for H264E_REF_MODE_4X */ 105 H264E_REFSLICE_FOR_BUTT /* slice not for reference */ 106 } H264E_REFSLICE_TYPE_E; 107 108 /* the pack type of JPEGE */ 109 typedef enum hiJPEGE_PACK_TYPE_E { 110 JPEGE_PACK_ECS = 5, /* ECS types */ 111 JPEGE_PACK_APP = 6, /* APP types */ 112 JPEGE_PACK_VDO = 7, /* VDO types */ 113 JPEGE_PACK_PIC = 8, /* PIC types */ 114 JPEGE_PACK_DCF = 9, /* DCF types */ 115 JPEGE_PACK_DCF_PIC = 10, /* DCF PIC types */ 116 JPEGE_PACK_BUTT 117 } JPEGE_PACK_TYPE_E; 118 119 /* the pack type of PRORES */ 120 typedef enum hiPRORES_PACK_TYPE_E { 121 PRORES_PACK_PIC = 1, /* PIC types */ 122 PRORES_PACK_BUTT 123 } PRORES_PACK_TYPE_E; 124 125 /* the data type of VENC */ 126 typedef union hiVENC_DATA_TYPE_U { 127 H264E_NALU_TYPE_E enH264EType; /* R; H264E NALU types */ 128 JPEGE_PACK_TYPE_E enJPEGEType; /* R; JPEGE pack types */ 129 H265E_NALU_TYPE_E enH265EType; /* R; H264E NALU types */ 130 PRORES_PACK_TYPE_E enPRORESType; 131 } VENC_DATA_TYPE_U; 132 133 /* the pack info of VENC */ 134 typedef struct hiVENC_PACK_INFO_S { 135 VENC_DATA_TYPE_U u32PackType; /* R; the pack type */ 136 HI_U32 u32PackOffset; 137 HI_U32 u32PackLength; 138 } VENC_PACK_INFO_S; 139 140 /* Defines a stream packet */ 141 typedef struct hiVENC_PACK_S { 142 HI_U64 u64PhyAddr; /* R; the physics address of stream */ 143 HI_U8 ATTRIBUTE *pu8Addr; /* R; the virtual address of stream */ 144 HI_U32 ATTRIBUTE u32Len; /* R; the length of stream */ 145 146 HI_U64 u64PTS; /* R; PTS */ 147 HI_BOOL bFrameEnd; /* R; frame end */ 148 149 VENC_DATA_TYPE_U DataType; /* R; the type of stream */ 150 HI_U32 u32Offset; /* R; the offset between the Valid data and the start address */ 151 HI_U32 u32DataNum; /* R; the stream packets num */ 152 VENC_PACK_INFO_S stPackInfo[HI_VENC_MAX_PACK_INFO_NUM]; /* R; the stream packet Information */ 153 } VENC_PACK_S; 154 155 /* Defines the frame type and reference attributes of the H.264 frame skipping reference streams */ 156 typedef enum hiH264E_REF_TYPE_E { 157 BASE_IDRSLICE = 0, /* the Idr frame at Base layer */ 158 BASE_PSLICE_REFTOIDR, /* the P frame at Base layer, referenced by other frames 159 at Base layer and reference to Idr frame */ 160 BASE_PSLICE_REFBYBASE, /* the P frame at Base layer, referenced by other frames 161 at Base layer */ 162 BASE_PSLICE_REFBYENHANCE, /* the P frame at Base layer, referenced by other frames 163 at Enhance layer */ 164 ENHANCE_PSLICE_REFBYENHANCE, /* the P frame at Enhance layer, referenced by other frames 165 at Enhance layer */ 166 ENHANCE_PSLICE_NOTFORREF, /* the P frame at Enhance layer, not referenced */ 167 ENHANCE_PSLICE_BUTT 168 } H264E_REF_TYPE_E; 169 170 typedef enum hiH264E_REF_TYPE_E H265E_REF_TYPE_E; 171 172 /* Defines the features of an H.264 stream */ 173 typedef struct hiVENC_STREAM_INFO_H264_S { 174 HI_U32 u32PicBytesNum; /* R; the coded picture stream byte number */ 175 HI_U32 u32Inter16x16MbNum; /* R; the inter16x16 macroblock num */ 176 HI_U32 u32Inter8x8MbNum; /* R; the inter8x8 macroblock num */ 177 HI_U32 u32Intra16MbNum; /* R; the intra16x16 macroblock num */ 178 HI_U32 u32Intra8MbNum; /* R; the intra8x8 macroblock num */ 179 HI_U32 u32Intra4MbNum; /* R; the inter4x4 macroblock num */ 180 181 H264E_REF_TYPE_E enRefType; /* R; Type of encoded frames in 182 advanced frame skipping reference mode */ 183 HI_U32 u32UpdateAttrCnt; /* R; Number of times that channel attributes or parameters 184 (including RC parameters) are set */ 185 HI_U32 u32StartQp; /* R; the start Qp of encoded frames */ 186 HI_U32 u32MeanQp; /* R; the mean Qp of encoded frames */ 187 HI_BOOL bPSkip; 188 } VENC_STREAM_INFO_H264_S; 189 190 /* Defines the features of an H.265 stream */ 191 typedef struct hiVENC_STREAM_INFO_H265_S { 192 HI_U32 u32PicBytesNum; /* R; the coded picture stream byte number */ 193 HI_U32 u32Inter64x64CuNum; /* R; the inter64x64 cu num */ 194 HI_U32 u32Inter32x32CuNum; /* R; the inter32x32 cu num */ 195 HI_U32 u32Inter16x16CuNum; /* R; the inter16x16 cu num */ 196 HI_U32 u32Inter8x8CuNum; /* R; the inter8x8 cu num */ 197 HI_U32 u32Intra32x32CuNum; /* R; the Intra32x32 cu num */ 198 HI_U32 u32Intra16x16CuNum; /* R; the Intra16x16 cu num */ 199 HI_U32 u32Intra8x8CuNum; /* R; the Intra8x8 cu num */ 200 HI_U32 u32Intra4x4CuNum; /* R; the Intra4x4 cu num */ 201 202 H265E_REF_TYPE_E enRefType; /* R; Type of encoded frames 203 in advanced frame skipping reference mode */ 204 HI_U32 u32UpdateAttrCnt; /* R; Number of times that channel attributes or 205 parameters (including RC parameters) are set */ 206 HI_U32 u32StartQp; /* R; the start Qp of encoded frames */ 207 HI_U32 u32MeanQp; /* R; the mean Qp of encoded frames */ 208 HI_BOOL bPSkip; 209 } VENC_STREAM_INFO_H265_S; 210 211 /* the sse info */ 212 typedef struct hiVENC_SSE_INFO_S { 213 HI_BOOL bSSEEn; /* RW; Range:[0, 1]; Region SSE enable */ 214 HI_U32 u32SSEVal; /* R; Region SSE value */ 215 } VENC_SSE_INFO_S; 216 217 /* the advance information of the h264e */ 218 typedef struct hiVENC_STREAM_ADVANCE_INFO_H264_S { 219 HI_U32 u32ResidualBitNum; /* R; the residual num */ 220 HI_U32 u32HeadBitNum; /* R; the head bit num */ 221 HI_U32 u32MadiVal; /* R; the madi value */ 222 HI_U32 u32MadpVal; /* R; the madp value */ 223 HI_DOUBLE dPSNRVal; /* R; the PSNR value */ 224 HI_U32 u32MseLcuCnt; /* R; the lcu cnt of the mse */ 225 HI_U32 u32MseSum; /* R; the sum of the mse */ 226 VENC_SSE_INFO_S stSSEInfo[HI_VENC_MAX_SSE_NUM]; /* R; the information of the sse */ 227 HI_U32 u32QpHstgrm[VENC_QP_HISGRM_NUM]; /* R; the Qp histogram value */ 228 HI_U32 u32MoveScene16x16Num; /* R; the 16x16 cu num of the move scene */ 229 HI_U32 u32MoveSceneBits; /* R; the stream bit num of the move scene */ 230 } VENC_STREAM_ADVANCE_INFO_H264_S; 231 232 /* the advance information of the Jpege */ 233 typedef struct hiVENC_STREAM_ADVANCE_INFO_JPEG_S { 234 /* Reserved */ 235 } VENC_STREAM_ADVANCE_INFO_JPEG_S; 236 237 /* the advance information of the Prores */ 238 typedef struct hiVENC_STREAM_ADVANCE_INFO_PRORES_S { 239 /* Reserved */ 240 } VENC_STREAM_ADVANCE_INFO_PRORES_S; 241 242 /* the advance information of the h265e */ 243 typedef struct hiVENC_STREAM_ADVANCE_INFO_H265_S { 244 HI_U32 u32ResidualBitNum; /* R; the residual num */ 245 HI_U32 u32HeadBitNum; /* R; the head bit num */ 246 HI_U32 u32MadiVal; /* R; the madi value */ 247 HI_U32 u32MadpVal; /* R; the madp value */ 248 HI_DOUBLE dPSNRVal; /* R; the PSNR value */ 249 HI_U32 u32MseLcuCnt; /* R; the lcu cnt of the mse */ 250 HI_U32 u32MseSum; /* R; the sum of the mse */ 251 VENC_SSE_INFO_S stSSEInfo[HI_VENC_MAX_SSE_NUM]; /* R; the information of the sse */ 252 HI_U32 u32QpHstgrm[VENC_QP_HISGRM_NUM]; /* R; the Qp histogram value */ 253 HI_U32 u32MoveScene32x32Num; /* R; the 32x32 cu num of the move scene */ 254 HI_U32 u32MoveSceneBits; /* R; the stream bit num of the move scene */ 255 } VENC_STREAM_ADVANCE_INFO_H265_S; 256 257 /* Defines the features of an jpege stream */ 258 typedef struct hiVENC_STREAM_INFO_PRORES_S { 259 HI_U32 u32PicBytesNum; 260 HI_U32 u32UpdateAttrCnt; 261 } VENC_STREAM_INFO_PRORES_S; 262 263 /* Defines the features of an jpege stream */ 264 typedef struct hiVENC_STREAM_INFO_JPEG_S { 265 HI_U32 u32PicBytesNum; /* R; the coded picture stream byte number */ 266 HI_U32 u32UpdateAttrCnt; /* R; Number of times that channel attributes or parameters 267 (including RC parameters) are set */ 268 HI_U32 u32Qfactor; /* R; image quality */ 269 } VENC_STREAM_INFO_JPEG_S; 270 271 /* Defines the features of an stream */ 272 typedef struct hiVENC_STREAM_S { 273 VENC_PACK_S ATTRIBUTE *pstPack; /* R; stream pack attribute */ 274 HI_U32 ATTRIBUTE u32PackCount; /* R; the pack number of one frame stream */ 275 HI_U32 u32Seq; /* R; the list number of stream */ 276 277 union { 278 VENC_STREAM_INFO_H264_S stH264Info; /* R; the stream info of h264 */ 279 VENC_STREAM_INFO_JPEG_S stJpegInfo; /* R; the stream info of jpeg */ 280 VENC_STREAM_INFO_H265_S stH265Info; /* R; the stream info of h265 */ 281 VENC_STREAM_INFO_PRORES_S stProresInfo; /* R; the stream info of prores */ 282 }; 283 284 union { 285 VENC_STREAM_ADVANCE_INFO_H264_S stAdvanceH264Info; /* R; the stream info of h264 */ 286 VENC_STREAM_ADVANCE_INFO_JPEG_S stAdvanceJpegInfo; /* R; the stream info of jpeg */ 287 VENC_STREAM_ADVANCE_INFO_H265_S stAdvanceH265Info; /* R; the stream info of h265 */ 288 VENC_STREAM_ADVANCE_INFO_PRORES_S stAdvanceProresInfo; /* R; the stream info of prores */ 289 }; 290 } VENC_STREAM_S; 291 292 typedef struct hiVENC_STREAM_INFO_S { 293 H265E_REF_TYPE_E enRefType; /* R;Type of encoded frames in advanced frame skipping reference mode */ 294 295 HI_U32 u32PicBytesNum; /* R;the coded picture stream byte number */ 296 HI_U32 u32PicCnt; /* R;When channel attributes 'bByFrame == 1', it means count of frames. 297 When channel attributes 'bByFrame == 0', it means count of packets */ 298 HI_U32 u32StartQp; /* R;the start Qp of encoded frames */ 299 HI_U32 u32MeanQp; /* R;the mean Qp of encoded frames */ 300 HI_BOOL bPSkip; 301 302 HI_U32 u32ResidualBitNum; /* R;residual */ 303 HI_U32 u32HeadBitNum; /* R;head information */ 304 HI_U32 u32MadiVal; /* R;madi */ 305 HI_U32 u32MadpVal; /* R;madp */ 306 HI_U32 u32MseSum; /* R;Sum of MSE value */ 307 HI_U32 u32MseLcuCnt; /* R;Sum of LCU number */ 308 HI_DOUBLE dPSNRVal; /* R;PSNR */ 309 } VENC_STREAM_INFO_S; 310 311 /* the size of array is 2, that is the maximum */ 312 typedef struct hiVENC_MPF_CFG_S { 313 HI_U8 u8LargeThumbNailNum; /* RW; Range:[0, 2]; the large thumbnail pic num of the MPF */ 314 SIZE_S astLargeThumbNailSize[HI_VENC_MAX_MPF_NUM]; /* RW; The resolution of large ThumbNail */ 315 } VENC_MPF_CFG_S; 316 317 typedef enum hiVENC_PIC_RECEIVE_MODE_E { 318 VENC_PIC_RECEIVE_SINGLE = 0, 319 VENC_PIC_RECEIVE_MULTI, 320 321 VENC_PIC_RECEIVE_BUTT 322 } VENC_PIC_RECEIVE_MODE_E; 323 324 /* the attribute of jpege */ 325 typedef struct hiVENC_ATTR_JPEG_S { 326 HI_BOOL bSupportDCF; /* RW; Range:[0, 1]; support dcf */ 327 VENC_MPF_CFG_S stMPFCfg; /* RW; Range:[0, 1]; config of Mpf */ 328 VENC_PIC_RECEIVE_MODE_E enReceiveMode; /* RW; Config the receive mode;Not support for Hi3559AV100 */ 329 } VENC_ATTR_JPEG_S; 330 331 /* the attribute of mjpege */ 332 typedef struct hiVENC_ATTR_MJPEG_S { 333 /* reserved */ 334 } VENC_ATTR_MJPEG_S; 335 336 /* the attribute of h264e */ 337 typedef struct hiVENC_ATTR_H264_S { 338 HI_BOOL bRcnRefShareBuf; /* RW; Range:[0, 1]; Whether to enable the Share Buf of Rcn and Ref */ 339 } VENC_ATTR_H264_S; 340 341 /* the attribute of h265e */ 342 typedef struct hiVENC_ATTR_H265_S { 343 HI_BOOL bRcnRefShareBuf; /* RW; Range:[0, 1]; Whether to enable the Share Buf of Rcn and Ref */ 344 } VENC_ATTR_H265_S; 345 346 /* the frame rate of PRORES */ 347 typedef enum hiPRORES_FRAMERATE { 348 PRORES_FR_UNKNOWN = 0, 349 PRORES_FR_23_976, 350 PRORES_FR_24, 351 PRORES_FR_25, 352 PRORES_FR_29_97, 353 PRORES_FR_30, 354 PRORES_FR_50, 355 PRORES_FR_59_94, 356 PRORES_FR_60, 357 PRORES_FR_100, 358 PRORES_FR_119_88, 359 PRORES_FR_120, 360 PRORES_FR_BUTT 361 } PRORES_FRAMERATE; 362 363 /* the aspect ratio of PRORES */ 364 typedef enum hiPRORES_ASPECT_RATIO { 365 PRORES_ASPECT_RATIO_UNKNOWN = 0, 366 PRORES_ASPECT_RATIO_SQUARE, 367 PRORES_ASPECT_RATIO_4_3, 368 PRORES_ASPECT_RATIO_16_9, 369 PRORES_ASPECT_RATIO_BUTT 370 } PRORES_ASPECT_RATIO; 371 372 /* the attribute of PRORES */ 373 typedef struct hiVENC_ATTR_PRORES_S { 374 HI_CHAR cIdentifier[HI_VENC_PRORES_MAX_ID_CHAR_NUM]; 375 PRORES_FRAMERATE enFrameRateCode; 376 PRORES_ASPECT_RATIO enAspectRatio; 377 } VENC_ATTR_PRORES_S; 378 379 /* the attribute of the Venc */ 380 typedef struct hiVENC_ATTR_S { 381 PAYLOAD_TYPE_E enType; /* RW; the type of payload */ 382 383 HI_U32 u32MaxPicWidth; /* RW; Range:[0, 16384];maximum width of a picture to be encoded, in pixel */ 384 HI_U32 u32MaxPicHeight; /* RW; Range:[0, 16384];maximum height of a picture to be encoded, in pixel */ 385 386 HI_U32 u32BufSize; /* RW; stream buffer size */ 387 HI_U32 u32Profile; /* RW; Range:[0, 3]; 388 H.264: 0: baseline; 1:MP; 2:HP; 3: SVC-T [0, 3]; 389 H.265: 0:MP; 1:Main 10 [0 1]; 390 Jpege/MJpege: 0:Baseline 391 prores: 0:ProRes Proxy; 1:ProRes 422(LT); 2:ProRes 422; 3:ProRes 422(HQ) */ 392 HI_BOOL bByFrame; /* RW; Range:[0, 1]; get stream mode is slice mode or frame mode */ 393 HI_U32 u32PicWidth; /* RW; Range:[0, 16384];width of a picture to be encoded, in pixel */ 394 HI_U32 u32PicHeight; /* RW; Range:[0, 16384];height of a picture to be encoded, in pixel */ 395 union { 396 VENC_ATTR_H264_S stAttrH264e; /* attributes of H264e */ 397 VENC_ATTR_H265_S stAttrH265e; /* attributes of H265e */ 398 VENC_ATTR_MJPEG_S stAttrMjpege; /* attributes of Mjpeg */ 399 VENC_ATTR_JPEG_S stAttrJpege; /* attributes of jpeg */ 400 VENC_ATTR_PRORES_S stAttrProres; /* attributes of prores */ 401 }; 402 } VENC_ATTR_S; 403 404 /* the gop mode */ 405 typedef enum hiVENC_GOP_MODE_E { 406 VENC_GOPMODE_NORMALP = 0, /* NORMALP */ 407 VENC_GOPMODE_DUALP = 1, /* DUALP; Not support for Hi3556AV100 */ 408 VENC_GOPMODE_SMARTP = 2, /* SMARTP; Not support for Hi3556AV100 */ 409 VENC_GOPMODE_ADVSMARTP = 3, /* ADVSMARTP ; Only used for Hi3559AV100 */ 410 VENC_GOPMODE_BIPREDB = 4, /* BIPREDB ;Only used for Hi3559AV100/Hi3519AV100 */ 411 VENC_GOPMODE_LOWDELAYB = 5, /* LOWDELAYB; Not support */ 412 413 VENC_GOPMODE_BUTT, 414 } VENC_GOP_MODE_E; 415 416 /* the attribute of the normalp */ 417 typedef struct hiVENC_GOP_NORMALP_S { 418 HI_S32 s32IPQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and I frame */ 419 } VENC_GOP_NORMALP_S; 420 421 /* the attribute of the dualp */ 422 typedef struct hiVENC_GOP_DUALP_S { 423 HI_U32 u32SPInterval; /* RW; Range:[0, 65536]; Interval of the special P frames, 424 1 is not supported and should be less than Gop */ 425 HI_S32 s32SPQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and special P frame */ 426 HI_S32 s32IPQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and I frame */ 427 } VENC_GOP_DUALP_S; 428 429 /* the attribute of the smartp */ 430 typedef struct hiVENC_GOP_SMARTP_S { 431 HI_U32 u32BgInterval; /* RW; Interval of the long-term reference frame, can not be less than gop */ 432 HI_S32 s32BgQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and Bg frame */ 433 HI_S32 s32ViQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and virtual I frame */ 434 } VENC_GOP_SMARTP_S; 435 436 /* the attribute of the advsmartp */ 437 typedef struct hiVENC_GOP_ADVSMARTP_S { 438 HI_U32 u32BgInterval; /* RW; Interval of the long-term reference frame, can not be less than gop */ 439 HI_S32 s32BgQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and Bg frame */ 440 HI_S32 s32ViQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and virtual I frame */ 441 } VENC_GOP_ADVSMARTP_S; 442 443 /* the attribute of the bipredb */ 444 typedef struct hiVENC_GOP_BIPREDB_S { 445 HI_U32 u32BFrmNum; /* RW; Range:[1, 3]; Number of B frames */ 446 HI_S32 s32BQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and B frame */ 447 HI_S32 s32IPQpDelta; /* RW; Range:[-10, 30]; QP variance between P frame and I frame */ 448 } VENC_GOP_BIPREDB_S; 449 450 /* the attribute of the gop */ 451 typedef struct hiVENC_GOP_ATTR_S { 452 VENC_GOP_MODE_E enGopMode; /* RW; Encoding GOP type */ 453 union { 454 VENC_GOP_NORMALP_S stNormalP; /* attributes of normal P */ 455 VENC_GOP_DUALP_S stDualP; /* attributes of dual P */ 456 VENC_GOP_SMARTP_S stSmartP; /* attributes of Smart P */ 457 VENC_GOP_ADVSMARTP_S stAdvSmartP; /* attributes of AdvSmart P */ 458 VENC_GOP_BIPREDB_S stBipredB; /* attributes of b */ 459 }; 460 } VENC_GOP_ATTR_S; 461 462 /* the attribute of the venc chnl */ 463 typedef struct hiVENC_CHN_ATTR_S { 464 VENC_ATTR_S stVencAttr; /* the attribute of video encoder */ 465 VENC_RC_ATTR_S stRcAttr; /* the attribute of rate ctrl */ 466 VENC_GOP_ATTR_S stGopAttr; /* the attribute of gop */ 467 } VENC_CHN_ATTR_S; 468 469 /* the param of receive picture */ 470 typedef struct hiVENC_RECV_PIC_PARAM_S { 471 HI_S32 s32RecvPicNum; /* RW; Range:[-1, 2147483647]; Number of frames received and 472 encoded by the encoding channel, 0 is not supported */ 473 } VENC_RECV_PIC_PARAM_S; 474 475 /* the status of the venc chnl */ 476 typedef struct hiVENC_CHN_STATUS_S { 477 HI_U32 u32LeftPics; /* R; left picture number */ 478 HI_U32 u32LeftStreamBytes; /* R; left stream bytes */ 479 HI_U32 u32LeftStreamFrames; /* R; left stream frames */ 480 HI_U32 u32CurPacks; /* R; pack number of current frame */ 481 HI_U32 u32LeftRecvPics; /* R; Number of frames to be received. This member is valid 482 after HI_MPI_VENC_StartRecvPicEx is called. */ 483 HI_U32 u32LeftEncPics; /* R; Number of frames to be encoded. This member is valid 484 after HI_MPI_VENC_StartRecvPicEx is called. */ 485 HI_BOOL bJpegSnapEnd; /* R; the end of Snap. */ 486 VENC_STREAM_INFO_S stVencStrmInfo; 487 } VENC_CHN_STATUS_S; 488 489 /* the param of the h264e slice split */ 490 typedef struct hiVENC_H264_SLICE_SPLIT_S { 491 HI_BOOL bSplitEnable; /* RW; Range:[0, 1]; slice split enable, HI_TRUE:enable, 492 HI_FALSE:diable, default value:HI_FALSE */ 493 HI_U32 u32MbLineNum; /* RW; the max number is (Picture height + 15)/16; 494 this value presents the mb line number of one slice */ 495 } VENC_H264_SLICE_SPLIT_S; 496 497 /* the param of the h264e intra pred */ 498 typedef struct hiVENC_H264_INTRA_PRED_S { 499 HI_U32 constrained_intra_pred_flag; /* RW; Range:[0, 1];default: HI_FALSE, 500 see the H.264 protocol for the meaning */ 501 } VENC_H264_INTRA_PRED_S; 502 503 /* the param of the h264e trans */ 504 typedef struct hiVENC_H264_TRANS_S { 505 HI_U32 u32IntraTransMode; /* RW; Range:[0, 2]; Conversion mode for intra-prediction, 506 0: trans4x4, trans8x8; 1: trans4x4, 2: trans8x8 */ 507 HI_U32 u32InterTransMode; /* RW; Range:[0, 2]; Conversion mode for inter-prediction, 508 0: trans4x4, trans8x8; 1: trans4x4, 2: trans8x8 */ 509 510 HI_BOOL bScalingListValid; /* RW; Range:[0, 1]; enable Scaling, default: HI_FALSE */ 511 /* RW; Range:[1, 255]; A quantization table for 8x8 inter-prediction */ 512 HI_U8 InterScalingList8X8[HI_VENC_SCALING_LIST_SIZE_64]; 513 /* RW; Range:[1, 255]; A quantization table for 8x8 intra-prediction */ 514 HI_U8 IntraScalingList8X8[HI_VENC_SCALING_LIST_SIZE_64]; 515 516 HI_S32 chroma_qp_index_offset; /* RW; Range:[-12, 12];default value: 0, 517 see the H.264 protocol for the meaning */ 518 } VENC_H264_TRANS_S; 519 520 /* the param of the h264e entropy */ 521 typedef struct hiVENC_H264_ENTROPY_S { 522 HI_U32 u32EntropyEncModeI; /* RW; Range:[0, 1]; Entropy encoding mode for the I frame, 523 0:cavlc, 1:cabac */ 524 HI_U32 u32EntropyEncModeP; /* RW; Range:[0, 1]; Entropy encoding mode for the P frame, 525 0:cavlc, 1:cabac */ 526 HI_U32 u32EntropyEncModeB; /* RW; Range:[0, 1]; Entropy encoding mode for the B frame, 527 0:cavlc, 1:cabac */ 528 HI_U32 cabac_init_idc; /* RW; Range:[0, 2]; see the H.264 protocol for the meaning */ 529 } VENC_H264_ENTROPY_S; 530 531 /* the config of the h264e poc */ 532 typedef struct hiVENC_H264_POC_S { 533 HI_U32 pic_order_cnt_type; /* RW; Range:[0, 2]; see the H.264 protocol for the meaning */ 534 } VENC_H264_POC_S; 535 536 /* the param of the h264e deblocking */ 537 typedef struct hiVENC_H264_DBLK_S { 538 HI_U32 disable_deblocking_filter_idc; /* RW; Range:[0, 2]; see the H.264 protocol for the meaning */ 539 HI_S32 slice_alpha_c0_offset_div2; /* RW; Range:[-6, +6]; see the H.264 protocol for the meaning */ 540 HI_S32 slice_beta_offset_div2; /* RW; Range:[-6, +6]; see the H.264 protocol for the meaning */ 541 } VENC_H264_DBLK_S; 542 543 /* the param of the h264e vui timing info */ 544 typedef struct hiVENC_H264_VUI_TIME_INFO_S { 545 HI_U8 timing_info_present_flag; /* RW; Range:[0, 1]; 546 If 1, timing info belows will be encoded into vui. */ 547 HI_U8 fixed_frame_rate_flag; /* RW; Range:[0, 1]; 548 see the H.264 protocol for the meaning. */ 549 HI_U32 num_units_in_tick; /* RW; Range:(0, 4294967295]; 550 see the H.264 protocol for the meaning */ 551 HI_U32 time_scale; /* RW; Range:(0, 4294967295]; 552 see the H.264 protocol for the meaning */ 553 } VENC_VUI_H264_TIME_INFO_S; 554 555 /* the param of the vui aspct ratio */ 556 typedef struct hiVENC_VUI_ASPECT_RATIO_S { 557 HI_U8 aspect_ratio_info_present_flag; /* RW; Range:[0, 1]; If 1, aspectratio info belows 558 will be encoded into vui */ 559 HI_U8 aspect_ratio_idc; /* RW; Range:[0, 255]; 17~254 is reserved, 560 see the protocol for the meaning. */ 561 HI_U8 overscan_info_present_flag; /* RW; Range:[0, 1]; If 1, 562 oversacan info belows will be encoded into vui. */ 563 HI_U8 overscan_appropriate_flag; /* RW; Range:[0, 1]; see the protocol for the meaning. */ 564 HI_U16 sar_width; /* RW; Range:(0, 65535]; see the protocol for the meaning. */ 565 HI_U16 sar_height; /* RW; Range:(0, 65535]; see the protocol for the meaning. 566 notes: sar_width and sar_height shall be relatively prime. */ 567 } VENC_VUI_ASPECT_RATIO_S; 568 569 /* the param of the vui video signal */ 570 typedef struct hiVENC_VUI_VIDEO_SIGNAL_S { 571 HI_U8 video_signal_type_present_flag; /* RW; Range:[0, 1]; 572 If 1, video singnal info will be encoded into vui */ 573 HI_U8 video_format; /* RW; H.264e Range:[0, 7], H.265e Range:[0, 5]; 574 see the protocol for the meaning. */ 575 HI_U8 video_full_range_flag; /* RW; Range: [0, 1]; see the protocol for the meaning */ 576 HI_U8 colour_description_present_flag; /* RO; Range: [0, 1]; see the protocol for the meaning */ 577 HI_U8 colour_primaries; /* RO; Range: [0, 255]; see the protocol for the meaning */ 578 HI_U8 transfer_characteristics; /* RO; Range: [0, 255]; see the protocol for the meaning */ 579 HI_U8 matrix_coefficients; /* RO; Range:[0, 255]; see the protocol for the meaning */ 580 } VENC_VUI_VIDEO_SIGNAL_S; 581 582 /* the param of the vui video signal */ 583 typedef struct hiVENC_VUI_BITSTREAM_RESTRIC_S { 584 HI_U8 bitstream_restriction_flag; /* RW; Range: [0, 1]; see the protocol for the meaning */ 585 } VENC_VUI_BITSTREAM_RESTRIC_S; 586 587 /* the param of the h264e vui */ 588 typedef struct hiVENC_H264_VUI_S { 589 VENC_VUI_ASPECT_RATIO_S stVuiAspectRatio; 590 VENC_VUI_H264_TIME_INFO_S stVuiTimeInfo; 591 VENC_VUI_VIDEO_SIGNAL_S stVuiVideoSignal; 592 VENC_VUI_BITSTREAM_RESTRIC_S stVuiBitstreamRestric; 593 } VENC_H264_VUI_S; 594 595 /* the param of the h265e vui timing info */ 596 typedef struct hiVENC_VUI_H265_TIME_INFO_S { 597 HI_U32 timing_info_present_flag; /* RW; Range:[0, 1]; If 1, timing info belows will be encoded into vui. */ 598 HI_U32 num_units_in_tick; /* RW; Range:[0, 4294967295]; see the H.265 protocol for the meaning. */ 599 HI_U32 time_scale; /* RW; Range:(0, 4294967295]; see the H.265 protocol for the meaning */ 600 HI_U32 num_ticks_poc_diff_one_minus1; /* RW; Range:(0, 4294967294]; see the H.265 protocol for the meaning */ 601 } VENC_VUI_H265_TIME_INFO_S; 602 603 /* the param of the h265e vui */ 604 typedef struct hiVENC_H265_VUI_S { 605 VENC_VUI_ASPECT_RATIO_S stVuiAspectRatio; 606 VENC_VUI_H265_TIME_INFO_S stVuiTimeInfo; 607 VENC_VUI_VIDEO_SIGNAL_S stVuiVideoSignal; 608 VENC_VUI_BITSTREAM_RESTRIC_S stVuiBitstreamRestric; 609 } VENC_H265_VUI_S; 610 611 /* the param of the jpege */ 612 typedef struct hiVENC_JPEG_PARAM_S { 613 HI_U32 u32Qfactor; /* RW; Range:[1, 99]; Qfactor value */ 614 HI_U8 u8YQt[HI_VENC_JPEG_QT_COEF_NUM]; /* RW; Range:[1, 255]; Y quantization table */ 615 HI_U8 u8CbQt[HI_VENC_JPEG_QT_COEF_NUM]; /* RW; Range:[1, 255]; Cb quantization table */ 616 HI_U8 u8CrQt[HI_VENC_JPEG_QT_COEF_NUM]; /* RW; Range:[1, 255]; Cr quantization table */ 617 HI_U32 u32MCUPerECS; /* RW; the max MCU number is (picwidth + 15) >> 4 x (picheight + 15) >> 4 x 2]; 618 MCU number of one ECS */ 619 } VENC_JPEG_PARAM_S; 620 621 /* the param of the mjpege */ 622 typedef struct hiVENC_MJPEG_PARAM_S { 623 HI_U8 u8YQt[HI_VENC_MJPEG_QT_COEF_NUM]; /* RW; Range:[1, 255]; Y quantization table */ 624 HI_U8 u8CbQt[HI_VENC_MJPEG_QT_COEF_NUM]; /* RW; Range:[1, 255]; Cb quantization table */ 625 HI_U8 u8CrQt[HI_VENC_MJPEG_QT_COEF_NUM]; /* RW; Range:[1, 255]; Cr quantization table */ 626 HI_U32 u32MCUPerECS; /* RW; the max MCU number is (picwidth + 15) >> 4 x (picheight + 15) >> 4 x 2]; 627 MCU number of one ECS */ 628 } VENC_MJPEG_PARAM_S; 629 630 /* the param of the ProRes */ 631 typedef struct hiVENC_PRORES_PARAM_S { 632 HI_U8 u8LumaQt[HI_VENC_PRORES_QT_COEF_NUM]; /* RW; Range:[1, 255]; Luma quantization table */ 633 HI_U8 u8ChromaQt[HI_VENC_PRORES_QT_COEF_NUM]; /* RW; Range:[1, 255]; Chroma quantization table */ 634 HI_CHAR encoder_identifier[HI_VENC_PRORES_MAX_VENDOR_NUM]; /* RW: identifies the encoder vendor or product that 635 generated the compressed frame */ 636 } VENC_PRORES_PARAM_S; 637 638 /* the attribute of the roi */ 639 typedef struct hiVENC_ROI_ATTR_S { 640 HI_U32 u32Index; /* RW; Range:[0, 7]; Index of an ROI. 641 The system supports indexes ranging from 0 to 7 */ 642 HI_BOOL bEnable; /* RW; Range:[0, 1]; Whether to enable this ROI */ 643 HI_BOOL bAbsQp; /* RW; Range:[0, 1]; QP mode of an ROI. 644 HI_FALSE: relative QP.HI_TURE: absolute QP */ 645 HI_S32 s32Qp; /* RW; Range:[-51, 51]; 646 QP value, only relative mode can QP value less than 0. */ 647 RECT_S stRect; /* RW; Region of an ROI */ 648 } VENC_ROI_ATTR_S; 649 650 typedef enum { 651 HI_VENC_ROI_FOR_I = 0, 652 HI_VENC_ROI_FOR_P_B, 653 HI_VENC_ROI_FOR_VI, 654 HI_VENC_ROI_FOR_BUTT, 655 } HI_VENC_ROI_FOR_FRAME; 656 657 /* ROI struct */ 658 typedef struct hiVENC_ROI_ATTR_EX_S { 659 HI_U32 u32Index; /* RW; Range:[0, 7]; Index of an ROI. 660 The system supports indexes ranging from 0 to 7 */ 661 HI_BOOL bEnable[HI_VENC_ROI_FOR_BUTT]; /* RW; Range:[0, 1]; Subscript of array 662 0: I Frame; 1: P/B Frame; 2: VI Frame; other params are the same */ 663 HI_BOOL bAbsQp[HI_VENC_ROI_FOR_BUTT]; /* RW; Range:[0, 1]; QP mode of an ROI. 664 HI_FALSE: relative QP.HI_TURE: absolute QP */ 665 HI_S32 s32Qp[HI_VENC_ROI_FOR_BUTT]; /* RW; Range:[-51, 51]; QP value, 666 only relative mode can QP value less than 0 */ 667 RECT_S stRect[HI_VENC_ROI_FOR_BUTT]; /* RW;Region of an ROI */ 668 } VENC_ROI_ATTR_EX_S; 669 670 /* the param of the roibg frame rate */ 671 typedef struct hiVENC_ROIBG_FRAME_RATE_S { 672 HI_S32 s32SrcFrmRate; /* RW; Range:[-1, 2147483647];Source frame rate of a non-ROI, 673 can not be configured 0 */ 674 HI_S32 s32DstFrmRate; /* RW; Range:[-1, 2147483647];Target frame rate of a non-ROI, 675 can not be larger than s32SrcFrmRate */ 676 } VENC_ROIBG_FRAME_RATE_S; 677 678 /* the param of the roibg frame rate */ 679 typedef struct hiVENC_REF_PARAM_S { 680 HI_U32 u32Base; /* RW; Range:[0, 4294967295]; Base layer period */ 681 HI_U32 u32Enhance; /* RW; Range:[0, 255]; Enhance layer period */ 682 HI_BOOL bEnablePred; /* RW; Range:[0, 1]; Whether some frames at the base layer are referenced 683 by other frames at the base layer. When bEnablePred is HI_FALSE, 684 all frames at the base layer reference IDR frames */ 685 } VENC_REF_PARAM_S; 686 687 /* Jpeg snap mode */ 688 typedef enum hiVENC_JPEG_ENCODE_MODE_E { 689 JPEG_ENCODE_ALL = 0, /* Jpeg channel snap all the pictures when started. */ 690 JPEG_ENCODE_SNAP = 1, /* Jpeg channel snap the flashed pictures when started. */ 691 JPEG_ENCODE_BUTT, 692 } VENC_JPEG_ENCODE_MODE_E; 693 694 /* the information of the stream */ 695 typedef struct hiVENC_STREAM_BUF_INFO_S { 696 HI_U64 u64PhyAddr[MAX_TILE_NUM]; /* R; Start physical address for a stream buffer */ 697 HI_VOID ATTRIBUTE *pUserAddr[MAX_TILE_NUM]; /* R; Start virtual address for a stream buffer */ 698 HI_U64 ATTRIBUTE u64BufSize[MAX_TILE_NUM]; /* R; Stream buffer size */ 699 } VENC_STREAM_BUF_INFO_S; 700 701 /* the param of the h265e slice split */ 702 typedef struct hiVENC_H265_SLICE_SPLIT_S { 703 HI_BOOL bSplitEnable; /* RW; Range:[0, 1]; slice split enable, 704 HI_TRUE:enable, HI_FALSE:diable, default value:HI_FALSE */ 705 HI_U32 u32LcuLineNum; /* RW; Range:(Picture height + lcu size minus one)/lcu size; 706 this value presents lcu line number */ 707 } VENC_H265_SLICE_SPLIT_S; 708 709 /* the param of the h265e pu */ 710 typedef struct hiVENC_H265_PU_S { 711 HI_U32 constrained_intra_pred_flag; /* RW; Range:[0, 1]; see the H.265 protocol for the meaning. */ 712 HI_U32 strong_intra_smoothing_enabled_flag; /* RW; Range:[0, 1]; see the H.265 protocol for the meaning. */ 713 } VENC_H265_PU_S; 714 715 /* the param of the h265e trans */ 716 typedef struct hiVENC_H265_TRANS_S { 717 HI_S32 cb_qp_offset; /* RW; Range:[-12, 12]; see the H.265 protocol for the meaning. */ 718 HI_S32 cr_qp_offset; /* RW; Range:[-12, 12]; see the H.265 protocol for the meaning. */ 719 720 HI_BOOL bScalingListEnabled; /* RW; Range:[0, 1]; If 1, specifies that a scaling list is used. */ 721 722 HI_BOOL bScalingListTu4Valid; /* RW; Range:[0, 1]; If 1, ScalingList4X4 belows will be encoded. */ 723 /* RW; Range:[1, 255]; Scaling List for inter 4X4 block. */ 724 HI_U8 InterScalingList4X4[HI_VENC_SCALING_DIMENSION_NUM][HI_VENC_SCALING_LIST_SIZE_16]; 725 /* RW; Range:[1, 255]; Scaling List for intra 4X4 block. */ 726 HI_U8 IntraScalingList4X4[HI_VENC_SCALING_DIMENSION_NUM][HI_VENC_SCALING_LIST_SIZE_16]; 727 728 HI_BOOL bScalingListTu8Valid; /* RW; Range:[0, 1]; If 1, ScalingList8X8 belows will be encoded. */ 729 /* RW; Range:[1, 255]; Scaling List for inter 8X8 block. */ 730 HI_U8 InterScalingList8X8[HI_VENC_SCALING_DIMENSION_NUM][HI_VENC_SCALING_LIST_SIZE_64]; 731 /* RW; Range:[1, 255]; Scaling List for intra 8X8 block. */ 732 HI_U8 IntraScalingList8X8[HI_VENC_SCALING_DIMENSION_NUM][HI_VENC_SCALING_LIST_SIZE_64]; 733 734 HI_BOOL bScalingListTu16Valid; /* RW; Range:[0, 1]; If 1, ScalingList16X16 belows will be encoded. */ 735 /* RW; Range:[1, 255]; Scaling List for inter 16X16 block. */ 736 HI_U8 InterScalingList16X16[HI_VENC_SCALING_DIMENSION_NUM][HI_VENC_SCALING_LIST_SIZE_64]; 737 /* RW; Range:[1, 255]; Scaling List for inter 16X16 block. */ 738 HI_U8 IntraScalingList16X16[HI_VENC_SCALING_DIMENSION_NUM][HI_VENC_SCALING_LIST_SIZE_64]; 739 740 HI_BOOL bScalingListTu32Valid; /* RW; Range:[0, 1]; If 1, ScalingList32X32 belows will be encoded. */ 741 /* RW; Range:[1, 255]; Scaling List for inter 32X32 block. */ 742 HI_U8 InterScalingList32X32[HI_VENC_SCALING_LIST_SIZE_64]; 743 /* RW; Range:[1, 255]; Scaling List for inter 32X32 block. */ 744 HI_U8 IntraScalingList32X32[HI_VENC_SCALING_LIST_SIZE_64]; 745 } VENC_H265_TRANS_S; 746 747 /* the param of the h265e entroy */ 748 typedef struct hiVENC_H265_ENTROPY_S { 749 HI_U32 cabac_init_flag; /* RW; Range:[0, 1]; see the H.265 protocol for the meaning. */ 750 } VENC_H265_ENTROPY_S; 751 752 /* the param of the h265e deblocking */ 753 typedef struct hiVENC_H265_DBLK_S { 754 HI_U32 slice_deblocking_filter_disabled_flag; /* RW; Range:[0, 1]; see the H.265 protocol for the meaning. */ 755 HI_S32 slice_beta_offset_div2; /* RW; Range:[-6, 6]; see the H.265 protocol for the meaning. */ 756 HI_S32 slice_tc_offset_div2; /* RW; Range:[-6, 6]; see the H.265 protocol for the meaning. */ 757 HI_U32 loop_filter_across_tiles_enabled_flag; /* RW; Range:[0, 1]; see the H.265 protocol for the meaning. */ 758 HI_U32 loop_filter_across_slices_enabled_flag; /* RW; Range:[0, 1]; see the H.265 protocol for the meaning. */ 759 } VENC_H265_DBLK_S; 760 761 /* the param of the h265e sao */ 762 typedef struct hiVENC_H265_SAO_S { 763 HI_U32 slice_sao_luma_flag; /* RW; Range:[0, 1]; Indicates whether SAO filtering is performed on the 764 luminance component of the current slice. */ 765 HI_U32 slice_sao_chroma_flag; /* RW; Range:[0, 1]; Indicates whether SAO filtering is performed on 766 the chrominance component of the current slice */ 767 } VENC_H265_SAO_S; 768 769 /* venc mode type */ 770 typedef enum hiVENC_INTRA_REFRESH_MODE_E { 771 INTRA_REFRESH_ROW = 0, /* Line mode */ 772 INTRA_REFRESH_COLUMN, /* Column mode */ 773 INTRA_REFRESH_BUTT 774 } VENC_INTRA_REFRESH_MODE_E; 775 776 /* the param of the intra refresh */ 777 typedef struct hiVENC_INTRA_REFRESH_S { 778 HI_BOOL bRefreshEnable; /* RW; Range:[0, 1]; intra refresh enable, 779 HI_TRUE:enable, HI_FALSE:diable, default value:HI_FALSE */ 780 VENC_INTRA_REFRESH_MODE_E enIntraRefreshMode; /* RW; The mode of intra refresh */ 781 HI_U32 u32RefreshNum; /* RW; Number of rows/column to be refreshed 782 during each I macroblock refresh */ 783 HI_U32 u32ReqIQp; /* RW; Range:[0, 51]; QP value of the I frame */ 784 } VENC_INTRA_REFRESH_S; 785 786 /* venc mode type */ 787 typedef enum hiVENC_MODTYPE_E { 788 MODTYPE_VENC = 1, 789 MODTYPE_H264E, 790 MODTYPE_H265E, 791 MODTYPE_JPEGE, 792 MODTYPE_RC, 793 MODTYPE_BUTT 794 } VENC_MODTYPE_E; 795 796 /* the param of the h264e mod */ 797 typedef struct hiVENC_MOD_H264E_S { 798 HI_U32 u32OneStreamBuffer; /* RW; Range:[0, 1]; one stream buffer */ 799 HI_U32 u32H264eMiniBufMode; /* RW; Range:[0, 1]; H264e MiniBufMode */ 800 HI_U32 u32H264ePowerSaveEn; /* RW; Range:[0, 1]; H264e PowerSaveEn */ 801 VB_SOURCE_E enH264eVBSource; /* RW; H264e VBSource */ 802 HI_BOOL bQpHstgrmEn; /* RW; Range:[0, 1] */ 803 HI_U32 u32UserDataMaxLen; /* RW; Range:[0, 65536]; one user data buffer len */ 804 } VENC_MOD_H264E_S; 805 806 /* the param of the h265e mod */ 807 typedef struct hiVENC_MOD_H265E_S { 808 HI_U32 u32OneStreamBuffer; /* RW; Range:[0, 1]; one stream buffer */ 809 HI_U32 u32H265eMiniBufMode; /* RW; Range:[0, 1]; H265e MiniBufMode */ 810 HI_U32 u32H265ePowerSaveEn; /* RW; Range:[0, 2]; H265e PowerSaveEn */ 811 VB_SOURCE_E enH265eVBSource; /* RW; H265e VBSource */ 812 HI_BOOL bQpHstgrmEn; /* RW; Range:[0, 1] */ 813 HI_U32 u32UserDataMaxLen; /* RW; Range:[0, 65536]; one user data buffer len */ 814 } VENC_MOD_H265E_S; 815 816 /* the param of the jpege mod */ 817 typedef struct hiVENC_MOD_JPEGE_S { 818 HI_U32 u32OneStreamBuffer; /* RW; Range:[0, 1]; one stream buffer */ 819 HI_U32 u32JpegeMiniBufMode; /* RW; Range:[0, 1]; Jpege MiniBufMode */ 820 HI_U32 u32JpegClearStreamBuf; /* RW; Range:[0, 1]; JpegClearStreamBuf */ 821 HI_U32 u32JpegeDeringMode; /* RW; Range:[0, 1]; Jpege Dering Mode */ 822 } VENC_MOD_JPEGE_S; 823 824 typedef struct hiVENC_MOD_RC_S { 825 HI_U32 u32ClrStatAfterSetBr; 826 } VENC_MOD_RC_S; 827 /* the param of the venc mod */ 828 typedef struct hiVENC_MOD_VENC_S { 829 HI_U32 u32VencBufferCache; /* RW; Range:[0, 1]; VencBufferCache */ 830 HI_U32 u32FrameBufRecycle; /* RW; Range:[0, 1]; FrameBufRecycle */ 831 } VENC_MOD_VENC_S; 832 833 /* the param of the mod */ 834 typedef struct hiVENC_MODPARAM_S { 835 VENC_MODTYPE_E enVencModType; /* RW; VencModType */ 836 union { 837 VENC_MOD_VENC_S stVencModParam; 838 VENC_MOD_H264E_S stH264eModParam; 839 VENC_MOD_H265E_S stH265eModParam; 840 VENC_MOD_JPEGE_S stJpegeModParam; 841 VENC_MOD_RC_S stRcModParam; 842 }; 843 } VENC_PARAM_MOD_S; 844 845 typedef enum hiVENC_FRAME_TYPE_E { 846 VENC_FRAME_TYPE_NONE = 1, 847 VENC_FRAME_TYPE_IDR, 848 VENC_FRAME_TYPE_PSKIP, 849 VENC_FRAME_TYPE_BUTT 850 } VENC_FRAME_TYPE_E; 851 852 /* the information of the user rc */ 853 typedef struct hiUSER_RC_INFO_S { 854 HI_BOOL bQpMapValid; /* RW; Range:[0, 1]; 855 Indicates whether the QpMap mode is valid for the current frame */ 856 HI_BOOL bSkipWeightValid; /* RW; Range:[0, 1]; 857 Indicates whether the SkipWeight mode is valid for the current frame */ 858 HI_U32 u32BlkStartQp; /* RW; Range:[0, 51]; QP value of the first 16 x 16 block in QpMap mode */ 859 HI_U64 u64QpMapPhyAddr; /* RW; Physical address of the QP table in QpMap mode */ 860 HI_U64 u64SkipWeightPhyAddr; /* RW; Physical address of the SkipWeight table in QpMap mode */ 861 VENC_FRAME_TYPE_E enFrameType; /* RW; Encoding frame type of the current frame */ 862 } USER_RC_INFO_S; 863 864 /* the information of the user frame */ 865 typedef struct hiUSER_FRAME_INFO_S { 866 VIDEO_FRAME_INFO_S stUserFrame; 867 USER_RC_INFO_S stUserRcInfo; 868 } USER_FRAME_INFO_S; 869 870 typedef enum { 871 HI_VENC_MOSAIC_MODE_0 = 0, /* user input rect */ 872 HI_VENC_MOSAIC_MODE_1, /* user input squares mosaic map */ 873 HI_VENC_MOSAIC_MODE_2, /* user input user-defined shape map */ 874 HI_VENC_MOSAIC_MODE_BUTT 875 } HI_VENC_MOSAIC_MODE_E; 876 877 typedef enum { 878 HI_VENC_MOSAIC_SIZE_4x4 = 0, 879 HI_VENC_MOSAIC_SIZE_8x8, 880 HI_VENC_MOSAIC_SIZE_16x16, 881 HI_VENC_MOSAIC_SIZE_32x32, 882 HI_VENC_MOSAIC_SIZE_64x64, 883 HI_VENC_MOSAIC_SIZE_128x128, 884 HI_VENC_MOSAIC_SIZE_BUTT 885 } HI_VENC_MOSAIC_BLOCK_SIZE_E; 886 887 typedef struct { 888 HI_U8 u8DataY; 889 HI_U8 u8DataU; 890 HI_U8 u8DataV; 891 } VENC_MOSAIC_PIXEL_YUV; 892 893 typedef struct { 894 HI_U32 u32RectNum; 895 RECT_S stRect[HI_VENC_MAX_MOSAIC_RECT_NUM]; 896 } VENC_MOSAIC_MODE0_PARAM_S; 897 898 typedef struct { 899 HI_BOOL bMosaicMapValid; 900 HI_PHYS_ADDR_T MosaicMapPhysAddr; 901 } VENC_MOSAIC_MODE1_PARAM_S; 902 903 typedef struct { 904 HI_BOOL bMosaicMapValid; 905 HI_PHYS_ADDR_T MosaicMapPhysAddr; 906 VENC_MOSAIC_PIXEL_YUV stPixelYuv; 907 } VENC_MOSAIC_MODE2_PARAM_S; 908 909 /* the information of the mosaic area */ 910 typedef struct { 911 HI_VENC_MOSAIC_MODE_E enMosaicMode; 912 HI_VENC_MOSAIC_BLOCK_SIZE_E enSizeMode; 913 914 union { 915 VENC_MOSAIC_MODE0_PARAM_S stMode0Param; /* params for HI_VENC_MOSAIC_MODE_0 */ 916 VENC_MOSAIC_MODE1_PARAM_S stMode1Param; /* params for HI_VENC_MOSAIC_MODE_1 */ 917 VENC_MOSAIC_MODE2_PARAM_S stMode2Param; /* params for HI_VENC_MOSAIC_MODE_2 */ 918 }; 919 } MOSAIC_INFO_S; 920 921 /* the information of the user frame */ 922 typedef struct hiMULTI_FRAME_INFO_S { 923 HI_U32 u32FrameNum; 924 VIDEO_FRAME_INFO_S stFrame[HI_VENC_MAX_FRAME_NUM]; 925 MOSAIC_INFO_S stMosaicInfo; 926 } MULTI_FRAME_INFO_S; 927 928 typedef struct hiVENC_CHN_CONFIG_S { 929 HI_BOOL bMosaicEnable; 930 HI_BOOL bCompositeEncEnable; 931 HI_U32 u32QualityLevel; /* 0: lower quality; 1: higher quality. */ 932 } VENC_CHN_CONFIG_S; 933 934 /* the config of the sse */ 935 typedef struct hiVENC_SSE_CFG_S { 936 HI_U32 u32Index; /* RW; Range:[0, 7]; Index of an SSE. The system supports indexes ranging from 0 to 7 */ 937 HI_BOOL bEnable; /* RW; Range:[0, 1]; Whether to enable SSE */ 938 RECT_S stRect; /* RW; */ 939 } VENC_SSE_CFG_S; 940 941 /* the param of the crop */ 942 typedef struct hiVENC_CROP_INFO_S { 943 HI_BOOL bEnable; /* RW; Range:[0, 1]; Crop region enable */ 944 RECT_S stRect; /* RW; Crop region, note: s32X must be multi of 16 */ 945 } VENC_CROP_INFO_S; 946 947 /* the param of the venc frame rate */ 948 typedef struct hiVENC_FRAME_RATE_S { 949 HI_S32 s32SrcFrmRate; /* RW; Range:[0, 240]; Input frame rate of a channel */ 950 HI_S32 s32DstFrmRate; /* RW; Range:[0, 240]; Output frame rate of a channel */ 951 } VENC_FRAME_RATE_S; 952 953 /* the param of the venc encode chnl */ 954 typedef struct hiVENC_CHN_PARAM_S { 955 HI_BOOL bColor2Grey; /* RW; Range:[0, 1]; Whether to enable Color2Grey. */ 956 HI_U32 u32Priority; /* RW; Range:[0, 1]; The priority of the coding chnl. */ 957 HI_U32 u32MaxStrmCnt; /* RW: Range:[0, 4294967295]; Maximum number of frames in a stream buffer */ 958 HI_U32 u32PollWakeUpFrmCnt; /* RW: Range:(0, 4294967295]; the frame num needed to wake up obtaining streams */ 959 VENC_CROP_INFO_S stCropCfg; 960 VENC_FRAME_RATE_S stFrameRate; 961 } VENC_CHN_PARAM_S; 962 963 /* the ground protect of FOREGROUND */ 964 typedef struct hiVENC_FOREGROUND_PROTECT_S { 965 HI_BOOL bForegroundCuRcEn; 966 HI_U32 u32ForegroundDirectionThresh; /* RW; Range:[0, 16]; 967 The direction for controlling the macroblock-level bit rate */ 968 HI_U32 u32ForegroundThreshGain; /* RW; Range:[0, 15]; The gain of the thresh */ 969 HI_U32 u32ForegroundThreshOffset; /* RW; Range:[0, 255]; The offset of the thresh */ 970 HI_U32 u32ForegroundThreshP[RC_TEXTURE_THR_SIZE]; /* RW; Range:[0, 255]; Mad threshold for controlling 971 the foreground macroblock-level bit rate of P frames */ 972 HI_U32 u32ForegroundThreshB[RC_TEXTURE_THR_SIZE]; /* RW; Range:[0, 255]; Mad threshold for controlling 973 the foreground macroblock-level bit rate of B frames */ 974 } VENC_FOREGROUND_PROTECT_S; 975 976 /* the scene mode of the venc encode chnl */ 977 typedef enum hiVENC_SCENE_MODE_E { 978 SCENE_0 = 0, /* RW; A scene in which the camera does not move or periodically moves continuously */ 979 SCENE_1 = 1, /* RW; Motion scene at high bit rate */ 980 SCENE_2 = 2, /* RW; It has regular continuous motion at medium bit rate and 981 the encoding pressure is relatively large */ 982 SCENE_BUTT 983 } VENC_SCENE_MODE_E; 984 985 /* not support for Hi3559AV100/Hi3559v200/Hi3556v200 */ 986 typedef struct hiVENC_DEBREATHEFFECT_S { 987 HI_BOOL bEnable; /* RW; Range:[0, 1]; default: 0, DeBreathEffect enable */ 988 HI_S32 s32Strength0; /* RW; Range:[0, 35]; The Strength0 of DeBreathEffect. */ 989 HI_S32 s32Strength1; /* RW; Range:[0, 35]; The Strength1 of DeBreathEffect. */ 990 } VENC_DEBREATHEFFECT_S; 991 992 typedef struct hiVENC_CU_PREDICTION_S { 993 OPERATION_MODE_E enPredMode; /* RW; CU tendency configuration mode */ 994 995 HI_U32 u32Intra32Cost; /* RW; Range:[0, 15]; Tendency adjustment in Intra32 mode */ 996 HI_U32 u32Intra16Cost; /* RW; Range:[0, 15]; Tendency adjustment in Intra16 mode */ 997 HI_U32 u32Intra8Cost; /* RW; Range:[0, 15]; Tendency adjustment in Intra8 mode */ 998 HI_U32 u32Intra4Cost; /* RW; Range:[0, 15]; Tendency adjustment in Intra4 mode */ 999 1000 HI_U32 u32Inter64Cost; /* RW; Range:[0, 15]; Tendency adjustment in Intra64 mode */ 1001 HI_U32 u32Inter32Cost; /* RW; Range:[0, 15]; Tendency adjustment in Inter32 mode */ 1002 HI_U32 u32Inter16Cost; /* RW; Range:[0, 15]; Tendency adjustment in Inter16 mode */ 1003 HI_U32 u32Inter8Cost; /* RW; Range:[0, 15]; Tendency adjustment in Inter8 mode */ 1004 } VENC_CU_PREDICTION_S; 1005 1006 typedef struct hiVENC_SKIP_BIAS_S { 1007 HI_BOOL bSkipBiasEn; /* RW; Range:[0, 1]; 1008 Flag indicating whether the skip tendency function is enabled */ 1009 HI_U32 u32SkipThreshGain; /* RW; Range:[0, 15]; 1010 used to calculate the SAD threshold for foreground detection */ 1011 HI_U32 u32SkipThreshOffset; /* RW; Range:[0, 255]; 1012 used to calculate the SAD threshold for foreground detection */ 1013 HI_U32 u32SkipBackgroundCost; /* RW; Range:[0, 15]; 1014 Skip tendency adjustment in the background */ 1015 HI_U32 u32SkipForegroundCost; /* RW; Range:[0, 15]; 1016 Skip tendency adjustment in the foreground */ 1017 } VENC_SKIP_BIAS_S; 1018 1019 typedef struct hiVENC_HIERARCHICAL_QP_S { 1020 HI_BOOL bHierarchicalQpEn; /* RW; Range:[0, 1]; Hierarchical QP enable */ 1021 /* RW; Range:[-10, 10]; QP delta of the frames at each layer relative to the P-frame at layer 0 */ 1022 HI_S32 s32HierarchicalQpDelta[HI_VENC_MAX_HIERARCHY_NUM]; 1023 /* RW; Range:[0, 5]; Number of frames at each layer */ 1024 HI_S32 s32HierarchicalFrameNum[HI_VENC_MAX_HIERARCHY_NUM]; 1025 } VENC_HIERARCHICAL_QP_S; 1026 1027 typedef struct hiVENC_CHN_POOL_S { 1028 VB_POOL hPicVbPool; /* RW; vb pool id for pic buffer */ 1029 VB_POOL hPicInfoVbPool; /* RW; vb pool id for pic info buffer */ 1030 } VENC_CHN_POOL_S; 1031 1032 typedef struct hiVENC_RC_ADVPARAM_S { 1033 HI_U32 u32ClearStatAfterSetAttr; /* RW; Range:[0, 1]; Clear Stat After SetAttr enable */ 1034 } VENC_RC_ADVPARAM_S; 1035 1036 typedef struct { 1037 HI_BOOL bSplitEnable; 1038 HI_U32 u32SplitMode; 1039 HI_U32 u32SplitSize; 1040 } VENC_SLICE_SPLIT_S; 1041 1042 typedef struct { 1043 OPERATION_MODE_E enMode; 1044 HI_U32 u32Hor; 1045 HI_U32 u32Ver; 1046 } VENC_SEARCH_WINDOW_S; 1047 1048 typedef enum { 1049 SVC_RECT_TYPE0 = 0, 1050 SVC_RECT_TYPE1, 1051 SVC_RECT_TYPE2, 1052 SVC_RECT_TYPE3, 1053 SVC_RECT_TYPE4, 1054 SVC_RECT_TYPE_BUTT 1055 } VENC_SVC_RECT_TYPE_E; 1056 1057 typedef struct { 1058 HI_U8 u8QpmapValueI; /* RW;Range: [0, 255] */ 1059 HI_U8 u8QpmapValueP; /* RW;Range: [0, 255] */ 1060 HI_U8 u8SkipmapValue; /* RW;Range: [0, 255] */ 1061 } VENC_SVC_MAP_PARAM_S; 1062 1063 typedef struct { 1064 VENC_SVC_MAP_PARAM_S stFgRegion[SVC_RECT_TYPE_BUTT]; 1065 VENC_SVC_MAP_PARAM_S stActivityRegion; 1066 VENC_SVC_MAP_PARAM_S stBgRegion; 1067 HI_BOOL bFgProtectAdaptiveEn; /* RW;Range: [0, 1] */ 1068 } VENC_SVC_PARAM_S; 1069 1070 typedef struct { 1071 HI_U16 u16SceneComplexity; /* R;Range: [0, 65535], Proportional to total area of detected objects */ 1072 HI_U8 u8ObjectLevel; /* R;Range: [0, 2], Related to total number of detected objects */ 1073 } VENC_SVC_DETECT_RESULT_S; 1074 1075 typedef struct { 1076 HI_U32 u32RectNum; 1077 SIZE_S stBaseResolution; 1078 RECT_S stRectAttr[HI_VENC_MAX_SVC_RECT_NUM]; 1079 VENC_SVC_RECT_TYPE_E enDetectType[HI_VENC_MAX_SVC_RECT_NUM]; 1080 HI_U64 u64Pts; 1081 } VENC_SVC_RECT_INFO_S; 1082 1083 typedef struct { 1084 HI_U32 u32ParamSetId; /* Range: for H264: [0, 30]; for H265: [0, 15]; */ 1085 } VENC_PARAM_SET_ID_S; 1086 1087 #ifdef __cplusplus 1088 } 1089 #endif /* __cplusplus */ 1090 1091 #endif /* __HI_COMM_VENC_H__ */ 1092