view amrtest/mode_file.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 1ceda5586d01
children
line wrap: on
line source

/*
 * The functions in this module implement reading per-frame encoder mode
 * instructions from a file, as in 3GPP test sequences and code.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "../libtwamr/tw_amr.h"

static FILE *mode_file;
static int lineno;
static char *filename_for_errs;

void
open_mode_file(filename)
	char *filename;
{
	mode_file = fopen(filename, "r");
	if (!mode_file) {
		perror(filename);
		exit(1);
	}
}

void
read_mode_file_line(mode_out)
	enum Mode *mode_out;
{
	char linebuf[16], *cp;
	int rc;

	if (!fgets(linebuf, sizeof linebuf, mode_file)) {
		fprintf(stderr, "error: %s ends before speech input\n",
			filename_for_errs);
		exit(1);
	}
	lineno++;
	cp = index(linebuf, '\n');
	if (!cp) {
		fprintf(stderr, "%s line %d: too long or missing newline\n",
			filename_for_errs, lineno);
		exit(1);
	}
	if (cp > linebuf && cp[-1] == '\r')
		cp--;
	*cp = '\0';
	rc = grok_mode_name(linebuf, mode_out);
	if (rc < 0) {
		fprintf(stderr, "%s line %d: invalid mode setting\n",
			filename_for_errs, lineno);
		exit(1);
	}
}