Implement encoding mono (with SBR), re #2
This commit is contained in:
parent
ebee08d10e
commit
ec2e56f5f7
|
@ -145,8 +145,9 @@ aacPlusEncoder :: open ( void )
|
||||||
aacplusOpen = true;
|
aacplusOpen = true;
|
||||||
reportEvent(10, "bitrate=", bitrate);
|
reportEvent(10, "bitrate=", bitrate);
|
||||||
reportEvent(10, "nChannelsIn", getInChannel());
|
reportEvent(10, "nChannelsIn", getInChannel());
|
||||||
|
reportEvent(10, "nChannelsOut", getOutChannel());
|
||||||
reportEvent(10, "nChannelsSBR", nChannelsSBR);
|
reportEvent(10, "nChannelsSBR", nChannelsSBR);
|
||||||
reportEvent(10, "nChannelsOut", nChannelsAAC);
|
reportEvent(10, "nChannelsAAC", nChannelsAAC);
|
||||||
reportEvent(10, "sampleRateAAC", sampleRateAAC);
|
reportEvent(10, "sampleRateAAC", sampleRateAAC);
|
||||||
reportEvent(10, "inSamples", inSamples);
|
reportEvent(10, "inSamples", inSamples);
|
||||||
return true;
|
return true;
|
||||||
|
@ -181,8 +182,15 @@ 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++)
|
if(channels == 2) {
|
||||||
inBuf[i+writeOffset+writtenSamples] = (float) TimeDataPcm[i];
|
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;
|
writtenSamples+=samples;
|
||||||
reportEvent(10, "writtenSamples", writtenSamples);
|
reportEvent(10, "writtenSamples", writtenSamples);
|
||||||
|
|
||||||
|
@ -206,7 +214,7 @@ aacPlusEncoder :: write ( const void * buf,
|
||||||
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/channels,
|
||||||
MAX_CHANNELS,
|
MAX_CHANNELS,
|
||||||
inBuf+ch,
|
inBuf+ch,
|
||||||
&outSamples,
|
&outSamples,
|
||||||
|
|
|
@ -146,12 +146,12 @@ class aacPlusEncoder : public AudioEncoder, public virtual Reporter
|
||||||
getInBitsPerSample() );
|
getInBitsPerSample() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getInChannel() != 2 ) {
|
if ( getInChannel() > 2 ) {
|
||||||
throw Exception( __FILE__, __LINE__,
|
throw Exception( __FILE__, __LINE__,
|
||||||
"unsupported number of input channels for the encoder",
|
"unsupported number of input channels for the encoder",
|
||||||
getInChannel() );
|
getInChannel() );
|
||||||
}
|
}
|
||||||
if ( getOutChannel() != 2 ) {
|
if ( getOutChannel() > 2 ) {
|
||||||
throw Exception( __FILE__, __LINE__,
|
throw Exception( __FILE__, __LINE__,
|
||||||
"unsupported number of output channels for the encoder",
|
"unsupported number of output channels for the encoder",
|
||||||
getOutChannel() );
|
getOutChannel() );
|
||||||
|
|
Loading…
Reference in New Issue