xref: /OK3568_Linux_fs/external/rockit/mpi/sdk/include/rk_comm_venc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* GPL-2.0 WITH Linux-syscall-note OR Apache 2.0 */
2 /* Copyright (c) 2021 Fuzhou Rockchip Electronics Co., Ltd */
3 
4 #ifndef INCLUDE_RT_MPI_RK_COMM_VENC_H_
5 
6 #define INCLUDE_RT_MPI_RK_COMM_VENC_H_
7 #include "rk_type.h"
8 #include "rk_common.h"
9 #include "rk_errno.h"
10 #include "rk_comm_video.h"
11 #include "rk_comm_rc.h"
12 
13 #ifdef __cplusplus
14 #if __cplusplus
15 extern "C" {
16 #endif
17 #endif /* End of #ifdef __cplusplus */
18 
19 /* invlalid channel ID */
20 #define RK_ERR_VENC_INVALID_CHNID RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_CHNID)
21 /* at lease one parameter is illagal ,eg, an illegal enumeration value  */
22 #define RK_ERR_VENC_ILLEGAL_PARAM RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_ILLEGAL_PARAM)
23 /* channel exists */
24 #define RK_ERR_VENC_EXIST         RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_EXIST)
25 /* channel exists */
26 #define RK_ERR_VENC_UNEXIST       RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_UNEXIST)
27 /* using a NULL point */
28 #define RK_ERR_VENC_NULL_PTR      RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NULL_PTR)
29 /* try to enable or initialize system,device or channel, before configing attribute */
30 #define RK_ERR_VENC_NOT_CONFIG    RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_CONFIG)
31 /* operation is not supported by NOW */
32 #define RK_ERR_VENC_NOT_SUPPORT   RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_SUPPORT)
33 /* operation is not permitted ,eg, try to change stati attribute */
34 #define RK_ERR_VENC_NOT_PERM      RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_PERM)
35 /* failure caused by malloc memory */
36 #define RK_ERR_VENC_NOMEM         RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NOMEM)
37 /* failure caused by malloc buffer */
38 #define RK_ERR_VENC_NOBUF         RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NOBUF)
39 /* no data in buffer */
40 #define RK_ERR_VENC_BUF_EMPTY     RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_EMPTY)
41 /* no buffer for new data */
42 #define RK_ERR_VENC_BUF_FULL      RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_FULL)
43 /* system is not ready,had not initialed or loaded */
44 #define RK_ERR_VENC_SYS_NOTREADY  RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_NOTREADY)
45 /* system is busy */
46 #define RK_ERR_VENC_BUSY          RK_DEF_ERR(RK_ID_VENC, RK_ERR_LEVEL_ERROR, RK_ERR_BUSY)
47 
48 #define VENC_QP_SGRM_NUM               52
49 #define MAX_TILE_NUM                   1
50 #define RC_TEXTURE_THR_SIZE            16
51 
52 /* the nalu type of H264E */
53 typedef enum rkH264E_NALU_TYPE_E {
54     H264E_NALU_BSLICE = 0,                         /*B SLICE types*/
55     H264E_NALU_PSLICE = 1,                         /*P SLICE types*/
56     H264E_NALU_ISLICE = 2,                         /*I SLICE types*/
57     H264E_NALU_IDRSLICE = 5,                       /*IDR SLICE types*/
58     H264E_NALU_SEI    = 6,                         /*SEI types*/
59     H264E_NALU_SPS    = 7,                         /*SPS types*/
60     H264E_NALU_PPS    = 8,                         /*PPS types*/
61     H264E_NALU_BUTT
62 } H264E_NALU_TYPE_E;
63 
64 /* the nalu type of H265E */
65 typedef enum rkH265E_NALU_TYPE_E {
66     H265E_NALU_BSLICE = 0,                          /*B SLICE types*/
67     H265E_NALU_PSLICE = 1,                          /*P SLICE types*/
68     H265E_NALU_ISLICE = 2,                          /*I SLICE types*/
69     H265E_NALU_IDRSLICE = 19,                       /*IDR SLICE types*/
70     H265E_NALU_VPS    = 32,                         /*VPS types*/
71     H265E_NALU_SPS    = 33,                         /*SPS types*/
72     H265E_NALU_PPS    = 34,                         /*PPS types*/
73     H265E_NALU_SEI    = 39,                         /*SEI types*/
74 
75     H265E_NALU_BUTT
76 } H265E_NALU_TYPE_E;
77 
78 /* the reference type of H264E slice */
79 typedef enum rkH264E_REFSLICE_TYPE_E {
80     H264E_REFSLICE_FOR_1X = 1,                     /*Reference slice for H264E_REF_MODE_1X*/
81     H264E_REFSLICE_FOR_2X = 2,                     /*Reference slice for H264E_REF_MODE_2X*/
82     H264E_REFSLICE_FOR_4X = 5,                     /*Reference slice for H264E_REF_MODE_4X*/
83     H264E_REFSLICE_FOR_BUTT                        /*slice not for reference*/
84 } H264E_REFSLICE_TYPE_E;
85 
86 /* the pack type of JPEGE */
87 typedef enum rkJPEGE_PACK_TYPE_E {
88     JPEGE_PACK_ECS = 5,                            /*ECS types*/
89     JPEGE_PACK_APP = 6,                            /*APP types*/
90     JPEGE_PACK_VDO = 7,                            /*VDO types*/
91     JPEGE_PACK_PIC = 8,                            /*PIC types*/
92     JPEGE_PACK_DCF = 9,                            /*DCF types*/
93     JPEGE_PACK_DCF_PIC = 10,                       /*DCF PIC types*/
94     JPEGE_PACK_BUTT
95 } JPEGE_PACK_TYPE_E;
96 
97 typedef enum rkH264E_PROFILE_E {
98     H264E_PROFILE_BASELINE           = 66,
99     H264E_PROFILE_MAIN               = 77,
100     H264E_PROFILE_HIGH               = 100,
101     H264E_PROFILE__BUTT
102 } H264E_PROFILE_E;
103 
104 typedef enum rkH265E_PROFILE_E {
105     H265E_PROFILE_MAIN               = 0,
106     H265E_PROFILE_MAIN10             = 1,
107     H265E_PROFILE__BUTT
108 } H265E_PROFILE_E;
109 
110 /* the pack type of PRORES */
111 typedef enum rkPRORES_PACK_TYPE_E {
112     PRORES_PACK_PIC = 1,                            /*PIC types*/
113     PRORES_PACK_BUTT
114 } PRORES_PACK_TYPE_E;
115 
116 /* the data type of VENC */
117 typedef union rkVENC_DATA_TYPE_U {
118     H264E_NALU_TYPE_E    enH264EType;               /* R; H264E NALU types*/
119     JPEGE_PACK_TYPE_E    enJPEGEType;               /* R; JPEGE pack types*/
120     H265E_NALU_TYPE_E    enH265EType;               /* R; H264E NALU types*/
121     PRORES_PACK_TYPE_E   enPRORESType;
122 } VENC_DATA_TYPE_U;
123 
124 /* the pack info of VENC */
125 typedef struct rkVENC_PACK_INFO_S {
126     VENC_DATA_TYPE_U  u32PackType;                    /* R; the pack type*/
127     RK_U32 u32PackOffset;
128     RK_U32 u32PackLength;
129 } VENC_PACK_INFO_S;
130 
131 /* Defines a stream packet */
132 typedef struct rkVENC_PACK_S {
133     MB_BLK               pMbBlk;                     /* R; the virtual address of stream */
134     RK_U32               u32Len;                     /* R; the length of stream */
135 
136     RK_U64               u64PTS;                     /* R; PTS */
137     RK_BOOL              bFrameEnd;                  /* R; frame end */
138     RK_BOOL              bStreamEnd;                 /* R; stream end */
139 
140     VENC_DATA_TYPE_U     DataType;                   /* R; the type of stream */
141     RK_U32               u32Offset;                  /* R; the offset between the Valid data and the start address */
142     RK_U32               u32DataNum;                 /* R; the  stream packets num */
143     VENC_PACK_INFO_S     stPackInfo[8];              /* R; the stream packet Information */
144 } VENC_PACK_S;
145 
146 /* Defines the frame type and reference attributes of the H.264 frame skipping reference streams */
147 typedef enum rkH264E_REF_TYPE_E {
148     BASE_IDRSLICE = 0,                              /* the Idr frame at Base layer*/
149     /* the P frame at Base layer, referenced by other frames at Base layer and reference to Idr frame*/
150     BASE_PSLICE_REFTOIDR,
151     /* the P frame at Base layer, referenced by other frames at Base layer*/
152     BASE_PSLICE_REFBYBASE,
153     /* the P frame at Base layer, referenced by other frames at Enhance layer*/
154     BASE_PSLICE_REFBYENHANCE,
155     /* the P frame at Enhance layer, referenced by other frames at Enhance layer*/
156     ENHANCE_PSLICE_REFBYENHANCE,
157     /* the P frame at Enhance layer ,not referenced*/
158     ENHANCE_PSLICE_NOTFORREF,
159     ENHANCE_PSLICE_BUTT
160 } H264E_REF_TYPE_E;
161 
162 typedef enum rkH264E_REF_TYPE_E H265E_REF_TYPE_E;
163 
164 /* Defines the features of an H.264 stream */
165 typedef struct rkVENC_STREAM_INFO_H264_S {
166     RK_U32                 u32PicBytesNum;              /* R; the coded picture stream byte number */
167     RK_U32                 u32Inter16x16MbNum;          /* R; the inter16x16 macroblock num */
168     RK_U32                 u32Inter8x8MbNum;            /* R; the inter8x8 macroblock num */
169     RK_U32                 u32Intra16MbNum;             /* R; the intra16x16 macroblock num */
170     RK_U32                 u32Intra8MbNum;              /* R; the intra8x8 macroblock num */
171     RK_U32                 u32Intra4MbNum;              /* R; the inter4x4 macroblock num */
172     /* R; Type of encoded frames in advanced frame skipping reference mode*/
173     H264E_REF_TYPE_E       enRefType;
174     /* R; Number of times that channel attributes or parameters (including RC parameters) are set*/
175     RK_U32                 u32UpdateAttrCnt;
176     RK_U32                 u32StartQp;                  /* R; the start Qp of encoded frames*/
177     RK_U32                 u32MeanQp;                   /* R; the mean Qp of encoded frames*/
178     RK_BOOL                bPSkip;
179 } VENC_STREAM_INFO_H264_S;
180 
181 /* Defines the features of an H.265 stream */
182 typedef struct rkVENC_STREAM_INFO_H265_S {
183     RK_U32                 u32PicBytesNum;              /* R; the coded picture stream byte number */
184     RK_U32                 u32Inter64x64CuNum;          /* R; the inter64x64 cu num  */
185     RK_U32                 u32Inter32x32CuNum;          /* R; the inter32x32 cu num  */
186     RK_U32                 u32Inter16x16CuNum;          /* R; the inter16x16 cu num  */
187     RK_U32                 u32Inter8x8CuNum;            /* R; the inter8x8   cu num  */
188     RK_U32                 u32Intra32x32CuNum;          /* R; the Intra32x32 cu num  */
189     RK_U32                 u32Intra16x16CuNum;          /* R; the Intra16x16 cu num  */
190     RK_U32                 u32Intra8x8CuNum;            /* R; the Intra8x8   cu num  */
191     RK_U32                 u32Intra4x4CuNum;            /* R; the Intra4x4   cu num  */
192     /* R; Type of encoded frames in advanced frame skipping reference mode*/
193     H265E_REF_TYPE_E       enRefType;
194     /* R; Number of times that channel attributes or parameters (including RC parameters) are set*/
195     RK_U32                 u32UpdateAttrCnt;
196     RK_U32                 u32StartQp;                  /* R; the start Qp of encoded frames*/
197     RK_U32                 u32MeanQp;                   /* R; the mean Qp of encoded frames*/
198     RK_BOOL                bPSkip;
199 } VENC_STREAM_INFO_H265_S;
200 
201 /* the sse info */
202 typedef struct rkVENC_SSE_INFO_S {
203     RK_BOOL bSSEEn;        /* RW; Range:[0,1]; Region SSE enable */
204     RK_U32  u32SSEVal;     /* R; Region SSE value */
205 } VENC_SSE_INFO_S;
206 
207 /* the advance information of the h264e */
208 typedef struct rkVENC_STREAM_ADVANCE_INFO_H264_S {
209     RK_U32             u32ResidualBitNum;                    /* R; the residual num */
210     RK_U32             u32HeadBitNum;                        /* R; the head bit num */
211     RK_U32             u32MadiVal;                           /* R; the madi value */
212     RK_U32             u32MadpVal;                           /* R; the madp value */
213     RK_DOUBLE          dPSNRVal;                             /* R; the PSNR value */
214     RK_U32             u32MseLcuCnt;                         /* R; the lcu cnt of the mse */
215     RK_U32             u32MseSum;                            /* R; the sum of the mse */
216     VENC_SSE_INFO_S    stSSEInfo[8];                         /* R; the information of the sse */
217     RK_U32             u32QpHstgrm[VENC_QP_SGRM_NUM];      /* R; the Qp rkstogram value */
218     RK_U32             u32MoveScene16x16Num;                 /* R; the 16x16 cu num of the move scene*/
219     RK_U32             u32MoveSceneBits;                     /* R; the stream bit num of the move scene */
220 } VENC_STREAM_ADVANCE_INFO_H264_S;
221 
222 /* the advance information of the Jpege */
223 typedef struct rkVENC_STREAM_ADVANCE_INFO_JPEG_S {
224     // RK_U32 u32Reserved;
225 } VENC_STREAM_ADVANCE_INFO_JPEG_S;
226 
227 /* the advance information of the Prores */
228 typedef struct rkVENC_STREAM_ADVANCE_INFO_PRORES_S {
229     // RK_U32 u32Reserved;
230 } VENC_STREAM_ADVANCE_INFO_PRORES_S;
231 
232 /* the advance information of the h265e */
233 typedef struct rkVENC_STREAM_ADVANCE_INFO_H265_S {
234     RK_U32             u32ResidualBitNum;               /* R; the residual num */
235     RK_U32             u32HeadBitNum;                   /* R; the head bit num */
236     RK_U32             u32MadiVal;                      /* R; the madi value */
237     RK_U32             u32MadpVal;                      /* R; the madp value */
238     RK_DOUBLE          dPSNRVal;                        /* R; the PSNR value */
239     RK_U32             u32MseLcuCnt;                    /* R; the lcu cnt of the mse */
240     RK_U32             u32MseSum;                       /* R; the sum of the mse */
241     VENC_SSE_INFO_S    stSSEInfo[8];                    /* R; the information of the sse */
242     RK_U32             u32QpHstgrm[VENC_QP_SGRM_NUM]; /* R; the Qp histogram value */
243     RK_U32             u32MoveScene32x32Num;            /* R; the 32x32 cu num of the move scene*/
244     RK_U32             u32MoveSceneBits;                /* R; the stream bit num of the move scene */
245 } VENC_STREAM_ADVANCE_INFO_H265_S;
246 
247 /* Defines the features of an jpege stream */
248 typedef struct rkVENC_STREAM_INFO_PRORES_S {
249     RK_U32 u32PicBytesNum;
250     RK_U32 u32UpdateAttrCnt;
251 } VENC_STREAM_INFO_PRORES_S;
252 
253 /* Defines the features of an jpege stream */
254 typedef struct rkVENC_STREAM_INFO_JPEG_S {
255     RK_U32 u32PicBytesNum;                      /* R; the coded picture stream byte number */
256     /* R; Number of times that channel attributes or parameters (including RC parameters) are set*/
257     RK_U32 u32UpdateAttrCnt;
258     RK_U32 u32Qfactor;                          /* R; image quality */
259 } VENC_STREAM_INFO_JPEG_S;
260 
261 /* Defines the features of an stream */
262 typedef struct rkVENC_STREAM_S {
263     VENC_PACK_S ATTRIBUTE* pstPack;            /* R; stream pack attribute*/
264     RK_U32      ATTRIBUTE u32PackCount;        /* R; the pack number of one frame stream*/
265     RK_U32      u32Seq;                        /* R; the list number of stream*/
266 
267     union {
268         VENC_STREAM_INFO_H264_S   stH264Info;                        /* R; the stream info of h264*/
269         VENC_STREAM_INFO_JPEG_S   stJpegInfo;                        /* R; the stream info of jpeg*/
270         VENC_STREAM_INFO_H265_S   stH265Info;                        /* R; the stream info of h265*/
271         VENC_STREAM_INFO_PRORES_S stProresInfo;                      /* R; the stream info of prores*/
272     };
273 
274     union {
275         VENC_STREAM_ADVANCE_INFO_H264_S   stAdvanceH264Info;         /* R; the stream info of h264*/
276         VENC_STREAM_ADVANCE_INFO_JPEG_S   stAdvanceJpegInfo;         /* R; the stream info of jpeg*/
277         VENC_STREAM_ADVANCE_INFO_H265_S   stAdvanceH265Info;         /* R; the stream info of h265*/
278         VENC_STREAM_ADVANCE_INFO_PRORES_S stAdvanceProresInfo;       /* R; the stream info of prores*/
279     };
280 } VENC_STREAM_S;
281 
282 typedef struct rkVENC_STREAM_INFO_S {
283     H265E_REF_TYPE_E enRefType;  /* R;Type of encoded frames in advanced frame skipping reference mode*/
284 
285     RK_U32  u32PicBytesNum;      /* R;the coded picture stream byte number */
286 
287     /* R;When channel attributes 'bByFrame == 1', it means count of frames.
288      * When channel attributes 'bByFrame == 0', it means count of packets.
289      */
290     RK_U32  u32PicCnt;
291     RK_U32  u32StartQp;          /* R;the start Qp of encoded frames*/
292     RK_U32  u32MeanQp;           /* R;the mean Qp of encoded frames*/
293     RK_BOOL bPSkip;
294 
295     RK_U32  u32ResidualBitNum;   /* R;residual*/
296     RK_U32  u32HeadBitNum;       /* R;head information*/
297     RK_U32  u32MadiVal;          /* R;madi*/
298     RK_U32  u32MadpVal;          /* R;madp*/
299     RK_U32  u32MseSum;           /* R;Sum of MSE value */
300     RK_U32  u32MseLcuCnt;        /* R;Sum of LCU number */
301     RK_DOUBLE dPSNRVal;          /* R;PSNR*/
302 } VENC_STREAM_INFO_S;
303 
304 /* the gop mode */
305 typedef enum rkVENC_GOP_MODE_E {
306     VENC_GOPMODE_INIT = 0,      /* RO;  init mode(not set) */
307     VENC_GOPMODE_NORMALP,       /* RO;  normal p mode */
308     VENC_GOPMODE_TSVC2,         /* RO;  tsvc: 2 layer */
309     VENC_GOPMODE_TSVC3,         /* RO;  tsvc: 3 layer */
310     VENC_GOPMODE_TSVC4,         /* RO;  tsvc: 4 layer */
311     VENC_GOPMODE_SMARTP,        /* RO;  smart p mode */
312     VENC_GOPMODE_BUTT
313 } VENC_GOP_MODE_E;
314 
315 typedef enum rkVENC_ROTATION_E {
316     VENC_ROTATION_0 = 0,
317     VENC_ROTATION_90 = 90,
318     VENC_ROTATION_180 = 180,
319     VENC_ROTATION_270 = 270,
320     VENC_ROTATION_BUTT
321 } VENC_ROTATION_E;
322 
323 typedef struct rkVENC_MPF_CFG_S {
324     RK_U8 u8LargeThumbNailNum;
325     SIZE_S astLargeThumbNailSize[2];
326 } VENC_MPF_CFG_S;
327 
328 typedef enum rkVENC_PIC_RECEIVE_MODE_E {
329     VENC_PIC_RECEIVE_SINGLE = 0,
330     VENC_PIC_RECEIVE_MULTI,
331     VENC_PIC_RECEIVE_BUTT
332 } VENC_PIC_RECEIVE_MODE_E;
333 
334 /*the attribute of jpege*/
335 typedef struct rkVENC_ATTR_JPEG_S {
336     RK_BOOL bSupportDCF; /*RW; Range:[0,1]; support dcf */
337     VENC_MPF_CFG_S stMPFCfg; /*RW; Range:[0,1]; config of Mpf*/
338     VENC_PIC_RECEIVE_MODE_E enReceiveMode;
339 } VENC_ATTR_JPEG_S;
340 
341 /*the attribute of mjpege*/
342 typedef struct rkVENC_ATTR_MJPEG_S {
343     // reserved
344 } VENC_ATTR_MJPEG_S;
345 
346 /*the attribute of h264e*/
347 typedef struct rkVENC_ATTR_H264_S {
348     RK_U32 u32Level;
349     // reserved
350 } VENC_ATTR_H264_S;
351 
352 /*the attribute of h265e*/
353 typedef struct rkVENC_ATTR_H265_S {
354     // reserved
355 } VENC_ATTR_H265_S;
356 
357 /*the attribute of the Venc*/
358 typedef struct rkVENC_ATTR_S {
359     RK_CODEC_ID_E enType;
360     RK_U32 u32MaxPicWidth;
361     RK_U32 u32MaxPicHeight;
362     PIXEL_FORMAT_E enPixelFormat;
363     MIRROR_E enMirror;  // mirror type
364     RK_U32 u32BufSize;
365     RK_U32 u32Profile;
366     RK_BOOL bByFrame;
367     RK_U32 u32PicWidth;
368     RK_U32 u32PicHeight;
369     RK_U32 u32VirWidth;   // stride width, eg. u32VirWidth=(u32PicWidth+15)&(~15)
370     RK_U32 u32VirHeight;  // stride height, eg. u32VirHeight=(u32PicHeight+15)&(~15)
371     RK_U32 u32StreamBufCnt;  // RW; cache nums of encoded output
372     union {
373         VENC_ATTR_H264_S stAttrH264e;    // attributes of H264e
374         VENC_ATTR_H265_S stAttrH265e;    // attributes of H265e
375         VENC_ATTR_MJPEG_S stAttrMjpege;  // attributes of Mjpeg
376         VENC_ATTR_JPEG_S stAttrJpege;    // attributes of jpeg
377     };
378 } VENC_ATTR_S;
379 
380 /*the attribute of the gop*/
381 typedef struct rkVENC_GOP_ATTR_S {
382     VENC_GOP_MODE_E enGopMode;   /* RW;  reference gop mode */
383     RK_S32 s32VirIdrLen;         /* RW;  virtual IDR frame length for smartp mode*/
384     RK_U32 u32MaxLtrCount;       /* RW;  normalp and smartp mode switch without free Ltr buffer, setting to 1 */
385 } VENC_GOP_ATTR_S;
386 
387 /* the attribute of the venc chnl */
388 typedef struct rkVENC_CHN_ATTR_S {
389     VENC_ATTR_S     stVencAttr;                   /*the attribute of video encoder*/
390     VENC_RC_ATTR_S  stRcAttr;                     /*the attribute of rate ctrl*/
391     VENC_GOP_ATTR_S stGopAttr;                    /*the attribute of gop*/
392 } VENC_CHN_ATTR_S;
393 
394 /* the attribute of the buf wrap */
395 typedef struct rkVENC_CHN_BUF_WRAP_S {
396     RK_BOOL bEnable;
397     RK_U32  u32BufLine;          /* RW; Range: [128, H]; Chn buffer allocated by line. */
398     RK_U32  u32WrapBufferSize;   /* RW; Whether to allocate buffer according to compression. */
399 } VENC_CHN_BUF_WRAP_S;
400 
401 /* the attribute of the buf share */
402 typedef struct rkVENC_CHN_REF_BUF_SHARE_S {
403     RK_BOOL bEnable;
404 } VENC_CHN_REF_BUF_SHARE_S;
405 
406 /* the attribute of the combo */
407 typedef struct rkVENC_COMBO_ATTR_S {
408     RK_BOOL bEnable;
409     RK_S32  s32ChnId;           /* RW; Range: [0, VENC_MAX_CHN_NUM); The src combo channel */
410 } VENC_COMBO_ATTR_S;
411 
412 /* the param of receive picture */
413 typedef struct rkVENC_RECV_PIC_PARAM_S {
414     /* RW; Range:[-1, 2147483647]; Number of frames received and encoded by the encoding channel,
415            0 is not supported, -1 is not limit recv pic num*/
416     RK_S32 s32RecvPicNum;
417 } VENC_RECV_PIC_PARAM_S;
418 
419 /* the status of the venc chnl */
420 typedef struct rkVENC_CHN_STATUS_S {
421     RK_U32 u32LeftPics;                           /* R; left picture number */
422     RK_U32 u32LeftStreamBytes;                    /* R; left stream bytes*/
423     RK_U32 u32LeftStreamFrames;                   /* R; left stream frames*/
424     RK_U32 u32CurPacks;                           /* R; pack number of current frame*/
425     /* R; Number of frames to be received. This member is valid after RK_MPI_VENC_StartRecvPicEx is called.*/
426     RK_U32 u32LeftRecvPics;
427     /* R; Number of frames to be encoded. This member is valid after RK_MPI_VENC_StartRecvPicEx is called.*/
428     RK_U32 u32LeftEncPics;
429     RK_BOOL bJpegSnapEnd;                         /* R; the end of Snap.*/
430     VENC_STREAM_INFO_S stVencStrmInfo;
431 } VENC_CHN_STATUS_S;
432 
433 /* the param of the slice split */
434 typedef struct rkVENC_SLICE_SPLIT_S {
435     /* RW; Range:[0,1]; slice split enable, RK_TRUE:enable, RK_FALSE:diable, default value:RK_FALSE*/
436     RK_BOOL bSplitEnable;
437     /* RW; this value presents slice split mode;0:slice is split by byte number;1:slice is split by mb/ctu number*/
438     RK_U32  u32SplitMode;
439     /* RW; this value presents the mb number of one slice;
440     * When u32SplitMode = 0 this value is the max byte number for each slice.
441     * When u32SplitMode = 1 this value is the MB/CTU number for each slice.
442     */
443     RK_U32  u32SplitSize;
444 } VENC_SLICE_SPLIT_S;
445 
446 /* the param of the h264e intra pred */
447 typedef struct rkVENC_H264_INTRA_PRED_S {
448     /* RW; Range:[0,1];default: RK_FALSE, see the H.264 protocol for the meaning*/
449     RK_U32     constrained_intra_pred_flag;
450 } VENC_H264_INTRA_PRED_S;
451 
452 /* the param of the h264e trans */
453 typedef struct rkVENC_H264_TRANS_S {
454     /* RW; Range:[0,2]; Conversion mode for inter-prediction&intra-prediction,0: trans4x4, trans8x8; 1: trans4x4*/
455     RK_U32     u32TransMode;
456 
457     RK_U32     bScalingListValid;                 /* RW; Range:[0,1,2]; enable Scaling, default: 0(disable), 1(scaling list 1), 2(scaling list 2) */
458     RK_U8      InterScalingList8X8[64];           /* RW; Range:[1,255]; A quantization table for 8x8 inter-prediction*/
459     RK_U8      IntraScalingList8X8[64];           /* RW; Range:[1,255]; A quantization table for 8x8 intra-prediction*/
460     /* RW; Range:[-12,12];default value: -6, see the H.264 protocol for the meaning*/
461     RK_S32     chroma_qp_index_offset;
462 } VENC_H264_TRANS_S;
463 
464 /* the param of the h264e entropy */
465 typedef struct rkVENC_H264_ENTROPY_S {
466     /* RW; Range:[0,1];dafault 1.  Entropy encoding mode for the all frame, 0:cavlc, 1:cabac */
467     RK_U32 u32EntropyEncMode;
468     /* RW; Range:[0,2];dafault 0. see the H.264 protocol for the meaning(it works when u32EntropyEncMode equal to 1) */
469     RK_U32 cabac_init_idc;
470 } VENC_H264_ENTROPY_S;
471 
472 /* the config of the h264e poc */
473 typedef struct rkVENC_H264_POC_S {
474     RK_U32 pic_order_cnt_type;                     /* RW; Range:[0,2]; see the H.264 protocol for the meaning */
475 } VENC_H264_POC_S;
476 
477 /* the param of the h264e deblocking */
478 typedef struct rkVENC_H264_DBLK_S {
479     RK_U32 disable_deblocking_filter_idc;          /*  RW; Range:[0,2]; see the H.264 protocol for the meaning */
480     RK_S32 slice_alpha_c0_offset_div2;             /*  RW; Range:[-6,+6]; see the H.264 protocol for the meaning */
481     RK_S32 slice_beta_offset_div2;                 /*  RW; Range:[-6,+6]; see the H.264 protocol for the meaning */
482 } VENC_H264_DBLK_S;
483 
484 /* the param of the h264e vui timing info */
485 typedef struct rkVENC_H264_VUI_TIME_INFO_S {
486     /* RW; Range:[0,1]; If 1, timing info belows will be encoded into vui.*/
487     RK_U8  timing_info_present_flag;
488     /* RW; Range:[0,1]; see the H.264 protocol for the meaning. */
489     RK_U8  fixed_frame_rate_flag;
490     /* RW; Range:(0,4294967295]; see the H.264 protocol for the meaning */
491     RK_U32 num_units_in_tick;
492     /* RW; Range:(0,4294967295]; see the H.264 protocol for the meaning */
493     RK_U32 time_scale;
494 } VENC_VUI_H264_TIME_INFO_S;
495 
496 /* the param of the vui aspct ratio */
497 typedef struct rkVENC_VUI_ASPECT_RATIO_S {
498     /* RW; Range:[0,1]; If 1, aspectratio info belows will be encoded into vui */
499     RK_U8  aspect_ratio_info_present_flag;
500     /* RW; Range:[0,255]; 17~254 is reserved,see the protocol for the meaning.*/
501     RK_U8  aspect_ratio_idc;
502     /* RW; Range:[0,1]; If 1, oversacan info belows will be encoded into vui.*/
503     RK_U8  overscan_info_present_flag;
504     /* RW; Range:[0,1]; see the protocol for the meaning. */
505     RK_U8  overscan_appropriate_flag;
506     /* RW; Range:(0, 65535]; see the protocol for the meaning. */
507     RK_U16 sar_width;
508     /* RW; Range:(0, 65535]; see the protocol for the meaning. notes:
509      * sar_width  and  sar_height  shall  be  relatively  prime.
510      */
511     RK_U16 sar_height;
512 } VENC_VUI_ASPECT_RATIO_S;
513 
514 /* the param of the vui video signal */
515 typedef struct rkVENC_VUI_VIDEO_SIGNAL_S {
516     /* RW; Range:[0,1]; If 1, video singnal info will be encoded into vui. */
517     RK_U8  video_signal_type_present_flag;
518     /* RW; H.264e Range:[0,7], H.265e Range:[0,5]; see the protocol for the meaning. */
519     RK_U8  video_format;
520     RK_U8  video_full_range_flag;                  /* RW; Range: [0,1]; see the protocol for the meaning.*/
521     RK_U8  colour_description_present_flag;       /* RO; Range: [0,1]; see the protocol for the meaning.*/
522     RK_U8  colour_primaries;                      /* RO; Range: [0,255]; see the protocol for the meaning. */
523     RK_U8  transfer_characteristics;               /* RO; Range: [0,255]; see the protocol for the meaning. */
524     RK_U8  matrix_coefficients;                    /* RO; Range:[0,255]; see the protocol for the meaning. */
525 } VENC_VUI_VIDEO_SIGNAL_S;
526 
527 /* the param of the vui video signal */
528 typedef struct rkVENC_VUI_BITSTREAM_RESTRIC_S {
529     RK_U8  bitstream_restriction_flag;            /* RW; Range: [0,1]; see the protocol for the meaning.*/
530 } VENC_VUI_BITSTREAM_RESTRIC_S;
531 
532 /* the param of the h264e vui */
533 typedef struct rkVENC_H264_VUI_S {
534     VENC_VUI_ASPECT_RATIO_S           stVuiAspectRatio;
535     VENC_VUI_H264_TIME_INFO_S          stVuiTimeInfo;
536     VENC_VUI_VIDEO_SIGNAL_S           stVuiVideoSignal;
537     VENC_VUI_BITSTREAM_RESTRIC_S      stVuiBitstreamRestric;
538 } VENC_H264_VUI_S;
539 
540 /* the param of the h265e vui timing info */
541 typedef struct rkVENC_VUI_H265_TIME_INFO_S {
542     /* RW; Range:[0,1]; If 1, timing info belows will be encoded into vui.*/
543     RK_U32 timing_info_present_flag;
544     /* RW; Range:[0,4294967295]; see the H.265 protocol for the meaning. */
545     RK_U32 num_units_in_tick;
546     /* RW; Range:(0,4294967295]; see the H.265 protocol for the meaning */
547     RK_U32 time_scale;
548     /* RW; Range:(0,4294967294]; see the H.265 protocol for the meaning */
549     RK_U32 num_ticks_poc_diff_one_minus1;
550 } VENC_VUI_H265_TIME_INFO_S;
551 
552 /* the param of the h265e vui */
553 typedef struct rkVENC_H265_VUI_S {
554     VENC_VUI_ASPECT_RATIO_S        stVuiAspectRatio;
555     VENC_VUI_H265_TIME_INFO_S     stVuiTimeInfo;
556     VENC_VUI_VIDEO_SIGNAL_S       stVuiVideoSignal;
557     VENC_VUI_BITSTREAM_RESTRIC_S  stVuiBitstreamRestric;
558 } VENC_H265_VUI_S;
559 
560 /* the param of the jpege */
561 typedef struct rkVENC_JPEG_PARAM_S {
562     RK_U32 u32Qfactor;                     /* RW; Range:[1,99]; Qfactor value  */
563     RK_U8  u8YQt[64];                      /* RW; Range:[1, 255]; Y quantization table */
564     RK_U8  u8CbQt[64];                     /* RW; Range:[1, 255]; Cb quantization table */
565     RK_U8  u8CrQt[64];                     /* RW; Range:[1, 255]; Cr quantization table */
566     /* RW; the max MCU number is
567      * (picwidth + 15) >> 4 x (picheight + 15) >> 4 x 2]; MCU number of one ECS
568      */
569     RK_U32 u32MCUPerECS;
570 } VENC_JPEG_PARAM_S;
571 
572 /* the param of the mjpege */
573 typedef struct rkVENC_MJPEG_PARAM_S {
574     RK_U8 u8YQt[64];                       /* RW; Range:[1, 255]; Y quantization table */
575     RK_U8 u8CbQt[64];                      /* RW; Range:[1, 255]; Cb quantization table */
576     RK_U8 u8CrQt[64];                      /* RW; Range:[1, 255]; Cr quantization table */
577     /* RW; the max MCU number is
578      * (picwidth + 15) >> 4 x (picheight + 15) >> 4 x 2]; MCU number of one ECS
579      */
580     RK_U32 u32MCUPerECS;
581 } VENC_MJPEG_PARAM_S;
582 
583 /* the param of the ProRes */
584 typedef struct rkVENC_PRORES_PARAM_S {
585     /* RW; Range:[1, 255]; Luma quantization table */
586     RK_U8 u8LumaQt[64];
587     /* RW; Range:[1, 255]; Chroma quantization table */
588     RK_U8 u8ChromaQt[64];
589     /* RW:  identifies the encoder vendor or product that generated the compressed frame*/
590     RK_CHAR encoder_identifier[4];
591 } VENC_PRORES_PARAM_S;
592 
593 /* the attribute of the roi */
594 typedef struct rkVENC_ROI_ATTR_S {
595     /* RW; Range:[0, 7]; Index of an ROI. The system supports indexes ranging from 0 to 7 */
596     RK_U32  u32Index;
597     /* RW; Range:[0, 1]; Whether to enable this ROI */
598     RK_BOOL bEnable;
599     /* RW; Range:[0, 1]; QP mode of an ROI.RK_FALSE: relative QP.RK_TURE: absolute QP.*/
600     RK_BOOL bAbsQp;
601     /* RW; Range:[-51, 51]; QP value,only relative mode can QP value less than 0. */
602     RK_S32  s32Qp;
603     RK_BOOL bIntra;                      /* flag of forced intra macroblock*/
604     RECT_S  stRect;                       /* RW; Region of an ROI*/
605 } VENC_ROI_ATTR_S;
606 
607 /* ROI struct */
608 typedef struct rkVENC_ROI_ATTR_EX_S {
609     /* RW; Range:[0, 7]; Index of an ROI. The system supports indexes ranging from 0 to 7 */
610     RK_U32  u32Index;
611     /* RW; Range:[0, 1]; Subscript of array   0: I Frame; 1: P/B Frame; 2: VI Frame; other params are the same. */
612     RK_BOOL bEnable[3];
613     /* RW; Range:[0, 1]; QP mode of an ROI.RK_FALSE: relative QP.RK_TURE: absolute QP.*/
614     RK_BOOL bAbsQp[3];
615     /* RW; Range:[-51, 51]; QP value,only relative mode can QP value less than 0. */
616     RK_S32  s32Qp[3];
617     RECT_S  stRect[3];                    /* RW;Region of an ROI*/
618 }VENC_ROI_ATTR_EX_S;
619 
620 /* the param of the roibg frame rate */
621 typedef struct rkVENC_ROIBG_FRAME_RATE_S {
622     /* RW; Range:[-1, 2147483647];Source frame rate of a non-ROI,can not be configured 0*/
623     RK_S32 s32SrcFrmRate;
624     /* RW; Range:[-1, 2147483647];Target frame rate of a non-ROI,can not be larger than s32SrcFrmRate*/
625     RK_S32 s32DstFrmRate;
626 } VENC_ROIBG_FRAME_RATE_S;
627 
628 /* the param of the roibg frame rate */
629 typedef struct rkVENC_REF_PARAM_S {
630     RK_U32       u32Base;                          /* RW; Range:[0,4294967295]; Base layer period*/
631     RK_U32       u32Enhance;                       /* RW; Range:[0,255]; Enhance layer period*/
632 	/* RW; Range:[0, 1]; Whether some frames at the base layer are referenced by other frames at the base layer.
633 	 * When bEnablePred is rk_FALSE, all frames at the base layer reference IDR frames.
634 	 */
635     RK_BOOL      bEnablePred;
636 } VENC_REF_PARAM_S;
637 
638 /* Jpeg snap mode */
639 typedef enum rkVENC_JPEG_ENCODE_MODE_E {
640     JPEG_ENCODE_ALL   = 0,                        /* Jpeg channel snap all the pictures when started. */
641     JPEG_ENCODE_SNAP  = 1,                        /* Jpeg channel snap the flashed pictures when started. */
642     JPEG_ENCODE_BUTT,
643 } VENC_JPEG_ENCODE_MODE_E;
644 
645 
646 /* the information of the stream */
647 typedef struct rkVENC_STREAM_BUF_INFO_S {
648     RK_U64   u64PhyAddr[MAX_TILE_NUM];             /* R; Start physical address for a stream buffer */
649     RK_VOID ATTRIBUTE* pUserAddr[MAX_TILE_NUM];    /* R; Start virtual address for a stream buffer */
650     RK_U64  ATTRIBUTE u64BufSize[MAX_TILE_NUM];    /* R; Stream buffer size */
651 } VENC_STREAM_BUF_INFO_S;
652 
653 /* the param of the h265e slice split */
654 typedef struct rkVENC_H265_SLICE_SPLIT_S {
655     /* RW; Range:[0,1]; slice split enable, RK_TRUE:enable, RK_FALSE:diable, default value:RK_FALSE */
656     RK_BOOL bSplitEnable;
657     /* RW; Range:(Picture height + lcu size minus one)/lcu size;this value presents lcu line number */
658     RK_U32  u32LcuLineNum;
659 } VENC_H265_SLICE_SPLIT_S;
660 
661 /* the param of the h265e pu */
662 typedef struct rkVENC_H265_PU_S {
663     RK_U32    constrained_intra_pred_flag;         /* RW; Range:[0,1]; see the H.265 protocol for the meaning. */
664     RK_U32    strong_intra_smoothing_enabled_flag; /* RW; Range:[0,1]; see the H.265 protocol for the meaning. */
665 } VENC_H265_PU_S;
666 
667 /* the param of the h265e trans */
668 typedef struct rkVENC_H265_TRANS_S {
669     RK_S32  cb_qp_offset;                          /* RW; Range:[-12,12]; see the H.265 protocol for the meaning. */
670     RK_S32  cr_qp_offset;                          /* RW; Range:[-12,12]; see the H.265 protocol for the meaning. */
671 
672     RK_U32  bScalingListEnabled;                   /* RW; Range:[0,1,2]; enable Scaling, default: 0(disable), 1(scaling list 1), 2(scaling list 2) */
673 
674     RK_BOOL bScalingListTu4Valid;                  /* RW; Range:[0,1]; If 1, ScalingList4X4 belows will be encoded.*/
675     RK_U8   InterScalingList4X4[2][16];            /* RW; Range:[1,255]; Scaling List for inter 4X4 block.*/
676     RK_U8   IntraScalingList4X4[2][16];            /* RW; Range:[1,255]; Scaling List for intra 4X4 block.*/
677 
678     RK_BOOL bScalingListTu8Valid;                  /* RW; Range:[0,1]; If 1, ScalingList8X8 belows will be encoded.*/
679     RK_U8   InterScalingList8X8[2][64];            /* RW; Range:[1,255]; Scaling List for inter 8X8 block.*/
680     RK_U8   IntraScalingList8X8[2][64];            /* RW; Range:[1,255]; Scaling List for intra 8X8 block.*/
681 
682     RK_BOOL bScalingListTu16Valid;                 /* RW; Range:[0,1]; If 1, ScalingList16X16 belows will be encoded.*/
683     RK_U8   InterScalingList16X16[2][64];          /* RW; Range:[1,255]; Scaling List for inter 16X16 block..*/
684     RK_U8   IntraScalingList16X16[2][64];          /* RW; Range:[1,255]; Scaling List for inter 16X16 block.*/
685 
686     RK_BOOL bScalingListTu32Valid;                 /* RW; Range:[0,1]; If 1, ScalingList32X32 belows will be encoded.*/
687     RK_U8   InterScalingList32X32[64];             /* RW; Range:[1,255]; Scaling List for inter 32X32 block..*/
688     RK_U8   IntraScalingList32X32[64];             /* RW; Range:[1,255]; Scaling List for inter 32X32 block.*/
689 } VENC_H265_TRANS_S;
690 
691 /* the param of the h265e entroy */
692 typedef struct rkVENC_H265_ENTROPY_S {
693     RK_U32 cabac_init_flag;                         /* RW; Range:[0,1]; see the H.265 protocol for the meaning. */
694 } VENC_H265_ENTROPY_S;
695 
696 /* the param of the h265e deblocking */
697 typedef struct rkVENC_H265_DBLK_S {
698     RK_U32 slice_deblocking_filter_disabled_flag;   /* RW; Range:[0,1]; see the H.265 protocol for the meaning. */
699     RK_S32 slice_beta_offset_div2;                  /* RW; Range:[-6,6]; see the H.265 protocol for the meaning. */
700     RK_S32 slice_tc_offset_div2;                    /* RW; Range:[-6,6]; see the H.265 protocol for the meaning. */
701 } VENC_H265_DBLK_S;
702 
703 /* the param of the h265e sao */
704 typedef struct rkVENC_H265_SAO_S {
705     /*RW; Range:[0,1]; Indicates whether SAO filtering is performed on the luminance component of the current slice. */
706     RK_U32  slice_sao_luma_flag;
707     /*RW; Range:[0,1]; Indicates whether SAO filtering is performed on the chrominance component of the current slice*/
708     RK_U32  slice_sao_chroma_flag;
709     /*RW; Range:[0,7]*/
710     RK_U32  slice_sao_bit_ratio;
711 } VENC_H265_SAO_S;
712 
713 /* venc mode type */
714 typedef enum rkVENC_INTRA_REFRESH_MODE_E {
715     INTRA_REFRESH_ROW = 0,                      /* Line mode */
716     INTRA_REFRESH_COLUMN,                       /* Column mode */
717     INTRA_REFRESH_BUTT
718 } VENC_INTRA_REFRESH_MODE_E;
719 
720 
721 /* the param of the intra refresh */
722 typedef struct rkVENC_INTRA_REFRESH_S {
723     /*RW; Range:[0,1]; intra refresh enable, RK_TRUE:enable, RK_FALSE:diable, default value:RK_FALSE*/
724     RK_BOOL                     bRefreshEnable;
725     /*RW; The mode of intra refresh*/
726     VENC_INTRA_REFRESH_MODE_E   enIntraRefreshMode;
727     /*RW; Number of rows/column to be refreshed during each I macroblock refresh*/
728     RK_U32                      u32RefreshNum;
729     /*RW; Range:[0,51]; QP value of the I frame*/
730     RK_U32                      u32ReqIQp;
731 } VENC_INTRA_REFRESH_S;
732 
733 /* venc mode type */
734 typedef enum rkVENC_MODTYPE_E {
735     MODTYPE_VENC = 1,                   /* VENC */
736     MODTYPE_H264E,                     /* H264e */
737     MODTYPE_H265E,                       /* H265e */
738     MODTYPE_JPEGE,                       /* Jpege */
739     MODTYPE_RC,              /* Rc */
740     MODTYPE_BUTT
741 } VENC_MODTYPE_E;
742 
743 /* the param of the h264e mod */
744 typedef struct rkVENC_MOD_H264E_S {
745     RK_U32          u32OneStreamBuffer;     /* RW; Range:[0,1]; one stream buffer*/
746     RK_U32          u32H264eMiniBufMode;    /* RW; Range:[0,1]; H264e MiniBufMode*/
747     RK_U32          u32H264ePowerSaveEn;    /* RW; Range:[0,1]; H264e PowerSaveEn*/
748     MB_SOURCE_E     enH264eMBSource;        /* RW; H264e VBSource*/
749     RK_BOOL         bQpHstgrmEn;            /* RW; Range:[0,1]*/
750 } VENC_MOD_H264E_S;
751 
752 /* the param of the h265e mod */
753 typedef struct rkVENC_MOD_H265E_S {
754     RK_U32          u32OneStreamBuffer;      /* RW; Range:[0,1]; one stream buffer*/
755     RK_U32          u32H265eMiniBufMode;     /* RW; Range:[0,1]; H265e MiniBufMode*/
756     RK_U32          u32H265ePowerSaveEn;     /* RW; Range:[0,2]; H265e PowerSaveEn*/
757     MB_SOURCE_E     enH265eMBSource;         /* RW; H265e VBSource*/
758     RK_BOOL         bQpHstgrmEn;             /* RW; Range:[0,1]*/
759 } VENC_MOD_H265E_S;
760 
761 /* the param of the jpege mod */
762 typedef struct rkVENC_MOD_JPEGE_S {
763     RK_U32  u32OneStreamBuffer;         /* RW; Range:[0,1]; one stream buffer*/
764     RK_U32  u32JpegeMiniBufMode;        /* RW; Range:[0,1]; Jpege MiniBufMode*/
765     RK_U32  u32JpegClearStreamBuf;      /* RW; Range:[0,1]; JpegClearStreamBuf*/
766 } VENC_MOD_JPEGE_S;
767 
768 typedef struct rkVENC_MOD_RC_S {
769     RK_U32  u32ClrStatAfterSetBr;
770 } VENC_MOD_RC_S;
771 /* the param of the venc mod */
772 typedef struct rkVENC_MOD_VENC_S {
773     RK_U32 u32VencBufferCache;  /* RW; Range:[0,1]; VencBufferCache*/
774     RK_U32 u32FrameBufRecycle;  /* RW; Range:[0,1]; FrameBufRecycle*/
775 } VENC_MOD_VENC_S;
776 
777 /* the param of the mod */
778 typedef struct rkVENC_MODPARAM_S {
779     VENC_MODTYPE_E enVencModType;        /* RW; VencModType*/
780     union {
781         VENC_MOD_VENC_S  stVencModParam;
782         VENC_MOD_H264E_S stH264eModParam;
783         VENC_MOD_H265E_S stH265eModParam;
784         VENC_MOD_JPEGE_S stJpegeModParam;
785         VENC_MOD_RC_S    stRcModParam;
786     };
787 } VENC_PARAM_MOD_S;
788 
789 typedef enum rkVENC_FRAME_TYPE_E {
790     VENC_FRAME_TYPE_NONE = 1,
791     VENC_FRAME_TYPE_IDR,
792     VENC_FRAME_TYPE_BUTT
793 } VENC_FRAME_TYPE_E;
794 
795 /* the information of the user rc*/
796 typedef struct rkUSER_RC_INFO_S {
797     /* RW; Range:[0,1]; Indicates whether the QpMap mode is valid for the current frame*/
798     RK_BOOL bQpMapValid;
799     /* RW; Range:[0,1]; Indicates whether the SkipWeight mode is valid for the current frame*/
800     RK_BOOL bSkipWeightValid;
801     /* RW; Range:[0,51];QP value of the first 16 x 16 block in QpMap mode */
802     RK_U32  u32BlkStartQp;
803     MB_BLK  pMbBlkQpMap;      /* RW; Blk of the QP table in QpMap mode*/
804     MB_BLK  pMbBlkSkipWeight; /* RW; Blk of the SkipWeight table in QpMap mode*/
805     VENC_FRAME_TYPE_E enFrameType;/* RW; Encoding frame type of the current frame */
806 } USER_RC_INFO_S;
807 
808 
809 /* the information of the user frame*/
810 typedef struct rkUSER_FRAME_INFO_S {
811     VIDEO_FRAME_INFO_S stUserFrame;
812     USER_RC_INFO_S     stUserRcInfo;
813 } USER_FRAME_INFO_S;
814 
815 /* the config of the sse*/
816 typedef struct rkVENC_SSE_CFG_S {
817     /* RW; Range:[0, 7]; Index of an SSE. The system supports indexes ranging from 0 to 7 */
818     RK_U32  u32Index;
819     RK_BOOL bEnable;        /* RW; Range:[0, 1]; Whether to enable SSE */
820     RECT_S  stRect;         /* RW; */
821 } VENC_SSE_CFG_S;
822 
823 typedef enum rkVENC_CROP_TYPE_E {
824     VENC_CROP_NONE = 0,
825     VENC_CROP_ONLY,
826     VENC_CROP_SCALE,
827     VENC_CROP_BUTT
828 } VENC_CROP_TYPE_E;
829 
830 typedef struct rkVENC_SCALE_RECT_S {
831     RECT_S stSrc;          /* RW; Scale src region, note: x/y/w/h must be multi of 2, scale ratio not more than 16*/
832     RECT_S stDst;          /* RW; Scale dst region, note: x/y/w/h must be multi of 2, scale ratio not more than 16*/
833 } VENC_SCALE_RECT_S;
834 
835 /* the param of the crop/scale */
836 typedef struct rkVENC_CROP_INFO_S {
837     VENC_CROP_TYPE_E enCropType;           /* RW; Range:[0, 3); Crop/Scale region enable */
838     RECT_S  stCropRect;                    /* RW; Crop region, note: x/w/h must be multi of 2*/
839     VENC_SCALE_RECT_S stScaleRect;         /* RW; Scale region, note: x/y/w/h must be multi of 2 */
840 } VENC_CROP_INFO_S;
841 
842 /* the param of the venc frame rate */
843 typedef struct rkVENC_FRAME_RATE_S {
844     RK_BOOL bEnable;                       /* RW; Range:[0, 1];  frame rate enable */
845     RK_S32 s32SrcFrmRateNum;               /* RW; Range:[0, 240]; Input frame rate of num for a  channel*/
846     RK_S32 s32SrcFrmRateDen;               /* RW; Range:[0, 240]; Input frame rate of den for a  channel*/
847     RK_S32 s32DstFrmRateNum;               /* RW; Range:[0, 240]; Output frame rate of num for a channel*/
848     RK_S32 s32DstFrmRateDen;               /* RW; Range:[0, 240]; Output frame rate of den for a  channel*/
849 } VENC_FRAME_RATE_S;
850 
851 /* the param of the venc encode chnl */
852 typedef struct rkVENC_CHN_PARAM_S {
853     RK_BOOL bColor2Grey;                /* RW; Range:[0, 1]; Whether to enable Color2Grey.*/
854     RK_U32  u32Priority;                /* RW; Range:[0, 1]; The priority of the coding chnl.*/
855     /* RW: Range:[0,4294967295]; Maximum number of frames in a stream buffer*/
856     RK_U32  u32MaxStrmCnt;
857     /* RW: Range:(0,4294967295]; the frame num needed to wake up  obtaining streams */
858     RK_U32  u32PollWakeUpFrmCnt;
859     VENC_CROP_INFO_S stCropCfg;
860     VENC_FRAME_RATE_S stFrameRate;
861 } VENC_CHN_PARAM_S;
862 
863 /*the ground protect of FOREGROUND*/
864 typedef struct rkVENC_FOREGROUND_PROTECT_S {
865     RK_BOOL bForegroundCuRcEn;
866     /*RW; Range:[0, 16]; The direction for controlling the macroblock-level bit rate*/
867     RK_U32  u32ForegroundDirectionThresh;
868     /*RW; Range:[0, 15]; The gain of the thresh*/
869     RK_U32  u32ForegroundThreshGain;
870     /*RW; Range:[0, 255]; The offset of the thresh*/
871     RK_U32  u32ForegroundThreshOffset;
872     /*RW; Range:[0, 255]; Mad threshold for controlling the foreground macroblock-level bit rate of P frames */
873     RK_U32  u32ForegroundThreshP[RC_TEXTURE_THR_SIZE];
874     /*RW; Range:[0, 255]; Mad threshold for controlling the foreground macroblock-level bit rate of B frames */
875     RK_U32  u32ForegroundThreshB[RC_TEXTURE_THR_SIZE];
876 } VENC_FOREGROUND_PROTECT_S;
877 
878 /* the scene mode of the venc encode chnl */
879 typedef enum rkVENC_SCENE_MODE_E {
880     /* RW; A scene in which the camera does not move or periodically moves continuously*/
881     SCENE_0  = 0,
882     /* RW; Motion scene at high bit rate*/
883     SCENE_1  = 1,
884     /* RW; It has regular continuous motion at medium bit rate and the encoding pressure is relatively large*/
885     SCENE_2  = 2,
886     SCENE_BUTT
887 } VENC_SCENE_MODE_E;
888 
889 
890 typedef struct rkVENC_DEBREATHEFFECT_S {
891     RK_BOOL   bEnable;                 /* RW; Range:[0,1];default: 0, DeBreathEffect enable */
892     RK_S32    s32Strength0;            /* RW; Range:[0,35];The Strength0 of DeBreathEffect.*/
893     RK_S32    s32Strength1;            /* RW; Range:[0,35];The Strength1 of DeBreathEffect.*/
894 } VENC_DEBREATHEFFECT_S;
895 
896 typedef struct rkVENC_CU_PREDICTION_S {
897      OPERATION_MODE_E enPredMode;     /* RW; CU tendency configuration mode  */
898 
899      RK_U32 u32Intra32Cost;           /* RW; Range:[0,15]; Tendency adjustment in Intra32 mode*/
900      RK_U32 u32Intra16Cost;           /* RW; Range:[0,15]; Tendency adjustment in Intra16 mode*/
901      RK_U32 u32Intra8Cost;            /* RW; Range:[0,15]; Tendency adjustment in Intra8 mode*/
902      RK_U32 u32Intra4Cost;            /* RW; Range:[0,15]; Tendency adjustment in Intra4 mode*/
903 
904      RK_U32 u32Inter64Cost;           /* RW; Range:[0,15]; Tendency adjustment in Intra64 mode*/
905      RK_U32 u32Inter32Cost;           /* RW; Range:[0,15]; Tendency adjustment in Inter32 mode*/
906      RK_U32 u32Inter16Cost;           /* RW; Range:[0,15]; Tendency adjustment in Inter16 mode*/
907      RK_U32 u32Inter8Cost;            /* RW; Range:[0,15]; Tendency adjustment in Inter8 mode*/
908 } VENC_CU_PREDICTION_S;
909 
910 typedef struct rkVENC_SKIP_BIAS_S {
911      /* RW; Range:[0,1];   Flag indicating whether the skip tendency function is enabled*/
912      RK_BOOL   bSkipBiasEn;
913      /* RW; Range:[0,15];  used to calculate the SAD threshold for foreground detection*/
914      RK_U32    u32SkipThreshGain;
915      /* RW; Range:[0,255]; used to calculate the SAD threshold for foreground detection*/
916      RK_U32    u32SkipThreshOffset;
917      RK_U32    u32SkipBackgroundCost;   /* RW; Range:[0,15];  Skip tendency adjustment in the background*/
918      RK_U32    u32SkipForegroundCost;   /* RW; Range:[0,15];  Skip tendency adjustment in the foreground*/
919 } VENC_SKIP_BIAS_S;
920 
921 typedef struct rkVENC_HIERARCHICAL_QP_S {
922     RK_BOOL     bHierarchicalQpEn;              /* RW; Range:[0,1];    Hierarchical QP enable*/
923     /* RW; Range:[-10,10]; QP delta of the frames at each layer relative to the P-frame at layer 0*/
924     RK_S32      s32HierarchicalQpDelta[4];
925     /* RW; Range:[0,5]; Number of frames at each layer*/
926     RK_S32      s32HierarchicalFrameNum[4];
927 } VENC_HIERARCHICAL_QP_S;
928 
929 typedef struct rkVENC_CHN_POOL_S {
930     //  VB_POOL hPicVbPool;     /* RW;  vb pool id for pic buffer */
931     //  VB_POOL hPicInfoVbPool; /* RW;  vb pool id for pic info buffer */
932 } VENC_CHN_POOL_S;
933 
934 typedef struct rkVENC_RC_ADVPARAM_S {
935     RK_U32 u32ClearStatAfterSetAttr; /* RW; Range:[0,1]; Clear Stat After SetAttr enable */
936 } VENC_RC_ADVPARAM_S;
937 
938 typedef enum rkRC_SUPERFRM_MODE_E {
939     SUPERFRM_NONE = 0,
940     SUPERFRM_DISCARD,
941     SUPERFRM_REENCODE,
942     SUPERFRM_BUTT
943 } VENC_SUPERFRM_MODE_E;
944 
945 typedef enum rkVENC_RC_PRIORITY_E {
946     VENC_RC_PRIORITY_BITRATE_FIRST = 1,
947     VENC_RC_PRIORITY_FRAMEBITS_FIRST,
948     VENC_RC_PRIORITY_BUTT,
949 } VENC_RC_PRIORITY_E;
950 
951 typedef struct rkVENC_SUPERFRAME_CFG_S {
952     VENC_SUPERFRM_MODE_E enSuperFrmMode;
953     RK_U32 u32SuperIFrmBitsThr;
954     RK_U32 u32SuperPFrmBitsThr;
955     RK_U32 u32SuperBFrmBitsThr;
956     VENC_RC_PRIORITY_E enRcPriority;
957 } VENC_SUPERFRAME_CFG_S;
958 
959 typedef enum rkVENC_FRAMELOST_MODE_E {
960     FRMLOST_NORMAL = 0,
961     FRMLOST_PSKIP,
962     FRMLOST_BUTT,
963 } VENC_FRAMELOST_MODE_E;
964 
965 typedef struct rkVENC_FRAMELOST_S {
966     RK_BOOL bFrmLostOpen;
967     RK_U32 u32FrmLostBpsThr;
968     VENC_FRAMELOST_MODE_E enFrmLostMode;
969     RK_U32 u32EncFrmGaps;
970 } VENC_FRAMELOST_S;
971 
972 #ifdef __cplusplus
973 #if __cplusplus
974 }
975 #endif
976 #endif /* End of #ifdef __cplusplus */
977 
978 #endif /* End of #ifndef  INCLUDE_RT_MPI_RK_COMM_VENC_H_ */
979 
980 
981