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

📄 maimp3enc.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif    DPRINTF(("MP3ENC: _processbuffer() input insize %x iread %x\n", insize, iread*4));    if (iread == 0)      outsize = 0;    else    {//      err = mp3encEncode(pPInfo->pmp3, short_buffer, iread, pPInfo->outputbuffer, pPInfo->encInfo.cbBufsizeMin, &outsize);      //outsize = lame_encode_buffer_int(pPInfo->gf, Buffer[0], Buffer[1], iread, mp3buffer, sizeof(mp3buffer));    }        if ((insize == 0) && (outsize == 0))    {      if (eof_bail_count++ > 10)        break;     }    /* was our output buffer big enough? */    if (!err && (outsize > 0))    {      /* write to destination data (mp3 file) */      /* if a frame has been encoded, output it */      DPRINTF(("MP3ENC: _processbuffer() OutputPutBuf(%d)\n", outsize));      BufferInfo.dwFlags = 0;  /* default - no special flags */      BufferInfo.tTimeStamp = 0;      BufferInfo.pBuffer = (unsigned char *)pPInfo->outputbuffer;      BufferInfo.uiDataSize = BufferInfo.uiBufSize = outsize;      eStatus=MAICompBase_OutputPutBuf(hComp, 0, &BufferInfo);    }    else /* encoder did not succeed */    {      eStatus = MAI_STATUS_OK;      if (!err)      {        printf("mp3enc internal error:  error code=%x\n", err);      }      if (error_bail_count++ > 10)        break; // but we do not want to get stuck here!    }    insize -= 2 * iread;    short_buffer += iread;    DPRINTF(("MP3ENC: _processbuffer() insize %x\n", insize));  }    DPRINTF(("MP3ENC: _processbuffer() exit\n"));  return eStatus;}static MAIStatus_e MAICompInitInput(MAICompHandle_t hComp, unsigned int uiPinID,                                   pfMAICompGetBufferCB_t *ppfInputGetBuffer,                                   pfMAICompPutBufferCB_t *ppfInputPutBuffer){  MAIStatus_e  eStatus;  eStatus=MAICompBase_InitInput(hComp, uiPinID, ppfInputGetBuffer, ppfInputPutBuffer, DEFAULT_INBUFSIZE, DEFAULT_INBUFCOUNT);  return eStatus;}static MAIStatus_e MAICompInitOutput(MAICompHandle_t hComp, unsigned int uiPinID,                                   pfMAICompGetBufferCB_t pfOutputGetBuf, pfMAICompPutBufferCB_t pfOutputPutBuf,                                   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(("MP3ENC: MAICompStart() enter\n"));  _startprocessing(hComp);  eStatus=MAICompBase_StartStreaming(hComp, MAICompBase_ProcessorThread, 0);  APIPRINTF(("MP3ENC: MAICompStart() done: status=0x%X\n", eStatus));  return eStatus;}static MAIStatus_e MAICompEnd(MAICompHandle_t hComp){  MAIStatus_e eStatus = MAI_STATUS_OK;  APIPRINTF(("MP3ENC: 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(("MP3ENC: 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){  ProcessorInfo_t *pPInfo=(ProcessorInfo_t *)HCOMP_TO_USERINFO(hComp);  MAIStatus_e eStatus = MAI_STATUS_OK;    switch (uiCommand)  {    /* handle component specific Commands here */    default:                                             break;  }  ERRORPRINTF((M_TEXT("MP3ENC: MAICompSetParam(%d,%d) Passing command to compbase\n"), uiParam1, uiParam2) );  eStatus=MAICompBase_SendCommand(hComp, uiCommand, uiParam1, uiParam2, uiParam3, pUserInstance, uiTimeOut);  return eStatus;}static MAIStatus_e MAICompGetParam(MAICompHandle_t hComp, unsigned int uiParam, void *pvParamData, unsigned int uiDataSize){  return MAICompBase_GetParam(hComp,uiParam,pvParamData,uiDataSize);}static MAIStatus_e MAICompSetParam(MAICompHandle_t hComp, unsigned int uiParam, void *pvParamData, unsigned int uiDataSize){  return MAICompBase_SetParam(hComp,uiParam,pvParamData,uiDataSize);}static MAIStatus_e MAICompGetMediaType(MAICompHandle_t hComp, MAICompDirection_e eDirection, MAICompPinID_t 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    {      MAIMediaTypeAudio_t *pAudioInfo=(MAIMediaTypeAudio_t *)pMediaType;      /* clear the info structure */      memset(pAudioInfo, 0, sizeof(MAIMediaTypeAudio_t));      /* fill in Common MediaType fields */      pAudioInfo->MediaTypeInfo.uiSize=sizeof(MAIMediaTypeAudio_t);      pAudioInfo->MediaTypeInfo.eMType=MAI_MTYPE_AUDIO;      pAudioInfo->MediaTypeInfo.eMSubtype=MAI_MSUBTYPE_MPA;      pAudioInfo->MediaTypeInfo.uiFlags=0;      /* Fill in Audio MediaType specific fields */      pAudioInfo->uiFlags = 0; /* init to no flags set */      pAudioInfo->uiModeFlags = 0; /* init to no mode flags set *///      pAudioInfo->uiSamplesPerSec = mp3decGetStreamInfo(pPInfo->hDec)->SFreq;//      pAudioInfo->uiBitsPerSample = mp3decGetStreamInfo(pPInfo->hDec)->BitsPerSample;//      pAudioInfo->uiChannels = mp3decGetStreamInfo(pPInfo->hDec)->Channels;//      pAudioInfo->uiBitrate = mp3decGetStreamInfo(pPInfo->hDec)->Bitrate;//      pAudioInfo->uiFramesize = mp3decGetStreamInfo(pPInfo->hDec)->BitsPerFrame;//      pAudioInfo->uiLayer = mp3decGetStreamInfo(pPInfo->hDec)->Layer;//      if (mpeg_decoder.decode_context.vbr)//        pAudioInfo->uiFlags |= MAI_AUDIOMTFLAG_VBR;//      pAudioInfo->uiEmphasis = mpeg_decoder.decode_context.emphasis; /* 0, 1, 2, 3 *///      if (mpeg_decoder.decode_context.sbr)//        pAudioInfo->uiModeFlags |= MAI_AUDIOMODEFLAG_SBR;//      if (mpeg_decoder.decode_context.mode_ext & MODE_EXT_I_STEREO)//        pAudioInfo->uiModeFlags |= MAI_AUDIOMODEFLAG_INTENSITYSTEREO;//      if (mpeg_decoder.decode_context.mode_ext & MODE_EXT_MS_STEREO)//        pAudioInfo->uiModeFlags |= MAI_AUDIOMODEFLAG_MSSTEREO;//      if (mpeg_decoder.decode_context.mode == MPA_JSTEREO)//        pAudioInfo->uiModeFlags |= MAI_AUDIOMODEFLAG_JOINTSTEREO;      eStatus=MAI_STATUS_OK;    }  }  else if (eDirection==MAICOMP_DIR_OUTPUT && uiPinID==0)  {    if (!pMediaType)      eStatus=MAI_STATUS_BADARG;    else    {      MAIMediaTypeAudio_t *pAudioInfo=(MAIMediaTypeAudio_t *)pMediaType;      /* clear the info structure */      memset(pAudioInfo, 0, sizeof(MAIMediaTypeAudio_t));      /* fill in Common MediaType fields */      pAudioInfo->MediaTypeInfo.uiSize=sizeof(MAIMediaTypeAudio_t);      pAudioInfo->MediaTypeInfo.eMType=MAI_MTYPE_AUDIO;      pAudioInfo->MediaTypeInfo.eMSubtype=MAI_MSUBTYPE_PCM;      pAudioInfo->MediaTypeInfo.uiFlags=0;      /* fill in Audio MediaType specific fields */      pAudioInfo->uiFlags = 0; /* init to no flags set */      pAudioInfo->uiModeFlags = 0; /* init to no mode flags set *///      pAudioInfo->uiSamplesPerSec = mp3decGetStreamInfo(pPInfo->hDec)->SFreq;//      pAudioInfo->uiBitsPerSample = mp3decGetStreamInfo(pPInfo->hDec)->BitsPerSample;//      pAudioInfo->uiChannels = mp3decGetStreamInfo(pPInfo->hDec)->Channels;//      pAudioInfo->uiBitrate = mp3decGetStreamInfo(pPInfo->hDec)->Bitrate;//      pAudioInfo->uiFramesize = mp3decGetStreamInfo(pPInfo->hDec)->BitsPerFrame;      pAudioInfo->uiMaxBufSize = 1152*2*2;    }  }  return eStatus;}/********** Public Component interfaces - REQUIRED **********/#define _COMPCOUNT    1  /* just one component implemented here */static MAICompHandleInfo_t _CompTemplate[_COMPCOUNT] ={  { /* CompInfo #1 - MPEG Audio Decoder */      DECLARE_MAICOMPINFO(      /* _eType */ MAICOMP_TYPE_ENCODE|MAICOMP_TYPE_AUDIO,      /* _uiCompVer */ 0x0001,      /* _uiBuildVer */ BUILD_VERSION,      /* _GUID */ MAICOMP_GUID(0x00, 0x10, 0xef, 0x00, 0x00, 0x00, 0x00, 0x1b),      /* _pszName */ "MP3ENC", /* _pszDesc */ "MP3 Audio Encoder",      /* _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);    /* 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 */    /* call base release */    eStatus=MAICompBase_CompRelease(hComp);  }  else    eStatus=MAI_STATUS_BADHANDLE;  return eStatus;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -