diff libgsmfr2/pp_good.c @ 256:a33edf624061

libgsmfr2: start with API definition and port of libgsmfrp code
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Apr 2024 20:49:53 +0000
parents libgsmfrp/good_frame.c@f081a6850fb5
children 573afa985df6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgsmfr2/pp_good.c	Fri Apr 12 20:49:53 2024 +0000
@@ -0,0 +1,32 @@
+/*
+ * In this module we implement preprocessing of received good frames.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "tw_gsmfr.h"
+#include "pp_internal.h"
+
+void gsmfr_preproc_good_frame(struct gsmfr_preproc_state *st, uint8_t *frame)
+{
+	int sid;
+
+	/* always set correct magic */
+	frame[0] = 0xD0 | frame[0] & 0x0F;
+	/* now classify by SID */
+	sid = gsmfr_preproc_sid_classify(frame);
+	switch (sid) {
+	case 0:		/* good speech frame */
+		st->rx_state = SPEECH;
+		memcpy(&st->speech_frame, frame, GSMFR_RTP_FRAME_LEN);
+		return;
+	case 1:		/* invalid SID frame */
+		/* state-dependent handling, similar to BFI */
+		gsmfr_preproc_invalid_sid(st, frame);
+		return;
+	case 2:		/* valid SID frame */
+		st->rx_state = COMFORT_NOISE;
+		gsmfr_preproc_sid2cn(st, frame);
+		return;
+	}
+}