From 94d79fdeef612bcc3216813e5d6ef3eaf6f652b1 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 1 Mar 2019 10:40:48 +0100 Subject: gsm0808_utils: fix gsm48 multirate to S-bit converter 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 --- src/gsm/gsm0808_utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gsm') 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; } -- cgit v1.2.3