Implement encoding mono (with SBR), re #2

This commit is contained in:
tipok 2008-11-06 22:00:00 +00:00
parent ebee08d10e
commit ec2e56f5f7
2 changed files with 14 additions and 6 deletions

View File

@ -145,8 +145,9 @@ aacPlusEncoder :: open ( void )
aacplusOpen = true;
reportEvent(10, "bitrate=", bitrate);
reportEvent(10, "nChannelsIn", getInChannel());
reportEvent(10, "nChannelsOut", getOutChannel());
reportEvent(10, "nChannelsSBR", nChannelsSBR);
reportEvent(10, "nChannelsOut", nChannelsAAC);
reportEvent(10, "nChannelsAAC", nChannelsAAC);
reportEvent(10, "sampleRateAAC", sampleRateAAC);
reportEvent(10, "inSamples", inSamples);
return true;
@ -181,8 +182,15 @@ aacPlusEncoder :: write ( const void * buf,
reportEvent(10, "converting short to float");
short *TimeDataPcm = (short *) buf;
for (i=0; i<samples; i++)
inBuf[i+writeOffset+writtenSamples] = (float) TimeDataPcm[i];
if(channels == 2) {
for (i=0; i<samples; i++)
inBuf[i+writeOffset+writtenSamples] = (float) TimeDataPcm[i];
} else {
/* using only left channel buffer for mono encoder */
for (i=0; i<samples; i++)
inBuf[writeOffset+2*writtenSamples+2*i] = (float) TimeDataPcm[i];
}
writtenSamples+=samples;
reportEvent(10, "writtenSamples", writtenSamples);
@ -206,7 +214,7 @@ aacPlusEncoder :: write ( const void * buf,
for( ch=0; ch<nChannelsAAC; ch++ )
IIR21_Downsample( &(IIR21_reSampler[ch]),
inBuf + writeOffset+ch,
writtenSamples/getInChannel(),
writtenSamples/channels,
MAX_CHANNELS,
inBuf+ch,
&outSamples,

View File

@ -146,12 +146,12 @@ class aacPlusEncoder : public AudioEncoder, public virtual Reporter
getInBitsPerSample() );
}
if ( getInChannel() != 2 ) {
if ( getInChannel() > 2 ) {
throw Exception( __FILE__, __LINE__,
"unsupported number of input channels for the encoder",
getInChannel() );
}
if ( getOutChannel() != 2 ) {
if ( getOutChannel() > 2 ) {
throw Exception( __FILE__, __LINE__,
"unsupported number of output channels for the encoder",
getOutChannel() );