Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/9994 )

Change subject: coding: Fix (E)GPRS BER calculation to correctly account for 
puncturing.
......................................................................

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
---
M src/coding/gsm0503_coding.c
1 file changed, 24 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 215cc6d..1d06adb 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -528,16 +528,18 @@
        },
 };

-/*! 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 @@
        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 @@
        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 @@
                        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)

-- 
To view, visit https://gerrit.osmocom.org/9994
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9da22e7051522d06d923fcec3b63cbed8db93910
Gerrit-Change-Number: 9994
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Chemeris <[email protected]>
Gerrit-Reviewer: Alexander Chemeris <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <[email protected]>

Reply via email to