diff options
Diffstat (limited to 'tests/codec')
-rw-r--r-- | tests/codec/codec_ecu_fr_test.c | 37 | ||||
-rw-r--r-- | tests/codec/codec_ecu_fr_test.ok | 42 |
2 files changed, 54 insertions, 25 deletions
diff --git a/tests/codec/codec_ecu_fr_test.c b/tests/codec/codec_ecu_fr_test.c index 0fdc489d..3a99fc72 100644 --- a/tests/codec/codec_ecu_fr_test.c +++ b/tests/codec/codec_ecu_fr_test.c @@ -1,12 +1,14 @@ #include <stdio.h> #include <stdint.h> #include <string.h> +#include <inttypes.h> #include <osmocom/core/bitvec.h> #include <osmocom/core/utils.h> #include <osmocom/codec/codec.h> #include <osmocom/codec/ecu.h> +#include <osmocom/codec/gsm610_bits.h> /* Set with sample full-rate voice frames and some intentional dropouts */ static const char *fr_frames_hex[] = { @@ -74,6 +76,28 @@ static const char *fr_frames_hex[] = { static const char *sample_frame_hex = \ "d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da"; +#define GSM610_XMAXC_LEN 6 +static void parse_xmaxc_frame(uint8_t *frame, uint64_t xmaxc_res[4]) +{ + unsigned int field_index, len; + + struct bitvec *frame_bitvec = bitvec_alloc(GSM_FR_BYTES, NULL); + OSMO_ASSERT(frame_bitvec); + len = bitvec_unpack(frame_bitvec, frame); + OSMO_ASSERT(len == GSM_FR_BYTES); + + field_index = GSM610_RTP_XMAXC00; + xmaxc_res[0] = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN); + field_index = GSM610_RTP_XMAXC10; + xmaxc_res[1] = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN); + field_index = GSM610_RTP_XMAXC20; + xmaxc_res[2] = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN); + field_index = GSM610_RTP_XMAXC30; + xmaxc_res[3] = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN); + + bitvec_free(frame_bitvec); +} + /** * Start with a good voice frame and then simulate 20 consecutive bad frames, * watching how the error concealment decreases the XMAXC parameters. @@ -82,23 +106,28 @@ void test_fr_concealment(void) { struct osmo_ecu_fr_state state; uint8_t frame[GSM_FR_BYTES]; + uint64_t xmaxc[4]; int i, rc; /* Parse frame from string to hex */ osmo_hexparse(sample_frame_hex, frame, GSM_FR_BYTES); - - printf("Start with: %s\n", sample_frame_hex); + parse_xmaxc_frame(frame, xmaxc); + printf("Start with: %s, XMAXC: [%"PRIx64", %"PRIx64", %"PRIx64", %"PRIx64"]\n", + sample_frame_hex, xmaxc[0], xmaxc[1], xmaxc[2], xmaxc[3]); /* Reset the ECU with the proposed known good frame */ osmo_ecu_fr_reset(&state, frame); /* Now pretend that we do not receive any good frames anymore */ for (i = 0; i < 20; i++) { + rc = osmo_ecu_fr_conceal(&state, frame); OSMO_ASSERT(rc == 0); + parse_xmaxc_frame(frame, xmaxc); - printf("conceal: %02i, result: %s\n", - i, osmo_hexdump_nospc(frame, GSM_FR_BYTES)); + printf("conceal: %02i, result: %s XMAXC: [%"PRIx64", %"PRIx64", %"PRIx64", %"PRIx64"]\n", + i, osmo_hexdump_nospc(frame, GSM_FR_BYTES), + xmaxc[0], xmaxc[1], xmaxc[2], xmaxc[3]); } } diff --git a/tests/codec/codec_ecu_fr_test.ok b/tests/codec/codec_ecu_fr_test.ok index 6e200994..52d06a1b 100644 --- a/tests/codec/codec_ecu_fr_test.ok +++ b/tests/codec/codec_ecu_fr_test.ok @@ -1,24 +1,24 @@ -Start with: d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da -conceal: 00, result: d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da -conceal: 01, result: d9ec9be212901d802335598c501d805bad3d4ba01d809b69df5a501d809cd1b4da -conceal: 02, result: d9ec9be212901b802335598c501b805bad3d4ba01b809b69df5a501b809cd1b4da -conceal: 03, result: d9ec9be2129019802335598c5019805bad3d4ba019809b69df5a5019809cd1b4da -conceal: 04, result: d9ec9be2129017802335598c5017805bad3d4ba017809b69df5a5017809cd1b4da -conceal: 05, result: d9ec9be2129015802335598c5015805bad3d4ba015809b69df5a5015809cd1b4da -conceal: 06, result: d9ec9be2129013802335598c5013805bad3d4ba013809b69df5a5013809cd1b4da -conceal: 07, result: d9ec9be2129011802335598c5011805bad3d4ba011809b69df5a5011809cd1b4da -conceal: 08, result: d9ec9be212900f802335598c500f805bad3d4ba00f809b69df5a500f809cd1b4da -conceal: 09, result: d9ec9be212900d802335598c500d805bad3d4ba00d809b69df5a500d809cd1b4da -conceal: 10, result: d9ec9be212900b802335598c500b805bad3d4ba00b809b69df5a500b809cd1b4da -conceal: 11, result: d9ec9be2129009802335598c5009805bad3d4ba009809b69df5a5009809cd1b4da -conceal: 12, result: d9ec9be2129007802335598c5007805bad3d4ba007809b69df5a5007809cd1b4da -conceal: 13, result: d9ec9be2129005802335598c5005805bad3d4ba005809b69df5a5005809cd1b4da -conceal: 14, result: d9ec9be2129003802335598c5003805bad3d4ba003809b69df5a5003809cd1b4da -conceal: 15, result: d9ec9be2129001802335598c5001805bad3d4ba001809b69df5a5001809cd1b4da -conceal: 16, result: d00000000000000000000000000000000000000000000000000000000000000000 -conceal: 17, result: d00000000000000000000000000000000000000000000000000000000000000000 -conceal: 18, result: d00000000000000000000000000000000000000000000000000000000000000000 -conceal: 19, result: d00000000000000000000000000000000000000000000000000000000000000000 +Start with: d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da, XMAXC: [3f, 3f, 3f, 3f] +conceal: 00, result: d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da XMAXC: [3f, 3f, 3f, 3f] +conceal: 01, result: d9ec9be212901d802335598c501d805bad3d4ba01d809b69df5a501d809cd1b4da XMAXC: [3b, 3b, 3b, 3b] +conceal: 02, result: d9ec9be212901b802335598c501b805bad3d4ba01b809b69df5a501b809cd1b4da XMAXC: [37, 37, 37, 37] +conceal: 03, result: d9ec9be2129019802335598c5019805bad3d4ba019809b69df5a5019809cd1b4da XMAXC: [33, 33, 33, 33] +conceal: 04, result: d9ec9be2129017802335598c5017805bad3d4ba017809b69df5a5017809cd1b4da XMAXC: [2f, 2f, 2f, 2f] +conceal: 05, result: d9ec9be2129015802335598c5015805bad3d4ba015809b69df5a5015809cd1b4da XMAXC: [2b, 2b, 2b, 2b] +conceal: 06, result: d9ec9be2129013802335598c5013805bad3d4ba013809b69df5a5013809cd1b4da XMAXC: [27, 27, 27, 27] +conceal: 07, result: d9ec9be2129011802335598c5011805bad3d4ba011809b69df5a5011809cd1b4da XMAXC: [23, 23, 23, 23] +conceal: 08, result: d9ec9be212900f802335598c500f805bad3d4ba00f809b69df5a500f809cd1b4da XMAXC: [1f, 1f, 1f, 1f] +conceal: 09, result: d9ec9be212900d802335598c500d805bad3d4ba00d809b69df5a500d809cd1b4da XMAXC: [1b, 1b, 1b, 1b] +conceal: 10, result: d9ec9be212900b802335598c500b805bad3d4ba00b809b69df5a500b809cd1b4da XMAXC: [17, 17, 17, 17] +conceal: 11, result: d9ec9be2129009802335598c5009805bad3d4ba009809b69df5a5009809cd1b4da XMAXC: [13, 13, 13, 13] +conceal: 12, result: d9ec9be2129007802335598c5007805bad3d4ba007809b69df5a5007809cd1b4da XMAXC: [f, f, f, f] +conceal: 13, result: d9ec9be2129005802335598c5005805bad3d4ba005809b69df5a5005809cd1b4da XMAXC: [b, b, b, b] +conceal: 14, result: d9ec9be2129003802335598c5003805bad3d4ba003809b69df5a5003809cd1b4da XMAXC: [7, 7, 7, 7] +conceal: 15, result: d9ec9be2129001802335598c5001805bad3d4ba001809b69df5a5001809cd1b4da XMAXC: [3, 3, 3, 3] +conceal: 16, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] +conceal: 17, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] +conceal: 18, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] +conceal: 19, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] Frame No. 000: * input: d9aa93ae63de00471a91b95b8660471392b4a2daa037628f391c624039258dc723 * output: d9aa93ae63de00471a91b95b8660471392b4a2daa037628f391c624039258dc723 |