changeset 112:035424a6ca83

libgsmefr: encoder main function put together
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Nov 2022 07:05:59 +0000
parents 756605c4850f
children 269d341db403
files libgsmefr/Makefile libgsmefr/e_homing.c libgsmefr/e_homing.h libgsmefr/enc_main.c
diffstat 4 files changed, 66 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmefr/Makefile	Tue Nov 29 04:16:33 2022 +0000
+++ b/libgsmefr/Makefile	Tue Nov 29 07:05:59 2022 +0000
@@ -3,11 +3,12 @@
 OBJS=	agc.o autocorr.o az_lsp.o basicop2.o bfi_nodata.o c1035pf.o cod_12k2.o \
 	convolve.o d1035pf.o d_gains.o d_homing.o d_plsf_5.o dec_12k2.o \
 	dec_create.o dec_lag6.o dec_main.o dec_wrap.o dtx.o e_homing.o \
-	enc_create.o enc_lag6.o frame2params.o g_code.o g_pitch.o int_lpc.o \
-	inter_6.o inv_sqrt.o lag_wind.o levinson.o log2.o lsp_az.o lsp_lsf.o \
-	oper_32b.o params2frame.o pitch_f6.o pitch_ol.o pow2.o pre_proc.o \
-	pred_lt6.o preemph.o pstfilt2.o q_gains.o q_plsf_5.o reorder.o residu.o\
-	sid_class.o sid_insert.o syn_filt.o tls_flags.o vad.o weight_a.o
+	enc_create.o enc_lag6.o enc_main.o frame2params.o g_code.o g_pitch.o \
+	int_lpc.o inter_6.o inv_sqrt.o lag_wind.o levinson.o log2.o lsp_az.o \
+	lsp_lsf.o oper_32b.o params2frame.o pitch_f6.o pitch_ol.o pow2.o \
+	pre_proc.o pred_lt6.o preemph.o pstfilt2.o q_gains.o q_plsf_5.o \
+	reorder.o residu.o sid_class.o sid_insert.o syn_filt.o tls_flags.o \
+	vad.o weight_a.o
 HDRS=	basic_op.h cnst.h codec.h d_homing.h dec_state.h dtx.h e_homing.h \
 	enc_state.h gains_tb.h gsm_efr.h memops.h namespace.h no_count.h \
 	oper_32b.h sig_proc.h typedef.h vad.h
--- a/libgsmefr/e_homing.c	Tue Nov 29 04:16:33 2022 +0000
+++ b/libgsmefr/e_homing.c	Tue Nov 29 07:05:59 2022 +0000
@@ -49,7 +49,7 @@
  *
  **************************************************************************/
 
-Word16 encoder_homing_frame_test (Word16 input_frame[])
+Word16 encoder_homing_frame_test (const Word16 input_frame[])
 {
     Word16 i, j;
 
--- a/libgsmefr/e_homing.h	Tue Nov 29 04:16:33 2022 +0000
+++ b/libgsmefr/e_homing.h	Tue Nov 29 07:05:59 2022 +0000
@@ -11,6 +11,6 @@
 
 /* Function Prototypes */
 
-Word16 encoder_homing_frame_test (Word16 input_frame[]);
+Word16 encoder_homing_frame_test (const Word16 input_frame[]);
 
 void encoder_reset (struct EFR_encoder_state *st);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgsmefr/enc_main.c	Tue Nov 29 07:05:59 2022 +0000
@@ -0,0 +1,58 @@
+/*
+ * This module contains our GSM EFR encoder main function, EFR_encode_params(),
+ * that stands at the boundary between our public interface and the guts of
+ * ETSI-based codec.
+ */
+
+#include "gsm_efr.h"
+#include "typedef.h"
+#include "namespace.h"
+#include "basic_op.h"
+#include "cnst.h"
+#include "codec.h"
+#include "sig_proc.h"
+#include "memops.h"
+#include "enc_state.h"
+#include "e_homing.h"
+#include "dtx.h"
+
+void EFR_encode_params(struct EFR_encoder_state *st, const int16_t *pcm_in,
+			int16_t *params, int *sp_out, int *vad_out)
+{
+	Word16 *new_speech = st->old_speech + L_TOTAL - L_FRAME;
+	Word16 syn[L_FRAME];
+	Word16 reset_flag;
+	Word16 i;
+
+        /* Check whether this frame is an encoder homing frame */
+        reset_flag = encoder_homing_frame_test (pcm_in);
+
+        for (i = 0; i < L_FRAME; i++)   /* Delete the 3 LSBs (13-bit input) */
+        {
+            new_speech[i] = pcm_in[i] & 0xfff8;
+        }
+
+        Pre_Process (st, new_speech, L_FRAME);       /* filter + downscaling */
+
+        Coder_12k2 (st, params, syn);    /* Find speech parameters   */
+
+        if ((st->txdtx_ctrl & TX_SP_FLAG) == 0)
+        {
+            /* Write comfort noise parameters into the parameter frame.
+            Use old parameters in case SID frame is not to be updated */
+            CN_encoding (st, params, st->txdtx_ctrl);
+        }
+
+        /* VAD and SP flag outputs */
+        if (vad_out)
+            *vad_out = ((st->txdtx_ctrl & TX_VAD_FLAG) != 0);
+
+        if (sp_out)
+            *sp_out = ((st->txdtx_ctrl & TX_SP_FLAG) != 0);
+
+        if (reset_flag != 0)
+        {
+            /* Bring the encoder, VAD and DTX to the home state */
+            EFR_encoder_reset(st, st->dtx_mode);
+        }
+}