aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/osmo-bts-trx/gsm0503_coding.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c
index c601cac3..4c4f7f1e 100644
--- a/src/osmo-bts-trx/gsm0503_coding.c
+++ b/src/osmo-bts-trx/gsm0503_coding.c
@@ -442,30 +442,33 @@ struct gsm0503_mcs_code gsm0503_mcs_dl_codes[EGPRS_NUM_MCS] = {
},
};
-int osmo_conv_decode_ber(const struct osmo_conv_code *code,
+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)
{
- int res, i;
+ int res, i, coded_len;
ubit_t recoded[EGPRS_DATA_C_MAX];
res = osmo_conv_decode(code, input, output);
- if (n_bits_total) {
- *n_bits_total = osmo_conv_encode(code, output, recoded);
- OSMO_ASSERT(sizeof(recoded)/sizeof(recoded[0]) >= *n_bits_total);
+ if (n_bits_total || n_errors) {
+ coded_len = osmo_conv_encode(code, output, recoded);
+ OSMO_ASSERT(sizeof(recoded)/sizeof(recoded[0]) >= coded_len);
}
/* Count bit errors */
if (n_errors) {
*n_errors = 0;
- for (i=0; i< *n_bits_total; i++) {
+ for (i = 0; i < coded_len; i++) {
if (! ((recoded[i] && input[i]<0) ||
(!recoded[i] && input[i]>0)) )
*n_errors += 1;
}
}
+ if (n_bits_total)
+ *n_bits_total = coded_len;
+
return res;
}