aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2023-05-26 01:38:23 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2023-05-26 02:48:21 +0700
commitb04d59e9973f372ed863be54a250a91eae1a1fd1 (patch)
tree39d41a2583b01d15212d3b2cce250ddf0e1c0127 /src/coding
parent31f761f7c112a30191be04391dbbbe7cbb377634 (diff)
coding: fix _tch_csd_burst_map(): do not overwrite FACCH
As was demonstrated in the unit test [1], FACCH bitstealing does not work as expected in conjunction CSD specific encoding functions. The problem is in _tch_csd_burst_map(): we don't check the stealing flags hu(B) and hl(B) and overwrite both odd and even numbered bits unconditionally. Even worse, we reset these stealing flags to 0. * Do not overwrite the hu(B) and hl(B) flags. * Copy *even* numbered bits only if hu(B) is not set. * Copy *odd* numbered bits only if hl(B) is not set. Change-Id: Ib5395c70e3e725469c18ff7d4c47c62ddfdbd55d Related: [1] Idc6decec3b84981d2aab4e27caab9ad65180f945 Related: OS#1572
Diffstat (limited to 'src/coding')
-rw-r--r--src/coding/gsm0503_coding.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 5badbd09..a34cd923 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -3298,13 +3298,23 @@ int gsm0503_sch_encode(ubit_t *burst, const uint8_t *sb_info)
static inline void _tch_csd_burst_map(ubit_t *burst, const ubit_t *iB)
{
- for (unsigned int i = 0; i < 57; i++) {
- burst[i] |= iB[i];
- burst[59 + i] |= iB[57 + i];
+ unsigned int i;
+
+ /* hu(B): copy *even* numbered bits if not stolen by FACCH */
+ if (burst[58] == 0) {
+ for (i = 0; i < 57; i += 2)
+ burst[i] |= iB[i];
+ for (i = 58; i < 114; i += 2)
+ burst[i + 2] |= iB[i];
}
- burst[57] = 0; /* hl(B) */
- burst[58] = 0; /* hu(B) */
+ /* hl(B): copy *odd* numbered bits if not stolen by FACCH */
+ if (burst[57] == 0) {
+ for (i = 1; i < 57; i += 2)
+ burst[i] |= iB[i];
+ for (i = 57; i < 114; i += 2)
+ burst[i + 2] |= iB[i];
+ }
}
/*! Perform channel encoding of a TCH/F9.6 channel as per section 3.3.