changeset 266:8821ffaa93a5

libgsmfr2: integrate decoder main function from libgsm
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 00:36:16 +0000
parents a7b593e68ac3
children 65d3304502bd
files libgsmfr2/Makefile libgsmfr2/dec_main.c
diffstat 2 files changed, 58 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmfr2/Makefile	Sun Apr 14 00:24:21 2024 +0000
+++ b/libgsmfr2/Makefile	Sun Apr 14 00:36:16 2024 +0000
@@ -1,8 +1,8 @@
 CC=	gcc
 CFLAGS=	-O2
-OBJS=	add.o comfort_noise.o ed_state.o enc_main.o pack_frame.o pack_frame2.o \
-	pp_bad.o pp_good.o pp_state.o prng.o sidclass.o silence_frame.o \
-	unpack_frame.o unpack_frame2.o xmaxc_mean.o
+OBJS=	add.o comfort_noise.o dec_main.o ed_state.o enc_main.o pack_frame.o \
+	pack_frame2.o pp_bad.o pp_good.o pp_state.o prng.o sidclass.o \
+	silence_frame.o unpack_frame.o unpack_frame2.o xmaxc_mean.o
 HDRS=	ed_internal.h ed_state.h pp_internal.h pp_state.h tw_gsmfr.h typedef.h
 LIB=	libgsmfr2.a
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgsmfr2/dec_main.c	Sun Apr 14 00:36:16 2024 +0000
@@ -0,0 +1,55 @@
+/*
+ * This C source file has been adapted from TU-Berlin libgsm source
+ * (src/decode.c), original notice follows:
+ *
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+#include <stdint.h>
+#include "tw_gsmfr.h"
+#include "typedef.h"
+#include "ed_state.h"
+#include "ed_internal.h"
+
+/*
+ *  4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER
+ */
+
+static void Postprocessing (
+	struct gsmfr_0610_state	* S,
+	register word 		* s)
+{
+	register int		k;
+	register word		msr = S->msr;
+	register longword	ltmp;	/* for GSM_ADD */
+	register word		tmp;
+
+	for (k = 160; k--; s++) {
+		tmp = GSM_MULT_R( msr, 28180 );
+		msr = GSM_ADD(*s, tmp);  	   /* Deemphasis 	     */
+		*s  = GSM_ADD(msr, msr) & 0xFFF8;  /* Truncation & Upscaling */
+	}
+	S->msr = msr;
+}
+
+void gsmfr_0610_decode_params(struct gsmfr_0610_state *S,
+			      const struct gsmfr_param_frame *inp, int16_t *s)
+{
+	int		j, k;
+	word		erp[40], wt[160];
+	word		* drp = S->dp0 + 120;
+
+	for (j=0; j <= 3; j++) {
+		Gsm_RPE_Decoding(S, inp->xmaxc[j], inp->Mc[j], inp->xMc[j],
+				 erp);
+		Gsm_Long_Term_Synthesis_Filtering(S, inp->Nc[j], inp->bc[j],
+						  erp, drp);
+
+		for (k = 0; k <= 39; k++) wt[ j * 40 + k ] =  drp[ k ];
+	}
+
+	Gsm_Short_Term_Synthesis_Filter(S, inp->LARc, wt, s);
+	Postprocessing(S, s);
+}