view ae-dec-dhf/gen-test-frames.c @ 57:a64e5ed217c0 default tip

top Makefile: add fr-sid
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 22 Aug 2024 06:43:31 +0000
parents ab7c80f6f02d
children
line wrap: on
line source

/*
 * 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);
}