summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-06-19 05:41:49 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-06-19 14:35:22 +0000
commit34da6b5f47be586d20c8af30ff6d7f23c2d357c9 (patch)
treecfa9d4b62502d392b8f7a9564d27e506a20a56e1 /src
parent23d3bc01ea9de48a0ba2a2255fb7e30fc9c632ea (diff)
core/conv/conv_acc.c: delete reset_decoder()
Currently this implementation exposes nothing than osmo_conv_decode_acc(), so it wasn't possible to call reset_decoder() from outside. The method itself was used to initialize accumulated path metrics and the starting state of encoder. Now this code is moved to generate_trellis(). Moreover, setting accumulated path metrics inside existing loop is a bit faster that calling memset(). Change-Id: I8f17cebf468cf0106927ccee091cfb2896649cb2
Diffstat (limited to 'src')
-rw-r--r--src/conv_acc.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/conv_acc.c b/src/conv_acc.c
index c4545d70..7f036284 100644
--- a/src/conv_acc.c
+++ b/src/conv_acc.c
@@ -413,10 +413,21 @@ static struct vtrellis *generate_trellis(const struct osmo_conv_code *code)
rc = gen_state_info(&trellis->vals[i],
i, outputs, code);
}
+
+ if (rc < 0)
+ goto fail;
+
+ /* Set accumulated path metrics to zero */
+ trellis->sums[i] = 0;
}
- if (rc < 0)
- goto fail;
+ /**
+ * For termination other than tail-biting, initialize the zero state
+ * as the encoder starting state. Initialize with the maximum
+ * accumulated sum at length equal to the constraint length.
+ */
+ if (code->term != CONV_TERM_TAIL_BITING)
+ trellis->sums[0] = INT8_MAX * code->N * code->K;
return trellis;
@@ -425,22 +436,6 @@ fail:
return NULL;
}
-/* Reset decoder
- * Set accumulated path metrics to zero. For termination other than
- * tail-biting, initialize the zero state as the encoder starting state.
- * Initialize with the maximum accumulated sum at length equal to the
- * constraint length.
- */
-static void reset_decoder(struct vdecoder *dec, int term)
-{
- int ns = dec->trellis->num_states;
-
- memset(dec->trellis->sums, 0, sizeof(int16_t) * ns);
-
- if (term != CONV_TERM_TAIL_BITING)
- dec->trellis->sums[0] = INT8_MAX * dec->n * dec->k;
-}
-
static void _traceback(struct vdecoder *dec,
unsigned state, uint8_t *out, int len)
{
@@ -641,8 +636,6 @@ static int conv_decode(struct vdecoder *dec, const int8_t *seq,
{
int8_t depunc[dec->len * dec->n];
- reset_decoder(dec, term);
-
if (punc) {
depuncture(seq, punc, depunc, dec->len * dec->n);
seq = depunc;