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
This commit is contained in:
Alexander Chemeris 2018-07-14 21:02:29 +02:00
parent f2cda621c0
commit 147051f1a1
1 changed files with 24 additions and 5 deletions

View File

@ -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)