📄 maimpeg4dec.c
字号:
MAICompHandle_t hBufferOwnerComp){ return MAICompBase_InitOutput(hComp, uiPinID, pfOutputGetBuf, pfOutputPutBuf, hBufferOwnerComp);}static MAIStatus_e MAICompStart(MAICompHandle_t hComp){ ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); MAIStatus_e eStatus = MAI_STATUS_OK; APIPRINTF((M_TEXT("MP4V: MAICompStart() enter\n"))); _startprocessing(hComp); eStatus=MAICompBase_StartStreaming(hComp, MAICompBase_ProcessorThread, 0); APIPRINTF( (M_TEXT("MP4V: MAICompStart() done: status=0x%X\n"), eStatus) ); return eStatus;}static MAIStatus_e MAICompEnd(MAICompHandle_t hComp){ MAIStatus_e eStatus = MAI_STATUS_OK; APIPRINTF( (M_TEXT("MP4V: MAICompEnd() enter\n")) ); /* call base EndStreaming to close down any running threads */ eStatus=MAICompBase_EndStreaming(hComp, MAI_TIMEOUT_INFINITE); /* now call our local endprocessing logic */ if (!MAICompBase_IsState(hComp, MAI_RUNSTATE_NONE)) eStatus=_endprocessing(hComp); APIPRINTF( (M_TEXT("MP4V: MAICompEnd() done: status=0x%X\n"), eStatus) ); return eStatus;}static MAIStatus_e MAICompSendCommand(MAICompHandle_t hComp, m_u32 uiCommand, m_u32 uiParam1, m_u32 uiParam2, m_u32 uiParam3, void *pUserInstance, MAITimeOut_t uiTimeOut){ MAIStatus_e eStatus = MAI_STATUS_OK; ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); switch (uiCommand) { case MAICOMP_CMD_STOP: if (MAICompBase_IsStreaming(hComp)) { /* ensure decoder completes current frame before Stopping */ if (MAICompBase_ChangeStateIFF(hComp, MAI_RUNSTATE_PLAYING|MAI_RUNSTATE_STARTING, MAI_RUNSTATE_PAUSING)) { if (uiTimeOut) MAICompBase_WaitForState(hComp, ~MAI_RUNSTATE_PAUSING, (uiTimeOut>1000)?1000:uiTimeOut); } } /* pass command to base routines for default processing */ eStatus=MAICompBase_SendCommand(hComp, uiCommand, uiParam1, uiParam2, uiParam3, pUserInstance, uiTimeOut); break; case MAI_CMD_EMPTY: APIPRINTF((M_TEXT("MPV4: MAICompSendCommand() CMD_EMPTY: DecodeMode=%d\n"), pPInfo->m_uiCurrentDecodeMode)); eStatus=MAICompBase_SendCommand(hComp, uiCommand, uiParam1, uiParam2, uiParam3, pUserInstance, uiTimeOut); if (pPInfo->m_uiCurrentDecodeMode!=DECODE_I_ONLY) g_uiWaitForIFrame = M_TRUE; //mpeg4_setmode(DECODE_WAITFORI); break; case MAICOMP_CMD_PLAY: { MAISpeed_e NewSpeed=(MAISpeed_e)uiParam1; unsigned int uiNewPlayRate=NewSpeed&MAI_SPEED_RATEMASK; APIPRINTF((M_TEXT("MPV4: MAICompSendCommand() CMD_PLAY(speed=0x%X): DecodeMode=%d\n"), uiParam1, pPInfo->m_uiCurrentDecodeMode)); if (uiNewPlayRate!=0 && NewSpeed!=MAI_SPEED_UNSPECIFIED) { pPInfo->m_NextSpeed=NewSpeed; update_speed(pPInfo, 0); } } /* pass command to base routines for default processing */ eStatus=MAICompBase_SendCommand(hComp, uiCommand, uiParam1, uiParam2, uiParam3, pUserInstance, uiTimeOut); break; default: APIPRINTF((M_TEXT("MPV4: MAICompSendCommand(Cmd=%d,%d,%d,%d) Passing command to compbase\n"), uiCommand, uiParam1, uiParam2, uiParam3) ); eStatus=MAICompBase_SendCommand(hComp, uiCommand, uiParam1, uiParam2, uiParam3, pUserInstance, uiTimeOut); break; }; return eStatus;}static MAIStatus_e MAICompGetParam(MAICompHandle_t hComp, unsigned int uiParam, void *pvParamData, unsigned int uiDataSize){ ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); MAIStatus_e eStatus=MAI_STATUS_UNSUPPORTED; switch (uiParam) { default: eStatus=MAICompBase_GetParam(hComp,uiParam,pvParamData,uiDataSize); break; } return eStatus;}static MAIStatus_e MAICompSetParam(MAICompHandle_t hComp, unsigned int uiParam, void *pvParamData, unsigned int uiDataSize){ ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); MAIStatus_e eStatus=MAI_STATUS_UNSUPPORTED; switch (uiParam) { case MAI_PARAM_VIDEOACCEL: /* HWG050620: used to receive open MAE driver instance from engine */ DPRINTF( (M_TEXT("MPV4: MAICompSetParam(MAI_PARAM_VIDEOACCEL, 0x%08X)\n"), pvParamData) ); { MAIParamVideoAccel_t *pVideoAccel=(MAIParamVideoAccel_t *)pvParamData; if (uiDataSize<sizeof(MAIParamVideoAccel_t)) eStatus=MAI_STATUS_BADARG; /* structure to small */ else {#ifdef MAE_HW setup_mae_driver(pVideoAccel); /* here we pass open MAE driver to wrapper (hHandle) */#endif eStatus=MAI_STATUS_OK; } } break;#ifdef SYNC_SKIPPING_SUPPORT case MAI_PARAM_CLOCK: /* HWG050715: used to receive current clock that engine is syncing to */ { MAIParamClock_t *pClock=(MAIParamClock_t *)pvParamData; if (uiDataSize<sizeof(MAIParamClock_t)) eStatus=MAI_STATUS_BADARG; /* structure to small */ else { /* here we'll use the clock to see if we need to skip */ check_sync(pPInfo, pClock); eStatus=MAI_STATUS_OK; } } break;#endif /* SYNC_SKIPPING_SUPPORT */ default: eStatus=MAICompBase_SetParam(hComp,uiParam,pvParamData,uiDataSize); break; } return eStatus;}static MAIStatus_e MAICompGetMediaType(MAICompHandle_t hComp, MAICompDirection_e eDirection, unsigned int uiPinID, MAIMediaType_t *pMediaType){ ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); MAIStatus_e eStatus = MAI_STATUS_UNSUPPORTED; if ((eDirection==MAICOMP_DIR_INPUT || eDirection==MAICOMP_DIR_OUTPUT) && uiPinID==0) { if (!pMediaType) eStatus=MAI_STATUS_BADARG; else { MAIMediaTypeVideo_t *pVideoInfo=(MAIMediaTypeVideo_t *)pMediaType; DPRINTF((M_TEXT("MPV4: MAICompGetMediaType() enter\n"))); /* clear the info structure */ memset(pVideoInfo, 0, sizeof(MAIMediaTypeVideo_t)); /* fill in Common MediaType fields */ pVideoInfo->MediaTypeInfo.uiSize=sizeof(MAIMediaType_t); pVideoInfo->MediaTypeInfo.eMType=MAI_MTYPE_VIDEO; if (eDirection==MAICOMP_DIR_OUTPUT) pVideoInfo->MediaTypeInfo.eMSubtype=MAI_MSUBTYPE_YUV420; else pVideoInfo->MediaTypeInfo.eMSubtype=MAI_MSUBTYPE_MPV4; pVideoInfo->MediaTypeInfo.uiFlags=0; if (!MAICompBase_IsState(hComp, (MAI_RUNSTATE_DESTROYING|MAI_RUNSTATE_NONE))) { /* fill in Video MediaType specific fields */ pVideoInfo->uiFlags=0; pVideoInfo->eFrameRate=MAI_FRAMERATE_30; /* default */ pVideoInfo->uiFinalMSubType=pVideoInfo->uiImageMSubType=MAI_MSUBTYPE_YUV420; pVideoInfo->uiFinalWidth=pVideoInfo->uiImageWidth=(unsigned int)pPInfo->m_iImageWidth; /* default */ pVideoInfo->uiFinalHeight=pVideoInfo->uiImageHeight=(unsigned int)pPInfo->m_iImageHeight; /* default */ pVideoInfo->uiFinalPARh=pVideoInfo->uiImagePARh=0; /* 0=unknown */ pVideoInfo->uiFinalPARv=pVideoInfo->uiImagePARv=0; /* 0=unknown */ pVideoInfo->uiExtraInfoSize=0; } DPRINTF((M_TEXT("MPV4: MAICompGetMediaType() done\n"))); eStatus = MAI_STATUS_OK; } } return eStatus;}/********** Public Component interfaces - REQUIRED **********/#define _COMPCOUNT 1 /* just one component implemented here */static MAICompHandleInfo_t _CompTemplate[_COMPCOUNT] ={ { /* CompInfo #1 - MPEG4 Video Decoder */ DECLARE_MAICOMPINFO( /* _eType */ MAICOMP_TYPE_DECODE|MAICOMP_TYPE_VIDEO, /* _uiCompVer */ 0x0001, /* _uiBuildVer */ BUILD_VERSION, /* _GUID */ MAICOMP_GUID(0x00, 0x10, 0xef, 0x00, 0x00, 0x00, 0x00, 0x27), /* _pszName */ "MPEG4DEC", /* _pszDesc */ "MPEG4 Video Decoder", /* _uiMaxInputs */ 1, /* _MaxOutputs */ 1, /* _MaxInstances */ 1, /* _uiFlags */ 0 ), /* CompHandle fields */ (pfMAICompErrorCB_t)0, /* pfMAICompErrorCB_t pfErrorCB */ (pfMAICompProgressCB_t)0, /* pfMAICompProgressCB_t pfProgressCB; */ MAICompInitInput, /* pfMAICompInitInput_t pfInitInput */ MAICompInitOutput, /* pfMAICompInitOutput_t pfInitOutput */ MAICompGetMediaType, /* pfMAICompGetMediaType_t pfGetMediaType */ MAICompGetParam, /* pfMAICompGetParam_t pfGetParam */ MAICompSetParam, /* pfMAICompSetParam_t pfSetParam */ MAICompStart, /* pfMAICompStart_t pfStart */ MAICompSendCommand, /* pfMAICompSendCommand_t pfSendCommand */ MAICompEnd, /* pfMAICompEnd_t pfEnd */ MAICompBase_SetErrorCB, /* pfMAICompSetErrorCB_t pfSetErrorCB */ MAICompBase_SetProgressCB, /* pfMAICompSetProgressCB_t pfSetProgressCB */ MAICompBase_GetState, /* pfMAICompGetState_t pfGetState */ (pfMAICompSetStream_t)0, /* pfMAICompSetStream_t pfSetStream */ (pfMAICompReserved_t)0, /* pfMAICompRead_t pfRead */ MAICompBase_ReadBuffer, /* pfMAICompReadBuffer_t pfReadBuffer */ MAICompBase_WriteBuffer, (pfMAICompReserved_t)0, (pfMAICompReserved_t)0, (pfMAICompReserved_t)0, (pfMAICompReserved_t)0, (pfMAICompReserved_t)0 }}; /* MAICompLibInit - initialize the MAI component library */PUBLIC_EXTERN MAIStatus_e MAICompLibInit(){ return MAICompBase_LibInit(_CompTemplate, _COMPCOUNT);}/* MAICompLibRelease - release the MAI component library */PUBLIC_EXTERN MAIStatus_e MAICompLibRelease(){ return MAICompBase_LibRelease();}/* MAICompLibGetCount - return number of components implemented in this library */PUBLIC_EXTERN unsigned int MAICompLibGetCount(){ MAICompLibInit(); /* make sure lib has been initialized */ return MAICompBase_LibGetCount();}/* MAICompGetInfo - return info on a specific component */PUBLIC_EXTERN MAIStatus_e MAICompGetInfo(unsigned int uiCompIndex, MAICompInfo_t *pInfoOut){ MAICompLibInit(); /* make sure lib has been initialized */ return MAICompBase_CompGetInfo(uiCompIndex, pInfoOut);}/* MAICompCreate - create an instance of a specific component */PUBLIC_EXTERN MAIStatus_e MAICompCreate(unsigned char *pucGUID, MAICompHandle_t *phCompOut){ MAIStatus_e eStatus; MAICompHandle_t hComp=M_HANDLE_INVALID; MAICompLibInit(); /* make sure lib has been initialized */ eStatus=MAICompBase_CompCreate(pucGUID, sizeof(ProcessorInfo_t), &hComp); if (eStatus==MAI_STATUS_OK) { /* init private component info */ ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); MAICompBase_SetProcessBufferMode(hComp, COMP_PROCESSBUFMODE_NOBUF_SPIN); /* input buffers will be read through callbacks */ pPInfo->m_uiFrameCount=0; pPInfo->m_uiOutputFrameCount=0; pPInfo->m_bDecoderInit = M_FALSE; pPInfo->m_uiSyncSkippingThreshold = 90; /* allows a couple frames to drift, any more and audio stream may get breaks */ pPInfo->m_uiSyncSkippingThresholdI = 360; MAIOSCriticalSecCreate(&pPInfo->m_hCSDecode); /* return handle */ *phCompOut=(MAICompHandle_t)hComp; } return eStatus;}/* MAICompRelease - release an instance of a specific component */PUBLIC_EXTERN MAIStatus_e MAICompRelease(MAICompHandle_t hComp){ MAIStatus_e eStatus; if (hComp!=M_HANDLE_INVALID) { ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp); /* release private component info */ MAIOSCriticalSecDestroy(pPInfo->m_hCSDecode); /* call base release */ eStatus=MAICompBase_CompRelease(hComp); } else eStatus=MAI_STATUS_BADHANDLE; return eStatus;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -