hi_comm_rc.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. /******************************************************************************
  2. Copyright (C), 2016-2017, Hisilicon Tech. Co., Ltd.
  3. ******************************************************************************
  4. File Name : hi_comm_rc.h
  5. Version : Initial Draft
  6. Author : Hisilicon multimedia software group
  7. Created : 2016/11/15
  8. Last Modified :
  9. Description : common struct definition for Rate control
  10. Function List :
  11. ******************************************************************************/
  12. #ifndef __HI_COMM_RC_H__
  13. #define __HI_COMM_RC_H__
  14. #include "hi_defines.h"
  15. #ifdef __cplusplus
  16. #if __cplusplus
  17. extern "C"{
  18. #endif
  19. #endif /* __cplusplus */
  20. typedef HI_U32 HI_FR32;
  21. /* rc mode */
  22. typedef enum hiVENC_RC_MODE_E
  23. {
  24. VENC_RC_MODE_H264CBR = 1,
  25. VENC_RC_MODE_H264VBR,
  26. VENC_RC_MODE_H264AVBR,
  27. VENC_RC_MODE_H264FIXQP,
  28. VENC_RC_MODE_H264QPMAP,
  29. VENC_RC_MODE_MJPEGCBR,
  30. VENC_RC_MODE_MJPEGVBR,
  31. VENC_RC_MODE_MJPEGFIXQP,
  32. VENC_RC_MODE_H265CBR,
  33. VENC_RC_MODE_H265VBR,
  34. VENC_RC_MODE_H265AVBR,
  35. VENC_RC_MODE_H265FIXQP,
  36. VENC_RC_MODE_H265QPMAP,
  37. VENC_RC_MODE_BUTT,
  38. }VENC_RC_MODE_E;
  39. /* qpmap mode*/
  40. typedef enum hiVENC_RC_QPMAP_MODE_E
  41. {
  42. VENC_RC_QPMAP_MODE_MEANQP= 0,
  43. VENC_RC_QPMAP_MODE_MINQP ,
  44. VENC_RC_QPMAP_MODE_MAXQP,
  45. VENC_RC_QPMAP_MODE_BUTT,
  46. }VENC_RC_QPMAP_MODE_E;
  47. /* the attribute of h264e fixqp*/
  48. typedef struct hiVENC_H264_FIXQP_S
  49. {
  50. HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
  51. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  52. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  53. HI_U32 u32IQp; /* RW; Range:[0, 51]; qp of the i frame */
  54. HI_U32 u32PQp; /* RW; Range:[0, 51]; qp of the p frame */
  55. HI_U32 u32BQp; /* RW; Range:[0, 51]; qp of the b frame */
  56. } VENC_H264_FIXQP_S;
  57. /* the attribute of h264e cbr*/
  58. typedef struct hiVENC_H264_CBR_S
  59. {
  60. HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of I Frame. */
  61. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  62. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  63. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  64. HI_U32 u32BitRate; /* RW; Range:[2, 409600]; average bitrate */
  65. } VENC_H264_CBR_S;
  66. /* the attribute of h264e vbr*/
  67. typedef struct hiVENC_H264_VBR_S
  68. {
  69. HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
  70. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  71. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  72. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  73. HI_U32 u32MaxBitRate; /* RW; Range:[2, 409600];the max bitrate */
  74. }VENC_H264_VBR_S;
  75. /* the attribute of h264e avbr*/
  76. typedef struct hiVENC_H264_AVBR_S
  77. {
  78. HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
  79. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  80. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  81. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  82. HI_U32 u32MaxBitRate; /* RW; Range:[2, 409600];the max bitrate */
  83. }VENC_H264_AVBR_S;
  84. /* the attribute of h264e qpmap*/
  85. typedef struct hiVENC_H264_QPMAP_S
  86. {
  87. HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
  88. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  89. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  90. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  91. }VENC_H264_QPMAP_S;
  92. /* the attribute of h265e qpmap*/
  93. typedef struct hiVENC_H265_QPMAP_S
  94. {
  95. HI_U32 u32Gop; /* RW; Range:[1, 65536]; the interval of ISLICE. */
  96. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  97. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  98. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  99. VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; the QpMap Mode.*/
  100. }VENC_H265_QPMAP_S;
  101. typedef struct hiVENC_H264_CBR_S VENC_H265_CBR_S;
  102. typedef struct hiVENC_H264_VBR_S VENC_H265_VBR_S;
  103. typedef struct hiVENC_H264_AVBR_S VENC_H265_AVBR_S;
  104. typedef struct hiVENC_H264_FIXQP_S VENC_H265_FIXQP_S;
  105. /* the attribute of mjpege fixqp*/
  106. typedef struct hiVENC_MJPEG_FIXQP_S
  107. {
  108. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  109. HI_FR32 fr32DstFrameRate; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  110. HI_U32 u32Qfactor; /* RW; Range:[1,99];image quality. */
  111. }VENC_MJPEG_FIXQP_S;
  112. /* the attribute of mjpege cbr*/
  113. typedef struct hiVENC_MJPEG_CBR_S
  114. {
  115. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  116. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  117. HI_FR32 fr32DstFrameRate ; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  118. HI_U32 u32BitRate; /* RW; Range:[2, 409600]; average bitrate */
  119. } VENC_MJPEG_CBR_S;
  120. /* the attribute of mjpege vbr*/
  121. typedef struct hiVENC_MJPEG_VBR_S
  122. {
  123. HI_U32 u32StatTime; /* RW; Range:[1, 60]; the rate statistic time, the unit is senconds(s) */
  124. HI_U32 u32SrcFrameRate; /* RW; Range:[1, 240]; the input frame rate of the venc chnnel */
  125. HI_FR32 fr32DstFrameRate; /* RW; Range:[0.015625, u32SrcFrmRate]; the target frame rate of the venc chnnel */
  126. HI_U32 u32MaxBitRate; /* RW; Range:[2, 409600];the max bitrate */
  127. }VENC_MJPEG_VBR_S;
  128. /* the attribute of rc*/
  129. typedef struct hiVENC_RC_ATTR_S
  130. {
  131. VENC_RC_MODE_E enRcMode; /* RW; the type of rc*/
  132. union
  133. {
  134. VENC_H264_CBR_S stH264Cbr;
  135. VENC_H264_VBR_S stH264Vbr;
  136. VENC_H264_AVBR_S stH264AVbr;
  137. VENC_H264_FIXQP_S stH264FixQp;
  138. VENC_H264_QPMAP_S stH264QpMap;
  139. VENC_MJPEG_CBR_S stMjpegCbr;
  140. VENC_MJPEG_VBR_S stMjpegVbr;
  141. VENC_MJPEG_FIXQP_S stMjpegFixQp;
  142. VENC_H265_CBR_S stH265Cbr;
  143. VENC_H265_VBR_S stH265Vbr;
  144. VENC_H265_AVBR_S stH265AVbr;
  145. VENC_H265_FIXQP_S stH265FixQp;
  146. VENC_H265_QPMAP_S stH265QpMap;
  147. };
  148. }VENC_RC_ATTR_S;
  149. /*the super frame mode*/
  150. typedef enum hiRC_SUPERFRM_MODE_E
  151. {
  152. SUPERFRM_NONE=0, /* sdk don't care super frame */
  153. SUPERFRM_DISCARD, /* the super frame is discarded */
  154. SUPERFRM_REENCODE, /* the super frame is re-encode */
  155. SUPERFRM_BUTT
  156. }VENC_SUPERFRM_MODE_E;
  157. /* The param of H264e cbr*/
  158. typedef struct hiVENC_PARAM_H264_CBR_S
  159. {
  160. HI_U32 u32MinIprop; /* RW; Range:[1, 100]; the min ratio of i frame and p frame */
  161. HI_U32 u32MaxIprop; /* RW; Range:[u32MinIprop, 100]; the max ratio of i frame and p frame */
  162. HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51];the max QP value */
  163. HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min QP value */
  164. HI_U32 u32MaxIQp; /* RW; Range:(MinQp, 51]; max qp for i frame */
  165. HI_U32 u32MinIQp; /* RW; Range:[0, 51]; min qp for i frame */
  166. HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
  167. HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
  168. }VENC_PARAM_H264_CBR_S;
  169. /* The param of H264e vbr*/
  170. typedef struct hiVENC_PARAM_H264_VBR_S
  171. {
  172. HI_S32 s32ChangePos; /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to the maximum
  173. bit rate when the QP value starts to be adjusted */
  174. HI_U32 u32MinIprop; /* RW; Range:[1, 100] ; the min ratio of i frame and p frame */
  175. HI_U32 u32MaxIprop; /* RW; Range:[u32MinIprop, 100] ; the max ratio of i frame and p frame */
  176. HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; max number of re-encode times */
  177. HI_BOOL bQpMapEn;
  178. HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51]; the max P B qp */
  179. HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min P B qp */
  180. HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51]; the max I qp */
  181. HI_U32 u32MinIQp; /* RW; Range:[0, 51]; the min I qp */
  182. } VENC_PARAM_H264_VBR_S;
  183. /* The param of H264e avbr*/
  184. typedef struct hiVENC_PARAM_H264_AVBR_S
  185. {
  186. HI_S32 s32ChangePos; /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to the maximum
  187. bit rate when the QP value starts to be adjusted */
  188. HI_U32 u32MinIprop; /* RW; Range:[1, 100] ; the min ratio of i frame and p frame */
  189. HI_U32 u32MaxIprop; /* RW; Range:[u32MinIprop, 100] ; the max ratio of i frame and p frame */
  190. HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; max number of re-encode times */
  191. HI_BOOL bQpMapEn;
  192. HI_S32 s32MinStillPercent; /* RW; Range:[20, 100]; the min percent of target bitrate for still scene */
  193. HI_U32 u32MaxStillQP; /* RW; Range:[MinIQp, MaxIQp]; the max QP value of I frame for still scene*/
  194. HI_U32 u32MinStillPSNR; /* RW; reserved,Invalid member currently */
  195. HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51]; the max P B qp */
  196. HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min P B qp */
  197. HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51]; the max I qp */
  198. HI_U32 u32MinIQp; /* RW; Range:[0, 51]; the min I qp */
  199. HI_U32 u32MotionSensitivity; /* RW; Range:[0, 100]; Motion Sensitivity */
  200. } VENC_PARAM_H264_AVBR_S;
  201. /* The param of mjpege cbr*/
  202. typedef struct hiVENC_PARAM_MJPEG_CBR_S
  203. {
  204. HI_U32 u32MaxQfactor; /* RW; Range:[MinQfactor, 99]; the max Qfactor value*/
  205. HI_U32 u32MinQfactor; /* RW; Range:[1, 99]; the min Qfactor value */
  206. }VENC_PARAM_MJPEG_CBR_S;
  207. /* The param of mjpege vbr*/
  208. typedef struct hiVENC_PARAM_MJPEG_VBR_S
  209. {
  210. HI_S32 s32ChangePos; /* RW; Range:[50, 100]; Indicates the ratio of the current bit rate to the maximum
  211. bit rate when the Qfactor value starts to be adjusted */
  212. HI_U32 u32MaxQfactor; /* RW; Range:[MinQfactor, 99]; max image quailty allowed */
  213. HI_U32 u32MinQfactor; /* RW; Range:[1, 99]; min image quality allowed */
  214. }VENC_PARAM_MJPEG_VBR_S;
  215. /* The param of h265e cbr*/
  216. typedef struct hiVENC_PARAM_H265_CBR_S
  217. {
  218. HI_U32 u32MinIprop; /* RW; Range: [u32MinIprop, 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. HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51];the max QP value */
  221. HI_U32 u32MinQp; /* RW; Range:[1, 51];the min QP value */
  222. HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51];max qp for i frame */
  223. HI_U32 u32MinIQp; /* RW; Range:[1, 51];min qp for i frame */
  224. HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
  225. HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
  226. VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; Qpmap Mode*/
  227. }VENC_PARAM_H265_CBR_S;
  228. /* The param of h265e vbr*/
  229. typedef struct hiVENC_PARAM_H265_VBR_S
  230. {
  231. HI_S32 s32ChangePos; /* RW; Range:[50, 100];Indicates the ratio of the current bit rate to the maximum bit rate when the QP value starts to be adjusted */
  232. HI_U32 u32MinIprop; /* RW; [1, 100]the min ratio of i frame and p frame */
  233. HI_U32 u32MaxIprop; /* RW; (MinIprop, 100]the max ratio of i frame and p frame */
  234. HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
  235. HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51]; the max P B qp */
  236. HI_U32 u32MinQp; /* RW; Range:[0, 51]; the min P B qp */
  237. HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51]; the max I qp */
  238. HI_U32 u32MinIQp; /* RW; Range:[0, 51]; the min I qp */
  239. HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
  240. VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; Qpmap Mode*/
  241. } VENC_PARAM_H265_VBR_S;
  242. /* The param of h265e vbr*/
  243. typedef struct hiVENC_PARAM_H265_AVBR_S
  244. {
  245. HI_S32 s32ChangePos; /* RW; Range:[50, 100];Indicates the ratio of the current bit rate to the maximum
  246. bit rate when the QP value starts to be adjusted */
  247. HI_U32 u32MinIprop; /* RW; [1, 100]the min ratio of i frame and p frame */
  248. HI_U32 u32MaxIprop; /* RW; (MinIprop, 100]the max ratio of i frame and p frame */
  249. HI_S32 s32MaxReEncodeTimes; /* RW; Range:[0, 3]; Range:max number of re-encode times.*/
  250. HI_S32 s32MinStillPercent; /* RW; Range:[20, 100]; the min percent of target bitrate for still scene */
  251. HI_U32 u32MaxStillQP; /* RW; Range:[MinIQp, MaxIQp]; the max QP value of I frame for still scene*/
  252. HI_U32 u32MinStillPSNR; /* RW; reserved */
  253. HI_U32 u32MaxQp; /* RW; Range:(MinQp, 51];the max P B qp */
  254. HI_U32 u32MinQp; /* RW; Range:[1, 51];the min P B qp */
  255. HI_U32 u32MaxIQp; /* RW; Range:(MinIQp, 51];the max I qp */
  256. HI_U32 u32MinIQp; /* RW; Range:[1, 51];the min I qp */
  257. HI_U32 u32MotionSensitivity; /* RW; Range:[0, 100]; Motion Sensitivity */
  258. HI_BOOL bQpMapEn; /* RW; Range:[0, 1]; enable qpmap.*/
  259. VENC_RC_QPMAP_MODE_E enQpMapMode; /* RW; Qpmap Mode*/
  260. } VENC_PARAM_H265_AVBR_S;
  261. /* The param of rc*/
  262. typedef struct hiVENC_RC_PARAM_S
  263. {
  264. HI_U32 u32ThrdI[RC_TEXTURE_THR_SIZE]; /*RW; Range:[0, 255]; Mad threshold for controlling the macroblock-level bit rate of I frames */
  265. HI_U32 u32ThrdP[RC_TEXTURE_THR_SIZE]; /*RW; Range:[0, 255]; Mad threshold for controlling the macroblock-level bit rate of P frames */
  266. HI_U32 u32ThrdB[RC_TEXTURE_THR_SIZE]; /*RW; Range:[0, 255]; Mad threshold for controlling the macroblock-level bit rate of B frames */
  267. HI_U32 u32DirectionThrd; /*RW; Range:[0, 16]; The direction for controlling the macroblock-level bit rate*/
  268. HI_U32 u32RowQpDelta; /* RW; Range:[0, 10];the start QP value of each macroblock row relative to the start QP value */
  269. HI_S32 s32FirstFrameStartQp; /* RW; Range:[1, 51];Start QP value of the first frame*/
  270. union
  271. {
  272. VENC_PARAM_H264_CBR_S stParamH264Cbr;
  273. VENC_PARAM_H264_VBR_S stParamH264Vbr;
  274. VENC_PARAM_H264_AVBR_S stParamH264AVbr;
  275. VENC_PARAM_H265_CBR_S stParamH265Cbr;
  276. VENC_PARAM_H265_VBR_S stParamH265Vbr;
  277. VENC_PARAM_H265_AVBR_S stParamH265AVbr;
  278. VENC_PARAM_MJPEG_CBR_S stParamMjpegCbr;
  279. VENC_PARAM_MJPEG_VBR_S stParamMjpegVbr;
  280. };
  281. }VENC_RC_PARAM_S;
  282. /* the frame lost mode*/
  283. typedef enum hiVENC_FRAMELOST_MODE_E
  284. {
  285. FRMLOST_NORMAL=0, /*normal mode*/
  286. FRMLOST_PSKIP, /*pskip*/
  287. FRMLOST_BUTT,
  288. }VENC_FRAMELOST_MODE_E;
  289. /* The param of the frame lost mode*/
  290. typedef struct hiVENC_FRAMELOST_S
  291. {
  292. HI_BOOL bFrmLostOpen; /* RW; Range:[0,1];Indicates whether to discard frames to ensure stable bit rate when the instant bit rate is exceeded */
  293. HI_U32 u32FrmLostBpsThr; /* RW; Range:[64k, 163840k];the instant bit rate threshold */
  294. VENC_FRAMELOST_MODE_E enFrmLostMode; /* frame lost strategy*/
  295. HI_U32 u32EncFrmGaps; /* RW; Range:[0,65535]; the gap of frame lost*/
  296. }VENC_FRAMELOST_S;
  297. /* the rc priority*/
  298. typedef enum hiVENC_RC_PRIORITY_E
  299. {
  300. VENC_RC_PRIORITY_BITRATE_FIRST = 1, /* bitrate first */
  301. VENC_RC_PRIORITY_FRAMEBITS_FIRST, /* framebits first*/
  302. VENC_RC_PRIORITY_BUTT,
  303. } VENC_RC_PRIORITY_E;
  304. /* the config of the superframe */
  305. typedef struct hiVENC_SUPERFRAME_CFG_S
  306. {
  307. VENC_SUPERFRM_MODE_E enSuperFrmMode; /* RW; Indicates the mode of processing the super frame*/
  308. HI_U32 u32SuperIFrmBitsThr; /* RW; Range:[0, 4294967295];Indicate the threshold of the super I frame for enabling the super frame processing mode */
  309. HI_U32 u32SuperPFrmBitsThr; /* RW; Range:[0, 4294967295];Indicate the threshold of the super P frame for enabling the super frame processing mode */
  310. HI_U32 u32SuperBFrmBitsThr; /* RW; Range:[0, 4294967295];Indicate the threshold of the super B frame for enabling the super frame processing mode */
  311. VENC_RC_PRIORITY_E enRcPriority; /* RW; Rc Priority*/
  312. }VENC_SUPERFRAME_CFG_S;
  313. #ifdef __cplusplus
  314. #if __cplusplus
  315. }
  316. #endif
  317. #endif /* __cplusplus */
  318. #endif /* __HI_COMM_RC_H__ */