FreeCalypso > hg > vband-misc
diff ae-dec-dhf/gen-test-frames.c @ 39:ab7c80f6f02d
ae-dec-dhf: initial generation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 14 May 2024 08:13:01 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ae-dec-dhf/gen-test-frames.c Tue May 14 08:13:01 2024 +0000 @@ -0,0 +1,59 @@ +/* + * This program generates some test EFR frames that are meant to be fed + * to the uplink input of the alien GSM network under study, seeking to + * test if the AMR-EFR hybrid decoder's handling of DHF matches our model. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <gsm_efr.h> +#include <tw_amr.h> + +static FILE *outf; + +static void +emit_mr122_dhf() +{ + uint8_t frame[EFR_RTP_FRAME_LEN]; + + EFR_params2frame(amr_dhf_mr122, frame); + fwrite(frame, 1, EFR_RTP_FRAME_LEN, outf); +} + +static void +emit_mixed_dhf() +{ + int16_t params[EFR_NUM_PARAMS]; + uint8_t frame[EFR_RTP_FRAME_LEN]; + + memcpy(params, amr_dhf_gsmefr, sizeof(int16_t) * 18); + memcpy(params + 18, amr_dhf_mr122 + 18, sizeof(int16_t) * 39); + EFR_params2frame(params, frame); + fwrite(frame, 1, EFR_RTP_FRAME_LEN, outf); +} + +main(argc, argv) + char **argv; +{ + if (argc != 2) { + fprintf(stderr, "usage: %s gsmx-out-file\n", argv[0]); + exit(1); + } + outf = fopen(argv[1], "w"); + if (!outf) { + perror(argv[1]); + exit(1); + } + emit_mr122_dhf(); + emit_mr122_dhf(); + emit_mixed_dhf(); + fwrite(EFR_decoder_homing_frame, 1, EFR_RTP_FRAME_LEN, outf); + emit_mixed_dhf(); + emit_mixed_dhf(); + emit_mr122_dhf(); + fclose(outf); + exit(0); +}