summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2018-09-25 15:57:49 +0200
committerHarald Welte <laforge@gnumonks.org>2018-09-25 15:32:29 +0000
commit8515d035ae09edf3ad4d6e0dcbe526eee8bce3eb (patch)
tree7d2aa142f40d85f6ae1766de11ccd04153c8a214 /tests
parentb066305016141606e7f031065dc71c2002a6af0a (diff)
gsm0808: add function to convert AMR S15-S0 to gsm0408 settings
Add a function to convert S0-S15 bits to struct gsm48_multi_rate_conf, which hold the codec settings for AMR. Change-Id: I973736273c236eee84decf15868190e339c3fed4 Related: OS#3548
Diffstat (limited to 'tests')
-rw-r--r--tests/gsm0808/gsm0808_test.c57
-rw-r--r--tests/gsm0808/gsm0808_test.ok133
2 files changed, 190 insertions, 0 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 6faa6890..8cf1cf4c 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -1640,6 +1640,62 @@ static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg(void)
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)
+{
+ struct gsm48_multi_rate_conf cfg;
+
+ printf("Input:\n");
+ printf(" S15-S0 = %04x = 0b" OSMO_BIN_SPEC OSMO_BIN_SPEC "\n", s15_s0,
+ OSMO_BIN_PRINT(s15_s0 >> 8), OSMO_BIN_PRINT(s15_s0));
+
+ gsm48_mr_cfg_from_gsm0808_sc_cfg(&cfg, s15_s0);
+
+ printf("Output:\n");
+ printf(" m4_75= %u smod= %u\n", cfg.m4_75, cfg.smod);
+ printf(" m5_15= %u spare= %u\n", cfg.m5_15, cfg.spare);
+ printf(" m5_90= %u icmi= %u\n", cfg.m5_90, cfg.icmi);
+ printf(" m6_70= %u nscb= %u\n", cfg.m6_70, cfg.nscb);
+ printf(" m7_40= %u ver= %u\n", cfg.m7_40, cfg.ver);
+ printf(" m7_95= %u\n", cfg.m7_95);
+ printf(" m10_2= %u\n", cfg.m10_2);
+ printf(" m12_2= %u\n", cfg.m12_2);
+
+ printf("\n");
+}
+
+void test_gsm48_mr_cfg_from_gsm0808_sc_cfg()
+{
+ printf("Testing gsm48_mr_cfg_from_gsm0808_sc_cfg():\n");
+
+ /* Only one codec per setting */
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_4_75);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_5_15);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_5_90);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_6_70);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_7_40);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_7_95);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_10_2);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_12_2);
+
+ /* Combinations */
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_4_75 | GSM0808_SC_CFG_DEFAULT_AMR_6_70 |
+ GSM0808_SC_CFG_DEFAULT_AMR_10_2);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_10_2 | GSM0808_SC_CFG_DEFAULT_AMR_12_2 |
+ GSM0808_SC_CFG_DEFAULT_AMR_7_40);
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg_single
+ (GSM0808_SC_CFG_DEFAULT_AMR_7_95 | GSM0808_SC_CFG_DEFAULT_AMR_12_2);
+}
+
int main(int argc, char **argv)
{
printf("Testing generation of GSM0808 messages\n");
@@ -1692,6 +1748,7 @@ int main(int argc, char **argv)
test_gsm0808_enc_dec_cell_id_global();
test_gsm0808_sc_cfg_from_gsm48_mr_cfg();
+ test_gsm48_mr_cfg_from_gsm0808_sc_cfg();
printf("Done\n");
return EXIT_SUCCESS;
diff --git a/tests/gsm0808/gsm0808_test.ok b/tests/gsm0808/gsm0808_test.ok
index dc1debac..58bc5099 100644
--- a/tests/gsm0808/gsm0808_test.ok
+++ b/tests/gsm0808/gsm0808_test.ok
@@ -299,4 +299,137 @@ Result (fr):
Result (hr):
S15-S0 = 073f = 0b0000011100111111
+Testing gsm48_mr_cfg_from_gsm0808_sc_cfg():
+Input:
+ S15-S0 = ff03 = 0b1111111100000011
+Output:
+ m4_75= 1 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 0
+ m12_2= 0
+
+Input:
+ S15-S0 = 0000 = 0b0000000000000000
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 0
+ m12_2= 0
+
+Input:
+ S15-S0 = ff06 = 0b1111111100000110
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 1 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 0
+ m12_2= 0
+
+Input:
+ S15-S0 = 3e08 = 0b0011111000001000
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 1 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 0
+ m12_2= 0
+
+Input:
+ S15-S0 = 0c12 = 0b0000110000010010
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 1 ver= 1
+ m7_95= 0
+ m10_2= 0
+ m12_2= 0
+
+Input:
+ S15-S0 = c020 = 0b1100000000100000
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 1
+ m10_2= 0
+ m12_2= 0
+
+Input:
+ S15-S0 = 3040 = 0b0011000001000000
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 1
+ m12_2= 0
+
+Input:
+ S15-S0 = c082 = 0b1100000010000010
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 0
+ m12_2= 1
+
+Input:
+ S15-S0 = ff4b = 0b1111111101001011
+Output:
+ m4_75= 1 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 1 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 0
+ m10_2= 1
+ m12_2= 0
+
+Input:
+ S15-S0 = fcd2 = 0b1111110011010010
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 1 ver= 1
+ m7_95= 0
+ m10_2= 1
+ m12_2= 1
+
+Input:
+ S15-S0 = c0a2 = 0b1100000010100010
+Output:
+ m4_75= 0 smod= 0
+ m5_15= 1 spare= 0
+ m5_90= 0 icmi= 1
+ m6_70= 0 nscb= 0
+ m7_40= 0 ver= 1
+ m7_95= 1
+ m10_2= 0
+ m12_2= 1
+
Done