From fa7df8726001146c902d3a93e2a4b425fa9024b0 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 27 Feb 2019 12:29:19 +0100 Subject: AMR: add functions to convert between bw-efficient and octet-aligned RFC 3267 describes two different AMR frame formats. Octet Aligned and Bandwidth efficient mode. In Bandwith efficient mode the padding bits, which are used to align CMR, TOC and payload on octet boundaries are saved and the fielda are packed directly one after another. - Add functions to convert from one mode to the other and vice versa. - Add function to detect in which mode an AMR frame is encoded. Change-Id: I5b5a0fa644d8dbb1f04f9d7e35312683c7b3d196 Related: SYS#4470 --- include/osmocom/netif/amr.h | 8 ++ src/amr.c | 112 +++++++++++++++++++++ tests/Makefile.am | 9 +- tests/amr/amr_test.c | 239 +++++++++++++++++++++++++++++++++++++++++++ tests/amr/amr_test.ok | 240 ++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 6 ++ 6 files changed, 612 insertions(+), 2 deletions(-) create mode 100644 tests/amr/amr_test.c create mode 100644 tests/amr/amr_test.ok diff --git a/include/osmocom/netif/amr.h b/include/osmocom/netif/amr.h index 1f048b1..46ec86a 100644 --- a/include/osmocom/netif/amr.h +++ b/include/osmocom/netif/amr.h @@ -95,7 +95,15 @@ static inline void *osmo_amr_get_payload(struct amr_hdr *amrh) #define AMR_FT_7_LEN 31 /* 12.2 */ #define AMR_FT_SID_LEN 5 /* SID */ +/* NOTE: the above constant refers to the length of one AMR speech frame-block, + * not counting CMR, TOC. */ + int osmo_amr_ft_valid(uint8_t amr_ft); size_t osmo_amr_bytes(uint8_t amr_cmr); +bool osmo_amr_is_oa(uint8_t *payload, unsigned int payload_len); +int osmo_amr_oa_to_bwe(uint8_t *payload, unsigned int payload_len); +int osmo_amr_bwe_to_oa(uint8_t *payload, unsigned int payload_len, + unsigned int payload_maxlen); + #endif diff --git a/src/amr.c b/src/amr.c index 06cf429..d3f7b38 100644 --- a/src/amr.c +++ b/src/amr.c @@ -12,6 +12,8 @@ #include #include +#include +#include #include /* According to TS 26.101: @@ -62,3 +64,113 @@ int osmo_amr_ft_valid(uint8_t amr_ft) return 1; } + +/*! Check if an AMR frame is octet aligned by looking at the padding bits. + * \param[inout] payload user provided memory containing the AMR payload. + * \param[in] payload_len overall length of the AMR payload. + * \returns true when the payload is octet aligned. */ +bool osmo_amr_is_oa(uint8_t *payload, unsigned int payload_len) +{ + /* NOTE: The distinction between octet-aligned and bandwith-efficient + * mode normally relys on out of band methods that explicitly select + * one of the two modes. (See also RFC 3267, chapter 3.8). However the + * A interface in GSM does not provide ways to communicate which mode + * is used exactly used. The following functions uses some heuristics + * to check if an AMR payload is octet aligned or not. */ + + struct amr_hdr *oa_hdr = (struct amr_hdr *)payload; + unsigned int frame_len; + + /* Broken payload? */ + if (!payload || payload_len < 2) + return false; + + /* In octet aligned mode, padding bits are specified to be + * set to zero. (However, there is a remaining risk that the FT0 or FT1 + * is selected and the first two bits of the frame are zero as well, + * in this case a bandwith-efficient mode payload would look like an + * octet-aligned payload, thats why additional checks are required.) */ + if (oa_hdr->pad1 != 0) + return false; + if (oa_hdr->pad2 != 0) + return false; + + /* This implementation is limited to single-frame payloads only and + * since multi-frame payloads are not common in GSM anyway, we may + * include the final bit of the first header into this check. */ + if (oa_hdr->f != 0) + return false; + + /* Match the length of the received payload against the expected frame + * length that is defined by the frame type. */ + if(!osmo_amr_ft_valid(oa_hdr->ft)) + return false; + frame_len = osmo_amr_bytes(oa_hdr->ft); + if (frame_len != payload_len - 2) + return false; + + return true; +} + +/*! Convert an AMR frame from octet-aligned mode to bandwith-efficient mode. + * \param[inout] payload user provided memory containing the AMR payload. + * \param[in] payload_len overall length of the AMR payload. + * \returns resulting payload length, -1 on error. */ +int osmo_amr_oa_to_bwe(uint8_t *payload, unsigned int payload_len) +{ + struct amr_hdr *oa_hdr = (struct amr_hdr *)payload; + unsigned int frame_len = payload_len - 2; + unsigned int i; + + /* This implementation is not capable to handle multi-frame + * packets, so we need to make sure that the frame we operate on + * contains only one payload. */ + if (oa_hdr->f != 0) + return -1; + + /* Move TOC close to CMR */ + payload[0] |= (payload[1] >> 4) & 0x0f; + payload[1] = (payload[1] << 4) & 0xf0; + + for (i = 0; i < frame_len; i++) { + payload[i + 1] |= payload[i + 2] >> 2; + payload[i + 2] = payload[i + 2] << 6; + } + + /* The overall saving is one byte! */ + return payload_len - 1; +} + +/*! Convert an AMR frame from bandwith-efficient mode to octet-aligned mode. + * \param[inout] payload user provided memory containing the AMR payload. + * \param[in] payload_len overall length of the AMR payload. + * \param[in] payload_maxlen maximum length of the user provided memory. + * \returns resulting payload length, -1 on error. */ +int osmo_amr_bwe_to_oa(uint8_t *payload, unsigned int payload_len, + unsigned int payload_maxlen) +{ + uint8_t buf[256]; + unsigned int frame_len = payload_len - 1; + unsigned int i; + + memset(buf, 0, sizeof(buf)); + + if (payload_len + 1 > payload_maxlen) + return -1; + + if (payload_len > sizeof(buf)) + return -1; + + buf[0] = payload[0] & 0xf0; + buf[1] = payload[0] << 4; + buf[1] |= (payload[1] >> 4) & 0x0c; + + for (i = 0; i < frame_len -1; i++) { + buf[i + 2] = payload[i + 1] << 2; + buf[i + 2] |= payload[i + 2] >> 6; + } + buf[i + 2] = payload[i + 1] << 2; + + memcpy(payload, buf, payload_len + 1); + return payload_len + 1; +} diff --git a/tests/Makefile.am b/tests/Makefile.am index c3628ac..36447be 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,7 @@ AM_CFLAGS = -Wall -I$(top_srcdir)/include $(LIBOSMOCORE_CFLAGS) -g AM_LDFLAGS = $(LIBOSMOCORE_LDFLAGS) -check_PROGRAMS = osmux/osmux_test osmux/osmux_test2 stream/stream_test jibuf/jibuf_test +check_PROGRAMS = osmux/osmux_test osmux/osmux_test2 stream/stream_test jibuf/jibuf_test amr/amr_test check_HEADERS = osmux_osmux_test_SOURCES = osmux/osmux_test.c @@ -17,6 +17,9 @@ stream_stream_test_LDFLAGS = -no-install jibuf_jibuf_test_SOURCES = jibuf/jibuf_test.c jibuf_jibuf_test_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(top_builddir)/src/libosmonetif.la +amr_amr_test_SOURCES = amr/amr_test.c +amr_amr_test_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(top_builddir)/src/libosmonetif.la + if HAVE_PCAP check_PROGRAMS += jibuf/jibuf_tool check_HEADERS += \ @@ -63,7 +66,9 @@ EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ osmux/osmux_test2.ok \ stream/stream_test.ok \ stream/stream_test.err \ - jibuf/jibuf_test.ok + jibuf/jibuf_test.ok \ + amr/amr_test.ok + DISTCLEANFILES = atconfig diff --git a/tests/amr/amr_test.c b/tests/amr/amr_test.c new file mode 100644 index 0000000..fff686c --- /dev/null +++ b/tests/amr/amr_test.c @@ -0,0 +1,239 @@ +/* (C) 2017 by sysmocom - s.f.m.c. GmbH + * + * Author: Pau Espin Pedrol + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Some octet aligned single-payload AMR frames on different rates */ +char *oa_amr_samples[] = { + "703c22f979890338540179209572624a0f8535871c2f7039cbf926b7e4425b6ef0", + "703c2e671f3b1b0810412d5adae61e2b2a319885c6ced4e909b4eeaa2ea0f0cd80", + "703cf8fc77356c948141686cda34d35220db719e36a359d86b64420dc64b563850", + "60344e300c0e6251342c2ae51fd8a698a945488d16c98922726f3e50", + "60341fc722c7880328a9c280030bc9755c3ef519f80000295323e000", + "60342c338655c00008efba03592419adf62478a79278b3e2d68ab0f0", + "502c98ab841e491ff7a1a555016a32a3c7f913210630", + "502cc5459a0d200e7097c4dfe86ec8d27f1756d776f0", + "502c42b332081813d7e916e7aa5e80d7fde812b8c080", + "40240343e959c79bacd20c77501054880a718db200", + "4024172c53401e39115ceecd12606df5689bdd0ca0", + "4024f871cf48801ec427f0fc3f7318898622062200", + "20141fd4c02667c742b164aef659ffe708", + "2014197e10ead7b250bccbbf3b81887c64", + "2014e959f35fdfe5e9667ffbc088818088", + "100c4e9ba850e30d5d53d04de41e7c", + "100c6c18e7b7fff53aeb055e7d1c54", + "100c1fb967f7f1fdf547bf2e61c060", + "a038ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00fc", /* test pattern */ + "END", +}; + +/* Some bandwith efficient single-payload AMR frames */ +char *bwe_amr_samples[] = { + "f4495c7cda8f80", + "f44aaa6c969780", + "f3d09c20e32da600c025a72e0a9b360386e40f87e19282094adc1a11e397d1d4", + "f3d39a49a09e7a802852e297e8c9246aadf5a45928bfc27177fed8404d97d3b8", + "f3c2155b65131c68682079fab4810911200003b360ae0446000025f11e539dd0", + "f3c381bc7061c9f8507f6029de6115c16e5fa470c243b21b6e35dbb48bd84c00", + "a7bfc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03f", /* test pattern */ + "END", +}; + +void dump_bits(uint8_t *buf, int len) +{ + unsigned int i; + if (len <= 0) { + printf("(no data)"); + return; + } + for (i = 0; i < (len * 8); i++) + printf("%u", (buf[i / 8] >> (7 - (i % 8))) & 1); + return; +} + +void osmo_amr_oa_to_bwe_test(void) +{ + uint8_t buf[256]; + unsigned int i = 0; + int len; + int rc; + + printf("\n\n"); + printf("Testing conversion from octet-aligned to bw-efficient:\n"); + + while (1) { + if (strcmp(oa_amr_samples[i], "END") == 0) + return; + printf("\n"); + printf("Sample No.: %i\n", i); + len = strlen(oa_amr_samples[i]); + + len = osmo_hexparse(oa_amr_samples[i], buf, sizeof(buf)); + OSMO_ASSERT(len > 0); + + printf(" octet aligned: %s\n", osmo_hexdump_nospc(buf, len)); + printf(" "); + dump_bits(buf, len); + printf("\n"); + rc = osmo_amr_oa_to_bwe(buf, len); + printf(" bw-efficient: %s\n", osmo_hexdump_nospc(buf, rc)); + printf(" "); + dump_bits(buf, rc); + printf("\n"); + printf(" rc: %i\n", rc); + + if (rc > 0) { + OSMO_ASSERT(rc == len - 1); + OSMO_ASSERT(buf[len - 1] == 0x00); + } + i++; + } +} + +void osmo_amr_bwe_to_oa_test(void) +{ + uint8_t buf[256]; + unsigned int i = 0; + int len; + int rc; + + printf("\n\n"); + printf("Testing conversion from bw-efficient to octet-aligned:\n"); + + while (1) { + if (strcmp(bwe_amr_samples[i], "END") == 0) + return; + printf("\n"); + printf("Sample No.: %i\n", i); + len = strlen(bwe_amr_samples[i]); + + len = osmo_hexparse(bwe_amr_samples[i], buf, sizeof(buf)); + OSMO_ASSERT(len > 0); + + printf(" bw-efficient: %s\n", osmo_hexdump_nospc(buf, len)); + printf(" "); + dump_bits(buf, len); + printf("\n"); + rc = osmo_amr_bwe_to_oa(buf, len, sizeof(buf)); + printf(" octet aligned: %s\n", osmo_hexdump_nospc(buf, rc)); + printf(" "); + dump_bits(buf, rc); + printf("\n"); + printf(" rc: %i\n", rc); + + OSMO_ASSERT(rc == len + 1); + i++; + } +} + +void osmo_amr_oa_to_bwe_and_inverse_test(void) +{ + uint8_t buf[256]; + uint8_t buf_chk[256]; + + unsigned int i = 0; + int len; + int rc; + + printf("\n\n"); + printf + ("Testing conversion from octet-aligned to bw-efficient and inverse:\n"); + + while (1) { + if (strcmp(oa_amr_samples[i], "END") == 0) + return; + printf("Sample No.: %i...\n", i); + len = strlen(oa_amr_samples[i]); + + len = osmo_hexparse(oa_amr_samples[i], buf, sizeof(buf)); + OSMO_ASSERT(len > 0); + memcpy(buf_chk, buf, sizeof(buf)); + + rc = osmo_amr_oa_to_bwe(buf, len); + OSMO_ASSERT(rc > 0); + rc = osmo_amr_bwe_to_oa(buf, rc, sizeof(buf)); + OSMO_ASSERT(memcmp(buf, buf_chk, len) == 0); + i++; + } +} + +void osmo_amr_is_oa_test(void) +{ + uint8_t buf[256]; + unsigned int i; + int len; + bool is_oc; + + printf("\n\n"); + printf("Testing detection of octet-aligned mode payloads:\n"); + + i = 0; + while (1) { + if (strcmp(oa_amr_samples[i], "END") == 0) + break; + printf("Sample No.: %i ==>", i); + len = strlen(oa_amr_samples[i]); + + len = osmo_hexparse(oa_amr_samples[i], buf, sizeof(buf)); + OSMO_ASSERT(len > 0); + + is_oc = osmo_amr_is_oa(buf, len); + if (is_oc) + printf("octet aligned\n"); + else + printf("bandwith efficient\n"); + + i++; + } + + i = 0; + while (1) { + if (strcmp(bwe_amr_samples[i], "END") == 0) + break; + printf("Sample No.: %i ==>", i); + len = strlen(oa_amr_samples[i]); + + len = osmo_hexparse(bwe_amr_samples[i], buf, sizeof(buf)); + OSMO_ASSERT(len > 0); + + is_oc = osmo_amr_is_oa(buf, len); + if (is_oc) + printf("octet aligned\n"); + else + printf("bandwith efficient\n"); + + i++; + } +} + +int main(int argc, char **argv) +{ + osmo_amr_oa_to_bwe_test(); + osmo_amr_bwe_to_oa_test(); + osmo_amr_oa_to_bwe_and_inverse_test(); + osmo_amr_is_oa_test(); + + fprintf(stdout, "OK: Test passed\n"); + return EXIT_SUCCESS; +} diff --git a/tests/amr/amr_test.ok b/tests/amr/amr_test.ok new file mode 100644 index 0000000..ea34fea --- /dev/null +++ b/tests/amr/amr_test.ok @@ -0,0 +1,240 @@ + + +Testing conversion from octet-aligned to bw-efficient: + +Sample No.: 0 + octet aligned: 703c22f979890338540179209572624a0f8535871c2f7039cbf926b7e4425b6ef0 + 011100000011110000100010111110010111100110001001000000110011100001010100000000010111100100100000100101010111001001100010010010100000111110000101001101011000011100011100001011110111000000111001110010111111100100100110101101111110010001000010010110110110111011110000 + bw-efficient: 73c8be5e6240ce15005e48255c989283e14d61c70bdc0e72fe49adf91096dbbc + 0111001111001000101111100101111001100010010000001100111000010101000000000101111001001000001001010101110010011000100100101000001111100001010011010110000111000111000010111101110000001110011100101111111001001001101011011111100100010000100101101101101110111100 + rc: 32 + +Sample No.: 1 + octet aligned: 703c2e671f3b1b0810412d5adae61e2b2a319885c6ced4e909b4eeaa2ea0f0cd80 + 011100000011110000101110011001110001111100111011000110110000100000010000010000010010110101011010110110101110011000011110001010110010101000110001100110001000010111000110110011101101010011101001000010011011010011101110101010100010111010100000111100001100110110000000 + bw-efficient: 73cb99c7cec6c204104b56b6b9878aca8c662171b3b53a426d3baa8ba83c3360 + 0111001111001011100110011100011111001110110001101100001000000100000100000100101101010110101101101011100110000111100010101100101010001100011001100010000101110001101100111011010100111010010000100110110100111011101010101000101110101000001111000011001101100000 + rc: 32 + +Sample No.: 2 + octet aligned: 703cf8fc77356c948141686cda34d35220db719e36a359d86b64420dc64b563850 + 011100000011110011111000111111000111011100110101011011001001010010000001010000010110100001101100110110100011010011010011010100100010000011011011011100011001111000110110101000110101100111011000011010110110010001000010000011011100011001001011010101100011100001010000 + bw-efficient: 73fe3f1dcd5b2520505a1b368d34d48836dc678da8d6761ad910837192d58e14 + 0111001111111110001111110001110111001101010110110010010100100000010100000101101000011011001101101000110100110100110101001000100000110110110111000110011110001101101010001101011001110110000110101101100100010000100000110111000110010010110101011000111000010100 + rc: 32 + +Sample No.: 3 + octet aligned: 60344e300c0e6251342c2ae51fd8a698a945488d16c98922726f3e50 + 01100000001101000100111000110000000011000000111001100010010100010011010000101100001010101110010100011111110110001010011010011000101010010100010101001000100011010001011011001001100010010010001001110010011011110011111001010000 + bw-efficient: 63538c030398944d0b0ab947f629a62a51522345b262489c9bcf94 + 011000110101001110001100000000110000001110011000100101000100110100001011000010101011100101000111111101100010100110100110001010100101000101010010001000110100010110110010011000100100100010011100100110111100111110010100 + rc: 27 + +Sample No.: 4 + octet aligned: 60341fc722c7880328a9c280030bc9755c3ef519f80000295323e000 + 01100000001101000001111111000111001000101100011110001000000000110010100010101001110000101000000000000011000010111100100101110101010111000011111011110101000110011111100000000000000000000010100101010011001000111110000000000000 + bw-efficient: 6347f1c8b1e200ca2a70a000c2f25d570fbd467e00000a54c8f800 + 011000110100011111110001110010001011000111100010000000001100101000101010011100001010000000000000110000101111001001011101010101110000111110111101010001100111111000000000000000000000101001010100110010001111100000000000 + rc: 27 + +Sample No.: 5 + octet aligned: 60342c338655c00008efba03592419adf62478a79278b3e2d68ab0f0 + 01100000001101000010110000110011100001100101010111000000000000000000100011101111101110100000001101011001001001000001100110101101111101100010010001111000101001111001001001111000101100111110001011010110100010101011000011110000 + bw-efficient: 634b0ce1957000023bee80d649066b7d891e29e49e2cf8b5a2ac3c + 011000110100101100001100111000011001010101110000000000000000001000111011111011101000000011010110010010010000011001101011011111011000100100011110001010011110010010011110001011001111100010110101101000101010110000111100 + rc: 27 + +Sample No.: 6 + octet aligned: 502c98ab841e491ff7a1a555016a32a3c7f913210630 + 01010000001011001001100010101011100001000001111001001001000111111111011110100001101001010101010100000001011010100011001010100011110001111111100100010011001000010000011000110000 + bw-efficient: 52e62ae1079247fde86955405a8ca8f1fe44c8418c + 010100101110011000101010111000010000011110010010010001111111110111101000011010010101010101000000010110101000110010101000111100011111111001000100110010000100000110001100 + rc: 21 + +Sample No.: 7 + octet aligned: 502cc5459a0d200e7097c4dfe86ec8d27f1756d776f0 + 01010000001011001100010101000101100110100000110100100000000011100111000010010111110001001101111111101000011011101100100011010010011111110001011101010110110101110111011011110000 + bw-efficient: 52f151668348039c25f137fa1bb2349fc5d5b5ddbc + 010100101111000101010001011001101000001101001000000000111001110000100101111100010011011111111010000110111011001000110100100111111100010111010101101101011101110110111100 + rc: 21 + +Sample No.: 8 + octet aligned: 502c42b332081813d7e916e7aa5e80d7fde812b8c080 + 01010000001011000100001010110011001100100000100000011000000100111101011111101001000101101110011110101010010111101000000011010111111111011110100000010010101110001100000010000000 + bw-efficient: 52d0accc820604f5fa45b9ea97a035ff7a04ae3020 + 010100101101000010101100110011001000001000000110000001001111010111111010010001011011100111101010100101111010000000110101111111110111101000000100101011100011000000100000 + rc: 21 + +Sample No.: 9 + octet aligned: 40240343e959c79bacd20c77501054880a718db200 + 010000000010010000000011010000111110100101011001110001111001101110101100110100100000110001110111010100000001000001010100100010000000101001110001100011011011001000000000 + bw-efficient: 4240d0fa5671e6eb34831dd4041522029c636c80 + 0100001001000000110100001111101001010110011100011110011011101011001101001000001100011101110101000000010000010101001000100000001010011100011000110110110010000000 + rc: 20 + +Sample No.: 10 + octet aligned: 4024172c53401e39115ceecd12606df5689bdd0ca0 + 010000000010010000010111001011000101001101000000000111100011100100010001010111001110111011001101000100100110000001101101111101010110100010011011110111010000110010100000 + bw-efficient: 4245cb14d0078e44573bb344981b7d5a26f74328 + 0100001001000101110010110001010011010000000001111000111001000100010101110011101110110011010001001001100000011011011111010101101000100110111101110100001100101000 + rc: 20 + +Sample No.: 11 + octet aligned: 4024f871cf48801ec427f0fc3f7318898622062200 + 010000000010010011111000011100011100111101001000100000000001111011000100001001111111000011111100001111110111001100011000100010011000011000100010000001100010001000000000 + bw-efficient: 427e1c73d22007b109fc3f0fdcc6226188818880 + 0100001001111110000111000111001111010010001000000000011110110001000010011111110000111111000011111101110011000110001000100110000110001000100000011000100010000000 + rc: 20 + +Sample No.: 12 + octet aligned: 20141fd4c02667c742b164aef659ffe708 + 0010000000010100000111111101010011000000001001100110011111000111010000101011000101100100101011101111011001011001111111111110011100001000 + bw-efficient: 2147f5300999f1d0ac592bbd967ff9c2 + 00100001010001111111010100110000000010011001100111110001110100001010110001011001001010111011110110010110011111111111100111000010 + rc: 16 + +Sample No.: 13 + octet aligned: 2014197e10ead7b250bccbbf3b81887c64 + 0010000000010100000110010111111000010000111010101101011110110010010100001011110011001011101111110011101110000001100010000111110001100100 + bw-efficient: 21465f843ab5ec942f32efcee0621f19 + 00100001010001100101111110000100001110101011010111101100100101000010111100110010111011111100111011100000011000100001111100011001 + rc: 16 + +Sample No.: 14 + octet aligned: 2014e959f35fdfe5e9667ffbc088818088 + 0010000000010100111010010101100111110011010111111101111111100101111010010110011001111111111110111100000010001000100000011000000010001000 + bw-efficient: 217a567cd7f7f97a599ffef022206022 + 00100001011110100101011001111100110101111111011111111001011110100101100110011111111111101111000000100010001000000110000000100010 + rc: 16 + +Sample No.: 15 + octet aligned: 100c4e9ba850e30d5d53d04de41e7c + 000100000000110001001110100110111010100001010000111000110000110101011101010100111101000001001101111001000001111001111100 + bw-efficient: 10d3a6ea1438c35754f41379079f + 0001000011010011101001101110101000010100001110001100001101010111010101001111010000010011011110010000011110011111 + rc: 14 + +Sample No.: 16 + octet aligned: 100c6c18e7b7fff53aeb055e7d1c54 + 000100000000110001101100000110001110011110110111111111111111010100111010111010110000010101011110011111010001110001010100 + bw-efficient: 10db0639edfffd4ebac1579f4715 + 0001000011011011000001100011100111101101111111111111110101001110101110101100000101010111100111110100011100010101 + rc: 14 + +Sample No.: 17 + octet aligned: 100c1fb967f7f1fdf547bf2e61c060 + 000100000000110000011111101110010110011111110111111100011111110111110101010001111011111100101110011000011100000001100000 + bw-efficient: 10c7ee59fdfc7f7d51efcb987018 + 0001000011000111111011100101100111111101111111000111111101111101010100011110111111001011100110000111000000011000 + rc: 14 + +Sample No.: 18 + octet aligned: a038ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00fc + 101000000011100011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111100 + bw-efficient: a3bfc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03f + 1010001110111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111 + rc: 32 + + +Testing conversion from bw-efficient to octet-aligned: + +Sample No.: 0 + bw-efficient: f4495c7cda8f80 + 11110100010010010101110001111100110110101000111110000000 + octet aligned: f0442571f36a3e00 + 1111000001000100001001010111000111110011011010100011111000000000 + rc: 8 + +Sample No.: 1 + bw-efficient: f44aaa6c969780 + 11110100010010101010101001101100100101101001011110000000 + octet aligned: f0442aa9b25a5e00 + 1111000001000100001010101010100110110010010110100101111000000000 + rc: 8 + +Sample No.: 2 + bw-efficient: f3d09c20e32da600c025a72e0a9b360386e40f87e19282094adc1a11e397d1d4 + 1111001111010000100111000010000011100011001011011010011000000000110000000010010110100111001011100000101010011011001101100000001110000110111001000000111110000111111000011001001010000010000010010100101011011100000110100001000111100011100101111101000111010100 + octet aligned: f03c4270838cb6980300969cb82a6cd80e1b903e1f864a08252b7068478e5f4750 + 111100000011110001000010011100001000001110001100101101101001100000000011000000001001011010011100101110000010101001101100110110000000111000011011100100000011111000011111100001100100101000001000001001010010101101110000011010000100011110001110010111110100011101010000 + rc: 33 + +Sample No.: 3 + bw-efficient: f3d39a49a09e7a802852e297e8c9246aadf5a45928bfc27177fed8404d97d3b8 + 1111001111010011100110100100100110100000100111100111101010000000001010000101001011100010100101111110100011001001001001000110101010101101111101011010010001011001001010001011111111000010011100010111011111111110110110000100000001001101100101111101001110111000 + octet aligned: f03c4e69268279ea00a14b8a5fa32491aab7d69164a2ff09c5dffb6101365f4ee0 + 111100000011110001001110011010010010011010000010011110011110101000000000101000010100101110001010010111111010001100100100100100011010101010110111110101101001000101100100101000101111111100001001110001011101111111111011011000010000000100110110010111110100111011100000 + rc: 33 + +Sample No.: 4 + bw-efficient: f3c2155b65131c68682079fab4810911200003b360ae0446000025f11e539dd0 + 1111001111000010000101010101101101100101000100110001110001101000011010000010000001111001111110101011010010000001000010010001000100100000000000000000001110110011011000001010111000000100010001100000000000000000001001011111000100011110010100111001110111010000 + octet aligned: f03c08556d944c71a1a081e7ead204244480000ecd82b81118000097c4794e7740 + 111100000011110000001000010101010110110110010100010011000111000110100001101000001000000111100111111010101101001000000100001001000100010010000000000000000000111011001101100000101011100000010001000110000000000000000000100101111100010001111001010011100111011101000000 + rc: 33 + +Sample No.: 5 + bw-efficient: f3c381bc7061c9f8507f6029de6115c16e5fa470c243b21b6e35dbb48bd84c00 + 1111001111000011100000011011110001110000011000011100100111111000010100000111111101100000001010011101111001100001000101011100000101101110010111111010010001110000110000100100001110110010000110110110111000110101110110111011010010001011110110000100110000000000 + octet aligned: f03c0e06f1c18727e141fd80a779845705b97e91c3090ec86db8d76ed22f613000 + 111100000011110000001110000001101111000111000001100001110010011111100001010000011111110110000000101001110111100110000100010101110000010110111001011111101001000111000011000010010000111011001000011011011011100011010111011011101101001000101111011000010011000000000000 + rc: 33 + +Sample No.: 6 + bw-efficient: a7bfc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03f + 1010011110111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111 + octet aligned: a078ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00fc + 101000000111100011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111100 + rc: 33 + + +Testing conversion from octet-aligned to bw-efficient and inverse: +Sample No.: 0... +Sample No.: 1... +Sample No.: 2... +Sample No.: 3... +Sample No.: 4... +Sample No.: 5... +Sample No.: 6... +Sample No.: 7... +Sample No.: 8... +Sample No.: 9... +Sample No.: 10... +Sample No.: 11... +Sample No.: 12... +Sample No.: 13... +Sample No.: 14... +Sample No.: 15... +Sample No.: 16... +Sample No.: 17... +Sample No.: 18... + + +Testing detection of octet-aligned mode payloads: +Sample No.: 0 ==>octet aligned +Sample No.: 1 ==>octet aligned +Sample No.: 2 ==>octet aligned +Sample No.: 3 ==>octet aligned +Sample No.: 4 ==>octet aligned +Sample No.: 5 ==>octet aligned +Sample No.: 6 ==>octet aligned +Sample No.: 7 ==>octet aligned +Sample No.: 8 ==>octet aligned +Sample No.: 9 ==>octet aligned +Sample No.: 10 ==>octet aligned +Sample No.: 11 ==>octet aligned +Sample No.: 12 ==>octet aligned +Sample No.: 13 ==>octet aligned +Sample No.: 14 ==>octet aligned +Sample No.: 15 ==>octet aligned +Sample No.: 16 ==>octet aligned +Sample No.: 17 ==>octet aligned +Sample No.: 18 ==>octet aligned +Sample No.: 0 ==>bandwith efficient +Sample No.: 1 ==>bandwith efficient +Sample No.: 2 ==>bandwith efficient +Sample No.: 3 ==>bandwith efficient +Sample No.: 4 ==>bandwith efficient +Sample No.: 5 ==>bandwith efficient +Sample No.: 6 ==>bandwith efficient +OK: Test passed diff --git a/tests/testsuite.at b/tests/testsuite.at index 8eb389d..fa4d63d 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -25,3 +25,9 @@ AT_KEYWORDS([jibuf_test]) cat $abs_srcdir/jibuf/jibuf_test.ok > expout AT_CHECK([$abs_top_builddir/tests/jibuf/jibuf_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([amr_test]) +AT_KEYWORDS([amr_test]) +cat $abs_srcdir/amr/amr_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/amr/amr_test], [0], [expout], [ignore]) +AT_CLEANUP -- cgit v1.2.3