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

📄 aacdecdll.cpp.svn-base

📁 MP3 for ARM codec. [asm+C]
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
    return HXR_OK;}/* tell the decoder to conceal nSamples samples. The concealed samples   will be returned with the next Decode() call. */STDMETHODIMP CAACDec::Conceal(UINT32 nSamples){#ifdef AAC_ENABLE_SBR    m_ulSamplesToConceal = (nSamples + 2*AAC_MAX_NSAMPS - 1) / (2*AAC_MAX_NSAMPS);#else    m_ulSamplesToConceal = (nSamples + AAC_MAX_NSAMPS - 1) / AAC_MAX_NSAMPS;#endif    return HXR_OK;}void CAACDec::ReorderPCMChannels(INT16 *pcmBuf, int nSamps, int nChans){    int i, ch, chanMap[6];    INT16 tmpBuf[6];    switch (nChans) {       case 3:           chanMap[0] = 1; /* L */           chanMap[1] = 2; /* R */           chanMap[2] = 0; /* C */           break;       case 4:           chanMap[0] = 1; /* L */           chanMap[1] = 2; /* R */           chanMap[2] = 0; /* C */           chanMap[3] = 3; /* S */           break;       case 5:           chanMap[0] = 1; /* L */           chanMap[1] = 2; /* R */           chanMap[2] = 0; /* C */           chanMap[3] = 3; /* LS */           chanMap[4] = 4; /* RS */           break;       case 6:           chanMap[0] = 1; /* L */           chanMap[1] = 2; /* R */            chanMap[2] = 0; /* C */           chanMap[3] = 5; /* LFE */           chanMap[4] = 3; /* LS */           chanMap[5] = 4; /* RS */           break;       default:           return;    }    for (i = 0; i < nSamps; i += nChans) {        for (ch = 0; ch < nChans; ch++)            tmpBuf[ch] = pcmBuf[chanMap[ch]];        for (ch = 0; ch < nChans; ch++)            pcmBuf[ch] = tmpBuf[ch];        pcmBuf += nChans;    }}/* Decode up to nbytes bytes of bitstream data. nBytesConsumed will be   updated to reflect how many bytes have been read by the decoder   (and can thus be discarded in the caller). The decoder does not   necessarily buffer the bitstream; that is up to the caller.   samplesOut should point to an array of INT16s, large enough to hold   MaxSamplesOut() samples.   nSamplesOut is updated to reflect the number of samples written by   the decoder.   set eof when no more data is available and keep calling the decoder   until it does not produce any more output.*/STDMETHODIMP CAACDec::Decode(const UCHAR* data, UINT32 nBytes, UINT32 &nBytesConsumed, INT16 *samplesOut, UINT32& nSamplesOut, HXBOOL eof){    unsigned char *readPtr;    int bytesLeft, err;    UINT32 maxSamplesOut;    if (m_ulSamplesToConceal) {        GetMaxSamplesOut(maxSamplesOut);        nSamplesOut = maxSamplesOut;        if (m_ulSamplesToConceal < maxSamplesOut)            nSamplesOut = m_ulSamplesToConceal;        /* just fill with silence */        memset(samplesOut, 0, nSamplesOut * sizeof(INT16));        m_ulSamplesToConceal -= nSamplesOut;        nBytesConsumed = 0;        AACFlushCodec(m_hAACDecoder);        return HXR_OK;    }    readPtr = (unsigned char *)data;    bytesLeft = nBytes;    err = AACDecode(m_hAACDecoder, &readPtr, &bytesLeft, (short *)samplesOut);    if (err) {        nSamplesOut = 0;        switch (err) {           case ERR_AAC_INDATA_UNDERFLOW:               /* need to provide more data on next call to AACDecode() (if possible) */               return HXR_OK;           default:               /* other error */               AACFreeDecoder(m_hAACDecoder);               m_hAACDecoder = 0;               return HXR_FAIL;        }    }    /* no error */    AACGetLastFrameInfo(m_hAACDecoder, &m_aacFrameInfo);    /* TODO - rather than reordering for multichannel, should init the     *        audio driver with correct channel map (it's hard coded     *        right now - see client\audiosvc\hxaudply.cpp,     *        updownmix.cpp)     */    ReorderPCMChannels(samplesOut, m_aacFrameInfo.outputSamps, m_ulChannels);    m_ulCoreSampleRate = m_aacFrameInfo.sampRateCore;    m_ulSampleRate = m_aacFrameInfo.sampRateOut;    m_ulChannels = m_aacFrameInfo.nChans;    nSamplesOut = m_aacFrameInfo.outputSamps;    nBytesConsumed = nBytes - bytesLeft;    return HXR_OK;}/* upper limit on the number of samples the decoder will produce per call */STDMETHODIMP CAACDec::GetMaxSamplesOut(UINT32& nSamples) CONSTMETHOD{    nSamples = m_ulChannels * m_ulMaxFrameLength;    return HXR_OK;}/* number of channels of audio in the audio stream (not valid until OpenDecoder() is called) */STDMETHODIMP CAACDec::GetNChannels(UINT32& nChannels) CONSTMETHOD{    nChannels = m_ulChannels;    return HXR_OK;}/* sample rate of the audio stream (not valid until OpenDecoder() is called) */STDMETHODIMP CAACDec::GetSampleRate(UINT32& sampleRate) CONSTMETHOD{    sampleRate = m_ulSampleRate;    return HXR_OK;}/* codec delay in samples */STDMETHODIMP CAACDec::GetDelay(UINT32& nSamples) CONSTMETHOD{    nSamples = m_ulChannels * m_ulFrameLength;    return HXR_OK;}/* query basic codec properties */void* CAACDec::GetFlavorProperty(UINT16 flvIndex, UINT16 propIndex, UINT16* pSize){    *pSize = 0;    switch (propIndex) {       case FLV_PROP_SAMPLES_IN:           m_propertyStore = m_ulChannels * m_ulFrameLength;           *pSize = sizeof(m_propertyStore);           return &m_propertyStore;                       case FLV_PROP_NAME:           *pSize = strlen(m_pszCodecName) + 1;           return (void*)m_pszCodecName;               default:           return 0;    }}HX_RESULT CAACDec::_RAInitDecoder(RADECODER_INIT_PARAMS* pParam){    HX_RESULT res = HXR_OK;    if (pParam->opaqueDataLength < 1)        return HXR_FAIL;    if (SUCCEEDED(res))        res = OpenDecoder(pParam->opaqueData[0], pParam->opaqueData+1, pParam->opaqueDataLength-1);    if (SUCCEEDED(res)) {        if (pParam->channels && pParam->channels != m_ulChannels)            res = HXR_FAIL;        else            pParam->channels = (UINT16)m_ulChannels;    }    if (SUCCEEDED(res)) {        pParam->sampleRate = (UINT32)m_ulSampleRate;        res = GetDelay(m_ulSamplesToEat);    }    return res;}HX_RESULT CAACDec::_RADecode(const UCHAR* in, UINT32 inLength, INT16* out, UINT32* pOutLength, UINT32 userData){    UINT32 nSamplesPerFrame, nBytesConsumed, nSamplesOut, ulEatSamples;    HX_RESULT res = HXR_OK;    *pOutLength = 0;    if (!userData) {        /* conceal one frame */        GetMaxSamplesOut(nSamplesPerFrame);        Conceal(nSamplesPerFrame);    }    nBytesConsumed = 0;    nSamplesOut = 0;    res = Decode(in, inLength, nBytesConsumed, out, nSamplesOut, 0);    inLength -= nBytesConsumed;    /* if we were not concealing, test if the AAC decoder consumed all data */    HX_ASSERT(!userData || 0 == inLength);    /* eat delay (if any) */    if (m_ulSamplesToEat) {        ulEatSamples = (m_ulSamplesToEat > nSamplesOut) ? nSamplesOut : m_ulSamplesToEat;        nSamplesOut -= ulEatSamples;        memmove(out, out+ulEatSamples, nSamplesOut*sizeof(INT16));        m_ulSamplesToEat -= ulEatSamples;    }    /* return output count in bytes */    *pOutLength = nSamplesOut * sizeof(INT16);    return res;}#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT/* create a dummy object to call init and free functions for * dynamically generated codec tables a static global object will be * constructed before the entrypoint for the DLL is called, so this * guarantees that the tables will be initialized before any instances * of the codec (CAACDec) are created order of construction and * destruction does not matter, since this object only calls the C * functions to init and free the codec tables */class CAACGenTrigtabsFloat{public:    CAACGenTrigtabsFloat();    ~CAACGenTrigtabsFloat();};CAACGenTrigtabsFloat::CAACGenTrigtabsFloat(){    AACInitTrigtabsFloat();}CAACGenTrigtabsFloat::~CAACGenTrigtabsFloat(){    AACFreeTrigtabsFloat();}static const CAACGenTrigtabsFloat g_cAACGenTrigtabsFloat;#endif

⌨️ 快捷键说明

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