aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-05-13 23:10:31 +0200
committerHarald Welte <laforge@osmocom.org>2020-05-14 14:51:22 +0200
commit5785a4a8fc3c0c685e02b969ad07c1751502f0d5 (patch)
tree12b092b74d2dbe0b1f40a6ef18bf5a469bcb9434 /tests
parentddb7586e9d9f4ca4dec3fedae44ecf0ec8231e96 (diff)
codec: Add functions for AMR s->d bits and d->s bits
These functions implement re-ordering of bits as per TS 06.90 / 26.101 based on the already existing tables we've had in libosmocoding. Change-Id: Ia4ac2aea2e96f9185f082a07ca64dfc5276efb46
Diffstat (limited to 'tests')
-rw-r--r--tests/codec/codec_test.c39
-rw-r--r--tests/codec/codec_test.ok9
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/codec/codec_test.c b/tests/codec/codec_test.c
index 7a10fc57..5579e996 100644
--- a/tests/codec/codec_test.c
+++ b/tests/codec/codec_test.c
@@ -190,6 +190,42 @@ static void test_sid_fr(void)
}
}
+
+
+static void test_amr_s_d(void)
+{
+ ubit_t in[244];
+ ubit_t mid[244];
+ ubit_t out[244];
+ int i, j;
+
+ for (j = AMR_4_75; j <= AMR_12_2; j++) {
+ unsigned int n_bits = gsm690_bitlength[j];
+
+ printf("=> AMR Mode %d (%d bits)\n", j, n_bits);
+ /* set a single bit in the input buffer */
+ for (i = 0; i < n_bits; i++) {
+
+ memset(in, 0, sizeof(in));
+ in[i] = 1;
+
+ /* re-order from s to d */
+ osmo_amr_s_to_d(mid, in, n_bits, j);
+
+ /* and back to d */
+ osmo_amr_d_to_s(out, mid, n_bits, j);
+
+ if (memcmp(in, out, n_bits)) {
+ printf("Error in bit %d of mode %d!\n", i, j);
+ printf("inp s-bits: %s\n", osmo_ubit_dump(in, n_bits));
+ printf("mid d-bits: %s\n", osmo_ubit_dump(mid, n_bits));
+ printf("out s-bits: %s\n", osmo_ubit_dump(out, n_bits));
+ //OSMO_ASSERT(0);
+ }
+ }
+ }
+}
+
int main(int argc, char **argv)
{
printf("AMR RTP payload decoder test:\n");
@@ -213,6 +249,9 @@ int main(int argc, char **argv)
printf("FR RTP payload SID test:\n");
test_sid_fr();
+ printf("AMR s/d bit re-ordering test:\n");
+ test_amr_s_d();
+
return 0;
}
diff --git a/tests/codec/codec_test.ok b/tests/codec/codec_test.ok
index b8cba19c..7d8609ba 100644
--- a/tests/codec/codec_test.ok
+++ b/tests/codec/codec_test.ok
@@ -30,3 +30,12 @@ FR SID d9 23 ba e5 e2 00 00 80 41 20 00 01 00 00 10 00 04 00 00 00 00 00 48 00 0
FR SID d8 62 a2 61 60 00 00 10 00 00 92 00 00 00 00 40 00 00 08 00 00 00 01 00 00 01 00 00 80 00 40 02 40 : 1
FR SID d9 e4 c3 6d 12 00 00 80 00 20 00 40 00 00 00 00 00 10 00 00 00 10 48 00 10 48 00 00 00 00 2d 04 00 : 1
FR SID d9 a4 c3 29 59 00 00 10 00 00 12 00 00 00 00 41 00 00 01 00 00 00 01 00 80 00 00 00 00 42 00 12 02 : 1
+AMR s/d bit re-ordering test:
+=> AMR Mode 0 (95 bits)
+=> AMR Mode 1 (103 bits)
+=> AMR Mode 2 (118 bits)
+=> AMR Mode 3 (134 bits)
+=> AMR Mode 4 (148 bits)
+=> AMR Mode 5 (159 bits)
+=> AMR Mode 6 (204 bits)
+=> AMR Mode 7 (244 bits)