changeset 420:eced57698c03

libtwamr: implement test sequence output
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 05:07:41 +0000
parents 2a094af3d384
children 09534cdc59ec
files libtwamr/Makefile libtwamr/tseq_out.c
diffstat 2 files changed, 41 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Tue May 07 04:51:04 2024 +0000
+++ b/libtwamr/Makefile	Tue May 07 05:07:41 2024 +0000
@@ -16,8 +16,8 @@
 	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 r_fft.o reorder.o residu.o \
 	s10_8pf.o set_sign.o sid_sync.o spreproc.o spstproc.o sqrt_l.o \
-	syn_filt.o tls_flags.o ton_stab.o vad1.o vad2.o vad_reset.o weight_a.o \
-	window.o
+	syn_filt.o tls_flags.o ton_stab.o tseq_out.o vad1.o vad2.o vad_reset.o \
+	weight_a.o window.o
 HDRS=	a_refl.h agc.h autocorr.h az_lsp.h b_cn_cod.h basic_op.h bgnscd.h \
 	bitno.h bits2prm.h c1035pf.h c2_11pf.h c2_9pf.h c3_14pf.h c4_17pf.h \
 	c8_31pf.h c_g_aver.h calc_cor.h calc_en.h cbsearch.h cl_ltp.h cnst.h \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/tseq_out.c	Tue May 07 05:07:41 2024 +0000
@@ -0,0 +1,39 @@
+/*
+ * In this module we implement encoder output conversion to 3GPP
+ * test sequence format.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "tw_amr.h"
+#include "namespace.h"
+#include "typedef.h"
+#include "cnst.h"
+#include "prm2bits.h"
+
+void amr_frame_to_tseq(const struct amr_param_frame *frame, uint16_t *cod)
+{
+	enum Mode pack_mode;
+
+	cod[0] = frame->type;
+	memset(cod + 1, 0, (AMR_COD_WORDS-1) * sizeof(uint16_t));
+	switch (frame->type) {
+	case TX_SPEECH_GOOD:
+		pack_mode = frame->mode;
+		cod[MAX_SERIAL_SIZE+1] = frame->mode;
+		break;
+	case TX_SID_FIRST:
+	case TX_SID_UPDATE:
+		pack_mode = MRDTX;
+		cod[MAX_SERIAL_SIZE+1] = frame->mode;
+		break;
+	case TX_NO_DATA:
+		pack_mode = MRDTX;
+		cod[MAX_SERIAL_SIZE+1] = 0xFFFF;
+		break;
+	default:
+		/* invalid usage, not allowed! */
+		return;
+	}
+	Prm2bits(pack_mode, frame->param, (Word16 *)(cod + 1));
+}