summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gsm/gsm0808_utils.c10
-rw-r--r--tests/gsm0808/gsm0808_test.c21
-rw-r--r--tests/gsm0808/gsm0808_test.ok66
3 files changed, 78 insertions, 19 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;
}
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 87f5d2a5..8f1e2993 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -1902,6 +1902,27 @@ static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg(void)
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 9fce0e8e..b620e369 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -110,9 +110,9 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 @@ Input:
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 (fr):
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