view libtwamr/prm2bits.c @ 451:614ae8dc6807

README: update for libgsmfr2+libgsmefr+libtwamr set
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 May 2024 02:36:34 +0000
parents ffd48f0a2ab5
children
line wrap: on
line source

/*
 * A cleaner reimplementation of AMR Prm2bits() function.
 */

#include "typedef.h"
#include "namespace.h"
#include "bitno.h"
#include "prm2bits.h"

void Prm2bits(enum Mode mode, const Word16 prm[], Word16 bits[])
{
	const Word16 *t = bitno[mode];
	unsigned nparam = prmno[mode];
	unsigned n, p, mask;
	Word16 *b = bits;

	for (n = 0; n < nparam; n++) {
		p = prm[n];
		mask = 1 << (*t++ - 1);
		for (; mask; mask >>= 1) {
			if (p & mask)
				*b++ = 1;
			else
				*b++ = 0;
		}
	}
}