changeset 400:ffd48f0a2ab5

libtwamr: implement Prm2bits() like Bits2prm()
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 19:34:59 +0000
parents 3618b5cf25a6
children 59655481e45b
files libtwamr/Makefile libtwamr/prm2bits.c
diffstat 2 files changed, 31 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Mon May 06 19:19:27 2024 +0000
+++ b/libtwamr/Makefile	Mon May 06 19:34:59 2024 +0000
@@ -10,10 +10,10 @@
 	gc_pred.o gmed_n.o graytab.o hp_max.o int_lpc.o int_lsf.o inter_36.o \
 	inv_sqrt.o lag_wind.o levinson.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o \
 	lsp_az.o lsp_lsf.o lsp_tab.o mac_32.o oper_32b.o ph_disp.o pitch_fr.o \
-	post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o preemph.o prmno.o \
-	q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o q_plsf_3.o \
-	q_plsf_5.o qgain475.o qgain795.o qua_gain.o qua_gain_tab.o reorder.o \
-	residu.o s10_8pf.o set_sign.o sqrt_l.o syn_filt.o tls_flags.o \
+	post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o preemph.o prm2bits.o \
+	prmno.o q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o \
+	q_plsf_3.o q_plsf_5.o qgain475.o qgain795.o qua_gain.o qua_gain_tab.o \
+	reorder.o residu.o s10_8pf.o set_sign.o sqrt_l.o syn_filt.o tls_flags.o\
 	weight_a.o window.o
 HDRS=	namespace.h
 LIB=	libtwamr.a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/prm2bits.c	Mon May 06 19:34:59 2024 +0000
@@ -0,0 +1,27 @@
+/*
+ * 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;
+		}
+	}
+}