coding: fix wrong n_bits_total reported for PDTCH CS2 and CS3
In gsm0503_pdtch_decode(), we decode CS2 and CS3 as if no puncturing
was employed, reordering the coded bits and setting punctured ones
to 0 manually. Because of that, osmo_conv_decode_ber_punctured()
reports n_bits_total higher than we actually receive over the air.
Change-Id: I6b20cc450f25c48175a61da02644d66c08e22ece
Related: OS#6342, OS#6200
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 69a7ad4..022f465 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -1059,6 +1059,7 @@
return 23;
case 2:
+ /* reorder, set punctured bits to 0 (unknown state) */
for (i = 587, j = 455; i >= 0; i--) {
if (!gsm0503_puncture_cs2[i])
cB[i] = cB[j--];
@@ -1066,10 +1067,13 @@
cB[i] = 0;
}
+ /* decode as if puncturing was not employed (note '_np') */
osmo_conv_decode_ber_punctured(&gsm0503_cs2_np, cB, conv,
- n_errors, n_bits_total,
+ n_errors, NULL,
gsm0503_puncture_cs2);
-
+ /* indicate the actual amount of coded bits (excluding punctured ones) */
+ if (n_bits_total != NULL)
+ *n_bits_total = 456;
/* 5.1.2.2 a) the three USF bits d(0),d(1),d(2) are precoded into six bits */
for (i = 0; i < 8; i++) {
@@ -1097,6 +1101,7 @@
return 34;
case 3:
+ /* reorder, set punctured bits to 0 (unknown state) */
for (i = 675, j = 455; i >= 0; i--) {
if (!gsm0503_puncture_cs3[i])
cB[i] = cB[j--];
@@ -1104,9 +1109,13 @@
cB[i] = 0;
}
+ /* decode as if puncturing was not employed (note '_np') */
osmo_conv_decode_ber_punctured(&gsm0503_cs3_np, cB, conv,
- n_errors, n_bits_total,
+ n_errors, NULL,
gsm0503_puncture_cs3);
+ /* indicate the actual amount of coded bits (excluding punctured ones) */
+ if (n_bits_total != NULL)
+ *n_bits_total = 456;
/* 5.1.3.2 a) the three USF bits d(0),d(1),d(2) are precoded into six bits */
for (i = 0; i < 8; i++) {