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_VDEC_H_ 5 6 #define INCLUDE_RT_MPI_RK_COMM_VDEC_H_ 7 #include "rk_type.h" 8 #include "rk_common.h" 9 #include "rk_errno.h" 10 #include "rk_comm_video.h" 11 #include "rk_comm_mb.h" 12 13 #ifdef __cplusplus 14 #if __cplusplus 15 extern "C" { 16 #endif 17 #endif /* End of #ifdef __cplusplus */ 18 19 #define RK_IO_BLOCK RK_TRUE 20 #define RK_IO_NOBLOCK RK_FALSE 21 22 typedef enum rkVIDEO_DEC_MODE_E { 23 VIDEO_DEC_MODE_IPB = 0, 24 VIDEO_DEC_MODE_IP, 25 VIDEO_DEC_MODE_I, 26 VIDEO_DEC_MODE_BUTT 27 } VIDEO_DEC_MODE_E; 28 29 typedef enum rkVIDEO_OUTPUT_ORDER_E { 30 VIDEO_OUTPUT_ORDER_DISP = 0, 31 VIDEO_OUTPUT_ORDER_DEC, 32 VIDEO_OUTPUT_ORDER_BUTT 33 } VIDEO_OUTPUT_ORDER_E; 34 35 typedef enum rkVIDEO_MODE_E { 36 VIDEO_MODE_STREAM = 0, /* send by stream */ 37 VIDEO_MODE_FRAME, /* send by frame */ 38 VIDEO_MODE_COMPAT, /* One frame supports multiple packets sending. */ 39 /* The current frame is considered to end when bEndOfFrame is equal to RK_TRUE */ 40 VIDEO_MODE_BUTT 41 } VIDEO_MODE_E; 42 43 typedef struct rkVDEC_PARAM_VIDEO_S { 44 RK_BOOL bDeiEn; /* RW, deinterlace enable */ 45 RK_S32 s32ErrThreshold; /* RW, Range: [0, 100]; */ 46 /* threshold for stream error process, 0: discard with any error, 100 : keep data with any error */ 47 VIDEO_DEC_MODE_E enDecMode; /* RW; */ 48 /* decode mode , 0: deocde IPB frames, 1: only decode I frame & P frame , 2: only decode I frame */ 49 VIDEO_OUTPUT_ORDER_E enOutputOrder; /* RW; */ 50 /* frames output order ,0: the same with display order , 1: the same width decoder order */ 51 COMPRESS_MODE_E enCompressMode; /* RW; compress mode */ 52 VIDEO_FORMAT_E enVideoFormat; /* RW; video format */ 53 } VDEC_PARAM_VIDEO_S; 54 55 typedef struct rkVDEC_PARAM_PICTURE_S { 56 PIXEL_FORMAT_E enPixelFormat; /* RW; out put pixel format */ 57 RK_U32 u32Alpha; /* RW, Range: [0, 255]; value 0 is transparent. */ 58 /* [0 ,127] is deemed to transparent when enPixelFormat is ARGB1555 or ABGR1555 59 * [128 ,256] is deemed to non-transparent when enPixelFormat is ARGB1555 or ABGR1555 60 */ 61 } VDEC_PARAM_PICTURE_S; 62 63 typedef struct rkVDEC_CHN_PARAM_S { 64 RK_CODEC_ID_E enType; /* RW; video type to be decoded */ 65 RK_U32 u32DisplayFrameNum; /* RW, Range: [0, 16]; display frame num */ 66 union { 67 VDEC_PARAM_VIDEO_S stVdecVideoParam; /* structure with video ( h265/h264/mpeg2/mpeg4) */ 68 VDEC_PARAM_PICTURE_S stVdecPictureParam; /* structure with picture (jpeg/mjpeg ) */ 69 }; 70 } VDEC_CHN_PARAM_S; 71 72 typedef struct rkVDEC_ATTR_VIDEO_S { 73 RK_U32 u32RefFrameNum; /* RW, Range: [0, 16]; reference frame num. */ 74 RK_BOOL bTemporalMvpEnable; /* RW; */ 75 /* specifies whether temporal motion vector predictors can be used for inter prediction */ 76 RK_U32 u32TmvBufSize; /* RW; tmv buffer size(Byte) */ 77 } VDEC_ATTR_VIDEO_S; 78 79 typedef struct rkVDEC_CHN_ATTR_S { 80 VIDEO_MODE_E enMode; 81 RK_CODEC_ID_E enType; /* RW; video type to be decoded */ 82 RK_U32 u32PicWidth; /* RW; pic width */ 83 RK_U32 u32PicHeight; /* RW; pic height */ 84 RK_U32 u32PicVirWidth; /* RW; pic virtual width */ 85 RK_U32 u32PicVirHeight; /* RW; pic virtual height */ 86 RK_U32 u32StreamBufSize; /* RW; stream buffer size(Byte) */ 87 RK_U32 u32FrameBufSize; /* RW; frame buffer size(Byte) */ 88 RK_U32 u32FrameBufCnt; /* RW; frame buffer cnt */ 89 RK_U32 u32StreamBufCnt; /* RW; stream buffer cnt */ 90 union { 91 VDEC_ATTR_VIDEO_S stVdecVideoAttr; /* structure with video ( h264/h265) */ 92 }; 93 } VDEC_CHN_ATTR_S; 94 95 typedef struct rkVDEC_STREAM_S { 96 MB_BLK pMbBlk; 97 RK_U32 u32Len; /* W; stream len */ 98 RK_U64 u64PTS; /* W; time stamp */ 99 RK_BOOL bEndOfStream; /* W; is the end of all stream */ 100 RK_BOOL bEndOfFrame; /* W; is the end of frame */ 101 RK_BOOL bBypassMbBlk; /* FALSE: copy, TRUE: MbBlock owned by internal */ 102 } VDEC_STREAM_S; 103 104 typedef struct rkVDEC_DECODE_ERROR_S { 105 RK_S32 s32FormatErr; /* R; format error. eg: do not support filed */ 106 RK_S32 s32PicSizeErrSet; /* R; picture width or height is larger than chnnel width or height */ 107 RK_S32 s32StreamUnsprt; /* R; unsupport the stream specification */ 108 RK_S32 s32PackErr; /* R; stream package error */ 109 RK_S32 s32PrtclNumErrSet; /* R; protocol num is not enough. eg: slice, pps, sps */ 110 RK_S32 s32RefErrSet; /* R; refrence num is not enough */ 111 RK_S32 s32PicBufSizeErrSet; /* R; the buffer size of picture is not enough */ 112 RK_S32 s32StreamSizeOver; /* R; the stream size is too big and and force discard stream */ 113 RK_S32 s32VdecStreamNotRelease; /* R; the stream not released for too long time */ 114 } VDEC_DECODE_ERROR_S; 115 116 typedef struct rkVDEC_CHN_STATUS_S { 117 RK_CODEC_ID_E enType; /* R; video type to be decoded */ 118 RK_U32 u32LeftStreamBytes; /* R; left stream bytes waiting for decode */ 119 RK_U32 u32LeftStreamFrames; /* R; left frames waiting for decode,only valid for VIDEO_MODE_FRAME */ 120 RK_U32 u32LeftPics; /* R; pics waiting for output */ 121 RK_BOOL bStartRecvStream; /* R; had started recv stream? */ 122 RK_U32 u32RecvStreamFrames; /* R; how many frames of stream has been received. valid when send by frame. */ 123 RK_U32 u32DecodeStreamFrames; /* R; how many frames of stream has been decoded. valid when send by frame. */ 124 VDEC_DECODE_ERROR_S stVdecDecErr; /* R; information about decode error */ 125 RK_U32 u32Width; 126 RK_U32 u32Height; 127 } VDEC_CHN_STATUS_S; 128 129 typedef enum rkVDEC_EVNT_E { 130 VDEC_EVNT_STREAM_ERR = 1, 131 VDEC_EVNT_UNSUPPORT, 132 VDEC_EVNT_OVER_REFTHR, 133 VDEC_EVNT_REF_NUM_OVER, 134 VDEC_EVNT_SLICE_NUM_OVER, 135 VDEC_EVNT_SPS_NUM_OVER, 136 VDEC_EVNT_PPS_NUM_OVER, 137 VDEC_EVNT_PICBUF_SIZE_ERR, 138 VDEC_EVNT_SIZE_OVER, 139 VDEC_EVNT_IMG_SIZE_CHANGE, 140 VDEC_EVNT_VPS_NUM_OVER, 141 VDEC_EVNT_BUTT 142 } VDEC_EVNT_E; 143 144 typedef struct rkVDEC_PICTURE_MOD_PARAM_S { 145 RK_U32 u32MaxPicWidth; 146 RK_U32 u32MaxPicHeight; 147 RK_BOOL bSupportProgressive; 148 RK_BOOL bDynamicAllocate; 149 } VDEC_PICTURE_MOD_PARAM_S; 150 151 typedef struct rkVDEC_VIDEO_MOD_PARAM_S { 152 RK_U32 u32MaxPicWidth; 153 RK_U32 u32MaxPicHeight; 154 RK_U32 u32MaxSliceNum; 155 RK_U32 u32VdhMsgNum; 156 RK_U32 u32VdhBinSize; 157 RK_U32 u32VdhExtMemLevel; 158 } VDEC_VIDEO_MOD_PARAM_S; 159 160 typedef struct rkVDEC_MOD_PARAM_S { 161 MB_SOURCE_E enVdecMBSource; /* RW, Range: [1, 3]; frame buffer mode */ 162 RK_U32 u32MiniBufMode; /* RW, Range: [0, 1]; stream buffer mode */ 163 RK_U32 u32ParallelMode; /* RW, Range: [0, 1]; VDH working mode */ 164 VDEC_VIDEO_MOD_PARAM_S stVideoModParam; 165 VDEC_PICTURE_MOD_PARAM_S stPictureModParam; 166 } VDEC_MOD_PARAM_S; 167 168 /*********************************************************************************************/ 169 /* invlalid channel ID */ 170 #define RK_ERR_VDEC_INVALID_CHNID RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_INVALID_CHNID) 171 /* at lease one parameter is illagal ,eg, an illegal enumeration value */ 172 #define RK_ERR_VDEC_ILLEGAL_PARAM RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_ILLEGAL_PARAM) 173 /* channel exists */ 174 #define RK_ERR_VDEC_EXIST RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_EXIST) 175 /* using a NULL point */ 176 #define RK_ERR_VDEC_NULL_PTR RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NULL_PTR) 177 /* try to enable or initialize system,device or channel, before configing attribute */ 178 #define RK_ERR_VDEC_NOT_CONFIG RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_CONFIG) 179 /* operation is not supported by NOW */ 180 #define RK_ERR_VDEC_NOT_SUPPORT RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_SUPPORT) 181 /* operation is not permitted ,eg, try to change stati attribute */ 182 #define RK_ERR_VDEC_NOT_PERM RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOT_PERM) 183 /* the channle is not existed */ 184 #define RK_ERR_VDEC_UNEXIST RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_UNEXIST) 185 /* failure caused by malloc memory */ 186 #define RK_ERR_VDEC_NOMEM RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOMEM) 187 /* failure caused by malloc buffer */ 188 #define RK_ERR_VDEC_NOBUF RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOBUF) 189 /* no data in buffer */ 190 #define RK_ERR_VDEC_BUF_EMPTY RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_EMPTY) 191 /* no buffer for new data */ 192 #define RK_ERR_VDEC_BUF_FULL RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_BUF_FULL) 193 /* system is not ready,had not initialed or loaded */ 194 #define RK_ERR_VDEC_SYS_NOTREADY RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_NOTREADY) 195 /* system busy */ 196 #define RK_ERR_VDEC_BUSY RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_BUSY) 197 /* bad address, eg. used for copy_from_user & copy_to_user */ 198 #define RK_ERR_VDEC_BADADDR RK_DEF_ERR(RK_ID_VDEC, RK_ERR_LEVEL_ERROR, RK_ERR_BADADDR) 199 200 #ifdef __cplusplus 201 #if __cplusplus 202 } 203 #endif 204 #endif /* End of #ifdef __cplusplus */ 205 206 #endif /* End of #ifndef INCLUDE_RT_MPI_RK_COMM_VDEC_H_ */ 207 208 209