view hrutil/cod2hex.c @ 602:72cdae602d6e

libgsmhr1/dec_func.c: rm unused static functions In the original code, sp_dec.c held two kinds of functions: those needed only as part of the decoder, and those used by both decoder and encoder engines. In this library, we have moved the latter class of functions to dec_func.c module. Almost all static functions from the original sp_dec.c, with the exception of aToRc(), are needed only on sp_dec.c side of the new divide - remove them from dec_func.c, where they became dead code.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 04 Dec 2025 18:58:22 +0000
parents cf62fe9fac3a
children
line wrap: on
line source

/*
 * This program reads an HRv1 *.cod file in ETSI test sequence format
 * (encoder output format) and converts it into TW-TS-005 Annex B
 * hexadecimal format.
 */

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "../libgsmhr1/tw_gsmhr.h"
#include "../libtest/local_endian.h"

main(argc, argv)
	char **argv;
{
	char *infname, *outfname;
	FILE *inf, *outf;
	int opt, rc, big_endian, emit_5993 = 0;
	unsigned frame_no;
	int16_t params[GSMHR_NUM_PARAMS_ENC];
	extern int optind;

	big_endian = is_native_big_endian();
	while ((opt = getopt(argc, argv, "blx")) != EOF) {
		switch (opt) {
		case 'b':
			big_endian = 1;
			continue;
		case 'l':
			big_endian = 0;
			continue;
		case 'x':
			emit_5993 = 1;
			continue;
		default:
		usage:
			fprintf(stderr,
				"usage: %s [-b|-l] [-x] input.cod output.hex\n",
				argv[0]);
			exit(1);
		}
	}
	if (argc != optind + 2)
		goto usage;
	infname = argv[optind];
	outfname = argv[optind+1];

	inf = fopen(infname, "r");
	if (!inf) {
		perror(infname);
		exit(1);
	}
	outf = fopen(outfname, "w");
	if (!outf) {
		perror(outfname);
		exit(1);
	}

	for (frame_no = 0; ; frame_no++) {
		rc = read_cod_frame(inf, big_endian, params, infname, frame_no);
		if (!rc)
			break;
		emit_cod_to_tw5b(outf, params, emit_5993);
	}
	exit(0);
}