view efrtest/etsi-pcm-out.c @ 468:4104b0390fab

efrtest: new program gsmefr-dlcap-sync
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 May 2024 07:21:09 +0000
parents 9f354d2aea13
children
line wrap: on
line source

/*
 * This C module holds some functions that have been split off from
 * etsi-dec.c, with the goal of making it easier to build both
 * standard-EFR and AMR-EFR versions of the ETSI-format EFR decoder.
 */

#include <stdio.h>
#include <stdint.h>

void
write_pcm_be(outf, pcm)
	FILE *outf;
	int16_t *pcm;
{
	uint8_t bytes[320], *dp;
	int16_t samp;
	unsigned n;

	dp = bytes;
	for (n = 0; n < 160; n++) {
		samp = pcm[n];
		*dp++ = (samp >> 8) & 0xFF;
		*dp++ = samp & 0xFF;
	}
	fwrite(bytes, 2, 160, outf);
}

void
write_pcm_le(outf, pcm)
	FILE *outf;
	int16_t *pcm;
{
	uint8_t bytes[320], *dp;
	int16_t samp;
	unsigned n;

	dp = bytes;
	for (n = 0; n < 160; n++) {
		samp = pcm[n];
		*dp++ = samp & 0xFF;
		*dp++ = (samp >> 8) & 0xFF;
	}
	fwrite(bytes, 2, 160, outf);
}