ax_comm_venc.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /**********************************************************************************
  2. *
  3. * Copyright (c) 2019-2020 Beijing AXera Technology Co., Ltd. All Rights Reserved.
  4. *
  5. * This source file is the property of Beijing AXera Technology Co., Ltd. and
  6. * may not be copied or distributed in any isomorphic form without the prior
  7. * written consent of Beijing AXera Technology Co., Ltd.
  8. *
  9. **********************************************************************************/
  10. #ifndef __AX_COMM_VENC_H__
  11. #define __AX_COMM_VENC_H__
  12. #include "ax_base_type.h"
  13. #include "ax_global_type.h"
  14. #include "ax_comm_venc_rc.h"
  15. #include "ax_comm_codec.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif /* End of #ifdef __cplusplus */
  19. #define MAX_OSD_NUM 6
  20. #define AX_FAILURE (-1)
  21. #define AX_SUCCESS 0
  22. #define VENC_QP_HISGRM_NUM 52
  23. #define MAX_VENC_NUM 64
  24. #define MAX_ROI_NUM 8
  25. #define VENC_MAX_NALU_NUM (64)
  26. #define MAX_VENC_PIC_WIDTH (5584)
  27. #define MAX_VENC_PIC_HEIGHT (4188)
  28. #define MIN_VENC_PIC_WIDTH (136)
  29. #define MIN_VENC_PIC_HEIGHT (136)
  30. #define MAX_JENC_PIC_WIDTH (32768)
  31. #define MAX_JENC_PIC_HEIGHT (32768)
  32. #define MIN_JENC_PIC_WIDTH (2)
  33. #define MIN_JENC_PIC_HEIGHT (2)
  34. typedef AX_S32 VENC_CHN;
  35. typedef enum
  36. {
  37. AX_JPEGENC_OK = 0,
  38. AX_JPEGENC_ERROR = -1
  39. } AX_JPEGENC_RET;
  40. /*the attribute of h264e*/
  41. typedef struct axVENC_ATTR_H264_S
  42. {
  43. AX_BOOL bRcnRefShareBuf; /* RW; Range:[0, 1]; Whether to enable the Share Buf of Rcn and Ref .*/
  44. //reserved
  45. } AX_VENC_ATTR_H264_S;
  46. /*the attribute of h265e*/
  47. typedef struct axVENC_ATTR_H265_S
  48. {
  49. AX_BOOL bRcnRefShareBuf; /* RW; Range:[0, 1]; Whether to enable the Share Buf of Rcn and Ref .*/
  50. //reserved
  51. } AX_VENC_ATTR_H265_S;
  52. /* the param of the jpege */
  53. typedef struct axVENC_JPEG_PARAM_S
  54. {
  55. AX_U32 u32Qfactor; /* RW; Range:[1,99]; Qfactor value */
  56. AX_U8 u8YQt[64]; /* RW; Range:[1, 255]; Y quantization table */
  57. AX_U8 u8CbCrQt[64]; /* RW; Range:[1, 255]; CbCr quantization table */
  58. AX_U32 u32MCUPerECS; /* RW; the max MCU number is (picwidth + 15) >> 4 x (picheight +
  59. 15) >> 4 x 2]; MCU number of one ECS*/
  60. } AX_VENC_JPEG_PARAM_S;
  61. /* the param of the mjpege */
  62. typedef struct axVENC_MJPEG_PARAM_S
  63. {
  64. AX_U8 u8YQt[64]; /* RW; Range:[1, 255]; Y quantization table */
  65. AX_U8 u8CbQt[64]; /* RW; Range:[1, 255]; Cb quantization table */
  66. AX_U8 u8CrQt[64]; /* RW; Range:[1, 255]; Cr quantization table */
  67. AX_U32 u32MCUPerECS; /* RW; the max MCU number is (picwidth + 15) >> 4 x (picheight +
  68. 15) >> 4 x 2]; MCU number of one ECS*/
  69. } AX_VENC_MJPEG_PARAM_S;
  70. typedef struct axSIZE_S
  71. {
  72. AX_U32 u32Width;
  73. AX_U32 u32Height;
  74. } AX_SIZE_S;
  75. /*the size of array is 2,that is the maximum*/
  76. typedef struct axVENC_MPF_CFG_S
  77. {
  78. AX_U8 u8LargeThumbNailNum; /* RW; Range:[0,2]; the large thumbnail pic num of the MPF */
  79. AX_SIZE_S astLargeThumbNailSize[2]; /* RW; The resolution of large ThumbNail*/
  80. } AX_VENC_MPF_CFG_S;
  81. typedef enum
  82. {
  83. VENC_PIC_RECEIVE_SINGLE = 0,
  84. VENC_PIC_RECEIVE_MULTI,
  85. VENC_PIC_RECEIVE_BUTT
  86. } AX_VENC_PIC_RECEIVE_MODE_E;
  87. /*the attribute of jpege*/
  88. typedef struct axVENC_ATTR_JPEG_S
  89. {
  90. // AX_VENC_PIC_RECEIVE_MODE_E enReceiveMode; /*RW; Config the receive mode*/ not support now
  91. } AX_VENC_ATTR_JPEG_S;
  92. /*the attribute of mjpege*/
  93. typedef struct axVENC_ATTR_MJPEG_S
  94. {
  95. // AX_VENC_PIC_RECEIVE_MODE_E enReceiveMode; /*RW; Config the receive mode*/ not support now
  96. } AX_VENC_ATTR_MJPEG_S;
  97. /* Profile for initialization */
  98. typedef enum
  99. {
  100. VENC_HEVC_MAIN_PROFILE = 0,
  101. VENC_HEVC_MAIN_STILL_PICTURE_PROFILE = 1,
  102. VENC_HEVC_MAIN_10_PROFILE = 2,
  103. VENC_HEVC_MAINREXT = 3,
  104. /* H264 Defination*/
  105. VENC_H264_BASE_PROFILE = 9,
  106. VENC_H264_MAIN_PROFILE = 10,
  107. VENC_H264_HIGH_PROFILE = 11,
  108. VENC_H264_HIGH_10_PROFILE = 12
  109. } AX_VENC_PROFILE_E;
  110. /* Level for initialization */
  111. typedef enum
  112. {
  113. VENC_HEVC_LEVEL_1 = 30,
  114. VENC_HEVC_LEVEL_2 = 60,
  115. VENC_HEVC_LEVEL_2_1 = 63,
  116. VENC_HEVC_LEVEL_3 = 90,
  117. VENC_HEVC_LEVEL_3_1 = 93,
  118. VENC_HEVC_LEVEL_4 = 120,
  119. VENC_HEVC_LEVEL_4_1 = 123,
  120. VENC_HEVC_LEVEL_5 = 150,
  121. VENC_HEVC_LEVEL_5_1 = 153,
  122. VENC_HEVC_LEVEL_5_2 = 156,
  123. VENC_HEVC_LEVEL_6 = 180,
  124. VENC_HEVC_LEVEL_6_1 = 183,
  125. VENC_HEVC_LEVEL_6_2 = 186,
  126. /* H264 Defination*/
  127. VENC_H264_LEVEL_1 = 10,
  128. VENC_H264_LEVEL_1_b = 99,
  129. VENC_H264_LEVEL_1_1 = 11,
  130. VENC_H264_LEVEL_1_2 = 12,
  131. VENC_H264_LEVEL_1_3 = 13,
  132. VENC_H264_LEVEL_2 = 20,
  133. VENC_H264_LEVEL_2_1 = 21,
  134. VENC_H264_LEVEL_2_2 = 22,
  135. VENC_H264_LEVEL_3 = 30,
  136. VENC_H264_LEVEL_3_1 = 31,
  137. VENC_H264_LEVEL_3_2 = 32,
  138. VENC_H264_LEVEL_4 = 40,
  139. VENC_H264_LEVEL_4_1 = 41,
  140. VENC_H264_LEVEL_4_2 = 42,
  141. VENC_H264_LEVEL_5 = 50,
  142. VENC_H264_LEVEL_5_1 = 51,
  143. VENC_H264_LEVEL_5_2 = 52,
  144. VENC_H264_LEVEL_6 = 60,
  145. VENC_H264_LEVEL_6_1 = 61,
  146. VENC_H264_LEVEL_6_2 = 62
  147. } AX_VENC_LEVEL_E;
  148. /* Tier for initialization */
  149. typedef enum
  150. {
  151. VENC_HEVC_MAIN_TIER = 0,
  152. VENC_HEVC_HIGH_TIER = 1,
  153. } AX_VENC_TIER_E;
  154. typedef enum
  155. {
  156. /* enable h264/hevc encoder */
  157. VENC_VIDEO_ENCODER = 1,
  158. /* enable jpeg/mjpeg encoder */
  159. VENC_JPEG_ENCODER = 2,
  160. /* enable h264/h265/jpeg/mjpeg encoder */
  161. VENC_MULTI_ENCODER = 3
  162. } AX_VENC_ENCODER_TYPE_E;
  163. typedef struct axVENC_MOD_ATTR_S
  164. {
  165. AX_VENC_ENCODER_TYPE_E enVencType;
  166. } AX_VENC_MOD_ATTR_S;
  167. typedef struct axVENC_USERDATA_QUEUE_ATTR_S
  168. {
  169. AX_U32 u32UserDataBufferCount;
  170. AX_U32 u32UserDataBufferSize;
  171. } AX_VENC_USERDATA_QUEUE_ATTR_S;
  172. /* the attribute of the Venc*/
  173. typedef struct axVENC_ATTR_S
  174. {
  175. AX_PAYLOAD_TYPE_E enType; /* RW; the type of payload*/
  176. /* VENC: RW; Max input image width [8192], in pixel*/
  177. /* JENC: RW; Max input image width [32768], in pixel*/
  178. AX_U32 u32MaxPicWidth;
  179. /* VENC: RW; Max input image height [8192], in pixel*/
  180. /* JENC: RW; Max input image height [32768], in pixel*/
  181. AX_U32 u32MaxPicHeight;
  182. AX_MEMORY_SOURCE_E enMemSource ; /* RW; memory source of stream buffer */
  183. AX_U32 u32BufSize; /* RW; stream buffer size*/
  184. AX_VENC_PROFILE_E enProfile; /* RW; H.264: 9: Baseline; 10: Main; 11: High; 12: High 10;
  185. H.265: 0: Main; 1: Main Still Picture; 2: Main 10; */
  186. AX_VENC_LEVEL_E enLevel; /* RW; HEVC level: 180 = level 6.0 * 30; H264 level: 51 = Level 5.1*/
  187. AX_VENC_TIER_E enTier; /* RW; HEVC: 0: Main tier、 1: High tier*/
  188. AX_U32 u32MbLinesPerSlice; /* RW; 0: slice contain one frame; [1, align_up(picHeight)/BLK_SIZE]: a slice should contain how many MCU/MB/CTU lines. */
  189. /* VENC: RW; Range:[136, 5584];width of source image,must be even, in pixel*/
  190. /* JENC: RW; Range:[2, 32768];width of source image,must be even, in pixel*/
  191. AX_U32 u32PicWidthSrc;
  192. /* VENC: RW; Range:[136, 4188];height of source image,must be even, in pixel*/
  193. /* JENC: RW; Range:[2, 32768];height of source image,must be even, in pixel*/
  194. AX_U32 u32PicHeightSrc;
  195. /* VENC: RW; Range:[0, 8192];Output image horizontal cropping offset, must be even, in pixel*/
  196. /* JENC: RW; Range:[0, 32768];Output image horizontal cropping offset, must be even, in pixel*/
  197. AX_U32 u32CropOffsetX;
  198. /* VENC: RW; Range:[0, 8192];Output image vertical cropping offset, must be even, in pixel*/
  199. /* JENC: RW; Range:[0, 32768];Output image vertical cropping offset, must be even, in pixel*/
  200. AX_U32 u32CropOffsetY;
  201. /* VENC: RW; Range:[136, 5584];Width of encoded image, must be even,in pixel*/
  202. /* JENC: RW; Range:[1, 32768];Width of encoded image, must be even,in pixel*/
  203. AX_U32 u32CropWidth;
  204. /* VENC: RW; Range:[136, 4188];Height of encoded image, must be even, in pixel*/
  205. /* JENC: RW; Range:[1, 32768];Height of encoded image, must be even, in pixel*/
  206. AX_U32 u32CropHeight;
  207. AX_LINK_MODE_E enLinkMode;
  208. AX_U32 u32GdrDuration; /* how many frames it will take to do GDR, 0: disable GDR >0: enable GDR */
  209. AX_U32 u32VideoRange; /* 0: Narrow Range(NR), Y[16,235], Cb/Cr[16,240]; 1: Full Range(FR), Y/Cb/Cr[0,255] */
  210. /* whether flush output queue immediately when try to destroy channel,
  211. -1: wait until output queue empty; 0: not wait (default); >0: wait some time, in millisecond */
  212. AX_S32 s32StopWaitTime;
  213. AX_U8 u8InFifoDepth; /* RW; depth of input fifo */
  214. AX_U8 u8OutFifoDepth; /* RW; depth of output fifo */
  215. union {
  216. AX_VENC_ATTR_H264_S stAttrH264e; /* attributes of H264e */
  217. AX_VENC_ATTR_H265_S stAttrH265e; /* attributes of H265e */
  218. AX_VENC_ATTR_MJPEG_S stAttrMjpege; /* attributes of Mjpeg */
  219. AX_VENC_ATTR_JPEG_S stAttrJpege; /* attributes of jpeg */
  220. };
  221. } AX_VENC_ATTR_S;
  222. /* the gop mode */
  223. typedef enum axVENC_GOP_MODE_E
  224. {
  225. VENC_GOPMODE_NORMALP = 0, /* NORMALP */
  226. VENC_GOPMODE_ONELTR = 1, /* ONELTR */
  227. VENC_GOPMODE_SVC_T = 2, /* SVC-T */
  228. VENC_GOPMODE_BUTT
  229. } AX_VENC_GOP_MODE_E;
  230. /* QPFactor (quality preference) will be used in rate distorition optimization, higher value
  231. mean lower quality and less bits. Typical suggested range is between 0.3 and 1 */
  232. typedef struct ax_VENC_GOP_PIC_CONFIG_S
  233. {
  234. AX_S32 s32QpOffset; /* QP offset will be added to the QP parameter to set the final QP */
  235. AX_F32 f32QpFactor;
  236. } AX_VENC_GOP_PIC_CONFIG_S;
  237. /* QPFactor (quality preference) will be used in rate distorition optimization, higher value
  238. mean lower quality and less bits. Typical suggested range is between 0.3 and 1 */
  239. typedef struct ax_VENC_GOP_PIC_SPECIAL_CONFIG_S
  240. {
  241. AX_S32 s32QpOffset; /* QP offset will be added to the QP parameter to set the final QP */
  242. AX_F32 f32QpFactor;
  243. /* interval between two pictures using LTR as reference picture or
  244. interval between two pictures coded as special frame */
  245. AX_S32 s32Interval;
  246. } AX_VENC_GOP_PIC_SPECIAL_CONFIG_S;
  247. /* the attribute of the normalp*/
  248. typedef struct axVENC_GOP_NORMALP_S
  249. {
  250. AX_VENC_GOP_PIC_CONFIG_S stPicConfig; /* normal P frame config */
  251. } AX_VENC_GOP_NORMALP_S;
  252. /* the attribute of the one long-term reference frame */
  253. typedef struct axVENC_GOP_ONE_LTR_S
  254. {
  255. AX_VENC_GOP_PIC_CONFIG_S stPicConfig; /* normal P frame config */
  256. AX_VENC_GOP_PIC_SPECIAL_CONFIG_S stPicSpecialConfig; /* one long-term reference frame config */
  257. } AX_VENC_GOP_ONE_LTR_S;
  258. /* the attribute of the one long-term reference frame */
  259. typedef struct axVENC_GOP_SVC_T_S
  260. {
  261. AX_S8 **s8SvcTCfg;
  262. AX_U32 u32GopSize;
  263. } AX_VENC_GOP_SVC_T_S;
  264. /* the attribute of the gop*/
  265. typedef struct axVENC_GOP_ATTR_S
  266. {
  267. AX_VENC_GOP_MODE_E enGopMode; /* RW; Encoding GOP type */
  268. union
  269. {
  270. AX_VENC_GOP_NORMALP_S stNormalP; /*attributes of normal P*/
  271. AX_VENC_GOP_ONE_LTR_S stOneLTR; /*attributes of one long-term reference frame */
  272. AX_VENC_GOP_SVC_T_S stSvcT; /*attributes of svc-t */
  273. };
  274. } AX_VENC_GOP_ATTR_S;
  275. /* the attribute of the venc chnl*/
  276. typedef struct axVENC_CHN_ATTR_S
  277. {
  278. AX_VENC_ATTR_S stVencAttr; /*the attribute of video encoder channel */
  279. AX_VENC_RC_ATTR_S stRcAttr; /*the attribute of rate ctrl */
  280. AX_VENC_GOP_ATTR_S stGopAttr; /*the attribute of gop */
  281. } AX_VENC_CHN_ATTR_S;
  282. typedef enum
  283. {
  284. VENC_MOD_CLK_FREQUENCY_624M = 0, /* VENC hw mod clk frequency 624M*/
  285. VENC_MOD_CLK_FREQUENCY_500M = 1, /* VENC hw mod clk frequency 500M*/
  286. VENC_MOD_CLK_FREQUENCY_312M = 2, /* VENC hw mod clk frequency 312M*/
  287. JENC_MOD_CLK_FREQUENCY_624M = 3, /* JENC hw mod clk frequency 624M*/
  288. JENC_MOD_CLK_FREQUENCY_500M = 4, /* JENC hw mod clk frequency 500M*/
  289. JENC_MOD_CLK_FREQUENCY_312M = 5, /* JENC hw mod clk frequency 312M*/
  290. VENC_MOD_CLK_FREQUENCY_BUTT
  291. } AX_VENC_HW_CLK_E;
  292. /* the param of the venc hw mod */
  293. typedef struct axVENC_MOD_PARAM_S
  294. {
  295. AX_VENC_HW_CLK_E enVencHwClk; /* VENC Hw mod clk frequency */
  296. AX_VENC_HW_CLK_E enJencHwClk; /* JENC Hw mod clk frequency */
  297. } AX_VENC_MOD_PARAM_S;
  298. /* the param of vui */
  299. typedef struct axVENC_SPS_VUI_PARAM_S
  300. {
  301. AX_U32 u32VideoSignalTypePresentFlag; /* RW; see h264/hevc spec. Range:[0, 1], default 0 */
  302. AX_U32 u32ColourDescriptionPresentFlag; /* RW; see h264/hevc spec. Range:[0, 1], default 0 */
  303. AX_U32 u32ColourPrimaries; /* RW; see h264/hevc spec. Range:[0, 255], default 9 */
  304. AX_U32 u32TransferCharacteristics; /* RW; see h264/hevc spec. Range:[0, 255], default 0 */
  305. AX_U32 u32MatrixCoefficients; /* RW; see h264/hevc spec. Range:[0, 255], default 9 */
  306. } AX_VENC_SPS_VUI_PARAM_S;
  307. /*the nalu type of H264E*/
  308. typedef enum
  309. {
  310. H264E_NALU_BSLICE = 0, /*B SLICE types*/
  311. H264E_NALU_PSLICE = 1, /*P SLICE types*/
  312. H264E_NALU_ISLICE = 2, /*I SLICE types*/
  313. H264E_NALU_IDRSLICE = 5, /*IDR SLICE types*/
  314. H264E_NALU_SEI = 6, /*SEI types*/
  315. H264E_NALU_SPS = 7, /*SPS types*/
  316. H264E_NALU_PPS = 8, /*PPS types*/
  317. H264E_NALU_PREFIX_14 = 14, /*Prefix NAL unit */
  318. H264E_NALU_BUTT
  319. } AX_H264E_NALU_TYPE_E;
  320. /*the nalu type of H265E*/
  321. typedef enum
  322. {
  323. H265E_NALU_BSLICE = 0, /*B SLICE types*/
  324. H265E_NALU_PSLICE = 1, /*P SLICE types*/
  325. H265E_NALU_ISLICE = 2, /*I SLICE types*/
  326. H265E_NALU_TSA_R = 3,
  327. H265E_NALU_IDRSLICE = 19, /*IDR SLICE types*/
  328. H265E_NALU_VPS = 32, /*VPS types*/
  329. H265E_NALU_SPS = 33, /*SPS types*/
  330. H265E_NALU_PPS = 34, /*PPS types*/
  331. H265E_NALU_SEI = 39, /*SEI types*/
  332. H265E_NALU_BUTT
  333. } AX_H265E_NALU_TYPE_E;
  334. /* Picture type for encoding */
  335. typedef enum
  336. {
  337. VENC_INTRA_FRAME = 0, /* I Frame */
  338. VENC_PREDICTED_FRAME = 1, /* P Frame */
  339. VENC_BIDIR_PREDICTED_FRAME = 2, /* B Frame */
  340. VENC_VIRTUAL_INTRA_FRAME = 3, /* virtual I frame */
  341. VENC_NOTCODED_FRAME /* Used just as a return value */
  342. } AX_VENC_PICTURE_CODING_TYPE_E;
  343. /*the pack type of JPEGE*/
  344. typedef enum
  345. {
  346. JPEGE_PACK_ECS = 5, /*ECS types*/
  347. JPEGE_PACK_APP = 6, /*APP types*/
  348. JPEGE_PACK_VDO = 7, /*VDO types*/
  349. JPEGE_PACK_PIC = 8, /*PIC types*/
  350. JPEGE_PACK_DCF = 9, /*DCF types*/
  351. JPEGE_PACK_DCF_PIC = 10, /*DCF PIC types*/
  352. JPEGE_PACK_BUTT
  353. } AX_JPEGE_PACK_TYPE_E;
  354. /*the data type of VENC*/
  355. typedef union
  356. {
  357. AX_H264E_NALU_TYPE_E enH264EType; /* R; H264E NALU types*/
  358. AX_JPEGE_PACK_TYPE_E enJPEGEType; /* R; JPEGE pack types*/
  359. AX_H265E_NALU_TYPE_E enH265EType; /* R; H264E NALU types*/
  360. } AX_VENC_DATA_TYPE_U;
  361. /*the pack info of VENC*/
  362. typedef struct axVENC_NALU_INFO_S
  363. {
  364. AX_VENC_DATA_TYPE_U unNaluType; /* R; the nalu type*/
  365. AX_U32 u32NaluOffset;
  366. AX_U32 u32NaluLength;
  367. } AX_VENC_NALU_INFO_S;
  368. typedef struct axCHN_STREAM_STATUS_S
  369. {
  370. AX_U32 u32TotalChnNum; /* Range:[0, MAX_VENC_NUM], how many channels have stream. */
  371. AX_U32 au32ChnIndex[MAX_VENC_NUM]; /* the channel id set of venc channel that has stream */
  372. AX_PAYLOAD_TYPE_E aenChnCodecType[MAX_VENC_NUM]; /* channel payload type */
  373. } AX_CHN_STREAM_STATUS_S;
  374. /*Defines a stream packet*/
  375. typedef struct axVENC_PACK_S
  376. {
  377. AX_U64 ulPhyAddr; /* R; the physics address of stream */
  378. AX_U8 *pu8Addr; /* R; the virtual address of stream */
  379. AX_U32 u32Len; /* R; the length of stream */
  380. AX_U64 u64PTS; /* R; PTS */
  381. AX_U64 u64SeqNum; /* sequence number of input frame */
  382. AX_U64 u64UserData;
  383. AX_PAYLOAD_TYPE_E enType; /* RW; the type of payload*/
  384. AX_VENC_PICTURE_CODING_TYPE_E enCodingType; /* stream type */
  385. AX_U32 u32TemporalID; /* svc-t, layer id*/
  386. AX_U32 u32NaluNum; /* R; the stream nalus num */
  387. AX_VENC_NALU_INFO_S stNaluInfo[VENC_MAX_NALU_NUM]; /* R; the stream nalu Information */
  388. } AX_VENC_PACK_S;
  389. /*Defines the frame type and reference attributes of the H.264 frame skipping reference streams*/
  390. typedef enum
  391. {
  392. BASE_IDRSLICE = 0, /* the Idr frame at Base layer*/
  393. BASE_PSLICE_REFTOIDR, /* the P frame at Base layer, referenced by other frames at Base layer and reference to Idr frame*/
  394. BASE_PSLICE_REFBYBASE, /* the P frame at Base layer, referenced by other frames at Base layer*/
  395. BASE_PSLICE_REFBYENHANCE, /* the P frame at Base layer, referenced by other frames at Enhance layer*/
  396. ENHANCE_PSLICE_REFBYENHANCE, /* the P frame at Enhance layer, referenced by other frames at Enhance layer*/
  397. ENHANCE_PSLICE_NOTFORREF, /* the P frame at Enhance layer ,not referenced*/
  398. ENHANCE_PSLICE_BUTT
  399. } AX_H264E_REF_TYPE_E;
  400. typedef AX_H264E_REF_TYPE_E AX_H265E_REF_TYPE_E;
  401. /*Defines the features of an H.264 stream*/
  402. typedef struct axVENC_STREAM_INFO_H264_S
  403. {
  404. AX_U32 u32PicBytesNum; /* R; the coded picture stream byte number */
  405. AX_U32 u32Inter16x16MbNum; /* R; the inter16x16 macroblock num */
  406. AX_U32 u32Inter8x8MbNum; /* R; the inter8x8 macroblock num */
  407. AX_U32 u32Intra16MbNum; /* R; the intra16x16 macroblock num */
  408. AX_U32 u32Intra8MbNum; /* R; the intra8x8 macroblock num */
  409. AX_U32 u32Intra4MbNum; /* R; the inter4x4 macroblock num */
  410. AX_H264E_REF_TYPE_E enRefType; /* R; Type of encoded frames in advanced frame skipping reference mode*/
  411. AX_U32 u32UpdateAttrCnt; /* R; Number of times that channel attributes or parameters (including RC parameters) are set*/
  412. AX_U32 u32StartQp; /* R; the start Qp of encoded frames*/
  413. AX_U32 u32MeanQp; /* R; the mean Qp of encoded frames*/
  414. AX_BOOL bPSkip;
  415. } AX_VENC_STREAM_INFO_H264_S;
  416. /*Defines the features of an H.265 stream*/
  417. typedef struct axVENC_STREAM_INFO_H265_S
  418. {
  419. AX_U32 u32PicBytesNum; /* R; the coded picture stream byte number */
  420. AX_U32 u32Inter64x64CuNum; /* R; the inter64x64 cu num */
  421. AX_U32 u32Inter32x32CuNum; /* R; the inter32x32 cu num */
  422. AX_U32 u32Inter16x16CuNum; /* R; the inter16x16 cu num */
  423. AX_U32 u32Inter8x8CuNum; /* R; the inter8x8 cu num */
  424. AX_U32 u32Intra32x32CuNum; /* R; the Intra32x32 cu num */
  425. AX_U32 u32Intra16x16CuNum; /* R; the Intra16x16 cu num */
  426. AX_U32 u32Intra8x8CuNum; /* R; the Intra8x8 cu num */
  427. AX_U32 u32Intra4x4CuNum; /* R; the Intra4x4 cu num */
  428. AX_H265E_REF_TYPE_E enRefType; /* R; Type of encoded frames in advanced frame skipping reference mode*/
  429. AX_U32 u32UpdateAttrCnt; /* R; Number of times that channel attributes or parameters (including RC parameters) are set*/
  430. AX_U32 u32StartQp; /* R; the start Qp of encoded frames*/
  431. AX_U32 u32MeanQp; /* R; the mean Qp of encoded frames*/
  432. AX_BOOL bPSkip;
  433. } AX_VENC_STREAM_INFO_H265_S;
  434. /* the sse info*/
  435. typedef struct axVENC_SSE_INFO_S
  436. {
  437. AX_BOOL bSSEEn; /* RW; Range:[0,1]; Region SSE enable */
  438. AX_U32 u32SSEVal; /* R; Region SSE value */
  439. } AX_VENC_SSE_INFO_S;
  440. /* the advance information of the h264e */
  441. typedef struct axVENC_STREAM_ADVANCE_INFO_H264_S
  442. {
  443. AX_U32 u32ResidualBitNum; /* R; the residual num */
  444. AX_U32 u32HeadBitNum; /* R; the head bit num */
  445. AX_U32 u32MadiVal; /* R; the madi value */
  446. AX_U32 u32MadpVal; /* R; the madp value */
  447. AX_F64 f64PSNRVal; /* R; the PSNR value */
  448. AX_U32 u32MseLcuCnt; /* R; the lcu cnt of the mse */
  449. AX_U32 u32MseSum; /* R; the sum of the mse */
  450. AX_VENC_SSE_INFO_S stSSEInfo[8]; /* R; the information of the sse */
  451. AX_U32 u32QpHstgrm[VENC_QP_HISGRM_NUM]; /* R; the Qp histogram value */
  452. AX_U32 u32MoveScene16x16Num; /* R; the 16x16 cu num of the move scene*/
  453. AX_U32 u32MoveSceneBits; /* R; the stream bit num of the move scene */
  454. } AX_VENC_STREAM_ADVANCE_INFO_H264_S;
  455. /* the advance information of the h265e */
  456. typedef struct axVENC_STREAM_ADVANCE_INFO_H265_S
  457. {
  458. AX_U32 u32ResidualBitNum; /* R; the residual num */
  459. AX_U32 u32HeadBitNum; /* R; the head bit num */
  460. AX_U32 u32MadiVal; /* R; the madi value */
  461. AX_U32 u32MadpVal; /* R; the madp value */
  462. AX_F64 f64PSNRVal; /* R; the PSNR value */
  463. AX_U32 u32MseLcuCnt; /* R; the lcu cnt of the mse */
  464. AX_U32 u32MseSum; /* R; the sum of the mse */
  465. AX_VENC_SSE_INFO_S stSSEInfo[8]; /* R; the information of the sse */
  466. AX_U32 u32QpHstgrm[VENC_QP_HISGRM_NUM]; /* R; the Qp histogram value */
  467. AX_U32 u32MoveScene32x32Num; /* R; the 32x32 cu num of the move scene*/
  468. AX_U32 u32MoveSceneBits; /* R; the stream bit num of the move scene */
  469. } AX_VENC_STREAM_ADVANCE_INFO_H265_S;
  470. /*Defines the features of an jpege stream*/
  471. typedef struct axVENC_STREAM_INFO_JPEG_S
  472. {
  473. AX_U32 u32PicBytesNum; /* R; the coded picture stream byte number */
  474. AX_U32 u32UpdateAttrCnt; /* R; Number of times that channel attributes or parameters (including RC parameters) are set*/
  475. AX_U32 u32Qfactor; /* R; image quality */
  476. } AX_VENC_STREAM_INFO_JPEG_S;
  477. /* the advance information of the Jpege */
  478. typedef struct axVENC_STREAM_ADVANCE_INFO_JPEG_S
  479. {
  480. // AX_U32 u32Reserved;
  481. } AX_VENC_STREAM_ADVANCE_INFO_JPEG_S;
  482. /*Defines the features of an strAX_AX_*/
  483. typedef struct axVENC_STREAM_S
  484. {
  485. AX_VENC_PACK_S stPack; /* R; stream pack attribute*/
  486. union {
  487. AX_VENC_STREAM_INFO_H264_S stH264Info; /* R; the stream info of h264*/
  488. AX_VENC_STREAM_INFO_JPEG_S stJpegInfo; /* R; the stream info of jpeg*/
  489. AX_VENC_STREAM_INFO_H265_S stH265Info; /* R; the stream info of h265*/
  490. };
  491. union {
  492. AX_VENC_STREAM_ADVANCE_INFO_H264_S stAdvanceH264Info; /* R; the stream info of h264*/
  493. AX_VENC_STREAM_ADVANCE_INFO_JPEG_S stAdvanceJpegInfo; /* R; the stream info of jpeg*/
  494. AX_VENC_STREAM_ADVANCE_INFO_H265_S stAdvanceH265Info; /* R; the stream info of h265*/
  495. };
  496. } AX_VENC_STREAM_S;
  497. /* the param of receive picture */
  498. typedef struct axVENC_RECV_PIC_PARAM_S
  499. {
  500. AX_S32 s32RecvPicNum; /* RW; Range:[-1, 2147483647]; Number of frames received and encoded by the encoding channel,0 is not supported*/
  501. } AX_VENC_RECV_PIC_PARAM_S;
  502. typedef struct axVENC_STREAM_BUF_INFO_T
  503. {
  504. AX_U64 u64PhyAddr;
  505. AX_VOID * pUserAddr;
  506. AX_U32 u32BufSize;
  507. } AX_VENC_STREAM_BUF_INFO_T;
  508. #if 0
  509. typedef struct axVENC_OSD_AREA_ATTR_S
  510. {
  511. /* Overlay, support 6 osd regions at present */
  512. AX_U32 u32OverlayEnables;
  513. AX_U32 u32Format[MAX_OSD_NUM];
  514. AX_U32 u32Alpha[MAX_OSD_NUM];
  515. AX_U32 u32Xoffset[MAX_OSD_NUM];
  516. AX_U32 u32CropXoffset[MAX_OSD_NUM];
  517. AX_U32 u32Yoffset[MAX_OSD_NUM];
  518. AX_U32 u32CropYoffset[MAX_OSD_NUM];
  519. AX_U32 u32Width[MAX_OSD_NUM];
  520. AX_U32 u32CropWidth[MAX_OSD_NUM];
  521. AX_U32 u32Height[MAX_OSD_NUM];
  522. AX_U32 u32CropHeight[MAX_OSD_NUM];
  523. AX_U32 u32YStride[MAX_OSD_NUM];
  524. AX_U32 u32UVStride[MAX_OSD_NUM];
  525. AX_U32 u32BitmapY[MAX_OSD_NUM];
  526. AX_U32 u32BitmapU[MAX_OSD_NUM];
  527. AX_U32 u32BitmapV[MAX_OSD_NUM];
  528. AX_ADDR ulInputYAddr[MAX_OSD_NUM];
  529. AX_ADDR ulInputUAddr[MAX_OSD_NUM];
  530. AX_ADDR ulInputVAddr[MAX_OSD_NUM];
  531. } AX_VENC_OSD_AREA_ATTR_S;
  532. #endif
  533. /* the attribute of the roi */
  534. typedef struct axRECT_S
  535. {
  536. AX_U32 u32X;
  537. AX_U32 u32Y;
  538. AX_U32 u32Width;
  539. AX_U32 u32Height;
  540. } AX_RECT_S;
  541. typedef struct axVENC_ROI_ATTR_S
  542. {
  543. AX_U32 u32Index; /* RW; Range:[0, 7]; Index of an ROI. The system supports indexes ranging from 0 to 7 */
  544. AX_BOOL bEnable; /* RW; Range:[0, 1]; Whether to enable this ROI */
  545. AX_BOOL bAbsQp; /* RW; Range:[0, 1]; QP mode of an ROI. 0: relative QP. 1: absolute QP.*/
  546. AX_S32 s32RoiQp; /* RW; Range: [-51, 51] when bAbsQp==0; [0, 51] when bAbsQp==1; */
  547. AX_RECT_S stRoiArea; /* RW; Region of an ROI*/
  548. } AX_VENC_ROI_ATTR_S;
  549. /* ROI struct */
  550. typedef struct axVENC_ROI_ATTR_EX_S
  551. {
  552. AX_U32 u32Index; /* RW; Range:[0, 7]; Index of an ROI. The system supports indexes ranging from 0 to 7 */
  553. AX_BOOL bEnable[3]; /* RW; Range:[0, 1]; Subscript of array 0: I Frame; 1: P/B Frame; 2: VI Frame; other params are the same. */
  554. AX_BOOL bAbsQp[3]; /* RW; Range:[0, 1]; QP mode of an ROI.HI_FALSE: relative QP.HI_TURE: absolute QP.*/
  555. AX_S32 s32Qp[3]; /* RW; Range:[-51, 51]; QP value,only relative mode can QP value less than 0. */
  556. AX_RECT_S stRect[3]; /* RW;Region of an ROI*/
  557. } AX_VENC_ROI_ATTR_EX_S;
  558. /* VENC CHANNEL STATUS struct */
  559. typedef struct axVENC_CHN_STATUS_S
  560. {
  561. AX_U32 u32LeftPics; /* R; Number of frames yet to encode (until fifo empty) */
  562. AX_U32 u32LeftStreamBytes; /* R; Number of bytes remaining in the bitstream buffer */
  563. AX_U32 u32LeftStreamFrames; /* R; Number of frames remaining in the bitstream buffer */
  564. AX_U32 u32CurPacks; /* R; Number of current stream packets. not support now */
  565. AX_U32 u32LeftRecvPics; /* R; Number of frames yet to recieve (total number specified at start). not support now */
  566. AX_U32 u32LeftEncPics; /* R; Number of frames yet to encode (total number specified at start). not support now */
  567. AX_U32 u32Reserved; /* R; Reserved */
  568. } AX_VENC_CHN_STATUS_S;
  569. /* the information of the user rc*/
  570. typedef struct axUSER_RC_INFO_S
  571. {
  572. AX_BOOL bQpMapValid; /* RW; Range:[0,1]; Indicates whether the QpMap mode is valid for the current frame*/
  573. AX_BOOL bIPCMMapValid; /* RW; Range:[0,1]; Indicates whether the IpcmMap mode is valid for the current frame*/
  574. AX_U32 u32BlkStartQp; /* RW; Range:[0,51];QP value of the first 16 x 16 block in QpMap mode */
  575. AX_U64 u64QpMapPhyAddr; /* RW; Physical address of the QP table in QpMap mode*/
  576. AX_S8* pQpMapVirAddr; /* RW: virtaul address of the qpMap */
  577. AX_U64 u64IpcmMapPhyAddr; /* RW; Physical address of the IPCM table in QpMap mode*/
  578. AX_FRAME_TYPE_E enFrameType; /* RW; Encoding frame type of the current frame */
  579. AX_U32 u32RoiMapDeltaSize; /* size of QpDelta map (per frame) */
  580. } AX_USER_RC_INFO_S;
  581. /* the information of the user frame*/
  582. typedef struct axUSER_FRAME_INFO_S
  583. {
  584. AX_VIDEO_FRAME_INFO_S stUserFrame;
  585. AX_USER_RC_INFO_S stUserRcInfo;
  586. } AX_USER_FRAME_INFO_S;
  587. /* error code */
  588. typedef enum
  589. {
  590. AX_ID_VENC_INNER = 0x01,
  591. AX_ID_VENC_COMMON = 0x02,
  592. /* reserved */
  593. } AX_ENC_SUB_ID_E;
  594. typedef enum
  595. {
  596. AX_ERR_ENC_CREATE_CHAN_ERR = 0x80, // create encoder channel failed
  597. AX_ERR_ENC_SET_PRIORITY_FAIL = 0x81, // set encoder thread priority failed
  598. } AX_ENC_ERR_CODE_E;
  599. /* video encoder error code by inner sub_module*/
  600. #define AX_ERR_VENC_CREATE_CHAN_ERR AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_ENC_CREATE_CHAN_ERR)
  601. #define AX_ERR_VENC_SET_PRIORITY_FAIL AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_ENC_SET_PRIORITY_FAIL)
  602. /* video encoder error code by common sub_module*/
  603. #define AX_ERR_VENC_NULL_PTR AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NULL_PTR)
  604. #define AX_ERR_VENC_ILLEGAL_PARAM AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_ILLEGAL_PARAM)
  605. #define AX_ERR_VENC_BAD_ADDR AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_BAD_ADDR)
  606. #define AX_ERR_VENC_NOT_SUPPORT AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NOT_SUPPORT)
  607. #define AX_ERR_VENC_NOT_INIT AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NOT_INIT)
  608. #define AX_ERR_VENC_BUF_EMPTY AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_BUF_EMPTY)
  609. #define AX_ERR_VENC_BUF_FULL AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_BUF_FULL)
  610. #define AX_ERR_VENC_QUEUE_EMPTY AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_QUEUE_EMPTY)
  611. #define AX_ERR_VENC_QUEUE_FULL AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_QUEUE_FULL)
  612. #define AX_ERR_VENC_EXIST AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_EXIST)
  613. #define AX_ERR_VENC_UNEXIST AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_UNEXIST)
  614. #define AX_ERR_VENC_NOT_PERMIT AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NOT_PERM)
  615. #define AX_ERR_VENC_UNKNOWN AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_UNKNOWN)
  616. #define AX_ERR_VENC_TIMEOUT AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_TIMED_OUT)
  617. #define AX_ERR_VENC_FLOW_END AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_FLOW_END)
  618. #define AX_ERR_VENC_ATTR_NOT_CFG AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NOT_CONFIG)
  619. #define AX_ERR_VENC_SYS_NOTREADY AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_SYS_NOTREADY)
  620. #define AX_ERR_VENC_INVALID_CHNID AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_INVALID_CHNID)
  621. #define AX_ERR_VENC_NOMEM AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NOMEM)
  622. #define AX_ERR_VENC_NOT_MATCH AX_DEF_ERR(AX_ID_VENC, AX_ID_VENC_COMMON, AX_ERR_NOT_MATCH)
  623. #ifdef __cplusplus
  624. }
  625. #endif /* End of #ifdef __cplusplus */
  626. #endif /* End of __AX_COMM_ENC_H__ */