From d606610431c0e9b48d087ac94773e224ee12154a Mon Sep 17 00:00:00 2001 From: tipok Date: Wed, 5 Nov 2008 13:02:24 +0000 Subject: [PATCH] added svn keywords, tabs changed into 4 whitespaces, re #2 --- .../darkice-aacp/src/aacPlusEncoder.cpp | 187 +++++++++--------- .../darkice-aacp/src/aacPlusEncoder.h | 4 +- 2 files changed, 96 insertions(+), 95 deletions(-) diff --git a/darkice/branches/darkice-aacp/src/aacPlusEncoder.cpp b/darkice/branches/darkice-aacp/src/aacPlusEncoder.cpp index 69af462..53eb143 100644 --- a/darkice/branches/darkice-aacp/src/aacPlusEncoder.cpp +++ b/darkice/branches/darkice-aacp/src/aacPlusEncoder.cpp @@ -77,31 +77,30 @@ aacPlusEncoder :: open ( void ) } reportEvent(1, "Using aacplus codec version", "720 3gpp"); - + /* set up basic parameters for aacPlus codec */ AacInitDefaultConfig(&config); nChannelsAAC = nChannelsSBR = getOutChannel(); if ( (getInChannel() == 2) && (bitrate >= 16000) && (bitrate < 44001) ) { - useParametricStereo = 1; - nChannelsAAC = 1; - nChannelsSBR = 2; - - reportEvent(10, "use Parametric Stereo"); - - envReadOffset = (MAX_DS_FILTER_DELAY + INPUT_DELAY)*MAX_CHANNELS; - coreWriteOffset = CORE_INPUT_OFFSET_PS; - writeOffset = envReadOffset; + useParametricStereo = 1; + nChannelsAAC = 1; + nChannelsSBR = 2; + + reportEvent(10, "use Parametric Stereo"); + + envReadOffset = (MAX_DS_FILTER_DELAY + INPUT_DELAY)*MAX_CHANNELS; + coreWriteOffset = CORE_INPUT_OFFSET_PS; + writeOffset = envReadOffset; } else { - /* set up 2:1 downsampling */ - InitIIR21_Resampler(&(IIR21_reSampler[0])); - InitIIR21_Resampler(&(IIR21_reSampler[1])); - - if(IIR21_reSampler[0].delay > MAX_DS_FILTER_DELAY){ - throw Exception(__FILE__, __LINE__, "IIR21 resampler delay is bigger then MAX_DS_FILTER_DELAY"); - } - writeOffset += IIR21_reSampler[0].delay*MAX_CHANNELS; + /* set up 2:1 downsampling */ + InitIIR21_Resampler(&(IIR21_reSampler[0])); + InitIIR21_Resampler(&(IIR21_reSampler[1])); + + if(IIR21_reSampler[0].delay > MAX_DS_FILTER_DELAY) + throw Exception(__FILE__, __LINE__, "IIR21 resampler delay is bigger then MAX_DS_FILTER_DELAY"); + writeOffset += IIR21_reSampler[0].delay*MAX_CHANNELS; } sampleRateAAC = getInSampleRate(); @@ -110,31 +109,30 @@ aacPlusEncoder :: open ( void ) config.nChannelsOut=nChannelsAAC; config.bandWidth=bandwidth; - /* set up SBR configuration */ - if(!IsSbrSettingAvail (bitrate, nChannelsAAC, sampleRateAAC, &sampleRateAAC)) { - throw Exception(__FILE__, __LINE__, "No valid SBR configuration found"); - } + /* set up SBR configuration */ + if(!IsSbrSettingAvail(bitrate, nChannelsAAC, sampleRateAAC, &sampleRateAAC)) + throw Exception(__FILE__, __LINE__, "No valid SBR configuration found"); InitializeSbrDefaults (&sbrConfig); sbrConfig.usePs = useParametricStereo; - AdjustSbrSettings( &sbrConfig, - bitrate, - nChannelsAAC, - sampleRateAAC, - AACENC_TRANS_FAC, - 24000); - - EnvOpen( &hEnvEnc, - inBuf + coreWriteOffset, - &sbrConfig, - &config.bandWidth); + AdjustSbrSettings( &sbrConfig, + bitrate, + nChannelsAAC, + sampleRateAAC, + AACENC_TRANS_FAC, + 24000); + EnvOpen( &hEnvEnc, + inBuf + coreWriteOffset, + &sbrConfig, + &config.bandWidth); + /* set up AAC encoder, now that samling rate is known */ config.sampleRate = sampleRateAAC; if (AacEncOpen(&aacEnc, config) != 0){ - AacEncClose(aacEnc); - throw Exception(__FILE__, __LINE__, "Initialisation of AAC failed !"); + AacEncClose(aacEnc); + throw Exception(__FILE__, __LINE__, "Initialisation of AAC failed !"); } init_plans(); @@ -182,73 +180,76 @@ aacPlusEncoder :: write ( const void * buf, reportEvent(10, "converting short to float"); short *TimeDataPcm = (short *) buf; + for (i=0; iwrite(outBuf, numOutBytes+ADTS_HEADER_SIZE); + reportEvent(10, "Write one frame of encoded audio:", numOutBytes+ADTS_HEADER_SIZE); + adts_hdr_up(outBuf, numOutBytes); + sink->write(outBuf, numOutBytes+ADTS_HEADER_SIZE); } + writtenSamples=0; return samples; @@ -278,16 +279,16 @@ aacPlusEncoder :: close ( void ) throw ( Exception ) { if ( isOpen() ) { flush(); - - destroy_plans(); - AacEncClose(aacEnc); - if (hEnvEnc) { - EnvClose(hEnvEnc); - } - - aacplusOpen = false; - - sink->close(); + + destroy_plans(); + AacEncClose(aacEnc); + if (hEnvEnc) { + EnvClose(hEnvEnc); + } + + aacplusOpen = false; + + sink->close(); } } diff --git a/darkice/branches/darkice-aacp/src/aacPlusEncoder.h b/darkice/branches/darkice-aacp/src/aacPlusEncoder.h index f6db045..afe51d2 100644 --- a/darkice/branches/darkice-aacp/src/aacPlusEncoder.h +++ b/darkice/branches/darkice-aacp/src/aacPlusEncoder.h @@ -78,8 +78,8 @@ extern "C" { /** * A class representing aacplus AAC+ encoder. * - * @author $Author: tipok $ - * @version $Revision: 1 $ + * @author $Author$ + * @version $Revision$ */ #define CORE_DELAY (1600)