xref: /OK3568_Linux_fs/external/rockit/mpi/sdk/include/rk_comm_rc.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_RC_H_
5 #define INCLUDE_RT_MPI_RK_COMM_RC_H_
6 
7 #include "rk_type.h"
8 #include "rk_errno.h"
9 
10 #ifdef __cplusplus
11 #if __cplusplus
12 extern "C" {
13 #endif
14 #endif /* __cplusplus */
15 
16 /* rc quality */
17 typedef enum rkVENC_RC_QUALITY_E {
18     VENC_RC_QUALITY_HIGHEST,
19     VENC_RC_QUALITY_HIGHER,
20     VENC_RC_QUALITY_HIGH,
21     VENC_RC_QUALITY_MEDIUM,
22     VENC_RC_QUALITY_LOW,
23     VENC_RC_QUALITY_LOWER,
24     VENC_RC_QUALITY_LOWEST,
25     VENC_RC_QUALITY_BUTT,
26 } VENC_RC_QUALITY_E;
27 /* rc mode */
28 typedef enum rkVENC_RC_MODE_E {
29     // H264
30     VENC_RC_MODE_H264CBR = 1,
31     VENC_RC_MODE_H264VBR,
32     VENC_RC_MODE_H264AVBR,
33     VENC_RC_MODE_H264FIXQP,
34     // MJPEG
35     VENC_RC_MODE_MJPEGCBR,
36     VENC_RC_MODE_MJPEGVBR,
37     VENC_RC_MODE_MJPEGFIXQP,
38     // H265
39     VENC_RC_MODE_H265CBR,
40     VENC_RC_MODE_H265VBR,
41     VENC_RC_MODE_H265AVBR,
42     VENC_RC_MODE_H265FIXQP,
43     VENC_RC_MODE_BUTT,
44 } VENC_RC_MODE_E;
45 
46 typedef enum rkVENC_NALU_TYPE_E {
47     VENC_NALU_BSLICE = 1,
48     VENC_NALU_PSLICE,
49     VENC_NALU_ISLICE,
50     VENC_NALU_IDRSLICE,
51     VENC_NALU_SEI,
52     VENC_NALU_VPS,
53     VENC_NALU_SPS,
54     VENC_NALU_PPS,
55     VENC_NALU_BUTT
56 } VENC_NALU_TYPE_E;
57 
58 /* the attribute of h264e cbr*/
59 typedef struct rkVENC_H264_CBR_S {
60     RK_U32 u32Gop;  // RW; Range:[1, 65536]; the interval of I Frame.
61     RK_U32 u32SrcFrameRateNum;
62     RK_U32 u32SrcFrameRateDen;
63     RK_U32 fr32DstFrameRateNum;
64     RK_U32 fr32DstFrameRateDen;
65     RK_U32 u32BitRate;     // RW; Range:[2, 200000]kbps; average bitrate; default : u32VirWidth*u32VirHeight/8*30;
66     RK_U32 u32StatTime;    // RW; Range:[1,60]second;default : 3
67 } VENC_H264_CBR_S;
68 
69 /* the attribute of h264e vbr*/
70 typedef struct rkVENC_H264_VBR_S {
71     RK_U32 u32Gop;  // RW; Range:[1, 65536]; the interval of ISLICE.
72     RK_U32 u32SrcFrameRateNum;
73     RK_U32 u32SrcFrameRateDen;
74     RK_U32 fr32DstFrameRateNum;
75     RK_U32 fr32DstFrameRateDen;
76     RK_U32 u32BitRate;     // RW; Range:[2, 200000]kbps; average bitrate; default : u32VirWidth*u32VirHeight/8*30;
77     RK_U32 u32MaxBitRate;  // RW; Range:[u32BitRate, 200000]kbps; max bitrate; default : u32BitRate*3/2;
78     RK_U32 u32MinBitRate;  // RW; Range:[2, u32BitRate]kbps; min bitrate;; default : u32BitRate/2;
79     RK_U32 u32StatTime;    // RW; Range:[1,60]second;default : 3
80 } VENC_H264_VBR_S;
81 
82 /* the attribute of h264e vbr*/
83 typedef struct rkVENC_H264_AVBR_S {
84     RK_U32 u32Gop;  // RW; Range:[1, 65536]; the interval of ISLICE.
85     RK_U32 u32SrcFrameRateNum;
86     RK_U32 u32SrcFrameRateDen;
87     RK_U32 fr32DstFrameRateNum;
88     RK_U32 fr32DstFrameRateDen;
89     RK_U32 u32BitRate;     // RW; Range:[2, 200000]kbps; average bitrate; default : u32VirWidth*u32VirHeight/8*30;
90     RK_U32 u32MaxBitRate;  // RW; Range:[u32BitRate, 200000]kbps; max bitrate; default : u32BitRate*3/2;
91     RK_U32 u32MinBitRate;  // RW; Range:[2, u32BitRate]kbps; min bitrate;; default : u32BitRate/2;
92     RK_U32 u32StatTime;    // RW; Range:[1,60]second;default : 3
93 } VENC_H264_AVBR_S;
94 
95 /* the attribute of h264e fixqp*/
96 typedef struct rkVENC_H264_FIXQP_S {
97     RK_U32 u32Gop;  // RW; Range:[1, 65536]; the interval of ISLICE.
98     RK_U32 u32SrcFrameRateNum;
99     RK_U32 u32SrcFrameRateDen;
100     RK_U32 fr32DstFrameRateNum;
101     RK_U32 fr32DstFrameRateDen;
102     RK_U32 u32IQp;  // RW; Range:[1, 51];
103     RK_U32 u32PQp;  // RW; Range:[1, 51];
104     RK_U32 u32BQp;  // reserved.
105 } VENC_H264_FIXQP_S;
106 
107 /* the attribute of mjpege cbr*/
108 typedef struct rkVENC_MJPEG_CBR_S {
109     RK_U32 u32SrcFrameRateNum;
110     RK_U32 u32SrcFrameRateDen;
111     RK_U32 fr32DstFrameRateNum;
112     RK_U32 fr32DstFrameRateDen;
113     RK_U32 u32BitRate;     // RW; Range:[5, 800000]kbps; average bitrate; default : u32VirWidth*u32VirHeight/8*30;
114     RK_U32 u32StatTime;    // RW; Range:[1,60]second;default : 3
115 } VENC_MJPEG_CBR_S;
116 
117 /* the attribute of mjpege vbr*/
118 typedef struct rkVENC_MJPEG_VBR_S {
119     RK_U32 u32SrcFrameRateNum;
120     RK_U32 u32SrcFrameRateDen;
121     RK_U32 fr32DstFrameRateNum;
122     RK_U32 fr32DstFrameRateDen;
123     RK_U32 u32BitRate;      // RW; Range:[5, 800000]kbps; average bitrate; default : u32VirWidth*u32VirHeight/8*30;
124     RK_U32 u32MaxBitRate;   // RW; Range:[u32BitRate, 800000]kbps; max bitrate; default : u32BitRate*3/2;
125     RK_U32 u32MinBitRate;   // RW; Range:[5, u32BitRate]kbps; min bitrate;; default : u32BitRate/2;
126     RK_U32 u32StatTime;     // RW; Range:[1,60]second;default : 3
127 } VENC_MJPEG_VBR_S;
128 
129 /* the attribute of mjpege fixqp*/
130 typedef struct rkVENC_MJPEG_FIXQP_S {
131     RK_U32 u32SrcFrameRateNum;
132     RK_U32 u32SrcFrameRateDen;
133     RK_U32 fr32DstFrameRateNum;
134     RK_U32 fr32DstFrameRateDen;
135     RK_U32 u32Qfactor;  // RW; Range:[1, 99];
136 } VENC_MJPEG_FIXQP_S;
137 
138 typedef struct rkVENC_H264_CBR_S VENC_H265_CBR_S;
139 typedef struct rkVENC_H264_VBR_S VENC_H265_VBR_S;
140 typedef struct rkVENC_H264_AVBR_S VENC_H265_AVBR_S;
141 typedef struct rkVENC_H264_FIXQP_S VENC_H265_FIXQP_S;
142 
143 /* the attribute of rc*/
144 typedef struct rkVENC_RC_ATTR_S {
145     /* RW; the type of rc*/
146     VENC_RC_MODE_E enRcMode;
147     union {
148         VENC_H264_CBR_S stH264Cbr;
149         VENC_H264_VBR_S stH264Vbr;
150         VENC_H264_AVBR_S stH264Avbr;
151         VENC_H264_FIXQP_S stH264FixQp;
152 
153         VENC_MJPEG_CBR_S stMjpegCbr;
154         VENC_MJPEG_VBR_S stMjpegVbr;
155         VENC_MJPEG_FIXQP_S stMjpegFixQp;
156 
157         VENC_H265_CBR_S stH265Cbr;
158         VENC_H265_VBR_S stH265Vbr;
159         VENC_H265_AVBR_S stH265Avbr;
160         VENC_H265_FIXQP_S stH265FixQp;
161     };
162 } VENC_RC_ATTR_S;
163 
164 /* The param of H264e */
165 typedef struct rkVENC_PARAM_H264_S {
166     RK_U32 u32StepQp;
167     RK_U32 u32MaxQp;   // RW; Range:[8, 51];the max QP value
168     RK_U32 u32MinQp;   // RW; Range:[0, 48]; the min QP value,can not be larger than
169                        // u32MaxQp
170     RK_U32 u32MaxIQp;  // RW; max qp for i frame
171     RK_U32 u32MinIQp;  // RW; min qp for i frame,can not be larger than u32MaxIQp
172     RK_S32 s32DeltIpQp;  // RW; Range:[-7, 7]; pppp..i delta qp between the mean of p and I
173     RK_S32 s32MaxReEncodeTimes;  // RW; Range:[0, 3]; Range:max number of re-encode times.
174     RK_U32 u32FrmMaxQp; // RW; Range:[0, 51];the frame max QP value
175     RK_U32 u32FrmMinQp; // RW; Range:[0, 51];the frame min QP value, recommended larger than u32MinQp
176     RK_U32 u32FrmMaxIQp; // RW; Range:[0, 51];the I frame max QP value
177     RK_U32 u32FrmMinIQp; // RW; Range:[0, 51];the I frame min QP value, recommended larger than u32MinIQp
178 } VENC_PARAM_H264_S;
179 
180 /* The param of h265e */
181 typedef struct rkVENC_PARAM_H265_S {
182     RK_U32 u32StepQp;
183     RK_U32 u32MaxQp;   // RW; Range:[8, 51];the max QP value
184     RK_U32 u32MinQp;   // RW; Range:[0, 48];the min QP value ,can not be larger than
185                        // u32MaxQp
186     RK_U32 u32MaxIQp;  // RW; max qp for i frame
187     RK_U32 u32MinIQp;  // RW; min qp for i frame,can not be larger than u32MaxIQp
188     RK_S32 s32DeltIpQp;  // RW; Range:[-7, 7]; pppp..i delta qp between the mean of p and I
189     RK_S32 s32MaxReEncodeTimes;  // RW; Range:[0, 3]; Range:max number of re-encode times.
190     RK_U32 u32FrmMaxQp; // RW; Range:[0, 51];the frame max QP value
191     RK_U32 u32FrmMinQp; // RW; Range:[0, 51];the frame min QP value, recommended larger than u32MinQp
192     RK_U32 u32FrmMaxIQp; // RW; Range:[0, 51];the I frame max QP value
193     RK_U32 u32FrmMinIQp; // RW; Range:[0, 51];the I frame min QP value, recommended larger than u32MinIQp
194 } VENC_PARAM_H265_S;
195 
196 /* The param of mjpege */
197 typedef struct rkVENC_PARAM_MJPEG_S {
198     RK_U32 u32Qfactor;     // RW; Range:[1, 99]; default : 70
199     RK_U32 u32MaxQfactor;  // RW; Range:[u32Qfactor, 99]; default : 99
200     RK_U32 u32MinQfactor;  // RW; Range:[1, u32Qfactor]; default : 30
201 } VENC_PARAM_MJPEG_S;
202 
203 /* The param of rc */
204 typedef struct rkVENC_RC_PARAM_S {
205     RK_U32 s32FirstFrameStartQp;  // RW; Start QP value of the first frame
206     union {
207         VENC_PARAM_H264_S stParamH264;
208         VENC_PARAM_H265_S stParamH265;
209         VENC_PARAM_MJPEG_S stParamMjpeg;
210     };
211 } VENC_RC_PARAM_S;
212 
213 #ifdef __cplusplus
214 #if __cplusplus
215 }
216 #endif
217 #endif /* __cplusplus */
218 
219 #endif /* INCLUDE_RT_MPI_RK_COMM_RC_H_ */
220