From f96c7969ebab56cc4a1d192c7f2225a1ba9f983e Mon Sep 17 00:00:00 2001 From: darkeye Date: Thu, 28 Mar 2002 16:38:37 +0000 Subject: [PATCH] moved functions conv8() and conv16() to class Util --- darkice/trunk/src/LameLibEncoder.cpp | 117 +++------------------------ darkice/trunk/src/LameLibEncoder.h | 39 +-------- 2 files changed, 13 insertions(+), 143 deletions(-) diff --git a/darkice/trunk/src/LameLibEncoder.cpp b/darkice/trunk/src/LameLibEncoder.cpp index 74f941b..8300871 100644 --- a/darkice/trunk/src/LameLibEncoder.cpp +++ b/darkice/trunk/src/LameLibEncoder.cpp @@ -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 diff --git a/darkice/trunk/src/LameLibEncoder.h b/darkice/trunk/src/LameLibEncoder.h index c58a75f..ac470d1 100644 --- a/darkice/trunk/src/LameLibEncoder.h +++ b/darkice/trunk/src/LameLibEncoder.h @@ -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