diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-25 06:51:36 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-25 06:51:36 -0700 |
commit | 09761fe0f6ed40ff74317fbb47d6a74068fb4ce4 (patch) | |
tree | 294de35ab62833f4f24bef66ca99c9736c017570 /src/core/ao_viterbi.c | |
parent | 628076aa90e7bc9a894646e417dd8e1fe149b60d (diff) |
altos: Incremental viterbi decode
Decode radio input one interleave block at a time. This overlaps the
decode computation with the packet reception, leading to lower latency
in an attempt to keep up with the transmitter.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_viterbi.c')
-rw-r--r-- | src/core/ao_viterbi.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/ao_viterbi.c b/src/core/ao_viterbi.c index 77681556..69e9c1f5 100644 --- a/src/core/ao_viterbi.c +++ b/src/core/ao_viterbi.c @@ -91,7 +91,7 @@ ao_cost(struct ao_soft_sym a, struct ao_soft_sym b) */ uint8_t -ao_fec_decode(uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len) +ao_fec_decode(uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len, uint16_t (*callback)()) { static uint16_t cost[2][NUM_STATE]; /* path cost */ static uint16_t bits[2][NUM_STATE]; /* save bits to quickly output them */ @@ -105,6 +105,7 @@ ao_fec_decode(uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len) const uint8_t *whiten = ao_fec_whiten_table; uint16_t interleave; /* input byte array index */ struct ao_soft_sym s; /* input symbol pair */ + uint16_t avail; p = 0; for (state = 0; state < NUM_STATE; state++) { @@ -113,11 +114,22 @@ ao_fec_decode(uint8_t *in, uint16_t len, uint8_t *out, uint8_t out_len) } cost[0][0] = 0; + if (callback) + avail = 0; + else + avail = len; + o = 0; for (i = 0; i < len; i += 2) { b = i/2; n = p ^ 1; + if (!avail) { + avail = callback(); + if (!avail) + break; + } + /* Fetch one pair of input bytes, de-interleaving * the input. */ |