moved functions conv8() and conv16() to class Util

This commit is contained in:
darkeye 2002-03-28 16:38:37 +00:00
parent 867b7ffdc9
commit f96c7969eb
2 changed files with 13 additions and 143 deletions

View File

@ -191,111 +191,6 @@ LameLibEncoder :: open ( void )
return true;
}
/*------------------------------------------------------------------------------
* Convert an unsigned char buffer holding 8 bit PCM values with channels
* interleaved to two short int buffers (one for each channel)
*----------------------------------------------------------------------------*/
void
LameLibEncoder :: conv8 ( unsigned char * pcmBuffer,
unsigned int lenPcmBuffer,
short int * leftBuffer,
short int * rightBuffer,
unsigned int channels )
{
if ( channels == 1 ) {
unsigned int i, j;
for ( i = 0, j = 0; i < lenPcmBuffer; ) {
unsigned short int value;
value = pcmBuffer[i++];
leftBuffer[j] = (short int) value;
++j;
}
} else {
unsigned int i, j;
for ( i = 0, j = 0; i < lenPcmBuffer; ) {
unsigned short int value;
value = pcmBuffer[i++];
leftBuffer[j] = (short int) value;
value = pcmBuffer[i++];
rightBuffer[j] = (short int) value;
++j;
}
}
}
/*------------------------------------------------------------------------------
* Convert an unsigned char buffer holding 16 bit PCM values with channels
* interleaved to two short int buffers (one for each channel)
*----------------------------------------------------------------------------*/
void
LameLibEncoder :: conv16 ( unsigned char * pcmBuffer,
unsigned int lenPcmBuffer,
short int * leftBuffer,
short int * rightBuffer,
unsigned int channels )
{
if ( isInBigEndian() ) {
if ( channels == 1 ) {
unsigned int i, j;
for ( i = 0, j = 0; i < lenPcmBuffer; ) {
unsigned short int value;
value = pcmBuffer[i++] << 8;
value |= pcmBuffer[i++];
leftBuffer[j] = (short int) value;
++j;
}
} else {
unsigned int i, j;
for ( i = 0, j = 0; i < lenPcmBuffer; ) {
unsigned short int value;
value = pcmBuffer[i++] << 8;
value |= pcmBuffer[i++];
leftBuffer[j] = (short int) value;
value = pcmBuffer[i++] << 8;
value |= pcmBuffer[i++];
rightBuffer[j] = (short int) value;
++j;
}
}
} else {
if ( channels == 1 ) {
unsigned int i, j;
for ( i = 0, j = 0; i < lenPcmBuffer; ) {
unsigned short int value;
value = pcmBuffer[i++];
value |= pcmBuffer[i++] << 8;
leftBuffer[j] = (short int) value;
++j;
}
} else {
unsigned int i, j;
for ( i = 0, j = 0; i < lenPcmBuffer; ) {
unsigned short int value;
value = pcmBuffer[i++];
value |= pcmBuffer[i++] << 8;
leftBuffer[j] = (short int) value;
value = pcmBuffer[i++];
value |= pcmBuffer[i++] << 8;
rightBuffer[j] = (short int) value;
++j;
}
}
}
}
/*------------------------------------------------------------------------------
* Write data to the encoder
@ -325,9 +220,14 @@ LameLibEncoder :: write ( const void * buf,
short int rightBuffer[nSamples];
if ( bitsPerSample == 8 ) {
conv8( b, processed, leftBuffer, rightBuffer, channels);
Util::conv8( b, processed, leftBuffer, rightBuffer, channels);
} else if ( bitsPerSample == 16 ) {
conv16( b, processed, leftBuffer, rightBuffer, channels);
Util::conv16( b,
processed,
leftBuffer,
rightBuffer,
channels,
isInBigEndian());
} else {
throw Exception( __FILE__, __LINE__,
"unsupported number of bits per sample for the encoder",
@ -415,6 +315,9 @@ LameLibEncoder :: close ( void ) throw ( Exception )
$Source$
$Log$
Revision 1.10 2002/03/28 16:38:37 darkeye
moved functions conv8() and conv16() to class Util
Revision 1.9 2001/10/20 10:56:45 darkeye
added possibility to disable highpass and lowpass filters for lame

View File

@ -140,42 +140,6 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
{
}
/**
* Convert a char buffer holding 8 bit PCM values to a short buffer
*
* @param pcmBuffer buffer holding 8 bit PCM audio values,
* channels are interleaved
* @param lenPcmBuffer length of pcmBuffer
* @param leftBuffer put the left channel here (must be big enough)
* @param rightBuffer put the right channel here (if mono, not
* touched, must be big enough)
* @param channels number of channels (1 = mono, 2 = stereo)
*/
void
conv8 ( unsigned char * pcmBuffer,
unsigned int lenPcmBuffer,
short int * leftBuffer,
short int * rightBuffer,
unsigned int channels );
/**
* Convert a char buffer holding 16 bit PCM values to a short buffer
*
* @param pcmBuffer buffer holding 16 bit PCM audio values,
* channels are interleaved
* @param lenPcmBuffer length of pcmBuffer
* @param leftBuffer put the left channel here (must be big enough)
* @param rightBuffer put the right channel here (if mono, not
* touched, must be big enough)
* @param channels number of channels (1 = mono, 2 = stereo)
*/
void
conv16 ( unsigned char * pcmBuffer,
unsigned int lenPcmBuffer,
short int * leftBuffer,
short int * rightBuffer,
unsigned int channels );
protected:
@ -456,6 +420,9 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
$Source$
$Log$
Revision 1.11 2002/03/28 16:38:37 darkeye
moved functions conv8() and conv16() to class Util
Revision 1.10 2001/10/20 10:56:45 darkeye
added possibility to disable highpass and lowpass filters for lame