aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2019-03-01 10:40:48 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2019-03-11 09:08:31 +0100
commit94d79fdeef612bcc3216813e5d6ef3eaf6f652b1 (patch)
tree2ba0273c322f78b707ab9954e303bf92fac8a276 /src/gsm
parent3713af865503f78ad1a49604dc5d39908b94b2be (diff)
gsm0808_utils: fix gsm48 multirate to S-bit converterpmaier/amrmangle
The function gsm0808_sc_cfg_from_gsm48_mr_cfg() is used to convert a gsm48 multirate struct into a set of S-bits (S0 to S15). However, the conversion function currently does not take into account that bit S1 actually stands for four rates at once (Config-NB-Code = 1). Lets make sure that S1 is only set when the multirate configuration permits all four required rates. Change-Id: I6ad531d4e70c2252e32e2bbaca8e14a7ec6d9840 Related: SYS#4470
Diffstat (limited to 'src/gsm')
-rw-r--r--src/gsm/gsm0808_utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 2552c086..e0cdaaf6 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -1340,6 +1340,16 @@ uint16_t gsm0808_sc_cfg_from_gsm48_mr_cfg(const struct gsm48_multi_rate_conf *cf
else
s15_s0 &= GSM0808_SC_CFG_DEFAULT_HR_AMR;
+ /* The mode that is encoded by S1 (Config-NB-Code = 1), takes a special
+ * role as it does not stand for a single rate, but for up to four rates
+ * at once (12.2, 7.4, 5.9, 4.75). We must check if the supplied cfg
+ * covers this mode. If not, we need to make sure that the related
+ * bit is removed. (See also 3GPP TS 28.062, Table 7.11.3.1.3-2) */
+ if (!(cfg->m12_2 && cfg->m7_40 && cfg->m5_90 && cfg->m4_75) && fr)
+ s15_s0 &= ~GSM0808_SC_CFG_AMR_4_75_5_90_7_40_12_20;
+ else if (!(cfg->m7_40 && cfg->m5_90 && cfg->m4_75))
+ s15_s0 &= ~GSM0808_SC_CFG_AMR_4_75_5_90_7_40_12_20;
+
return s15_s0;
}