From 147051f1a1e47e7b0391c2cdc7033b840cebdca6 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sat, 14 Jul 2018 21:02:29 +0200 Subject: coding: Fix (E)GPRS BER calculation to correctly account for puncturing. Previously we didn't take into account puncturing and BER was always around 30% for GPRS/EDGE bursts because of they use puncturing coding unlike "classical" GSM bursts. Change-Id: I9da22e7051522d06d923fcec3b63cbed8db93910 --- src/coding/gsm0503_coding.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/coding') diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 215cc6dd..1d06adb5 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -528,16 +528,18 @@ const struct gsm0503_mcs_code gsm0503_mcs_dl_codes[EGPRS_NUM_MCS] = { }, }; -/*! Convolutional Decode + compute BER +/*! Convolutional Decode + compute BER for punctured codes * \param[in] code Description of Convolutional Code * \param[in] input Input soft-bits (-127...127) * \param[out] output bits * \param[out] n_errors Number of bit-errors * \param[out] n_bits_total Number of bits + * \param[in] data_punc Puncturing mask array. Can be NULL. */ -static int osmo_conv_decode_ber(const struct osmo_conv_code *code, +static int osmo_conv_decode_ber_punctured(const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output, - int *n_errors, int *n_bits_total) + int *n_errors, int *n_bits_total, + const uint8_t *data_punc) { int res, i, coded_len; ubit_t recoded[EGPRS_DATA_C_MAX]; @@ -553,7 +555,8 @@ static int osmo_conv_decode_ber(const struct osmo_conv_code *code, if (n_errors) { *n_errors = 0; for (i = 0; i < coded_len; i++) { - if (!((recoded[i] && input[i] < 0) || + if (((!data_punc) || (data_punc && !data_punc[i])) && + !((recoded[i] && input[i] < 0) || (!recoded[i] && input[i] > 0)) ) *n_errors += 1; } @@ -565,6 +568,21 @@ static int osmo_conv_decode_ber(const struct osmo_conv_code *code, return res; } +/*! Convolutional Decode + compute BER for non-punctured codes + * \param[in] code Description of Convolutional Code + * \param[in] input Input soft-bits (-127...127) + * \param[out] output bits + * \param[out] n_errors Number of bit-errors + * \param[out] n_bits_total Number of bits + */ +static int osmo_conv_decode_ber(const struct osmo_conv_code *code, + const sbit_t *input, ubit_t *output, + int *n_errors, int *n_bits_total) +{ + return osmo_conv_decode_ber_punctured(code, input, output, + n_errors, n_bits_total, NULL); +} + /*! convenience wrapper for decoding coded bits * \param[out] l2_data caller-allocated buffer for L2 Frame * \param[in] cB 456 coded (soft) bits as per TS 05.03 4.1.3 @@ -884,7 +902,8 @@ static int egprs_decode_data(uint8_t *l2_data, const sbit_t *c, C[i] = 0; } - osmo_conv_decode_ber(code->data_conv, C, u, n_errors, n_bits_total); + osmo_conv_decode_ber_punctured(code->data_conv, C, u, + n_errors, n_bits_total, code->data_punc[p]); rc = osmo_crc16gen_check_bits(&gsm0503_mcs_crc12, u, data_len, u + data_len); if (rc) -- cgit v1.2.3