Tweak LO dithering for better performance

This commit is contained in:
Jan Hamal Dvořák 2024-07-10 10:21:04 +02:00
parent 2fc01539f0
commit 57e36203aa

View file

@ -251,12 +251,11 @@ static void lo_generate(uint32_t *buf, double freq, uint32_t phase)
{
freq_step = STEP_BASE * freq;
unsigned down = 4 + __builtin_clz(freq_step);
unsigned down = 2 + __builtin_clz(freq_step);
for (size_t i = 0; i < LO_WORDS; i++) {
uint32_t bits = 0;
int shift = (rnd_next() >> down) - (rnd_next() >> down) + (rnd_next() >> down) -
(rnd_next() >> down);
int shift = (rnd_next() >> down) - (rnd_next() >> down);
for (int j = 0; j < 32; j++) {
bits |= (phase + shift) >> 31;
@ -272,13 +271,12 @@ static void lo_tweak(uint32_t *buf, uint32_t phase)
{
static size_t i = 0;
uint32_t bits = 0;
unsigned down = 4 + __builtin_clz(freq_step);
unsigned down = 2 + __builtin_clz(freq_step);
phase += freq_step * i * 32;
for (int j = 0; j < 32; j++) {
int shift = (rnd_next() >> down) - (rnd_next() >> down) + (rnd_next() >> down) -
(rnd_next() >> down);
int shift = (rnd_next() >> down) - (rnd_next() >> down);
bits |= (phase + shift) >> 31;
bits <<= 1;
phase += freq_step;
@ -602,8 +600,10 @@ static void rf_rx(void)
iq_queue_pos = (iq_queue_pos + 1) & (IQ_QUEUE_LEN - 1);
}
lo_tweak(lo_cos, COS_PHASE);
lo_tweak(lo_sin, SIN_PHASE);
for (int i = 0; i < 8; i++) {
lo_tweak(lo_cos, COS_PHASE);
lo_tweak(lo_sin, SIN_PHASE);
}
}
}