changeset 431:f0496507d409

libtwamr: implement amr_dhf_subst_efr()
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 08 May 2024 00:27:51 +0000
parents edbbbf1c4ab1
children d4f47d0962e7
files libtwamr/Makefile libtwamr/dhf_subst.c
diffstat 2 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Tue May 07 23:35:41 2024 +0000
+++ b/libtwamr/Makefile	Wed May 08 00:27:51 2024 +0000
@@ -6,14 +6,14 @@
 	convolve.o cor_h.o d1035pf.o d2_11pf.o d2_9pf.o d3_14pf.o d4_17pf.o \
 	d8_31pf.o d_gain_c.o d_gain_p.o d_plsf.o d_plsf_3.o d_plsf_5.o \
 	dec_amr.o dec_gain.o dec_lag3.o dec_lag6.o dec_main.o dhf_check.o \
-	dhf_tables.o dtx_dec.o dtx_enc.o e_homing.o ec_gains.o enc_lag3.o \
-	enc_lag6.o enc_main.o ex_ctrl.o fr_type_conv.o g_adapt.o g_code.o \
-	g_pitch.o gain_q.o gains_tab.o 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 \
-	lflg_upd.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o lsp_az.o lsp_lsf.o \
-	lsp_tab.o mac_32.o ol_ltp.o oper_32b.o p_ol_wgh.o ph_disp.o pitch_fr.o \
-	pitch_ol.o post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o preemph.o \
-	prm2bits.o prmno.o pstfilt.o q_gain_c.o q_gain_p.o q_plsf.o \
+	dhf_subst.o dhf_tables.o dtx_dec.o dtx_enc.o e_homing.o ec_gains.o \
+	enc_lag3.o enc_lag6.o enc_main.o ex_ctrl.o fr_type_conv.o g_adapt.o \
+	g_code.o g_pitch.o gain_q.o gains_tab.o 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 lflg_upd.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o lsp_az.o \
+	lsp_lsf.o lsp_tab.o mac_32.o ol_ltp.o oper_32b.o p_ol_wgh.o ph_disp.o \
+	pitch_fr.o pitch_ol.o post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o \
+	preemph.o prm2bits.o prmno.o pstfilt.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 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 \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/dhf_subst.c	Wed May 08 00:27:51 2024 +0000
@@ -0,0 +1,21 @@
+/*
+ * The function implemented in this module is an aid for AMR-EFR interworking:
+ * it is meant to be invoked directly after amr_encode_frame(), it checks
+ * the encoder output for MR122 DHF, and if the generated frame exactly
+ * matches MR122 DHF, it is changed to GSM-EFR DHF.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "tw_amr.h"
+
+void amr_dhf_subst_efr(struct amr_param_frame *frame)
+{
+	if (frame->type != TX_SPEECH_GOOD)
+		return;
+	if (frame->mode != MR122)
+		return;
+	if (memcmp(frame->param, amr_dhf_mr122, AMR_MAX_PRM * sizeof(int16_t)))
+		return;
+	memcpy(frame->param, amr_dhf_gsmefr, AMR_MAX_PRM * sizeof(int16_t));
+}