diff libhr/paramval_dec.c @ 40:e1eabf554a75

libhr: small subset of WIP libgsmhr1
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 30 Aug 2024 16:41:56 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libhr/paramval_dec.c	Fri Aug 30 16:41:56 2024 +0000
@@ -0,0 +1,23 @@
+/*
+ * The function implemented in this module examines a frame of 22 int16_t words
+ * that corresponds to GSM-HR decoder input format, and checks if the unused
+ * upper bits of each int16_t word are cleared as they should be.
+ * This function should be used when reading from ETSI-format *.dec files,
+ * to guard against reading garbage or wrong endian.
+ */
+
+#include <stdint.h>
+#include "tw_gsmhr.h"
+
+int gsmhr_check_decoder_params(const int16_t *params)
+{
+	if (params[18] < 0 || params[18] > 2)	/* BFI */
+		return -1;
+	if (params[19] < 0 || params[19] > 1)	/* UFI */
+		return -1;
+	if (params[20] < 0 || params[20] > 2)	/* SID */
+		return -1;
+	if (params[21] < 0 || params[21] > 1)	/* TAF */
+		return -1;
+	return gsmhr_check_common_params(params);
+}