From 1bc5434a9942325d660ddac6ec612a192b73e117 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 25 Nov 2011 20:13:51 +0100 Subject: [PATCH] lower_mac/viterbi: Use the high level API of conv.h from libosmocore It's more stable ... here we just need a flexible length, which we can 'fake' by creating a local copy of the 'code' definition on the stack. Signed-off-by: Sylvain Munaut --- src/lower_mac/viterbi_cch.c | 15 ++++----------- src/lower_mac/viterbi_tch.c | 15 ++++----------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/lower_mac/viterbi_cch.c b/src/lower_mac/viterbi_cch.c index 5cbc476..18fe0e5 100644 --- a/src/lower_mac/viterbi_cch.c +++ b/src/lower_mac/viterbi_cch.c @@ -57,17 +57,10 @@ static const struct osmo_conv_code conv_cch = { int conv_cch_decode(int8_t *input, uint8_t *output, int n) { - struct osmo_conv_decoder decoder; - int rv, l; + struct osmo_conv_code code; - osmo_conv_decode_init(&decoder, &conv_cch, n); + memcpy(&code, &conv_cch, sizeof(struct osmo_conv_code)); + code.len = n; - l = osmo_conv_decode_scan(&decoder, input, n); - l = osmo_conv_decode_finish(&decoder, &input[l]); - - rv = osmo_conv_decode_get_output(&decoder, output, 1); - - osmo_conv_decode_deinit(&decoder); - - return rv; + return osmo_conv_decode(&code, input, output); } diff --git a/src/lower_mac/viterbi_tch.c b/src/lower_mac/viterbi_tch.c index 428279a..5b92b8b 100644 --- a/src/lower_mac/viterbi_tch.c +++ b/src/lower_mac/viterbi_tch.c @@ -55,17 +55,10 @@ static const struct osmo_conv_code conv_tch = { int conv_tch_decode(int8_t *input, uint8_t *output, int n) { - struct osmo_conv_decoder decoder; - int rv, l; + struct osmo_conv_code code; - osmo_conv_decode_init(&decoder, &conv_tch, n); + memcpy(&code, &conv_tch, sizeof(struct osmo_conv_code)); + code.len = n; - l = osmo_conv_decode_scan(&decoder, input, n); - l = osmo_conv_decode_finish(&decoder, &input[l]); - - rv = osmo_conv_decode_get_output(&decoder, output, 1); - - osmo_conv_decode_deinit(&decoder); - - return rv; + return osmo_conv_decode(&code, input, output); }