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