aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2024-01-31 20:56:53 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2024-01-31 23:10:35 +0700
commit2a72d683d31e9f699ea854e1ff172fe0131d5bd0 (patch)
treee720e77e1da12b2044a79080395446f5b67bf0cd
parent97374514c5684a934576d4ab748afb0033d54461 (diff)
coding: improve readability in osmo_conv_decode_ber_punctured()
-rw-r--r--src/coding/gsm0503_coding.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index d63140e0..9272fdbc 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -536,7 +536,7 @@ static int osmo_conv_decode_ber_punctured(const struct osmo_conv_code *code,
int *n_errors, int *n_bits_total,
const uint8_t *data_punc)
{
- int res, i, coded_len;
+ int res, coded_len;
ubit_t recoded[EGPRS_DATA_C_MAX];
res = osmo_conv_decode(code, input, output);
@@ -550,11 +550,15 @@ static int osmo_conv_decode_ber_punctured(const struct osmo_conv_code *code,
/* Count bit errors */
if (n_errors) {
*n_errors = 0;
- for (i = 0; i < coded_len; i++) {
- if (((!data_punc) || (data_punc && !data_punc[i])) &&
- !((recoded[i] && input[i] < 0) ||
- (!recoded[i] && input[i] > 0)) )
- *n_errors += 1;
+ for (unsigned int i = 0; i < coded_len; i++) {
+ /* punctured bits do not count as bit errors */
+ if (data_punc != NULL && data_punc[i])
+ continue;
+ if (recoded[i] == 1 && input[i] < 0)
+ continue;
+ if (recoded[i] == 0 && input[i] > 0)
+ continue;
+ *n_errors += 1;
}
}