mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-21 10:12:04 +02:00
util/spkmodem-recv: optimise decode_pulse
the frame[] array is never actually used meaningfully. that setting of frame[ringpos] on the decode_state is only set here, but then the value isn't really used at all. the entire size of the annay is used for sizeof in print_stats, but then we can just declare that manually. since we also know that this value never changes, we can use a global define for the sizeof entry in print_stats, thereby simplifying operation further Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#define SAMPLES_PER_FRAME 240
|
#define SAMPLES_PER_FRAME 240
|
||||||
#define MAX_SAMPLES (2 * SAMPLES_PER_FRAME)
|
#define MAX_SAMPLES (2 * SAMPLES_PER_FRAME)
|
||||||
|
#define SAMPLE_OFFSET (MAX_SAMPLES * sizeof(short))
|
||||||
|
|
||||||
#define FREQ_SEP_MIN 5
|
#define FREQ_SEP_MIN 5
|
||||||
#define FREQ_SEP_MAX 15
|
#define FREQ_SEP_MAX 15
|
||||||
@@ -52,7 +53,6 @@
|
|||||||
#define READ_BUF 4096
|
#define READ_BUF 4096
|
||||||
|
|
||||||
struct decoder_state {
|
struct decoder_state {
|
||||||
signed short frame[MAX_SAMPLES];
|
|
||||||
unsigned char pulse[MAX_SAMPLES];
|
unsigned char pulse[MAX_SAMPLES];
|
||||||
|
|
||||||
signed short inbuf[READ_BUF];
|
signed short inbuf[READ_BUF];
|
||||||
@@ -192,7 +192,6 @@ decode_pulse(struct decoder_state *st)
|
|||||||
st->freq_separator -= old_sep;
|
st->freq_separator -= old_sep;
|
||||||
|
|
||||||
sample = read_sample(st);
|
sample = read_sample(st);
|
||||||
st->frame[ringpos] = sample;
|
|
||||||
|
|
||||||
if ((unsigned)(sample + THRESHOLD)
|
if ((unsigned)(sample + THRESHOLD)
|
||||||
> (unsigned)(2 * THRESHOLD))
|
> (unsigned)(2 * THRESHOLD))
|
||||||
@@ -291,7 +290,7 @@ print_stats(struct decoder_state *st)
|
|||||||
st->freq_data,
|
st->freq_data,
|
||||||
st->freq_separator,
|
st->freq_separator,
|
||||||
FREQ_DATA_THRESHOLD,
|
FREQ_DATA_THRESHOLD,
|
||||||
pos - sizeof(st->frame));
|
pos - SAMPLE_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user