#ifndef _VDEC_DRV_MPEG4_INFO_H_ #define _VDEC_DRV_MPEG4_INFO_H_ #include "drv_common.h" #include "vdec_common_if.h" #include "vdec_usage.h" #include "vdec_info_mpeg.h" #include "vdec_info_common.h" #define DISP_DUMMY_FRM #define VDEC_DEC_DUMMY_FRM #define VDEC_USE_MW_DXINFO #define VDEC_SUPPORT_HIGH_FRAME_RATE #if (CONFIG_CHIP_VER_CURR < CONFIG_CHIP_VER_MT8550) #define VDEC_MPEG4_SUPPORT_RESYNC_MARKER #endif /****************************************************************************** * brief MPEG4 log monitor level ******************************************************************************/ #define VDEC_MPEG4_SYSTEM_MONITOR 1 #define VDEC_MPEG4_ERROR_MONITOR 2 #define VDEC_MPEG4_PTS_MONITOR 4 #define VDEC_MPEG4_SEQ_HEADER_PARSER_MONITOR 6 #define VDEC_MPEG4_VOP_HEADER_PARSER_MONITOR 7 #define VDEC_MPEG4_ALL_MONITOR 9 /****************************************************************************** * Local definition ******************************************************************************/ /*! \name MPEG4 Video Start Code * @{ */ /// Video Start Code #define VIDEO_START_CODE 0x00000100 /// Video Object Start Code Min #define VIDEO_OBJECT_START_CODE_MIN 0x100 /// Video Object Start Code Max #define VIDEO_OBJECT_START_CODE_MAX 0x11F /// Video Object Layer Start Code Min #define VIDEO_OBJECT_LAYER_START_CODE_MIN 0x120 /// Video Object Start Code Max #define VIDEO_OBJECT_LAYER_START_CODE_MAX 0x12F /// Visual Object Sequence Start Code #define VISUAL_OBJECT_SEQUENCE_START_CODE 0x1B0 /// Visual Object Sequence End Code #define VISUAL_OBJECT_SEQUENCE_END_CODE 0x1B1 /// User Data Start Code #define USER_DATA_START_CODE 0x1B2 /// Group of Vop Start Code #define GROUP_OF_VOP_START_CODE 0x1B3 /// Video Session Error Code #define VIDEO_SESSION_ERROR_CODE 0x1B4 /// Visual Object Start Code #define VISUAL_OBJECT_START_CODE 0x1B5 #define VOP_START_CODE 0x1B6 //Reserved 0x1B7, 0x1B8, 0x1B9 /// FBA Object Start Code #define FBA_OBJ_START_CODE 0X1BA /// FBA Object Plane Start Code #define FBA_OBJ_PLANE_START_CODE 0x1BB /// Mesh Object Start Code #define MESH_OBJ_START_CODE 0x1BC /// Mesh Object Plane Start Code #define MESH_OBJ_PLANE_START_CODE 0x1BD /// Still Texture Object Start Code #define STILL_TEXT_OBJ_START_CODE 0x1BE /// Texture Spatial Layer Start Code #define TEXT_SPT_LAYER_START_CODE 0x1BF /// Texture SNR Layer Start Code #define TEXT_SNR_LAYER_START_CODE 0x1C0 /// Texture Tile Start Code #define TEXT_TIL_START_CODE 0x1C1 /// Texture Shape Layer Start Code #define TEXT_SHP_LAYER_START_CODE 0x1C2 /// Stuffing Start Code #define STUFFING_START_CODE 0x1C3 //Reserved 0x1C4, 0x1C5 /// System Start Code Min #define SYSTEM_START_CODE_MIN 0x1C6 /// System Start Code Max #define SYSTEM_START_CODE_MAX 0x1CF /// Short Video Start Code Mask #define SHORT_VIDEO_START_MASK 0xfffffc00 /// Short Video Start Code Marker #define SHORT_VIDEO_START_MARKER 0x00008000 #define SORENSON_H263_START_MASK 0xffff8000 #define SORENSON_H263_START_MARKER 0x00008000 /*! @} */ /// Video Object Type Definition //Reserved 0x0 #define VIDEO_ID 0x1 #define STILL_TEXT_ID 0x2 #define MESH_ID 0x3 #define FBA_ID 0x4 #define MESH_3D_ID 0x5 #define EXTENDED_PAR 0xf /// Video Shape Definition: Regular, Binary, Binary Only, GrayScale #define RECTANGULAR_SHAPE 0x0 #define BINARY_SHAPE 0x1 #define BINARY_ONLY_SHAPE 0x2 #define GRAYSCALE_SHAPE 0x3 /// Sprite Mode: Not Used, Static, GMC #define SPRITE_NOTE_USED 0x0 #define SPRITE_STATIC 0x1 #define SPRITE_GMC 0x2 #define SPRITE_RESERVED 0x3 /// Default Video Horizontal Size #define DEFAULT_H_SIZE 720 /// Default Video Vertical Size #define DEFAULT_V_SIZE 480 /// MPEG4 Decoder Picture Buffer Number #define MPEG4_DPB_NUM 3 /// Sprite Warping Error Code #define WARPING_PT_ERR 0x00000402 #define fgIsMPEG4VideoStartCode(arg) ((arg & 0xFFFFFF00) == VIDEO_START_CODE) #define fgPureIsoM4v() (FALSE) #define u4Div2Slash(v1, v2) (((v1)+(v2)/2)/(v2)) #ifndef VDEC_DEC_DUMMY_FRM #define fgIsMPEG4RefPic(arg) ( ((arg&0xFF) == I_VOP) || \ ((arg&0xFF) == SH_I_VOP) || \ ((arg&0xFF) == DX3_I_FRM) || \ ((arg&0xFF) == P_TYPE) || \ ((arg&0xFF) == P_VOP) || \ ((arg&0xFF) == S_VOP) ||\ ((arg&0xFF) == SH_I_VOP)||\ ((arg&0xFF) == SH_P_VOP) ||\ ((arg&0xFF) == DUMMY_FRM) ||\ ((arg&0xFF) == DX3_P_FRM)) #else #define fgIsMPEG4RefPic(arg) ( ((arg&0xFF) == I_VOP) || \ ((arg&0xFF) == SH_I_VOP) || \ ((arg&0xFF) == DX3_I_FRM) || \ ((arg&0xFF) == P_TYPE) || \ ((arg&0xFF) == P_VOP) || \ ((arg&0xFF) == S_VOP) ||\ ((arg&0xFF) == SH_I_VOP)||\ ((arg&0xFF) == SH_P_VOP) ||\ ((arg&0xFF) == DX3_P_FRM)) #endif /*! \name MPEG4 Working Buffer Size * @{ * \ingroup Private */ #if 0 #ifdef WRITE_FULL_DCAC_DATA #define DCAC_SZ ((((1920 / 16) * 4) * ((1088 / 16) * 4)) * 4) // (MBx * 4) * (MBy * 4) = 25920 #else #define DCAC_SZ ((((1920 / 16) * 4) * (4)) * 4) // (MBx * 4) * (4) = 7680 #endif #define MVEC_SZ (((1920 / 16) * 4 * (1088 / 16)) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB1_SZ (((1920 / 16) * 4 * (1088 / 16)) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB2_SZ (((1920 / 16) * 4 * (1088 / 16)) * 4) // (MBx * 4) * (MBy) = 6480 #define BCODE_SZ (((1920 / 16) * 2) * 4) // (MBx * 2) = 90 #else #ifdef WRITE_FULL_DCAC_DATA #if (CONFIG_CHIP_VER_CURR < CONFIG_CHIP_VER_MT8580) #define DCAC_SZ_W ((1920 / 16) * 4) #define DCAC_SZ_H ((1088 / 16) * 4 * 4) // (MBx * 4) * (MBy * 4) = 25920 #else//>=MT8580 #define DCAC_SZ_W ((4096 / 16) * 4) #define DCAC_SZ_H ((2048 / 16) * 4 * 4) // (MBx * 4) * (MBy * 4) = 25920 #endif #else #if (CONFIG_CHIP_VER_CURR < CONFIG_CHIP_VER_MT8580) #define DCAC_SZ_W ((1920 / 16) * 4) // (MBx * 4) * (4) = 7680 #define DCAC_SZ_H (4 * 4) #else//>=MT8580 #define DCAC_SZ_W ((4096 / 16) * 4) // (MBx * 4) * (4) = 7680 #define DCAC_SZ_H (4 * 4) #endif #endif #if (CONFIG_CHIP_VER_CURR < CONFIG_CHIP_VER_MT8580) #define MVEC_SZ_W ((1920 / 16) *4) // (MBx * 4) * (MBy) = 6480 #define MVEC_SZ_H ((1088 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB1_SZ_W ((1920 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB1_SZ_H ((1088 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB2_SZ_W ((1920 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB2_SZ_H ((1088 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BCODE_SZ_W ((1920 / 16) * 2) // (MBx * 2) = 90 #define BCODE_SZ_H (4) // (MBx * 2) = 90 #else #define MVEC_SZ_W ((4096 / 16) *4) // (MBx * 4) * (MBy) = 6480 #define MVEC_SZ_H ((2048 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB1_SZ_W ((4096 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB1_SZ_H ((2048 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB2_SZ_W ((4096 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BMB2_SZ_H ((2048 / 16) * 4) // (MBx * 4) * (MBy) = 6480 #define BCODE_SZ_W ((4096 / 16) * 8) // (MBx * 8) = 90,is difference with > 8) + ((value & 0xFF000000) >> 24)) /// \ingroup VLD #define CCSIZE(wp, rp, bufsize) \ (((wp) >= (rp)) ? ((wp) - (rp)) : (((bufsize) + (wp)) - (rp))) /// \ingroup VLD #define INVERSE_BIT_ORDER_8(value) \ { \ UCHAR ucTemp = 0; \ INT32 i4_i; \ for( i4_i = 0; i4_i<4; i4_i++) \ { \ ucTemp |= (value & (1 << i4_i)) << ((4-i4_i)*2 - 1); \ } \ for( i4_i = 4; i4_i<8; i4_i++) \ { \ ucTemp |= (value & (1 << i4_i)) >> ((i4_i-4)*2 + 1); \ } \ value = ucTemp; \ } /*! \name MPEG4 Driver API * @{ */ /// \ingroup API /// This function allocates memory for driver information /// - This API can should be called in the begining. /// . /// \return None. extern void vMPEG4InitProc( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function parse mpeg4 bitstream headers /// - This API can should be called before starting to decode. /// . /// \return parsing result. Please reference to Vdec_errcode.h extern INT32 i4MPEG4VParseProc( UCHAR ucEsId, ///< [IN] the ID of the elementary stream UINT32 u4VParseType ///< [IN] the specified pic type or header ); /// This function checks the parsing result. /// \return VDEC_NONE_ERROR: parse OK. Else: please reference to Vdec_errcode.h extern BOOL fgMPEG4VParseChkProc( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function updates information to Frame Buffer Group /// \return VDEC_NONE_ERROR: udate OK. Else: please reference to Vdec_errcode.h extern INT32 i4MPEG4UpdInfoToFbg( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function triggers Video decoder hardware ///\ return None. extern void vMPEG4StartToDecProc( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function is interrrupt service routine ///\ return None. extern void vMPEG4ISR( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function checks the decoded picture is complete or not /// - This API will check decoded picture in MB_X and MB_Y /// . ///\ return TRUE: decode OK, FALSE: decoding failed, drop it extern BOOL fgIsMPEG4DecEnd( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function checks the decoded error type and count /// - This API will check decoded error type and count /// . ///\ return TRUE: decode error, FALSE: decode correct extern BOOL fgIsMPEG4DecErr( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function checks is there any error code happened in HW ///\ return TRUE: decode OK, FALSE: decoding failed, drop it extern BOOL fgMPEG4ResultChk( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function sets up frame buffer index ready for display ///\ return TRUE: buffer index for display OK, FALSE: cannot get buffer for display extern BOOL fgIsMPEG4InsToDispQ( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function gets one decoded frame buffer and send to display ///\ return TRUE: get frame buffer OK, FALSE: Cannot get buffer for display extern BOOL fgIsMPEG4GetFrmToDispQ( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function does ending procedure ///\ return None. extern void vMPEG4EndProc( UCHAR ucEsId ///< [IN] the ID of the elementary stream ); /// This function flushes all decoded picture in DPB Buffer ///\ return TRUE: flush OK, FALSE: cannot get buffer for display extern BOOL fgMPEG4FlushDPB( UCHAR ucEsId, ///< [IN] the ID of the elementary stream BOOL fgWithOutput ///< [IN] '1' indicates to output decoded frame ); /// This function will release resources accupied by decoder ///\ return None. extern void vMPEG4ReleaseProc( UCHAR ucEsId, ///< [IN] the ID of the elementary stream BOOL fgResetHW ); extern void vMPEG4SetMcBufAddr(UCHAR ucFbgId, VDEC_ES_INFO_T *prVDecEsInfo); extern void vMPEG4DpbBufCopy(MPEG4_DRV_INFO_T *prMpeg4DrvInfo, UCHAR ucTarDpbBuf, UCHAR ucSrcDpbBuf); extern INT32 i4MPEG4OutputProc(UCHAR ucEsId, VDEC_ES_INFO_T *prVDecEsInfo); extern void vSetMpeg2Var(MPEG4_DRV_INFO_T *prMpeg4DrvInfo); extern void vMPEG4SetColorPrimaries(MPEG4_DRV_INFO_T *prMPEG4DrvDecInfo, UINT32 u4ColorPrimaries); extern void vMPEG4SetSampleAsp(VDEC_ES_INFO_T *prVDecEsInfo, UINT32 u4MPEG4Asp); extern void vMPEG4SetFrameTimingInfo(MPEG4_DRV_INFO_T *prMPEG4DrvDecInfo, UINT16 u2FrameRate); extern void _MPEG4SetDecPrm(MPEG4_DRV_INFO_T *prMpeg4DrvInfo); extern void vMPEG4CalGmcMv(MPEG4_DRV_INFO_T *prMpeg4DrvInfo); #ifdef FBM_ALLOC_SUPPORT extern void vFreeMpeg4WorkingArea(VDEC_ES_INFO_T *prVDecEsInfo); #endif extern void vMPEG4SetDownScaleParam(MPEG4_DRV_INFO_T *prMpeg4DrvInfo, BOOL fgEnable); /// This function will return vdec driver interface pointer ///\ return VDEC_DRV_IF* extern VDEC_DRV_IF *VDec_GetMPEG4If(void); /*! @} */ #if ((CONFIG_CHIP_VER_CURR >= CONFIG_CHIP_VER_MT8560) && CONFIG_DRV_FTS_SUPPORT) extern void vMPEG4SetLetterBoxParam(MPEG4_DRV_INFO_T *prMpeg4DrvInfo); #endif #ifdef MPV_DUMP_FBUF extern void VDec_Dump_Data(UINT32 u4StartAddr, UINT32 u4FileSize, UINT32 u4FileCnt, UCHAR *pucAddStr); #endif #ifdef DRV_VDEC_SUPPORT_FBM_OVERLAY extern BOOL fgMPEG4NeedDoDscl(UCHAR ucEsId); #endif #endif