diff options
Diffstat (limited to 'kradio3/src/soundformat.cpp')
-rw-r--r-- | kradio3/src/soundformat.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/kradio3/src/soundformat.cpp b/kradio3/src/soundformat.cpp index 9ca1b5d..50e0c75 100644 --- a/kradio3/src/soundformat.cpp +++ b/kradio3/src/soundformat.cpp @@ -87,15 +87,15 @@ int SoundFormat::convertSampleToInt(const char *sample, bool do_scale) const } int scale = (sizeof(unsigned) << 3) - m_SampleBits; - int signtqmask = do_scale ? (!m_IsSigned << ((sizeof(unsigned) << 3) - 1)) : + int signmask = do_scale ? (!m_IsSigned << ((sizeof(unsigned) << 3) - 1)) : (-m_IsSigned << ((size << 3) - 1)) ; if (do_scale) { // map to int number space - return (val << scale) ^ signtqmask; + return (val << scale) ^ signmask; } else { // do only sign extension - if (val & signtqmask) - val |= signtqmask; + if (val & signmask) + val |= signmask; return val; } } @@ -105,9 +105,9 @@ void SoundFormat::convertIntToSample(int src, char *dst, bool is_scaled) const { int size = sampleSize(); int scale = (sizeof(unsigned) * 8) - m_SampleBits; - int signtqmask = (!m_IsSigned << (sizeof(unsigned) * 8 - 1)); + int signmask = (!m_IsSigned << (sizeof(unsigned) * 8 - 1)); - unsigned val = is_scaled ? (src ^ signtqmask) >> scale : src; + unsigned val = is_scaled ? (src ^ signmask) >> scale : src; if (m_Endianess == LITTLE_ENDIAN) { for (int i = 0; i < size; ++i, ++dst) { (unsigned char &)*dst = val & 0xFF; @@ -127,7 +127,7 @@ void SoundFormat::convertSamplesToInts(const char *src, int *dst, size_t n, bool { int size = sampleSize(); int scale = (sizeof(unsigned) * 8) - m_SampleBits; - int signtqmask = do_scale ? (!m_IsSigned << ((sizeof(unsigned) << 3) - 1)) : + int signmask = do_scale ? (!m_IsSigned << ((sizeof(unsigned) << 3) - 1)) : (-m_IsSigned << ((size << 3) - 1)) ; if (m_Endianess == LITTLE_ENDIAN) { src = src - 1 + (size * n); @@ -138,9 +138,9 @@ void SoundFormat::convertSamplesToInts(const char *src, int *dst, size_t n, bool val = (val << 8) | (unsigned char)*src; } if (do_scale) { - *dst = (val << scale) ^ signtqmask; - } else if (val & signtqmask) { - *dst = val | signtqmask; + *dst = (val << scale) ^ signmask; + } else if (val & signmask) { + *dst = val | signmask; } } } else { @@ -150,9 +150,9 @@ void SoundFormat::convertSamplesToInts(const char *src, int *dst, size_t n, bool val = (val << 8) | (unsigned char)*src; } if (do_scale) { - *dst = (val << scale) ^ signtqmask; - } else if (val & signtqmask) { - *dst = val | signtqmask; + *dst = (val << scale) ^ signmask; + } else if (val & signmask) { + *dst = val | signmask; } } } @@ -163,11 +163,11 @@ void SoundFormat::convertIntsToSamples(const int *src, char *dst, size_t n, bool { int size = sampleSize(); int scale = (sizeof(unsigned) * 8) - m_SampleBits; - int signtqmask = (!m_IsSigned << (sizeof(unsigned) * 8 - 1)); + int signmask = (!m_IsSigned << (sizeof(unsigned) * 8 - 1)); if (m_Endianess == LITTLE_ENDIAN) { for (const int *end = src+n; src < end; ++src) { - unsigned val = is_scaled ? ((unsigned)(*src ^ signtqmask)) >> scale : *src; + unsigned val = is_scaled ? ((unsigned)(*src ^ signmask)) >> scale : *src; for (int i = 0; i < size; ++i, ++dst) { (unsigned char &)*dst = val & 0xFF; val >>= 8; @@ -177,7 +177,7 @@ void SoundFormat::convertIntsToSamples(const int *src, char *dst, size_t n, bool dst = dst - 1 + (size * n); const int *end = src; for (src = src - 1 + n; src >= end; --src) { - unsigned val = is_scaled ? ((unsigned)(*src ^ signtqmask)) >> scale : *src; + unsigned val = is_scaled ? ((unsigned)(*src ^ signmask)) >> scale : *src; for (int i = size - 1; i >= 0; --i, --dst) { (unsigned char &)*dst = val & 0xFF; val >>= 8; @@ -192,7 +192,7 @@ void SoundFormat::convertSamplesToFloat(const char *_src, float **_dst, size_t n int sample_size = sampleSize(); int frame_size = frameSize(); int scale = (sizeof(short) << 3) - m_SampleBits; - int signtqmask = !m_IsSigned << ((sizeof(short) << 3) - 1); + int signmask = !m_IsSigned << ((sizeof(short) << 3) - 1); int skip = frame_size - sample_size; if (m_Endianess == LITTLE_ENDIAN) { @@ -206,7 +206,7 @@ void SoundFormat::convertSamplesToFloat(const char *_src, float **_dst, size_t n for (int i = sample_size - 1; i >= 0; --i, --src) { val = (val << 8) | (unsigned char)*src; } - *dst = (float)(signed short)((val << scale) ^ signtqmask) / 32768.0f; + *dst = (float)(signed short)((val << scale) ^ signmask) / 32768.0f; src = src - skip; } } @@ -219,7 +219,7 @@ void SoundFormat::convertSamplesToFloat(const char *_src, float **_dst, size_t n for (int i = 0; i < sample_size; ++i, ++src) { val = (val << 8) | (unsigned char)*src; } - *dst = (float)(signed short)((val << scale) ^ signtqmask) / 32768.0f; + *dst = (float)(signed short)((val << scale) ^ signmask) / 32768.0f; src = src + skip; } } @@ -233,7 +233,7 @@ void SoundFormat::convertFloatsToSamples(const float **_src, char *_dst, size_t int sample_size = sampleSize(); int frame_size = frameSize(); int scale = (sizeof(short) << 3) - m_SampleBits; - int signtqmask = (!m_IsSigned << (sizeof(short) << 3) - 1); + int signmask = (!m_IsSigned << (sizeof(short) << 3) - 1); int skip = frame_size - sample_size; if (m_Endianess == LITTLE_ENDIAN) { @@ -241,7 +241,7 @@ void SoundFormat::convertFloatsToSamples(const float **_src, char *_dst, size_t const float *src = _src[ch]; char *dst = _dst + ch * sample_size; for (const float *end = src+n; src < end; ++src) { - unsigned val = (( ((unsigned)(*src * 32768.0f)) ^ signtqmask)) >> scale; + unsigned val = (( ((unsigned)(*src * 32768.0f)) ^ signmask)) >> scale; for (int i = 0; i < sample_size; ++i, ++dst) { (unsigned char &)*dst = val & 0xFF; val >>= 8; @@ -256,7 +256,7 @@ void SoundFormat::convertFloatsToSamples(const float **_src, char *_dst, size_t const float *src = _src[ch]; const float *end = src; for (src = src - 1 + n; src >= end; --src) { - unsigned val = (( ((unsigned)(*src * 32768.0f)) ^ signtqmask)) >> scale; + unsigned val = (( ((unsigned)(*src * 32768.0f)) ^ signmask)) >> scale; for (int i = sample_size - 1; i >= 0; --i, --dst) { (unsigned char &)*dst = val & 0xFF; val >>= 8; |