view trau-decode/extr-efr.c @ 69:cf60172895fe

pathloss: add sysmo-example-10w
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Oct 2024 16:26:26 +0000
parents 0565aaa84b17
children
line wrap: on
line source

/*
 * This module implements the EFR decoding part of trau-extr.
 */

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <gsm_efr.h>
#include "osmo_bits.h"

static void
dbits_to_frame(d_bits, frame)
	ubit_t *d_bits;
	uint8_t *frame;
{
	ubit_t intermed[248], *ip;
	uint8_t *op, mask;
	unsigned nb;

	intermed[0] = 1;
	intermed[1] = 1;
	intermed[2] = 0;
	intermed[3] = 0;
	bcopy(d_bits + 1, intermed + 4, 38);
	bcopy(d_bits + 42, intermed + 42, 53);
	bcopy(d_bits + 98, intermed + 95, 50);
	bcopy(d_bits + 151, intermed + 145, 53);
	bcopy(d_bits + 207, intermed + 198, 50);
	ip = intermed;
	op = frame;
	for (nb = 0; nb < EFR_RTP_FRAME_LEN; nb++) {
		*op = 0;
		for (mask = 0x80; mask; mask >>= 1) {
			if (*ip)
				*op |= mask;
			ip++;
		}
		op++;
	}
}

void
convert_efr_frame(d_bits, outf)
	ubit_t *d_bits;
	FILE *outf;
{
	uint8_t frame[EFR_RTP_FRAME_LEN];

	dbits_to_frame(d_bits, frame);
	fwrite(frame, 1, EFR_RTP_FRAME_LEN, outf);
}