mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-10-15 00:04:11 +02:00
Remove union, use pointer tricks instead
This commit is contained in:
+5
-3
@@ -23,10 +23,12 @@
|
|||||||
|
|
||||||
CFMDownsampler::CFMDownsampler(uint16_t length) :
|
CFMDownsampler::CFMDownsampler(uint16_t length) :
|
||||||
m_ringBuffer(length),//length might need tweaking
|
m_ringBuffer(length),//length might need tweaking
|
||||||
|
m_samplePack(0),
|
||||||
|
m_samplePackBytes(0),
|
||||||
m_packIndex(0),
|
m_packIndex(0),
|
||||||
m_downSampleIndex(0)
|
m_downSampleIndex(0)
|
||||||
{
|
{
|
||||||
m_samplePack = 0;
|
m_samplePackBytes = &m_samplePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFMDownsampler::addSample(q15_t sample)
|
void CFMDownsampler::addSample(q15_t sample)
|
||||||
@@ -45,7 +47,7 @@ void CFMDownsampler::addSample(q15_t sample)
|
|||||||
m_ringBuffer.put(m_samplePackBytes[2]);
|
m_ringBuffer.put(m_samplePackBytes[2]);
|
||||||
m_ringBuffer.put(m_samplePackBytes[3]);
|
m_ringBuffer.put(m_samplePackBytes[3]);
|
||||||
|
|
||||||
m_samplePack = 0;
|
m_samplePack = 0;//reset the sample pack
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -53,7 +55,7 @@ void CFMDownsampler::addSample(q15_t sample)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_packIndex++;
|
m_packIndex++;
|
||||||
if(m_packIndex >= 2)
|
if(m_packIndex >= 2)//did we pack to samples ?
|
||||||
m_packIndex = 0;
|
m_packIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -32,10 +32,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CFMDownsampleRB m_ringBuffer;
|
CFMDownsampleRB m_ringBuffer;
|
||||||
union {
|
|
||||||
int32_t m_samplePack;
|
int32_t m_samplePack;
|
||||||
int8_t m_samplePackBytes[4];
|
int32_t *m_samplePackBytes;
|
||||||
};
|
|
||||||
uint8_t m_packIndex;
|
uint8_t m_packIndex;
|
||||||
uint8_t m_downSampleIndex;
|
uint8_t m_downSampleIndex;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user