• 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_RC_H__
16 #define __HI_COMM_RC_H__
17 
18 #include "hi_type.h"
19 #include "hi_defines.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 typedef HI_U32 HI_FR32;
26 
27 /* rc mode */
28 typedef enum hiVENC_RC_MODE_E {
29     VENC_RC_MODE_H264CBR = 1,
30     VENC_RC_MODE_H264VBR,
31     VENC_RC_MODE_H264AVBR, /* Not support for Hi3556AV100/Hi3556V200/Hi3559V200 */
32     VENC_RC_MODE_H264QVBR,
33     VENC_RC_MODE_H264CVBR,
34     VENC_RC_MODE_H264FIXQP,
35     VENC_RC_MODE_H264QPMAP, /* Not support for Hi3556AV100/Hi3556V200/Hi3559V200 */
36 
37     VENC_RC_MODE_MJPEGCBR,
38     VENC_RC_MODE_MJPEGVBR,
39     VENC_RC_MODE_MJPEGFIXQP,
40 
41     VENC_RC_MODE_H265CBR,
42     VENC_RC_MODE_H265VBR,
43     VENC_RC_MODE_H265AVBR, /* Not support for Hi3556AV100/Hi3556V200/Hi3559V200 */
44     VENC_RC_MODE_H265QVBR,
45     VENC_RC_MODE_H265CVBR,
46     VENC_RC_MODE_H265FIXQP,
47     VENC_RC_MODE_H265QPMAP, /* Not support for Hi3556AV100/Hi3556V200/Hi3559V200 */
48 
49     VENC_RC_MODE_BUTT,
50 } VENC_RC_MODE_E;
51 
52 /* qpmap mode */
53 typedef enum hiVENC_RC_QPMAP_MODE_E {
54     VENC_RC_QPMAP_MODE_MEANQP = 0,
55     VENC_RC_QPMAP_MODE_MINQP,
56     VENC_RC_QPMAP_MODE_MAXQP,
57 
58     VENC_RC_QPMAP_MODE_BUTT,
59 } VENC_RC_QPMAP_MODE_E;
60 
61 /* the attribute of h264e fixqp */
62 typedef struct hiVENC_H264_FIXQP_S {
63     HI_U32      u32Gop;                    /* RW; Range:[1, 65536]; the interval of ISLICE. */
64     HI_U32      u32SrcFrameRate;           /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
65     HI_FR32     fr32DstFrameRate;         /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
66                                                 can not be larger than u32SrcFrameRate */
67     HI_U32      u32IQp;                    /* RW; Range:[0, 51]; qp of the i frame */
68     HI_U32      u32PQp;                    /* RW; Range:[0, 51]; qp of the p frame */
69     HI_U32      u32BQp;                    /* RW; Range:[0, 51]; qp of the b frame */
70 } VENC_H264_FIXQP_S;
71 
72 /* the attribute of h264e cbr */
73 typedef struct hiVENC_H264_CBR_S {
74     HI_U32      u32Gop;                    /* RW; Range:[1, 65536]; the interval of I Frame. */
75     HI_U32      u32StatTime;               /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
76     HI_U32      u32SrcFrameRate;           /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
77     HI_FR32     fr32DstFrameRate;         /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
78                                                 can not be larger than u32SrcFrameRate */
79     HI_U32      u32BitRate;                /* RW; Range:[2, 614400]; average bitrate */
80 } VENC_H264_CBR_S;
81 
82 /* the attribute of h264e vbr */
83 typedef struct hiVENC_H264_VBR_S {
84     HI_U32      u32Gop;                     /* RW; Range:[1, 65536]; the interval of ISLICE. */
85     HI_U32      u32StatTime;                /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
86     HI_U32      u32SrcFrameRate;            /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
87     HI_FR32     fr32DstFrameRate;          /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
88                                                 can not be larger than u32SrcFrameRate */
89     HI_U32      u32MaxBitRate;              /* RW; Range:[2, 614400]; the max bitrate */
90 } VENC_H264_VBR_S;
91 
92 /* the attribute of h264e cvbr */
93 typedef struct hiVENC_H264_CVBR_S {
94     HI_U32      u32Gop;                     /* RW; Range:[1, 65536]; the interval of ISLICE. */
95     HI_U32      u32StatTime;                /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
96     HI_U32      u32SrcFrameRate;            /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
97     HI_FR32     fr32DstFrameRate;          /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
98                                                 can not be larger than u32SrcFrameRate */
99     HI_U32      u32MaxBitRate;              /* RW; Range:[2, 614400];the max bitrate */
100 
101     HI_U32      u32ShortTermStatTime;       /* RW; Range:[1, 120]; the long-term rate statistic time,
102                                                 the unit is second (s) */
103     HI_U32      u32LongTermStatTime;        /* RW; Range:[1, 1440]; the long-term rate statistic time,
104                                                 the unit is u32LongTermStatTimeUnit */
105     HI_U32      u32LongTermMaxBitrate;     /* RW; Range:[2, 614400]; the long-term target max bitrate,
106                                                 can not be larger than u32MaxBitRate, the unit is kbps */
107     HI_U32      u32LongTermMinBitrate;     /* RW; Range:[0, 614400];the long-term target min bitrate,
108                                                 can not be larger than u32LongTermMaxBitrate, the unit is kbps */
109 } VENC_H264_CVBR_S;
110 
111 /* the attribute of h264e avbr */
112 typedef struct hiVENC_H264_AVBR_S {
113     HI_U32      u32Gop;                  /* RW; Range:[1, 65536]; the interval of ISLICE. */
114     HI_U32      u32StatTime;             /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
115     HI_U32      u32SrcFrameRate;         /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
116     HI_FR32     fr32DstFrameRate;       /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
117                                                 can not be larger than u32SrcFrameRate */
118     HI_U32      u32MaxBitRate;           /* RW; Range:[2, 614400];the max bitrate */
119 } VENC_H264_AVBR_S;
120 
121 /* the attribute of h264e qpmap */
122 typedef struct hiVENC_H264_QPMAP_S {
123     HI_U32      u32Gop;                   /* RW; Range:[1, 65536]; the interval of ISLICE. */
124     HI_U32      u32StatTime;              /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
125     HI_U32      u32SrcFrameRate;          /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
126     HI_FR32     fr32DstFrameRate;        /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
127                                                 can not be larger than u32SrcFrameRate */
128 } VENC_H264_QPMAP_S;
129 
130 typedef struct hiVENC_H264_QVBR_S {
131     HI_U32      u32Gop;                   /* RW; Range:[1, 65536]; the interval of ISLICE. */
132     HI_U32      u32StatTime;              /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
133     HI_U32      u32SrcFrameRate;          /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
134     HI_FR32     fr32DstFrameRate;        /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
135                                                 can not be larger than u32SrcFrameRate */
136     HI_U32      u32TargetBitRate;         /* RW; Range:[2, 614400]; the target bitrate */
137 } VENC_H264_QVBR_S;
138 
139 /* the attribute of h265e qpmap */
140 typedef struct hiVENC_H265_QPMAP_S {
141     HI_U32      u32Gop;                   /* RW; Range:[1, 65536]; the interval of ISLICE. */
142     HI_U32      u32StatTime;              /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
143     HI_U32      u32SrcFrameRate;          /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
144     HI_FR32     fr32DstFrameRate;        /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
145                                                 can not be larger than u32SrcFrameRate */
146     VENC_RC_QPMAP_MODE_E enQpMapMode;     /* RW;  the QpMap Mode. */
147 } VENC_H265_QPMAP_S;
148 
149 typedef struct hiVENC_H264_CBR_S   VENC_H265_CBR_S;
150 typedef struct hiVENC_H264_VBR_S   VENC_H265_VBR_S;
151 typedef struct hiVENC_H264_AVBR_S  VENC_H265_AVBR_S;
152 typedef struct hiVENC_H264_FIXQP_S VENC_H265_FIXQP_S;
153 typedef struct hiVENC_H264_QVBR_S  VENC_H265_QVBR_S;
154 typedef struct hiVENC_H264_CVBR_S  VENC_H265_CVBR_S;
155 
156 /* the attribute of mjpege fixqp */
157 typedef struct hiVENC_MJPEG_FIXQP_S {
158     HI_U32      u32SrcFrameRate;          /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
159     HI_FR32     fr32DstFrameRate;         /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
160                                                 can not be larger than u32SrcFrameRate */
161     HI_U32      u32Qfactor;               /* RW; Range:[1, 99]; image quality. */
162 } VENC_MJPEG_FIXQP_S;
163 
164 /* the attribute of mjpege cbr */
165 typedef struct hiVENC_MJPEG_CBR_S {
166     HI_U32      u32StatTime;              /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
167     HI_U32      u32SrcFrameRate;          /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
168     HI_FR32     fr32DstFrameRate;        /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
169                                                 can not be larger than u32SrcFrameRate */
170     HI_U32      u32BitRate;               /* RW; Range:[2, 614400]; average bitrate */
171 } VENC_MJPEG_CBR_S;
172 
173 /* the attribute of mjpege vbr */
174 typedef struct hiVENC_MJPEG_VBR_S {
175     HI_U32      u32StatTime;              /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
176     HI_U32      u32SrcFrameRate;          /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
177     HI_FR32     fr32DstFrameRate;         /* RW; Range:[0.015625, 240]; the target frame rate of the venc chnnel,
178                                                 can not be larger than u32SrcFrameRate */
179     HI_U32      u32MaxBitRate;            /* RW; Range:[2, 614400]; the max bitrate */
180 } VENC_MJPEG_VBR_S;
181 
182 /* the attribute of rc */
183 typedef struct hiVENC_RC_ATTR_S {
184     VENC_RC_MODE_E enRcMode;              /* RW; the type of rc */
185     union {
186         VENC_H264_CBR_S    stH264Cbr;
187         VENC_H264_VBR_S    stH264Vbr;
188         VENC_H264_AVBR_S   stH264AVbr;
189         VENC_H264_QVBR_S   stH264QVbr;
190         VENC_H264_CVBR_S   stH264CVbr;
191         VENC_H264_FIXQP_S  stH264FixQp;
192         VENC_H264_QPMAP_S  stH264QpMap;
193 
194         VENC_MJPEG_CBR_S   stMjpegCbr;
195         VENC_MJPEG_VBR_S   stMjpegVbr;
196         VENC_MJPEG_FIXQP_S stMjpegFixQp;
197 
198         VENC_H265_CBR_S    stH265Cbr;
199         VENC_H265_VBR_S    stH265Vbr;
200         VENC_H265_AVBR_S   stH265AVbr;
201         VENC_H265_QVBR_S   stH265QVbr;
202         VENC_H265_CVBR_S   stH265CVbr;
203         VENC_H265_FIXQP_S  stH265FixQp;
204         VENC_H265_QPMAP_S  stH265QpMap;
205     };
206 } VENC_RC_ATTR_S;
207 
208 /* the super frame mode */
209 typedef enum hiRC_SUPERFRM_MODE_E {
210     SUPERFRM_NONE = 0,                    /* sdk don't care super frame */
211     SUPERFRM_DISCARD,                   /* the super frame is discarded */
212     SUPERFRM_REENCODE,                  /* the super frame is re-encode */
213     SUPERFRM_BUTT
214 } VENC_SUPERFRM_MODE_E;
215 
216 /* The param of H264e cbr */
217 typedef struct hiVENC_PARAM_H264_CBR_S {
218     HI_U32  u32MinIprop;                /* RW; Range:[1, 100]; the min ratio of i frame and p frame */
219     HI_U32  u32MaxIprop;                /* RW; Range:[1, 100]; the max ratio of i frame and p frame,
220                                             can not be smaller than u32MinIprop */
221     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max QP value */
222     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min QP value, can not be larger than u32MaxQp */
223     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; max qp for i frame */
224     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; min qp for i frame, can not be larger than u32MaxIQp */
225     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; Range:max number of re-encode times */
226     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
227 } VENC_PARAM_H264_CBR_S;
228 
229 /* The param of H264e vbr */
230 typedef struct hiVENC_PARAM_H264_VBR_S {
231     HI_S32  s32ChangePos;               /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to
232                                             the maximum bit rate when the QP value starts to be adjusted */
233     HI_U32  u32MinIprop;                /* RW; Range:[1, 100] ; the min ratio of i frame and p frame */
234     HI_U32  u32MaxIprop;                /* RW; Range:[1, 100] ; the max ratio of i frame and p frame,
235                                             can not be smaller than u32MinIprop */
236     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; max number of re-encode times */
237     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
238 
239     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
240     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
241     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
242     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp , can not be larger than u32MaxIQp */
243 } VENC_PARAM_H264_VBR_S;
244 
245 /* The param of H264e avbr */
246 typedef struct hiVENC_PARAM_H264_AVBR_S {
247     HI_S32  s32ChangePos;               /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to
248                                             the maximum bit rate when the QP value starts to be adjusted */
249     HI_U32  u32MinIprop;                /* RW; Range:[1, 100] ; the min ratio of i frame and p frame,
250                                             can not be smaller than u32MinIprop */
251     HI_U32  u32MaxIprop;                /* RW; Range:[1, 100] ; the max ratio of i frame and p frame */
252     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; max number of re-encode times */
253     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
254 
255     HI_S32  s32MinStillPercent;         /* RW; Range:[5, 100]; the min percent of target bitrate for still scene */
256     HI_U32  u32MaxStillQP;              /* RW; Range:[0, 51]; the max QP value of I frame for still scene, can not be
257                                             smaller than u32MinIQp and can not be larger than su32MaxIQp */
258     HI_U32  u32MinStillPSNR;            /* RW; reserved, Invalid member currently */
259 
260     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
261     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
262     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
263     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
264     HI_U32  u32MinQpDelta;              /* RW; Range:[0, 4];Difference between FrameLevelMinQp and MinQp,
265                                             FrameLevelMinQp = MinQp(or MinIQp) + MinQpDelta  */
266     HI_U32  u32MotionSensitivity;       /* RW; Range:[0, 100]; Motion Sensitivity */
267 } VENC_PARAM_H264_AVBR_S;
268 
269 typedef struct hiVENC_PARAM_H264_QVBR_S {
270     HI_U32  u32MinIprop;               /* RW; Range:[1, 100]; the min ratio of i frame and p frame */
271     HI_U32  u32MaxIprop;               /* RW; Range:[1, 100] ;the max ratio of i frame and p frame,
272                                             can not be smaller than u32MinIprop */
273     HI_S32  s32MaxReEncodeTimes;       /* RW; Range:[0, 3];max number of re-encode times [0, 3] */
274     HI_BOOL bQpMapEn;                  /* RW; Range:[0, 1]; enable qpmap */
275 
276     HI_U32  u32MaxQp;                  /* RW; Range:[0, 51]; the max P B qp */
277     HI_U32  u32MinQp;                  /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
278     HI_U32  u32MaxIQp;                 /* RW; Range:[0, 51]; the max I qp */
279     HI_U32  u32MinIQp;                 /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
280 
281     HI_S32  s32BitPercentUL;           /* RW; Range:[30, 180]; Indicate the ratio of bitrate  upper limit */
282     HI_S32  s32BitPercentLL;           /* RW; Range:[30, 180]; Indicate the ratio of bitrate  lower limit,
283                                             can not be larger than s32BitPercentUL */
284     HI_S32  s32PsnrFluctuateUL;        /* RW; Range:[18, 40]; Reduce the target bitrate
285                                             when the value of psnr approch the upper limit */
286     HI_S32  s32PsnrFluctuateLL;        /* RW; Range:[18, 40]; Increase the target bitrate when the value of psnr
287                                             approch the lower limit, can not be larger than s32PsnrFluctuateUL */
288 } VENC_PARAM_H264_QVBR_S;
289 
290 /* The param of H264e cvbr */
291 typedef struct hiVENC_PARAM_H264_CVBR_S {
292     HI_U32  u32MinIprop;                /* RW; Range:[1, 100] ; the min ratio of i frame and p frame */
293     HI_U32  u32MaxIprop;                /* RW; Range:[1, 100] ; the max ratio of i frame and p frame,
294                                             can not be smaller than u32MinIprop */
295     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; max number of re-encode times */
296     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
297 
298     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
299     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
300     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
301     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
302 
303     HI_U32  u32MinQpDelta;              /* RW; Range:[0, 4]; Difference between FrameLevelMinQp and MinQp,
304                                             FrameLevelMinQp = MinQp(or MinIQp) + MinQpDelta */
305     HI_U32  u32MaxQpDelta;              /* RW; Range:[0, 4]; Difference between FrameLevelMaxQp and MaxQp,
306                                             FrameLevelMaxQp = MaxQp(or MaxIQp) - MaxQpDelta */
307 
308     HI_U32  u32ExtraBitPercent;         /* RW; Range:[0, 1000]; the extra bits that can be allocated
309                                             when the actual bitrate goes above the target bitrate */
310     HI_U32  u32LongTermStatTimeUnit;    /* RW; Range:[1, 1800]; the time unit of LongTermStatTime,
311                                             the unit is senconds(s) */
312 } VENC_PARAM_H264_CVBR_S;
313 
314 /* The param of mjpege cbr */
315 typedef struct hiVENC_PARAM_MJPEG_CBR_S {
316     HI_U32  u32MaxQfactor;               /* RW; Range:[1, 99]; the max Qfactor value */
317     HI_U32  u32MinQfactor;               /* RW; Range:[1, 99]; the min Qfactor value,
318                                             can not be larger than u32MaxQfactor */
319 } VENC_PARAM_MJPEG_CBR_S;
320 
321 /* The param of mjpege vbr */
322 typedef struct hiVENC_PARAM_MJPEG_VBR_S {
323     HI_S32 s32ChangePos;                 /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to
324                                             the maximum bit rate when the Qfactor value starts to be adjusted */
325     HI_U32 u32MaxQfactor;                /* RW; Range:[1, 99]; max image quailty allowed */
326     HI_U32 u32MinQfactor;                /* RW; Range:[1, 99]; min image quality allowed,
327                                             can not be larger than u32MaxQfactor */
328 } VENC_PARAM_MJPEG_VBR_S;
329 
330 /* The param of h265e cbr */
331 typedef struct hiVENC_PARAM_H265_CBR_S {
332     HI_U32  u32MinIprop;                 /* RW; Range:[1, 100]; the min ratio of i frame and p frame */
333     HI_U32  u32MaxIprop;                 /* RW; Range:[1, 100]; the max ratio of i frame and p frame,
334                                             can not be smaller than u32MinIprop */
335     HI_U32  u32MaxQp;                    /* RW; Range:[0, 51]; the max QP value */
336     HI_U32  u32MinQp;                    /* RW; Range:[0, 51]; the min QP value, can not be larger than u32MaxQp */
337     HI_U32  u32MaxIQp;                   /* RW; Range:[0, 51]; max qp for i frame */
338     HI_U32  u32MinIQp;                   /* RW; Range:[0, 51]; min qp for i frame, can not be larger than u32MaxIQp */
339     HI_S32  s32MaxReEncodeTimes;         /* RW; Range:[0, 3]; Range:max number of re-encode times */
340     HI_BOOL bQpMapEn;                    /* RW; Range:[0, 1]; enable qpmap */
341     VENC_RC_QPMAP_MODE_E enQpMapMode;    /* RW; Qpmap Mode */
342 } VENC_PARAM_H265_CBR_S;
343 
344 /* The param of h265e vbr */
345 typedef struct hiVENC_PARAM_H265_VBR_S {
346     HI_S32  s32ChangePos;               /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate
347                                             to the maximum bit rate when the QP value starts to be adjusted */
348     HI_U32  u32MinIprop;                /* RW; [1, 100]the min ratio of i frame and p frame */
349     HI_U32  u32MaxIprop;                /* RW; [1, 100]the max ratio of i frame and p frame,
350                                             can not be smaller than u32MinIprop */
351     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; Range:max number of re-encode times */
352 
353     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
354     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
355     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
356     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
357 
358     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
359     VENC_RC_QPMAP_MODE_E enQpMapMode;   /* RW; Qpmap Mode */
360 } VENC_PARAM_H265_VBR_S;
361 
362 /* The param of h265e vbr */
363 typedef struct hiVENC_PARAM_H265_AVBR_S {
364     HI_S32  s32ChangePos;               /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to
365                                             the maximum bit rate when the QP value starts to be adjusted */
366     HI_U32  u32MinIprop;                /* RW; [1, 100]the min ratio of i frame and p frame */
367     HI_U32  u32MaxIprop;                /* RW; [1, 100]the max ratio of i frame and p frame,
368                                             can not be smaller than u32MinIprop */
369     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; Range:max number of re-encode times */
370 
371     HI_S32  s32MinStillPercent;         /* RW; Range:[5, 100]; the min percent of target bitrate for still scene */
372     HI_U32  u32MaxStillQP;              /* RW; Range:[0, 51]; the max QP value of I frame for still scene, can not be
373                                             smaller than u32MinIQp and can not be larger than su32MaxIQp */
374     HI_U32  u32MinStillPSNR;            /* RW; reserved */
375 
376     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
377     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
378     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
379     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
380 
381     HI_U32  u32MinQpDelta;              /* RW; Range:[0, 4]; Difference between FrameLevelMinQp and MinQp,
382                                             FrameLevelMinQp = MinQp(or MinIQp) + MinQpDelta  */
383     HI_U32  u32MotionSensitivity;       /* RW; Range:[0, 100]; Motion Sensitivity */
384 
385     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
386     VENC_RC_QPMAP_MODE_E enQpMapMode;   /* RW; Qpmap Mode */
387 } VENC_PARAM_H265_AVBR_S;
388 
389 typedef struct hiVENC_PARAM_H265_QVBR_S {
390     HI_U32  u32MinIprop;                /* RW; [1, 100]; the min ratio of i frame and p frame */
391     HI_U32  u32MaxIprop;                /* RW; [1, 100]; the max ratio of i frame and p frame,
392                                             can not be smaller than u32MinIprop */
393     HI_S32  s32MaxReEncodeTimes;        /* RW; [0, 3]; max number of re-encode times [0, 3] */
394 
395     HI_BOOL bQpMapEn;                   /* RW; Range:[0, 1]; enable qpmap */
396     VENC_RC_QPMAP_MODE_E enQpMapMode;   /* RW; Qpmap Mode */
397 
398     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
399     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
400     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
401     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
402 
403     HI_S32  s32BitPercentUL;            /* RW; Range:[30, 180]; Indicate the ratio of bitrate  upper limit */
404     HI_S32  s32BitPercentLL;            /* RW; Range:[30, 180]; Indicate the ratio of bitrate  lower limit,
405                                             can not be larger than s32BitPercentUL */
406     HI_S32  s32PsnrFluctuateUL;         /* RW; Range:[18, 40];  Reduce the target bitrate
407                                             when the value of psnr approch the upper limit */
408     HI_S32  s32PsnrFluctuateLL;         /* RW; Range:[18, 40];  Increase the target bitrate when the value of psnr
409                                             approch the lower limit, can not be larger than s32PsnrFluctuateUL */
410 } VENC_PARAM_H265_QVBR_S;
411 
412 typedef struct hiVENC_PARAM_H265_CVBR_S {
413     HI_U32  u32MinIprop;                /* RW; Range:[1, 100]; the min ratio of i frame and p frame */
414     HI_U32  u32MaxIprop;                /* RW; Range:[1, 100]; the max ratio of i frame and p frame,
415     can not be smaller than u32MinIprop */
416     HI_S32  s32MaxReEncodeTimes;        /* RW; Range:[0, 3]; max number of re-encode times */
417     HI_BOOL bQpMapEn;
418     VENC_RC_QPMAP_MODE_E enQpMapMode;   /* RW; Qpmap Mode */
419 
420     HI_U32  u32MaxQp;                   /* RW; Range:[0, 51]; the max P B qp */
421     HI_U32  u32MinQp;                   /* RW; Range:[0, 51]; the min P B qp, can not be larger than u32MaxQp */
422     HI_U32  u32MaxIQp;                  /* RW; Range:[0, 51]; the max I qp */
423     HI_U32  u32MinIQp;                  /* RW; Range:[0, 51]; the min I qp, can not be larger than u32MaxIQp */
424 
425     HI_U32  u32MinQpDelta;              /* RW; Range:[0, 4]; Difference between FrameLevelMinQp and MinQp,
426                                             FrameLevelMinQp = MinQp(or MinIQp) + MinQpDelta  */
427     HI_U32  u32MaxQpDelta;              /* RW; Range:[0, 4]; Difference between FrameLevelMaxQp and MaxQp,
428                                             FrameLevelMaxQp = MaxQp(or MaxIQp) - MaxQpDelta  */
429 
430     HI_U32  u32ExtraBitPercent;         /* RW; Range:[0, 1000]; the extra ratio of bitrate that can be allocated
431                                             when the actual bitrate goes above the long-term target bitrate */
432     HI_U32  u32LongTermStatTimeUnit;    /* RW; Range:[1, 1800]; the time unit of LongTermStatTime,
433                                             the unit is senconds(s) */
434 } VENC_PARAM_H265_CVBR_S;
435 
436 typedef struct hiVENC_SCENE_CHANGE_DETECT_S {
437     HI_BOOL bDetectSceneChange;         /* RW; Range:[0, 1]; enable detect scene change. */
438     HI_BOOL bAdaptiveInsertIDRFrame;    /* RW; Range:[0, 1]; enable a daptive insertIDR frame. */
439 } VENC_SCENE_CHANGE_DETECT_S;
440 
441 /* The param of rc */
442 typedef struct hiVENC_RC_PARAM_S {
443     HI_U32 u32ThrdI[RC_TEXTURE_THR_SIZE];   /* RW; Range:[0, 255]; Mad threshold for controlling
444                                                 the macroblock-level bit rate of I frames */
445     HI_U32 u32ThrdP[RC_TEXTURE_THR_SIZE];   /* RW; Range:[0, 255]; Mad threshold for controlling
446                                                 the macroblock-level bit rate of P frames */
447     HI_U32 u32ThrdB[RC_TEXTURE_THR_SIZE];   /* RW; Range:[0, 255]; Mad threshold for controlling
448                                                 the macroblock-level bit rate of B frames */
449     HI_U32 u32DirectionThrd;                /* RW; Range:[0, 16]; The direction for controlling
450                                                 the macroblock-level bit rate */
451     HI_U32 u32RowQpDelta;                   /* RW; Range:[0, 10]; the start QP value of each macroblock row
452                                                 relative to the start QP value */
453     HI_S32 s32FirstFrameStartQp;            /* RW; Range:[-1, 51]; Start QP value of the first frame */
454     VENC_SCENE_CHANGE_DETECT_S stSceneChangeDetect; /* RW; */
455     union {
456         VENC_PARAM_H264_CBR_S     stParamH264Cbr;
457         VENC_PARAM_H264_VBR_S     stParamH264Vbr;
458         VENC_PARAM_H264_AVBR_S    stParamH264AVbr;
459         VENC_PARAM_H264_QVBR_S    stParamH264QVbr;
460         VENC_PARAM_H264_CVBR_S    stParamH264CVbr;
461         VENC_PARAM_H265_CBR_S     stParamH265Cbr;
462         VENC_PARAM_H265_VBR_S     stParamH265Vbr;
463         VENC_PARAM_H265_AVBR_S    stParamH265AVbr;
464         VENC_PARAM_H265_QVBR_S    stParamH265QVbr;
465         VENC_PARAM_H265_CVBR_S    stParamH265CVbr;
466         VENC_PARAM_MJPEG_CBR_S    stParamMjpegCbr;
467         VENC_PARAM_MJPEG_VBR_S    stParamMjpegVbr;
468     };
469 } VENC_RC_PARAM_S;
470 
471 /* the frame lost mode */
472 typedef enum hiVENC_FRAMELOST_MODE_E {
473     FRMLOST_NORMAL = 0,                               /* normal mode */
474     FRMLOST_PSKIP,                                  /* pskip */
475     FRMLOST_BUTT,
476 } VENC_FRAMELOST_MODE_E;
477 
478 /* The param of the frame lost mode */
479 typedef struct hiVENC_FRAMELOST_S {
480     HI_BOOL                bFrmLostOpen;          /* RW; Range:[0, 1];Indicates whether to discard frames to
481                                                     ensure stable bit rate when the instant bit rate is exceeded */
482     HI_U32                 u32FrmLostBpsThr;      /* RW; the instant bit rate threshold */
483     VENC_FRAMELOST_MODE_E  enFrmLostMode;         /* RW; frame lost strategy */
484     HI_U32                 u32EncFrmGaps;         /* RW; Range:[0, 65535]; the gap of frame lost */
485 } VENC_FRAMELOST_S;
486 
487 /* the rc priority */
488 typedef enum hiVENC_RC_PRIORITY_E {
489     VENC_RC_PRIORITY_BITRATE_FIRST = 1,           /* bitrate first */
490     VENC_RC_PRIORITY_FRAMEBITS_FIRST,             /* framebits first */
491     VENC_RC_PRIORITY_BUTT,
492 } VENC_RC_PRIORITY_E;
493 
494 /* the config of the superframe */
495 typedef struct hiVENC_SUPERFRAME_CFG_S {
496     VENC_SUPERFRM_MODE_E  enSuperFrmMode;          /* RW; Indicates the mode of processing the super frame */
497     HI_U32                u32SuperIFrmBitsThr;     /* RW; Range:[0, 4294967295];Indicate the threshold of the super
498                                                         I frame for enabling the super frame processing mode */
499     HI_U32                u32SuperPFrmBitsThr;     /* RW; Range:[0, 4294967295];Indicate the threshold of the super
500                                                         P frame for enabling the super frame processing mode */
501     HI_U32                u32SuperBFrmBitsThr;     /* RW; Range:[0, 4294967295];Indicate the threshold of the super
502                                                         B frame for enabling the super frame processing mode */
503     VENC_RC_PRIORITY_E    enRcPriority;            /* RW; Rc Priority */
504 } VENC_SUPERFRAME_CFG_S;
505 
506 #ifdef __cplusplus
507 }
508 #endif /* __cplusplus */
509 
510 #endif /* __HI_COMM_RC_H__ */
511