view hrutil/cod-parse.c @ 523:86d4ec69b36c

miscutil: new program tw5a-dump
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Sep 2024 04:13:28 +0000
parents bb36ef735f25
children
line wrap: on
line source

/*
 * This program reads an HRv1 *.cod file in ETSI test sequence format
 * (encoder output format) and displays its content in human-readable form.
 */

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

main(argc, argv)
	char **argv;
{
	char *infname;
	FILE *inf;
	int big_endian;
	unsigned frame_no;
	int16_t params[GSMHR_NUM_PARAMS_ENC];
	int rc;

	if (argc == 2 && argv[1][0] != '-') {
		big_endian = 0;
		infname = argv[1];
	} else if (argc == 3 && !strcmp(argv[1], "-b")) {
		big_endian = 1;
		infname = argv[2];
	} else {
		fprintf(stderr, "usage: %s [-b] file.cod\n", argv[0]);
		exit(1);
	}
	inf = fopen(infname, "r");
	if (!inf) {
		perror(infname);
		exit(1);
	}
	for (frame_no = 0; ; frame_no++) {
		rc = read_cod_frame(inf, big_endian, params, infname, frame_no);
		if (!rc)
			break;
		printf("#%u: VAD=%d SP=%d\n", frame_no, params[18], params[19]);
		print_frame_params(params);
	}
	exit(0);
}