summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-12 19:48:23 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-12 19:54:52 +0000
commit9f41591a46c8879bd99e8706f9ac0fdd0ad1f694 (patch)
tree96b4cb2c02b35628e7098c257b0c655bd5fb7f03 /util
parenta7c69c323381a82e143d88244e099be8d4b7ca82 (diff)
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>
Diffstat (limited to 'util')
-rw-r--r--util/spkmodem_recv/spkmodem-recv.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c
index 48b06527..d1e39aad 100644
--- a/util/spkmodem_recv/spkmodem-recv.c
+++ b/util/spkmodem_recv/spkmodem-recv.c
@@ -39,6 +39,7 @@
#define SAMPLES_PER_FRAME 240
#define MAX_SAMPLES (2 * SAMPLES_PER_FRAME)
+#define SAMPLE_OFFSET (MAX_SAMPLES * sizeof(short))
#define FREQ_SEP_MIN 5
#define FREQ_SEP_MAX 15
@@ -52,7 +53,6 @@
#define READ_BUF 4096
struct decoder_state {
- signed short frame[MAX_SAMPLES];
unsigned char pulse[MAX_SAMPLES];
signed short inbuf[READ_BUF];
@@ -192,7 +192,6 @@ decode_pulse(struct decoder_state *st)
st->freq_separator -= old_sep;
sample = read_sample(st);
- st->frame[ringpos] = sample;
if ((unsigned)(sample + THRESHOLD)
> (unsigned)(2 * THRESHOLD))
@@ -291,7 +290,7 @@ print_stats(struct decoder_state *st)
st->freq_data,
st->freq_separator,
FREQ_DATA_THRESHOLD,
- pos - sizeof(st->frame));
+ pos - SAMPLE_OFFSET);
}
static void