changeset 464:fa0652115168

libtwamr: add amr_dhf_subst_efr2()
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 May 2024 21:36:26 +0000
parents 9208db14b4b9
children 026bdc1f0dda
files libtwamr/Makefile libtwamr/dhf_subst2.c libtwamr/tw_amr.h
diffstat 3 files changed, 36 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Sat May 11 20:29:11 2024 +0000
+++ b/libtwamr/Makefile	Sun May 12 21:36:26 2024 +0000
@@ -4,18 +4,18 @@
 	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_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 ietf_fo.o ietf_hdr.o ietf_in.o ietf_out.o if1_bit_order.o \
-	if1_pack.o if1_unpack.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 \
+	dhf_subst.o dhf_subst2.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 ietf_fo.o ietf_hdr.o ietf_in.o ietf_out.o \
+	if1_bit_order.o if1_pack.o if1_unpack.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 tls_flags.o ton_stab.o tseq_in.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 \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/dhf_subst2.c	Sun May 12 21:36:26 2024 +0000
@@ -0,0 +1,18 @@
+/*
+ * 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 turns it into EFR DHF just like
+ * amr_dhf_subst_efr(), but only if the input PCM frame was an EHF.  This
+ * slightly more complicated logic is needed in order to replicate the observed
+ * behavior of AMR-EFR speech encoder in the extant GSM network of T-Mobile USA.
+ */
+
+#include "tw_amr.h"
+#include "namespace.h"
+#include "e_homing.h"
+
+void amr_dhf_subst_efr2(struct amr_param_frame *frame, const int16_t *pcm)
+{
+	if (encoder_homing_frame_test(pcm))
+		amr_dhf_subst_efr(frame);
+}
--- a/libtwamr/tw_amr.h	Sat May 11 20:29:11 2024 +0000
+++ b/libtwamr/tw_amr.h	Sun May 12 21:36:26 2024 +0000
@@ -94,12 +94,10 @@
 int amr_frame_from_tseq(const uint16_t *cod, int use_rxtype,
 			struct amr_param_frame *frame);
 
-/* stateless functions and const data for DHF detection */
+/* stateless function and const data for DHF detection */
 
 int amr_check_dhf(const struct amr_param_frame *frame, int first_sub_only);
 
-void amr_dhf_subst_efr(struct amr_param_frame *frame);
-
 extern const int16_t amr_dhf_mr475[AMR_MAX_PRM];
 extern const int16_t amr_dhf_mr515[AMR_MAX_PRM];
 extern const int16_t amr_dhf_mr59[AMR_MAX_PRM];
@@ -110,6 +108,11 @@
 extern const int16_t amr_dhf_mr122[AMR_MAX_PRM];
 extern const int16_t amr_dhf_gsmefr[AMR_MAX_PRM];
 
+/* DHF transformation on encoder output, for AMR-EFR emulation */
+
+void amr_dhf_subst_efr(struct amr_param_frame *frame);
+void amr_dhf_subst_efr2(struct amr_param_frame *frame, const int16_t *pcm);
+
 /* public const datum: RFC 4867 file header */
 
 extern const uint8_t amr_file_header_magic[AMR_IETF_HDR_LEN];