mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/spkmodem-recv: clean up decode_pulse
make it easier to read by clearer variable naming. this change also reduces memory accesses (fewer struct dereferences - see: struct decoder_state), when using much weaker/older compilers that don't optimise properly. this, in the most active part of the code, which is called.... 48000 times a second. peanuts on modern CPUs, but on old (early 90s) CPUs it makes a big difference. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -179,28 +179,35 @@ decode_pulse(struct decoder_state *st)
|
||||
{
|
||||
unsigned char old_ring, old_sep;
|
||||
unsigned char new_pulse;
|
||||
int ringpos;
|
||||
signed short sample;
|
||||
|
||||
old_ring = st->pulse[st->ringpos];
|
||||
ringpos = st->ringpos;
|
||||
|
||||
old_ring = st->pulse[ringpos];
|
||||
old_sep = st->pulse[st->sep_pos];
|
||||
|
||||
st->freq_data -= old_ring;
|
||||
st->freq_data += old_sep;
|
||||
st->freq_separator -= old_sep;
|
||||
|
||||
st->frame[st->ringpos] = read_sample(st);
|
||||
sample = read_sample(st);
|
||||
st->frame[ringpos] = sample;
|
||||
|
||||
if ((unsigned)(st->frame[st->ringpos] + THRESHOLD)
|
||||
if ((unsigned)(sample + THRESHOLD)
|
||||
> (unsigned)(2 * THRESHOLD))
|
||||
new_pulse = 1;
|
||||
else
|
||||
new_pulse = 0;
|
||||
|
||||
st->pulse[st->ringpos] = new_pulse;
|
||||
st->pulse[ringpos] = new_pulse;
|
||||
st->freq_separator += new_pulse;
|
||||
|
||||
st->ringpos++;
|
||||
if (st->ringpos >= MAX_SAMPLES)
|
||||
st->ringpos = 0;
|
||||
ringpos++;
|
||||
if (ringpos >= MAX_SAMPLES)
|
||||
ringpos = 0;
|
||||
|
||||
st->ringpos = ringpos;
|
||||
|
||||
st->sep_pos++;
|
||||
if (st->sep_pos >= MAX_SAMPLES)
|
||||
|
||||
Reference in New Issue
Block a user