hi_comm_vdec.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /******************************************************************************
  2. Copyright (C), 2016, Hisilicon Tech. Co., Ltd.
  3. ******************************************************************************
  4. File Name : hi_comm_vdec.h
  5. Version : Initial Draft
  6. Author : Hisilicon multimedia software group
  7. Created : 2016/07/15
  8. Last Modified :
  9. Description : Common defination Of video decode
  10. Function List :
  11. ******************************************************************************/
  12. #ifndef __HI_COMM_VDEC_H__
  13. #define __HI_COMM_VDEC_H__
  14. #include "hi_type.h"
  15. #include "hi_common.h"
  16. #include "hi_errno.h"
  17. #include "hi_comm_video.h"
  18. #include "hi_comm_vb.h"
  19. #include "hi_defines.h"
  20. #ifdef __cplusplus
  21. #if __cplusplus
  22. extern "C"{
  23. #endif
  24. #endif /* End of #ifdef __cplusplus */
  25. #define HI_IO_BLOCK HI_TRUE
  26. #define HI_IO_NOBLOCK HI_FALSE
  27. typedef enum hiVIDEO_MODE_E
  28. {
  29. VIDEO_MODE_STREAM = 0, /* send by stream */
  30. VIDEO_MODE_FRAME , /* send by frame */
  31. VIDEO_MODE_COMPAT , /* One frame supports multiple packets sending. The current frame is considered to end when bEndOfFrame is equal to HI_TRUE */
  32. VIDEO_MODE_BUTT
  33. }VIDEO_MODE_E;
  34. typedef struct hiVDEC_ATTR_VIDEO_S
  35. {
  36. HI_U32 u32RefFrameNum; /* RW, Range: [0, 16]; reference frame num. */
  37. HI_BOOL bTemporalMvpEnable; /* RW; specifies whether temporal motion vector predictors can be used for inter prediction */
  38. HI_U32 u32TmvBufSize; /* RW; tmv buffer size(Byte) */
  39. }VDEC_ATTR_VIDEO_S;
  40. typedef struct hiVDEC_CHN_ATTR_S
  41. {
  42. PAYLOAD_TYPE_E enType; /* RW; video type to be decoded */
  43. VIDEO_MODE_E enMode; /* RW; send by stream or by frame */
  44. HI_U32 u32PicWidth; /* RW; max pic width */
  45. HI_U32 u32PicHeight; /* RW; max pic height */
  46. HI_U32 u32StreamBufSize; /* RW; stream buffer size(Byte) */
  47. HI_U32 u32FrameBufSize; /* RW; frame buffer size(Byte) */
  48. HI_U32 u32FrameBufCnt;
  49. union
  50. {
  51. VDEC_ATTR_VIDEO_S stVdecVideoAttr; /* structure with video ( h264/h265) */
  52. };
  53. }VDEC_CHN_ATTR_S;
  54. typedef struct hiVDEC_STREAM_S
  55. {
  56. HI_U32 u32Len; /* W; stream len */
  57. HI_U64 u64PTS; /* W; time stamp */
  58. HI_BOOL bEndOfFrame; /* W; is the end of a frame */
  59. HI_BOOL bEndOfStream; /* W; is the end of all stream */
  60. HI_BOOL bDisplay; /* W; is the current frame displayed. only valid by VIDEO_MODE_FRAME */
  61. HI_U8* ATTRIBUTE pu8Addr; /* W; stream address */
  62. }VDEC_STREAM_S;
  63. typedef struct hiVDEC_USERDATA_S
  64. {
  65. HI_U64 u64PhyAddr; /* R; userdata data phy address */
  66. HI_U32 u32Len; /* R; userdata data len */
  67. HI_BOOL bValid; /* R; is valid? */
  68. HI_U8* ATTRIBUTE pu8Addr; /* R; userdata data vir address */
  69. }VDEC_USERDATA_S;
  70. typedef struct hi_VDEC_DECODE_ERROR_S
  71. {
  72. HI_S32 s32FormatErr; /* R; format error. eg: do not support filed */
  73. HI_S32 s32PicSizeErrSet; /* R; picture width or height is larger than chnnel width or height*/
  74. HI_S32 s32StreamUnsprt; /* R; unsupport the stream specification */
  75. HI_S32 s32PackErr; /* R; stream package error */
  76. HI_S32 s32PrtclNumErrSet; /* R; protocol num is not enough. eg: slice, pps, sps */
  77. HI_S32 s32RefErrSet; /* R; refrence num is not enough */
  78. HI_S32 s32PicBufSizeErrSet; /* R; the buffer size of picture is not enough */
  79. HI_S32 s32StreamSizeOver; /* R; the stream size is too big and and force discard stream */
  80. HI_S32 s32VdecStreamNotRelease; /* R; the stream not released for too long time */
  81. }VDEC_DECODE_ERROR_S;
  82. typedef struct hiVDEC_CHN_STATUS_S
  83. {
  84. PAYLOAD_TYPE_E enType; /* R; video type to be decoded */
  85. HI_U32 u32LeftStreamBytes; /* R; left stream bytes waiting for decode */
  86. HI_U32 u32LeftStreamFrames; /* R; left frames waiting for decode,only valid for VIDEO_MODE_FRAME*/
  87. HI_U32 u32LeftPics; /* R; pics waiting for output */
  88. HI_BOOL bStartRecvStream; /* R; had started recv stream? */
  89. HI_U32 u32RecvStreamFrames; /* R; how many frames of stream has been received. valid when send by frame. */
  90. HI_U32 u32DecodeStreamFrames; /* R; how many frames of stream has been decoded. valid when send by frame. */
  91. VDEC_DECODE_ERROR_S stVdecDecErr; /* R; information about decode error */
  92. }VDEC_CHN_STATUS_S;
  93. typedef enum hiVIDEO_DEC_MODE_E
  94. {
  95. VIDEO_DEC_MODE_IPB = 0,
  96. VIDEO_DEC_MODE_IP,
  97. VIDEO_DEC_MODE_I,
  98. VIDEO_DEC_MODE_BUTT
  99. }VIDEO_DEC_MODE_E;
  100. typedef enum hiVIDEO_OUTPUT_ORDER_E
  101. {
  102. VIDEO_OUTPUT_ORDER_DISP = 0,
  103. VIDEO_OUTPUT_ORDER_DEC,
  104. VIDEO_OUTPUT_ORDER_BUTT
  105. }VIDEO_OUTPUT_ORDER_E;
  106. typedef struct hiVDEC_PARAM_VIDEO_S
  107. {
  108. HI_S32 s32ErrThreshold; /* RW, Range: [0, 100]; threshold for stream error process, 0: discard with any error, 100 : keep data with any error */
  109. VIDEO_DEC_MODE_E enDecMode; /* RW; decode mode , 0: deocde IPB frames, 1: only decode I frame & P frame , 2: only decode I frame */
  110. VIDEO_OUTPUT_ORDER_E enOutputOrder; /* RW; frames output order ,0: the same with display order , 1: the same width decoder order */
  111. COMPRESS_MODE_E enCompressMode; /* RW; compress mode */
  112. VIDEO_FORMAT_E enVideoFormat; /* RW; video format */
  113. }VDEC_PARAM_VIDEO_S;
  114. typedef struct hiVDEC_PARAM_PICTURE_S
  115. {
  116. PIXEL_FORMAT_E enPixelFormat; /* RW; out put pixel format */
  117. HI_U32 u32Alpha; /* RW, Range: [0, 255]; value 0 is transparent.
  118. [0 ,127] is deemed to transparent when enPixelFormat is ARGB1555 or ABGR1555
  119. [128 ,256] is deemed to non-transparent when enPixelFormat is ARGB1555 or ABGR1555 */
  120. }VDEC_PARAM_PICTURE_S;
  121. typedef struct hiVDEC_CHN_PARAM_S
  122. {
  123. PAYLOAD_TYPE_E enType; /* RW; video type to be decoded */
  124. HI_U32 u32DisplayFrameNum; /* RW, Range: [0, 16]; display frame num */
  125. union
  126. {
  127. VDEC_PARAM_VIDEO_S stVdecVideoParam; /* structure with video ( h265/h264) */
  128. VDEC_PARAM_PICTURE_S stVdecPictureParam; /* structure with picture (jpeg/mjpeg )*/
  129. };
  130. }VDEC_CHN_PARAM_S;
  131. typedef struct hiH264_PRTCL_PARAM_S
  132. {
  133. HI_S32 s32MaxSliceNum; /* RW; max slice num support */
  134. HI_S32 s32MaxSpsNum; /* RW; max sps num support */
  135. HI_S32 s32MaxPpsNum; /* RW; max pps num support */
  136. }H264_PRTCL_PARAM_S;
  137. typedef struct hiH265_PRTCL_PARAM_S
  138. {
  139. HI_S32 s32MaxSliceSegmentNum; /* RW; max slice segmnet num support */
  140. HI_S32 s32MaxVpsNum; /* RW; max vps num support */
  141. HI_S32 s32MaxSpsNum; /* RW; max sps num support */
  142. HI_S32 s32MaxPpsNum; /* RW; max pps num support */
  143. }H265_PRTCL_PARAM_S;
  144. typedef struct hiVDEC_PRTCL_PARAM_S
  145. {
  146. PAYLOAD_TYPE_E enType; /* RW; video type to be decoded, only h264 and h265 supported*/
  147. union
  148. {
  149. H264_PRTCL_PARAM_S stH264PrtclParam; /* protocol param structure for h264 */
  150. H265_PRTCL_PARAM_S stH265PrtclParam; /* protocol param structure for h265 */
  151. };
  152. }VDEC_PRTCL_PARAM_S;
  153. typedef struct hiVDEC_CHN_POOL_S
  154. {
  155. VB_POOL hPicVbPool; /* RW; vb pool id for pic buffer */
  156. VB_POOL hTmvVbPool; /* RW; vb pool id for tmv buffer */
  157. }VDEC_CHN_POOL_S;
  158. typedef enum hiVDEC_EVNT_E
  159. {
  160. VDEC_EVNT_STREAM_ERR = 1,
  161. VDEC_EVNT_UNSUPPORT,
  162. VDEC_EVNT_OVER_REFTHR,
  163. VDEC_EVNT_REF_NUM_OVER,
  164. VDEC_EVNT_SLICE_NUM_OVER,
  165. VDEC_EVNT_SPS_NUM_OVER,
  166. VDEC_EVNT_PPS_NUM_OVER,
  167. VDEC_EVNT_PICBUF_SIZE_ERR,
  168. VDEC_EVNT_SIZE_OVER,
  169. VDEC_EVNT_IMG_SIZE_CHANGE,
  170. VDEC_EVNT_VPS_NUM_OVER,
  171. VDEC_EVNT_BUTT
  172. } VDEC_EVNT_E;
  173. typedef struct hiVDEC_VIDEO_MOD_PARAM_S
  174. {
  175. HI_U32 u32MaxPicWidth;
  176. HI_U32 u32MaxPicHeight;
  177. HI_U32 u32MaxSliceNum;
  178. HI_U32 u32VdhMsgNum;
  179. HI_U32 u32VdhBinSize;
  180. HI_U32 u32VdhExtMemLevel;
  181. } VDEC_VIDEO_MOD_PARAM_S;
  182. typedef struct hiVDEC_MOD_PARAM_S
  183. {
  184. VB_SOURCE_E enVdecVBSource; /* RW, Range: [1, 3]; frame buffer mode */
  185. HI_U32 u32MiniBufMode; /* RW, Range: [0, 1]; stream buffer mode */
  186. HI_U32 u32ParallelMode; /* RW, Range: [0, 1]; VDH working mode */
  187. VDEC_VIDEO_MOD_PARAM_S stVideoModParam;
  188. } VDEC_MOD_PARAM_S;
  189. /************************************************************************************************************************/
  190. /* invlalid channel ID */
  191. #define HI_ERR_VDEC_INVALID_CHNID HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
  192. /* at lease one parameter is illagal ,eg, an illegal enumeration value */
  193. #define HI_ERR_VDEC_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
  194. /* channel exists */
  195. #define HI_ERR_VDEC_EXIST HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST)
  196. /* using a NULL point */
  197. #define HI_ERR_VDEC_NULL_PTR HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
  198. /* try to enable or initialize system,device or channel, before configing attribute */
  199. #define HI_ERR_VDEC_NOT_CONFIG HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG)
  200. /* operation is not supported by NOW */
  201. #define HI_ERR_VDEC_NOT_SUPPORT HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
  202. /* operation is not permitted ,eg, try to change stati attribute */
  203. #define HI_ERR_VDEC_NOT_PERM HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
  204. /* the channle is not existed */
  205. #define HI_ERR_VDEC_UNEXIST HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
  206. /* failure caused by malloc memory */
  207. #define HI_ERR_VDEC_NOMEM HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
  208. /* failure caused by malloc buffer */
  209. #define HI_ERR_VDEC_NOBUF HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
  210. /* no data in buffer */
  211. #define HI_ERR_VDEC_BUF_EMPTY HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
  212. /* no buffer for new data */
  213. #define HI_ERR_VDEC_BUF_FULL HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL)
  214. /* system is not ready,had not initialed or loaded*/
  215. #define HI_ERR_VDEC_SYS_NOTREADY HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
  216. /*system busy*/
  217. #define HI_ERR_VDEC_BUSY HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
  218. /* bad address, eg. used for copy_from_user & copy_to_user */
  219. #define HI_ERR_VDEC_BADADDR HI_DEF_ERR(HI_ID_VDEC, EN_ERR_LEVEL_ERROR, EN_ERR_BADADDR)
  220. #ifdef __cplusplus
  221. #if __cplusplus
  222. }
  223. #endif
  224. #endif /* End of #ifdef __cplusplus */
  225. #endif /* End of #ifndef __HI_COMM_VDEC_H__ */