Change in libosmocore[master]: gsm0808_utils: fix gsm48 multirate to S-bit converter

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Mar 11 13:20:48 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13089 )

Change subject: gsm0808_utils: fix gsm48 multirate to S-bit converter
......................................................................

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
---
M src/gsm/gsm0808_utils.c
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
3 files changed, 78 insertions(+), 19 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 2552c08..e0cdaaf 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -1340,6 +1340,16 @@
 	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;
 }
 
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 87f5d2a..8f1e299 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -1902,6 +1902,27 @@
 	cfg.m10_2 = 1;
 	cfg.m12_2 = 1;
 	test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+	cfg.m4_75 = 1;
+	cfg.m5_15 = 0;
+	cfg.m5_90 = 1;
+	cfg.m6_70 = 0;
+	cfg.m7_40 = 1;
+	cfg.m7_95 = 0;
+	cfg.m10_2 = 0;
+	cfg.m12_2 = 1;
+	test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+	cfg.m4_75 = 1;
+	cfg.m5_15 = 0;
+	cfg.m5_90 = 1;
+	cfg.m6_70 = 0;
+	cfg.m7_40 = 1;
+	cfg.m7_95 = 0;
+	cfg.m10_2 = 0;
+	cfg.m12_2 = 0;
+	test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+	
 }
 
 static void test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single(uint16_t s15_s0)
diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok
index 9fce0e8..b620e36 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -110,9 +110,9 @@
  m10_2= 0
  m12_2= 0
 Result (fr):
- S15-S0 = 5703 = 0b0101011100000011
+ S15-S0 = 5701 = 0b0101011100000001
 Result (hr):
- S15-S0 = 0703 = 0b0000011100000011
+ S15-S0 = 0701 = 0b0000011100000001
 
 Input:
  m4_75= 0   smod=  0
@@ -138,9 +138,9 @@
  m10_2= 0
  m12_2= 0
 Result (fr):
- S15-S0 = 5706 = 0b0101011100000110
+ S15-S0 = 5704 = 0b0101011100000100
 Result (hr):
- S15-S0 = 0706 = 0b0000011100000110
+ S15-S0 = 0704 = 0b0000011100000100
 
 Input:
  m4_75= 0   smod=  0
@@ -166,9 +166,9 @@
  m10_2= 0
  m12_2= 0
 Result (fr):
- S15-S0 = 0412 = 0b0000010000010010
+ S15-S0 = 0410 = 0b0000010000010000
 Result (hr):
- S15-S0 = 0412 = 0b0000010000010010
+ S15-S0 = 0410 = 0b0000010000010000
 
 Input:
  m4_75= 0   smod=  0
@@ -208,9 +208,9 @@
  m10_2= 0
  m12_2= 1
 Result (fr):
- S15-S0 = 4082 = 0b0100000010000010
+ S15-S0 = 4080 = 0b0100000010000000
 Result (hr):
- S15-S0 = 0002 = 0b0000000000000010
+ S15-S0 = 0000 = 0b0000000000000000
 
 Input:
  m4_75= 1   smod=  0
@@ -222,9 +222,9 @@
  m10_2= 0
  m12_2= 0
 Result (fr):
- S15-S0 = 570f = 0b0101011100001111
+ S15-S0 = 570d = 0b0101011100001101
 Result (hr):
- S15-S0 = 070f = 0b0000011100001111
+ S15-S0 = 070d = 0b0000011100001101
 
 Input:
  m4_75= 0   smod=  0
@@ -236,9 +236,9 @@
  m10_2= 1
  m12_2= 1
 Result (fr):
- S15-S0 = 54f2 = 0b0101010011110010
+ S15-S0 = 54f0 = 0b0101010011110000
 Result (hr):
- S15-S0 = 0432 = 0b0000010000110010
+ S15-S0 = 0430 = 0b0000010000110000
 
 Input:
  m4_75= 0   smod=  0
@@ -250,9 +250,9 @@
  m10_2= 1
  m12_2= 1
 Result (fr):
- S15-S0 = 57ce = 0b0101011111001110
+ S15-S0 = 57cc = 0b0101011111001100
 Result (hr):
- S15-S0 = 070e = 0b0000011100001110
+ S15-S0 = 070c = 0b0000011100001100
 
 Input:
  m4_75= 1   smod=  0
@@ -264,9 +264,9 @@
  m10_2= 0
  m12_2= 0
 Result (fr):
- S15-S0 = 5733 = 0b0101011100110011
+ S15-S0 = 5731 = 0b0101011100110001
 Result (hr):
- S15-S0 = 0733 = 0b0000011100110011
+ S15-S0 = 0731 = 0b0000011100110001
 
 Input:
  m4_75= 0   smod=  0
@@ -278,9 +278,9 @@
  m10_2= 0
  m12_2= 1
 Result (fr):
- S15-S0 = 56aa = 0b0101011010101010
+ S15-S0 = 56a8 = 0b0101011010101000
 Result (hr):
- S15-S0 = 062a = 0b0000011000101010
+ S15-S0 = 0628 = 0b0000011000101000
 
 Input:
  m4_75= 1   smod=  0
@@ -292,7 +292,7 @@
  m10_2= 1
  m12_2= 0
 Result (fr):
- S15-S0 = 5757 = 0b0101011101010111
+ S15-S0 = 5755 = 0b0101011101010101
 Result (hr):
  S15-S0 = 0717 = 0b0000011100010111
 
@@ -310,6 +310,34 @@
 Result (hr):
  S15-S0 = 073f = 0b0000011100111111
 
+Input:
+ m4_75= 1   smod=  0
+ m5_15= 0   spare= 0
+ m5_90= 1   icmi=  0
+ m6_70= 0   nscb=  0
+ m7_40= 1   ver=   0
+ m7_95= 0
+ m10_2= 0
+ m12_2= 1
+Result (fr):
+ S15-S0 = 5797 = 0b0101011110010111
+Result (hr):
+ S15-S0 = 0717 = 0b0000011100010111
+
+Input:
+ m4_75= 1   smod=  0
+ m5_15= 0   spare= 0
+ m5_90= 1   icmi=  0
+ m6_70= 0   nscb=  0
+ m7_40= 1   ver=   0
+ m7_95= 0
+ m10_2= 0
+ m12_2= 0
+Result (fr):
+ S15-S0 = 5715 = 0b0101011100010101
+Result (hr):
+ S15-S0 = 0717 = 0b0000011100010111
+
 Testing gsm48_mr_cfg_from_gsm0808_sc_cfg():
 Input:
  S15-S0 = ff03 = 0b1111111100000011

-- 
To view, visit https://gerrit.osmocom.org/13089
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6ad531d4e70c2252e32e2bbaca8e14a7ec6d9840
Gerrit-Change-Number: 13089
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190311/5054d20e/attachment.html>


More information about the gerrit-log mailing list