added svn keywords, tabs changed into 4 whitespaces, re #2
This commit is contained in:
parent
c8260ff827
commit
d606610431
|
@ -84,24 +84,23 @@ aacPlusEncoder :: open ( void )
|
||||||
nChannelsAAC = nChannelsSBR = getOutChannel();
|
nChannelsAAC = nChannelsSBR = getOutChannel();
|
||||||
|
|
||||||
if ( (getInChannel() == 2) && (bitrate >= 16000) && (bitrate < 44001) ) {
|
if ( (getInChannel() == 2) && (bitrate >= 16000) && (bitrate < 44001) ) {
|
||||||
useParametricStereo = 1;
|
useParametricStereo = 1;
|
||||||
nChannelsAAC = 1;
|
nChannelsAAC = 1;
|
||||||
nChannelsSBR = 2;
|
nChannelsSBR = 2;
|
||||||
|
|
||||||
reportEvent(10, "use Parametric Stereo");
|
reportEvent(10, "use Parametric Stereo");
|
||||||
|
|
||||||
envReadOffset = (MAX_DS_FILTER_DELAY + INPUT_DELAY)*MAX_CHANNELS;
|
envReadOffset = (MAX_DS_FILTER_DELAY + INPUT_DELAY)*MAX_CHANNELS;
|
||||||
coreWriteOffset = CORE_INPUT_OFFSET_PS;
|
coreWriteOffset = CORE_INPUT_OFFSET_PS;
|
||||||
writeOffset = envReadOffset;
|
writeOffset = envReadOffset;
|
||||||
} else {
|
} else {
|
||||||
/* set up 2:1 downsampling */
|
/* set up 2:1 downsampling */
|
||||||
InitIIR21_Resampler(&(IIR21_reSampler[0]));
|
InitIIR21_Resampler(&(IIR21_reSampler[0]));
|
||||||
InitIIR21_Resampler(&(IIR21_reSampler[1]));
|
InitIIR21_Resampler(&(IIR21_reSampler[1]));
|
||||||
|
|
||||||
if(IIR21_reSampler[0].delay > MAX_DS_FILTER_DELAY){
|
if(IIR21_reSampler[0].delay > MAX_DS_FILTER_DELAY)
|
||||||
throw Exception(__FILE__, __LINE__, "IIR21 resampler delay is bigger then 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;
|
||||||
writeOffset += IIR21_reSampler[0].delay*MAX_CHANNELS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleRateAAC = getInSampleRate();
|
sampleRateAAC = getInSampleRate();
|
||||||
|
@ -110,31 +109,30 @@ aacPlusEncoder :: open ( void )
|
||||||
config.nChannelsOut=nChannelsAAC;
|
config.nChannelsOut=nChannelsAAC;
|
||||||
config.bandWidth=bandwidth;
|
config.bandWidth=bandwidth;
|
||||||
|
|
||||||
/* set up SBR configuration */
|
/* set up SBR configuration */
|
||||||
if(!IsSbrSettingAvail (bitrate, nChannelsAAC, sampleRateAAC, &sampleRateAAC)) {
|
if(!IsSbrSettingAvail(bitrate, nChannelsAAC, sampleRateAAC, &sampleRateAAC))
|
||||||
throw Exception(__FILE__, __LINE__, "No valid SBR configuration found");
|
throw Exception(__FILE__, __LINE__, "No valid SBR configuration found");
|
||||||
}
|
|
||||||
|
|
||||||
InitializeSbrDefaults (&sbrConfig);
|
InitializeSbrDefaults (&sbrConfig);
|
||||||
sbrConfig.usePs = useParametricStereo;
|
sbrConfig.usePs = useParametricStereo;
|
||||||
|
|
||||||
AdjustSbrSettings( &sbrConfig,
|
AdjustSbrSettings( &sbrConfig,
|
||||||
bitrate,
|
bitrate,
|
||||||
nChannelsAAC,
|
nChannelsAAC,
|
||||||
sampleRateAAC,
|
sampleRateAAC,
|
||||||
AACENC_TRANS_FAC,
|
AACENC_TRANS_FAC,
|
||||||
24000);
|
24000);
|
||||||
|
|
||||||
EnvOpen( &hEnvEnc,
|
EnvOpen( &hEnvEnc,
|
||||||
inBuf + coreWriteOffset,
|
inBuf + coreWriteOffset,
|
||||||
&sbrConfig,
|
&sbrConfig,
|
||||||
&config.bandWidth);
|
&config.bandWidth);
|
||||||
|
|
||||||
/* set up AAC encoder, now that samling rate is known */
|
/* set up AAC encoder, now that samling rate is known */
|
||||||
config.sampleRate = sampleRateAAC;
|
config.sampleRate = sampleRateAAC;
|
||||||
if (AacEncOpen(&aacEnc, config) != 0){
|
if (AacEncOpen(&aacEnc, config) != 0){
|
||||||
AacEncClose(aacEnc);
|
AacEncClose(aacEnc);
|
||||||
throw Exception(__FILE__, __LINE__, "Initialisation of AAC failed !");
|
throw Exception(__FILE__, __LINE__, "Initialisation of AAC failed !");
|
||||||
}
|
}
|
||||||
|
|
||||||
init_plans();
|
init_plans();
|
||||||
|
@ -182,73 +180,76 @@ aacPlusEncoder :: write ( const void * buf,
|
||||||
|
|
||||||
reportEvent(10, "converting short to float");
|
reportEvent(10, "converting short to float");
|
||||||
short *TimeDataPcm = (short *) buf;
|
short *TimeDataPcm = (short *) buf;
|
||||||
|
|
||||||
for (i=0; i<samples; i++)
|
for (i=0; i<samples; i++)
|
||||||
inBuf[i+writeOffset+writtenSamples] = (float) TimeDataPcm[i];
|
inBuf[i+writeOffset+writtenSamples] = (float) TimeDataPcm[i];
|
||||||
writtenSamples+=samples;
|
writtenSamples+=samples;
|
||||||
reportEvent(10, "writtenSamples", writtenSamples);
|
reportEvent(10, "writtenSamples", writtenSamples);
|
||||||
|
|
||||||
if (writtenSamples < inSamples)
|
if (writtenSamples < inSamples)
|
||||||
return samples;
|
return samples;
|
||||||
|
|
||||||
/* encode one SBR frame */
|
/* encode one SBR frame */
|
||||||
reportEvent(10, "encode one SBR frame");
|
reportEvent(10, "encode one SBR frame");
|
||||||
EnvEncodeFrame( hEnvEnc,
|
EnvEncodeFrame( hEnvEnc,
|
||||||
inBuf + envReadOffset,
|
inBuf + envReadOffset,
|
||||||
inBuf + coreWriteOffset,
|
inBuf + coreWriteOffset,
|
||||||
MAX_CHANNELS,
|
MAX_CHANNELS,
|
||||||
&numAncDataBytes,
|
&numAncDataBytes,
|
||||||
ancDataBytes);
|
ancDataBytes);
|
||||||
|
|
||||||
reportEvent(10, "numAncDataBytes=", numAncDataBytes);
|
reportEvent(10, "numAncDataBytes=", numAncDataBytes);
|
||||||
|
|
||||||
/* 2:1 downsampling for AAC core */
|
/* 2:1 downsampling for AAC core */
|
||||||
if (!useParametricStereo){
|
if (!useParametricStereo) {
|
||||||
reportEvent(10, "2:1 downsampling for AAC core");
|
reportEvent(10, "2:1 downsampling for AAC core");
|
||||||
for( ch=0; ch<nChannelsAAC; ch++ )
|
for( ch=0; ch<nChannelsAAC; ch++ )
|
||||||
IIR21_Downsample( &(IIR21_reSampler[ch]),
|
IIR21_Downsample( &(IIR21_reSampler[ch]),
|
||||||
inBuf+writeOffset+ch,
|
inBuf + writeOffset+ch,
|
||||||
writtenSamples/getInChannel(),
|
writtenSamples/getInChannel(),
|
||||||
MAX_CHANNELS,
|
MAX_CHANNELS,
|
||||||
inBuf+ch,
|
inBuf+ch,
|
||||||
&outSamples,
|
&outSamples,
|
||||||
MAX_CHANNELS);
|
MAX_CHANNELS);
|
||||||
reportEvent(10, "outSamples=", outSamples);
|
|
||||||
|
reportEvent(10, "outSamples=", outSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* encode one AAC frame */
|
/* encode one AAC frame */
|
||||||
if (hEnvEnc && useParametricStereo) {
|
if (hEnvEnc && useParametricStereo) {
|
||||||
reportEvent(10, "Parametric Stereo encode one AAC frame");
|
reportEvent(10, "Parametric Stereo encode one AAC frame");
|
||||||
AacEncEncode( aacEnc,
|
AacEncEncode( aacEnc,
|
||||||
inBuf,
|
inBuf,
|
||||||
1, /* stride (step) */
|
1, /* stride (step) */
|
||||||
ancDataBytes,
|
ancDataBytes,
|
||||||
&numAncDataBytes,
|
&numAncDataBytes,
|
||||||
(unsigned *) (outBuf+ADTS_HEADER_SIZE),
|
(unsigned *) (outBuf+ADTS_HEADER_SIZE),
|
||||||
&numOutBytes);
|
&numOutBytes);
|
||||||
|
if(hEnvEnc)
|
||||||
if(hEnvEnc)
|
memcpy( inBuf,inBuf+AACENC_BLOCKSIZE,CORE_INPUT_OFFSET_PS*sizeof(float));
|
||||||
memcpy( inBuf,inBuf+AACENC_BLOCKSIZE,CORE_INPUT_OFFSET_PS*sizeof(float));
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reportEvent(10, "encode one AAC frame");
|
reportEvent(10, "encode one AAC frame");
|
||||||
AacEncEncode( aacEnc,
|
AacEncEncode( aacEnc,
|
||||||
inBuf+coreReadOffset,
|
inBuf + coreReadOffset,
|
||||||
MAX_CHANNELS,
|
MAX_CHANNELS,
|
||||||
ancDataBytes,
|
ancDataBytes,
|
||||||
&numAncDataBytes,
|
&numAncDataBytes,
|
||||||
(unsigned *) (outBuf+ADTS_HEADER_SIZE),
|
(unsigned *) (outBuf+ADTS_HEADER_SIZE),
|
||||||
&numOutBytes);
|
&numOutBytes);
|
||||||
|
|
||||||
reportEvent(10, "done AAC=", numOutBytes);
|
reportEvent(10, "done AAC=", numOutBytes);
|
||||||
if(hEnvEnc)
|
if(hEnvEnc)
|
||||||
memmove( inBuf,inBuf+AACENC_BLOCKSIZE*2*MAX_CHANNELS,writeOffset*sizeof(float));
|
memmove( inBuf,inBuf+AACENC_BLOCKSIZE*2*MAX_CHANNELS,writeOffset*sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write one frame of encoded audio */
|
/* Write one frame of encoded audio */
|
||||||
if (numOutBytes) {
|
if (numOutBytes) {
|
||||||
reportEvent(10, "Write one frame of encoded audio:", numOutBytes+ADTS_HEADER_SIZE);
|
reportEvent(10, "Write one frame of encoded audio:", numOutBytes+ADTS_HEADER_SIZE);
|
||||||
adts_hdr_up(outBuf, numOutBytes);
|
adts_hdr_up(outBuf, numOutBytes);
|
||||||
sink->write(outBuf, numOutBytes+ADTS_HEADER_SIZE);
|
sink->write(outBuf, numOutBytes+ADTS_HEADER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
writtenSamples=0;
|
writtenSamples=0;
|
||||||
|
|
||||||
return samples;
|
return samples;
|
||||||
|
@ -279,15 +280,15 @@ aacPlusEncoder :: close ( void ) throw ( Exception )
|
||||||
if ( isOpen() ) {
|
if ( isOpen() ) {
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
destroy_plans();
|
destroy_plans();
|
||||||
AacEncClose(aacEnc);
|
AacEncClose(aacEnc);
|
||||||
if (hEnvEnc) {
|
if (hEnvEnc) {
|
||||||
EnvClose(hEnvEnc);
|
EnvClose(hEnvEnc);
|
||||||
}
|
}
|
||||||
|
|
||||||
aacplusOpen = false;
|
aacplusOpen = false;
|
||||||
|
|
||||||
sink->close();
|
sink->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,8 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
* A class representing aacplus AAC+ encoder.
|
* A class representing aacplus AAC+ encoder.
|
||||||
*
|
*
|
||||||
* @author $Author: tipok $
|
* @author $Author$
|
||||||
* @version $Revision: 1 $
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CORE_DELAY (1600)
|
#define CORE_DELAY (1600)
|
||||||
|
|
Loading…
Reference in New Issue