⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maimpeg2dec.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
                uiParam1, pPInfo->m_uiCurrentDecodeMode));          if (uiNewPlayRate!=0 && NewSpeed!=MAI_SPEED_UNSPECIFIED)          {            m_bool bForceUpdate=MAICompBase_IsStreaming(hComp);            pPInfo->m_NextSpeed=NewSpeed;            update_speed(pPInfo, bForceUpdate);          }        }        /* 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("MPV2: MAICompSendCommand(CMD_EMPTY) DecodeMode=%d\n"),              pPInfo->m_uiCurrentDecodeMode));        /*if (!MAICompBase_IsStreaming(hComp)) // ensure we flush all current frame in non-streaming mode        {          APIPRINTF((M_TEXT("MPV2: MAICompSendCommand(CMD_EMPTY) mpeg2_setflush(1)\n")));          mpeg2_setflush(pPInfo->m_pDecoder, 1 // flush);        }*/        /* we'll assume next data will be a discontinuity */        if (!MAICompBase_IsState(hComp, MAI_RUNSTATE_NONE) && pPInfo->m_pDecoder)        {          APIPRINTF((M_TEXT("MPV2: MAICompSendCommand(CMD_EMPTY) mpeg2_setdiscontinuity()\n")));          mpeg2_setdiscontinuity(pPInfo->m_pDecoder, 1);          if (pPInfo->m_uiCurrentDecodeMode==DECODE_NORMAL && pPInfo->m_CurrentSpeed==MAI_SPEED_NORMAL)          {            APIPRINTF((M_TEXT("MPV2: MAICompSendCommand(CMD_EMPTY) DECODE_NORMAL\n")));            SETDECODEMODE(pPInfo, DECODE_NORMAL, pPInfo->m_CurrentSpeed);          }        }        pPInfo->m_uiFramesOutInMode=0;        /* pass command to base routines for default processing */        eStatus=MAICompBase_SendCommand(hComp, uiCommand, uiParam1, uiParam2, uiParam3, pUserInstance, uiTimeOut);#if defined(MAE_HW) && defined(MAI_OS_WINCE)        request_mae_flush();#endif        break;    case MAICOMP_CMD_DECMODE:        APIPRINTF((M_TEXT("MPV2: MAICompSendCommand(CMD_DECMODE) Mode=%d->%d\n"),                         pPInfo->m_uiCurrentDecodeMode, uiParam1));        pPInfo->m_uiNextDecodeMode=uiParam1;        break;    default:        APIPRINTF((M_TEXT("MPV2: 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)  {    case MAI_PARAM_CLOCK:        eStatus=MAI_STATUS_WRONGSTATE; /* default: couldn't get current time - probably not setup yet */        if (pPInfo->m_pDecoder && MAICompBase_IsState(hComp, MAI_RUNSTATE_PAUSED|MAI_RUNSTATE_PLAYING))        {          mpeg_time_t tCurrent=0;          MAIParamClock_t *pClock=(MAIParamClock_t *)pvParamData;          if (mpeg2_gettimestamp (pPInfo->m_pDecoder, &tCurrent))          {            MAITIME_ASSIGN(pClock->tCurrentTime, tCurrent);            pClock->eTimeUnits=MAI_UNIT_TIME_MS;            eStatus=MAI_STATUS_OK;          }        }        break;    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 */        {          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 && uiPinID==0)  {    if (!pMediaType)      eStatus=MAI_STATUS_BADARG;    else    {      MAIMediaTypeVideo_t *pVideoInfo=(MAIMediaTypeVideo_t *)pMediaType;      DPRINTF((M_TEXT("MPV2: MAICompGetMediaType()\n")));      if (pVideoInfo->MediaTypeInfo.uiSize>=sizeof(MAIMediaTypeVideo_t)) /* has the user specified uiSize correctly */        memset(pVideoInfo, 0, sizeof(MAIMediaTypeVideo_t)); /* clear the info structure */      /* fill in Common MediaType fields */      pVideoInfo->MediaTypeInfo.uiSize=sizeof(MAIMediaType_t);      pVideoInfo->MediaTypeInfo.eMType=MAI_MTYPE_VIDEO;      pVideoInfo->MediaTypeInfo.eMSubtype=MAI_MSUBTYPE_MPV2;      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_29_97; /* default */        pVideoInfo->uiFinalMSubType=pVideoInfo->uiImageMSubType=MAI_MSUBTYPE_YUV420;        pVideoInfo->uiFinalWidth=pVideoInfo->uiImageWidth=720; /* default */        pVideoInfo->uiFinalHeight=pVideoInfo->uiImageHeight=480; /* default */        pVideoInfo->uiFinalPARh=pVideoInfo->uiImagePARh=0; /* default - unknown */        pVideoInfo->uiFinalPARv=pVideoInfo->uiImagePARv=0; /* default - unknown */        pVideoInfo->uiExtraInfoSize=0;        if (pPInfo->m_pDecoder) /* MPEG decode has been opened, copy sequence header params */        {          const mpeg2_info_t *pMPEGInfo = mpeg2_info (pPInfo->m_pDecoder);          if (pMPEGInfo && pMPEGInfo->sequence)          {            DPRINTF((M_TEXT("MPV2: MAICompGetMediaType() pMPEGInfo->sequence\n")));            if (pMPEGInfo->sequence->frame_period/1000) /* non-zero safety */            {                pVideoInfo->eFrameRate = 27000000/(pMPEGInfo->sequence->frame_period/1000);  /* Convert to MAI FPS in 1000 units */            }            pVideoInfo->uiFinalHeight = pVideoInfo->uiImageHeight = pMPEGInfo->sequence->picture_height;            pVideoInfo->uiFinalWidth = pVideoInfo->uiImageWidth = pMPEGInfo->sequence->picture_width;            pVideoInfo->uiFinalPARh = pVideoInfo->uiImagePARh = pMPEGInfo->sequence->pixel_width;            pVideoInfo->uiFinalPARv = pVideoInfo->uiImagePARv = pMPEGInfo->sequence->pixel_height;            if (pMPEGInfo->sequence->uiFormat == 2)                pVideoInfo->uiFinalMSubType = pVideoInfo->uiImageMSubType = MAI_MSUBTYPE_YUV444;             else if (pMPEGInfo->sequence->uiFormat == 1)                pVideoInfo->uiFinalMSubType = pVideoInfo->uiImageMSubType = MAI_MSUBTYPE_YUV422;            // Sinw we really know the format, flag this to the app so it can decide what to do */            pVideoInfo->uiFlags = MAI_STREAMMTFLAG_FORMATKNOWN;            // Update the status only if the decoder returned the right values            eStatus = MAI_STATUS_OK;          }        }        else            eStatus = eStatus = MAI_STATUS_UNKNOWNFORMAT;   // Flag an error      }      DPRINTF((M_TEXT("MPV2: MAICompGetMediaType() done\n")));    }  }  else if (eDirection==MAICOMP_DIR_OUTPUT && uiPinID==0)  {    if (!pMediaType)      eStatus=MAI_STATUS_BADARG;    else    {      MAIMediaTypeVideo_t *pVideoInfo=(MAIMediaTypeVideo_t *)pMediaType;            if (pVideoInfo->MediaTypeInfo.uiSize>=sizeof(MAIMediaTypeVideo_t)) /* has the user specified uiSize correctly */        memset(pVideoInfo, 0, sizeof(MAIMediaTypeVideo_t)); /* clear the info structure */      /* fill in Common MediaType fields */      pVideoInfo->MediaTypeInfo.uiSize=sizeof(MAIMediaType_t);      pVideoInfo->MediaTypeInfo.eMType=MAI_MTYPE_VIDEO;      pVideoInfo->MediaTypeInfo.eMSubtype=MAI_MSUBTYPE_YUV420;      pVideoInfo->MediaTypeInfo.uiFlags=0;      /* fill in Video MediaType specific fields */        if (pPInfo->m_pDecoder) /* MPEG decode has been opened, copy sequence header params */        {          const mpeg2_info_t *pMPEGInfo = mpeg2_info (pPInfo->m_pDecoder);          if (pMPEGInfo && pMPEGInfo->sequence)          {            DPRINTF((M_TEXT("MPV2: MAICompGetMediaType() pMPEGInfo->sequence\n")));            if (pMPEGInfo->sequence->frame_period/1000) /* non-zero safety */            {                pVideoInfo->eFrameRate = 27000000/(pMPEGInfo->sequence->frame_period/1000);  /* Convert to MAI FPS in 1000 units */            }            pVideoInfo->uiFinalHeight = pVideoInfo->uiImageHeight = pMPEGInfo->sequence->picture_height;            pVideoInfo->uiFinalWidth = pVideoInfo->uiImageWidth = pMPEGInfo->sequence->picture_width;            pVideoInfo->uiFinalPARh = pVideoInfo->uiImagePARh = pMPEGInfo->sequence->pixel_width;            pVideoInfo->uiFinalPARv = pVideoInfo->uiImagePARv = pMPEGInfo->sequence->pixel_height;            if (pMPEGInfo->sequence->uiFormat == 2)                pVideoInfo->uiFinalMSubType = pVideoInfo->uiImageMSubType = MAI_MSUBTYPE_YUV444;             else if (pMPEGInfo->sequence->uiFormat == 1)                pVideoInfo->uiFinalMSubType = pVideoInfo->uiImageMSubType = MAI_MSUBTYPE_YUV422;          }        }      pVideoInfo->uiFlags=0;      pVideoInfo->uiExtraInfoSize=0;      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 - MPV2 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, 0x22),      /* _pszName */ "MPEG2DEC", /* _pszDesc */ "MPEG2 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_pDecoder = M_NULL;#ifdef NO_DISPLAY    pPInfo->m_eOutputMode=OUTPUT_MODE_NONE;#elif defined(VREND_SUPPORT)    pPInfo->m_eOutputMode=OUTPUT_MODE_VREND;#else    pPInfo->m_eOutputMode=OUTPUT_MODE_OUTPUTPIN;#endif /* NO_DISPLAY */    pPInfo->m_bVideoOpen=0;    pPInfo->m_pVideoBuffer[0]=M_NULL;    pPInfo->m_pVideoBuffer[1]=M_NULL;    pPInfo->m_pVideoBuffer[2]=M_NULL;    pPInfo->m_uiSyncSkippingThreshold = 90; /* allows a couple frames to drift */    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 + -