view efr-sid/mk-sid-test.c @ 48:3e632126e099

efr-sid: generate efr-sid-test2.gsmx for OS#6538
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 11 Aug 2024 22:17:37 +0000
parents 8bfc517fda3b
children
line wrap: on
line source

/*
 * This program generates a sequence of 95 EFR codec frames that starts
 * with a perfect SID and is degraded by one bit in the SID field
 * on every output frame.
 */

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <gsm_efr.h>
#include "etsi.h"

extern const uint8_t SID_codeword_bit_idx[95];

static void
read_input_file(filename, cod_frame)
	char *filename;
	uint8_t *cod_frame;
{
	FILE *inf;

	inf = fopen(filename, "r");
	if (!inf) {
		perror(filename);
		exit(1);
	}
	read_etsi_bits(inf, 0, cod_frame, ETSI_ENC_NWORDS, filename);
	fclose(inf);
}

main(argc, argv)
	char **argv;
{
	uint8_t cod_frame[ETSI_ENC_NWORDS], packed_frame[EFR_RTP_FRAME_LEN];
	FILE *outf;
	unsigned nf;

	if (argc != 3) {
		fprintf(stderr, "usage: %s input.cod output.gsmx\n", argv[0]);
		exit(1);
	}
	read_input_file(argv[1], cod_frame);
	outf = fopen(argv[2], "w");
	if (!outf) {
		perror(argv[2]);
		exit(1);
	}
	for (nf = 0; nf < 95; nf++) {
		bits2frame(cod_frame, packed_frame, argv[1], 0);
		fwrite(packed_frame, 1, EFR_RTP_FRAME_LEN, outf);
		cod_frame[SID_codeword_bit_idx[nf]] = 0;
	}
	fclose(outf);
	exit(0);
}