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

📄 aacdec.c.svn-base

📁 MP3 for ARM codec. [asm+C]
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK *****   * Source last modified: $Id: aacdec.c,v 1.1 2005/02/26 01:47:31 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 ***** */  /************************************************************************************** * Fixed-point HE-AAC decoder * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) * February 2005 * * aacdec.c - platform-independent top level decoder API **************************************************************************************/#include "aaccommon.h"//#define PROFILE#ifdef PROFILE#include "systime.h"#endif/************************************************************************************** * Function:    AACInitDecoder * * Description: allocate memory for platform-specific data *              clear all the user-accessible fields *              initialize SBR decoder if enabled * * Inputs:      none * * Outputs:     none * * Return:      handle to AAC decoder instance, 0 if malloc fails **************************************************************************************/HAACDecoder AACInitDecoder(void){	AACDecInfo *aacDecInfo;	aacDecInfo = AllocateBuffers();	if (!aacDecInfo)		return 0;#ifdef AAC_ENABLE_SBR	if (InitSBR(aacDecInfo)) {		AACFreeDecoder(aacDecInfo);		return 0;	}#endif	return (HAACDecoder)aacDecInfo;}/************************************************************************************** * Function:    AACFreeDecoder * * Description: free platform-specific data allocated by AACInitDecoder *              free SBR decoder if enabled * * Inputs:      valid AAC decoder instance pointer (HAACDecoder) * * Outputs:     none * * Return:      none **************************************************************************************/void AACFreeDecoder(HAACDecoder hAACDecoder){	AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;	if (!aacDecInfo)		return;#ifdef AAC_ENABLE_SBR	FreeSBR(aacDecInfo);#endif	FreeBuffers(aacDecInfo);}/************************************************************************************** * Function:    AACFindSyncWord * * Description: locate the next byte-alinged sync word in the raw AAC stream * * Inputs:      buffer to search for sync word *              max number of bytes to search in buffer * * Outputs:     none * * Return:      offset to first sync word (bytes from start of buf) *              -1 if sync not found after searching nBytes **************************************************************************************/int AACFindSyncWord(unsigned char *buf, int nBytes){	int i;	/* find byte-aligned syncword (12 bits = 0xFFF) */	for (i = 0; i < nBytes - 1; i++) {		if ( (buf[i+0] & SYNCWORDH) == SYNCWORDH && (buf[i+1] & SYNCWORDL) == SYNCWORDL )			return i;	}		return -1;}/************************************************************************************** * Function:    AACGetLastFrameInfo * * Description: get info about last AAC frame decoded (number of samples decoded,  *                sample rate, bit rate, etc.) * * Inputs:      valid AAC decoder instance pointer (HAACDecoder) *              pointer to AACFrameInfo struct * * Outputs:     filled-in AACFrameInfo struct * * Return:      none * * Notes:       call this right after calling AACDecode() **************************************************************************************/void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo){	AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;	if (!aacDecInfo) {		aacFrameInfo->bitRate =       0;		aacFrameInfo->nChans =        0;		aacFrameInfo->sampRateCore =  0;		aacFrameInfo->sampRateOut =   0;		aacFrameInfo->bitsPerSample = 0;		aacFrameInfo->outputSamps =   0;		aacFrameInfo->profile =       0;		aacFrameInfo->tnsUsed =       0;		aacFrameInfo->pnsUsed =       0;	} else {		aacFrameInfo->bitRate =       aacDecInfo->bitRate;		aacFrameInfo->nChans =        aacDecInfo->nChans;		aacFrameInfo->sampRateCore =  aacDecInfo->sampRate;		aacFrameInfo->sampRateOut =   aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1);		aacFrameInfo->bitsPerSample = 16;		aacFrameInfo->outputSamps =   aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1);		aacFrameInfo->profile =       aacDecInfo->profile;		aacFrameInfo->tnsUsed =       aacDecInfo->tnsUsed;		aacFrameInfo->pnsUsed =       aacDecInfo->pnsUsed;	}}/************************************************************************************** * Function:    AACSetRawBlockParams * * Description: set internal state variables for decoding a stream of raw data blocks * * Inputs:      valid AAC decoder instance pointer (HAACDecoder) *              flag indicating source of parameters *              AACFrameInfo struct, with the members nChans, sampRate, and profile *                optionally filled-in * * Outputs:     updated codec state  * * Return:      0 if successful, error code (< 0) if error * * Notes:       if copyLast == 1, then the codec sets up its internal state (for  *                decoding raw blocks) based on previously-decoded ADTS header info *              if copyLast == 0, then the codec uses the values passed in *                aacFrameInfo to configure its internal state (useful when the *                source is MP4 format, for example) **************************************************************************************/int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo){	AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;	if (!aacDecInfo)		return ERR_AAC_NULL_POINTER;	aacDecInfo->format = AAC_FF_RAW;	if (copyLast)		return SetRawBlockParams(aacDecInfo, 1, 0, 0, 0);	else		return SetRawBlockParams(aacDecInfo, 0, aacFrameInfo->nChans, aacFrameInfo->sampRateCore, aacFrameInfo->profile);}/************************************************************************************** * Function:    AACFlushCodec * * Description: flush internal codec state (after seeking, for example) * * Inputs:      valid AAC decoder instance pointer (HAACDecoder) * * Outputs:     updated state variables in aacDecInfo * * Return:      0 if successful, error code (< 0) if error **************************************************************************************/int AACFlushCodec(HAACDecoder hAACDecoder){	int ch;	AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder;	if (!aacDecInfo)		return ERR_AAC_NULL_POINTER;	/* reset common state variables which change per-frame	 * don't touch state variables which are (usually) constant for entire clip 	 *   (nChans, sampRate, profile, format, sbrEnabled)	 */	aacDecInfo->prevBlockID = AAC_ID_INVALID;	aacDecInfo->currBlockID = AAC_ID_INVALID;	aacDecInfo->currInstTag = -1;	for (ch = 0; ch < MAX_NCHANS_ELEM; ch++)		aacDecInfo->sbDeinterleaveReqd[ch] = 0;	aacDecInfo->adtsBlocksLeft = 0;	aacDecInfo->tnsUsed = 0;	aacDecInfo->pnsUsed = 0;	/* reset internal codec state (flush overlap buffers, etc.) */	FlushCodec(aacDecInfo);#ifdef AAC_ENABLE_SBR

⌨️ 快捷键说明

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