1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-28 15:56:33 -04:00

Audio UDP/RTP: fixed A-law / mu-law compressors

This commit is contained in:
f4exb 2019-02-14 14:28:01 +01:00
parent c46bf5b110
commit 8582d52739
3 changed files with 7 additions and 7 deletions

View File

@ -86,15 +86,15 @@ void AudioCompressor::fillLUT2()
void AudioCompressor::fillALaw() void AudioCompressor::fillALaw()
{ {
for (int i=0; i<8*4096; i++) { for (int i=-32768; i<32768; i++) {
m_lut[i] = ALaw_Encode(i/2 + 16384); m_lut[i+32768] = ALaw_Encode(i);
} }
} }
void AudioCompressor::fillULaw() void AudioCompressor::fillULaw()
{ {
for (int i=0; i<8*4096; i++) { for (int i=-32768; i<32768; i++) {
m_lut[i] = MuLaw_Encode(i/2 + 16384); m_lut[i+32768] = MuLaw_Encode(i);
} }
} }
@ -107,7 +107,7 @@ int16_t AudioCompressor::compress(int16_t sample)
int8_t AudioCompressor::compress8(int16_t sample) int8_t AudioCompressor::compress8(int16_t sample)
{ {
return m_lut[sample/2 + 16384]; return m_lut[sample + 32768];
} }
/* http://dystopiancode.blogspot.com/2012/02/pcm-law-and-u-law-companding-algorithms.html /* http://dystopiancode.blogspot.com/2012/02/pcm-law-and-u-law-companding-algorithms.html

View File

@ -37,7 +37,7 @@ private:
int8_t ALaw_Encode(int16_t number); int8_t ALaw_Encode(int16_t number);
int8_t MuLaw_Encode(int16_t number); int8_t MuLaw_Encode(int16_t number);
int16_t m_lut[32768]; int16_t m_lut[65536];
static const uint16_t ALAW_MAX; static const uint16_t ALAW_MAX;
static const uint16_t MULAW_MAX; static const uint16_t MULAW_MAX;
static const uint16_t MULAW_BIAS; static const uint16_t MULAW_BIAS;

View File

@ -282,7 +282,7 @@ void AudioDialogX::updateOutputSDPString()
} }
int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo ? 2 : 1; int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo ? 2 : 1;
uint32_t decimationFactor = m_outputDeviceInfo.decimationFactor == 0 ? 1 : m_outputDeviceInfo.decimationFactor; uint32_t decimationFactor = m_outputDeviceInfo.decimationFactor == 0 ? 1 : m_outputDeviceInfo.decimationFactor;
ui->outputSDPText->setText(tr("%1/%2/%3").arg(format).arg(m_outputDeviceInfo.sampleRate/decimationFactor).arg(nChannels)); ui->outputSDPText->setText(tr("%1/%2/%3").arg(format).arg(m_outputDeviceInfo.sampleRate/decimationFactor).arg(nChannels));
} }