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

📄 aacdecdll.cpp.svn-base

📁 MP3 for ARM codec. [asm+C]
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK *****   * Source last modified: $Id: aacdecdll.cpp,v 1.5 2005/09/27 20:30:02 jrecker Exp $  *    * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved.   *        * The contents of this file, and the files included with this file,  * are subject to the current version of the RealNetworks Public  * Source License (the "RPSL") available at  * http://www.helixcommunity.org/content/rpsl unless you have licensed  * the file under the current version of the RealNetworks Community  * Source License (the "RCSL") available at  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL  * will apply. You may also obtain the license terms directly from  * RealNetworks.  You may not use this file except in compliance with  * the RPSL or, if you have a valid RCSL with RealNetworks applicable  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for  * the rights, obligations and limitations governing use of the  * contents of the file.  *    * This file is part of the Helix DNA Technology. RealNetworks is the  * developer of the Original Code and owns the copyrights in the  * portions it created.  *    * This file, and the files included with this file, is distributed  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET  * ENJOYMENT OR NON-INFRINGEMENT.  *   * Technology Compatibility Kit Test Suite(s) Location:   *    http://www.helixcommunity.org/content/tck   *   * Contributor(s):   *    * ***** END LICENSE BLOCK ***** */  #include "hxtypes.h"#include "hxresult.h"#include "hxcom.h"#include "hxassert.h"#include "hxacodec.h"#include "gaConfig.h"#include "racodec.h"#include "baseobj.h"#include "aacdecdll.h"#include "aacconstants.h"const char* const CAACDec::m_pszCodecName = "RealAudio 10";CAACDec::CAACDec()    : m_lRefCount(0)    , m_hAACDecoder(0)    , m_ulCoreSampleRate(0)    , m_ulSampleRate(0)    , m_ulChannels(0)    , m_ulFrameLength(0)    , m_ulMaxFrameLength(0)    , m_ulSamplesToConceal(0)    , m_ulSamplesToEat(0)    , m_propertyStore(0){    memset(&m_aacFrameInfo, 0, sizeof(AACFrameInfo));}CAACDec::~CAACDec(){    if (m_hAACDecoder)        AACFreeDecoder(m_hAACDecoder);    m_hAACDecoder = 0;}/**************************************************************************** *  IUnknown methods *////////////////////////////////////////////////////////////////////////////  Method://      IUnknown::QueryInterface//STDMETHODIMP CAACDec::QueryInterface(REFIID riid, void** ppvObj){    if (IsEqualIID(riid, IID_IHXAudioDecoder))    {        AddRef();        *ppvObj = (IHXAudioDecoder*) this;        return HXR_OK;    }    else if (IsEqualIID(riid, IID_IUnknown))    {        AddRef();        *ppvObj = this;        return HXR_OK;    }    *ppvObj = NULL;    return HXR_NOINTERFACE;}///////////////////////////////////////////////////////////////////////////  Method://      IUnknown::AddRef//STDMETHODIMP_(ULONG32) CAACDec::AddRef(){    return InterlockedIncrement(&m_lRefCount);}///////////////////////////////////////////////////////////////////////////  Method://      IUnknown::Release//STDMETHODIMP_(ULONG32) CAACDec::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}/* configure the decoder. Needs to be called before starting to decode.cfgType: The type of configuration data. For AAC decoders, the following valuesare defined:             eAACConfigADTS:             an ADTS-framed frame.eAACConfigAudioSpecificCfg: an mp4 audio specific config.hdr: a pointer to the config data.nBytes: the number of bytes in the config data.*/STDMETHODIMP CAACDec::OpenDecoder(UINT32 cfgType,                                  const void* config,                                  UINT32 nBytes){    unsigned char *readPtr;    int bytesLeft, err;    INT16 *temp;    UINT32 audioObjType;    /* for MP4 bitstream parsing */    struct BITSTREAM *pBs = 0;    CAudioSpecificConfig ASConfig;    readPtr = (UCHAR *)config;    bytesLeft = nBytes;    switch (cfgType) {       case eAACConfigADTS:           /* allocate temp output buffer for decoding first frame of ADTS (double in case of SBR) */#ifdef AAC_ENABLE_SBR           temp = new INT16[AAC_MAX_NSAMPS * AAC_MAX_NCHANS * 2];#else           temp = new INT16[AAC_MAX_NSAMPS * AAC_MAX_NCHANS];#endif           if (!temp)               return HXR_FAIL;           m_hAACDecoder = (HAACDecoder *)AACInitDecoder();           if (!m_hAACDecoder) {               delete[] temp;               return HXR_FAIL;           }           err = AACDecode(m_hAACDecoder, &readPtr, &bytesLeft, temp);           if (err) {               AACFreeDecoder(m_hAACDecoder);               m_hAACDecoder = 0;               delete[] temp;               return HXR_FAIL;           }           delete[] temp;           AACGetLastFrameInfo(m_hAACDecoder, &m_aacFrameInfo);           m_ulCoreSampleRate = m_aacFrameInfo.sampRateCore;           m_ulSampleRate = m_aacFrameInfo.sampRateOut;           m_ulChannels = m_aacFrameInfo.nChans;           m_ulFrameLength = m_aacFrameInfo.outputSamps / m_aacFrameInfo.nChans;           m_ulMaxFrameLength = m_ulFrameLength;           /* set AAC_MAX_NCHANS in aacdec.h */           if (m_ulChannels > AAC_MAX_NCHANS) {               AACFreeDecoder(m_hAACDecoder);               m_hAACDecoder = 0;               return HXR_FAIL;           }           /* setup decoder to handle raw data blocks (use ADTS params) */           AACSetRawBlockParams(m_hAACDecoder, 1, &m_aacFrameInfo);           return HXR_OK;       case eAACConfigAudioSpecificCfg:           if (newBitstream(&pBs, 8*nBytes))               return HXR_FAIL;           feedBitstream(pBs, (const unsigned char *)config, nBytes*8);           setAtBitstream(pBs, 0, 1);           if (ASConfig.Read(*pBs))               return HXR_FAIL;           if (pBs)               deleteBitstream(pBs);           m_ulChannels       = ASConfig.GetNChannels();           m_ulCoreSampleRate = ASConfig.GetCoreSampleRate();#ifdef AAC_ENABLE_SBR           m_ulSampleRate  = ASConfig.GetSampleRate();#else           m_ulSampleRate  = m_ulCoreSampleRate;#endif           /* set AAC_MAX_NCHANS in aacdec.h */           if (m_ulChannels > AAC_MAX_NCHANS) {               AACFreeDecoder(m_hAACDecoder);               m_hAACDecoder = 0;               return HXR_FAIL;           }           /* old notes:            *     m_ulFrameLength is set to what the frame            *     length will be initially. This might * change once            *     the first frame is handed in (if AAC+ is signalled            *     implicitly) * m_ulMaxFrameLength is set to what the            *     frame length could grow to in that case            */           m_ulFrameLength = ASConfig.GetFrameLength();           m_ulMaxFrameLength = 2*m_ulFrameLength;           if (m_ulSampleRate != m_ulCoreSampleRate)               m_ulFrameLength *= 2;           m_hAACDecoder = (HAACDecoder *)AACInitDecoder();           if (!m_hAACDecoder)               return HXR_FAIL;           /* setup decoder to handle raw data blocks (pass params from MP4 info) */           m_aacFrameInfo.nChans =    m_ulChannels;           m_aacFrameInfo.sampRateCore =  m_ulCoreSampleRate;      /* sample rate of BASE layer */           /* see MPEG4 spec for index of each object type */           audioObjType = ASConfig.GetObjectType();           if (audioObjType == 2) {               m_aacFrameInfo.profile = AAC_PROFILE_LC;           } else {               AACFreeDecoder(m_hAACDecoder);               m_hAACDecoder = 0;               return HXR_FAIL;           }           AACSetRawBlockParams(m_hAACDecoder, 0, &m_aacFrameInfo);           return HXR_OK;       default:           /* unknown format */           return HXR_FAIL;    }}/* reset the decoder to the state just after OpenDecoder(). Use this   when seeking or when decoding has returned with an error. */STDMETHODIMP CAACDec::Reset(){    m_ulSamplesToConceal = 0;    AACFlushCodec(m_hAACDecoder);

⌨️ 快捷键说明

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