1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-09 09:25:07 -04:00

Optimize A-Law and Mu-Law compressors

This commit is contained in:
f4exb
2019-02-19 23:27:00 +01:00
parent 1823a78509
commit 9d3d4674d7
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -86,15 +86,15 @@ void AudioCompressor::fillLUT2()
void AudioCompressor::fillALaw()
{
for (int i=-32768; i<32768; i++) {
m_lut[i+32768] = ALaw_Encode(i);
for (int i=-16384; i<16384; i++) {
m_lut[i+16384] = ALaw_Encode(2*i);
}
}
void AudioCompressor::fillULaw()
{
for (int i=-32768; i<32768; i++) {
m_lut[i+32768] = MuLaw_Encode(i);
for (int i=-16384; i<16384; i++) {
m_lut[i+16384] = MuLaw_Encode(2*i);
}
}
@@ -107,7 +107,7 @@ int16_t AudioCompressor::compress(int16_t sample)
int8_t AudioCompressor::compress8(int16_t sample)
{
return m_lut[sample + 32768];
return m_lut[sample/2 + 16384];
}
/* http://dystopiancode.blogspot.com/2012/02/pcm-law-and-u-law-companding-algorithms.html