changeset 505:17c0aabae474

libgsmhr1: integrate fillBitAlloc()
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 19 Jun 2024 01:49:03 +0000
parents 024615de06fe
children 2d6da062c452
files libgsmhr1/Makefile libgsmhr1/enc_out_order.c libgsmhr1/enc_out_order.h libgsmhr1/namespace.list
diffstat 4 files changed, 119 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmhr1/Makefile	Wed Jun 19 01:19:41 2024 +0000
+++ b/libgsmhr1/Makefile	Wed Jun 19 01:49:03 2024 +0000
@@ -1,6 +1,7 @@
-OBJS=	dhf_params.o mathdp31.o mathhalf.o pack_frame.o rtp_in.o sid_detect.o \
-	sid_reset.o twts002_in.o twts002_out.o unpack_frame.o
-HDRS=	mathdp31.h mathhalf.h namespace.h tw_gsmhr.h typedefs.h
+OBJS=	dhf_params.o enc_out_order.o mathdp31.o mathhalf.o pack_frame.o \
+	rtp_in.o sid_detect.o sid_reset.o twts002_in.o twts002_out.o \
+	unpack_frame.o
+HDRS=	enc_out_order.h mathdp31.h mathhalf.h namespace.h tw_gsmhr.h typedefs.h
 LIB=	libgsmhr1.a
 
 include ../config.defs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgsmhr1/enc_out_order.c	Wed Jun 19 01:49:03 2024 +0000
@@ -0,0 +1,101 @@
+/*
+ * This module was derived from host.c in the original GSM 06.06 source,
+ * reduced to just fillBitAlloc() function.
+ */
+
+/*_________________________________________________________________________
+ |                                                                         |
+ |                            Include Files                                |
+ |_________________________________________________________________________|
+*/
+
+#include "typedefs.h"
+#include "namespace.h"
+#include "enc_out_order.h"
+
+/***************************************************************************
+ *
+ *   FUNCTION NAME: fillBitAlloc
+ *
+ *   PURPOSE:
+ *
+ *     Arrange speech parameters for encoder output
+ *
+ *   INPUTS:
+ *
+ *     The speechcoders codewords:
+ *     iR0 - Frame energy
+ *     piVqIndeces[0:2] - LPC vector quantizer codewords
+ *     iSoftInterp - Soft interpolation bit 1 or 0
+ *     iVoicing - voicing mode 0,1,2,3
+ *     piLags[0:3] - Frame and delta lag codewords
+ *     piCodeWrdsA[0:3] - VSELP codevector 1
+ *     piCodeWrdsB[0:3] - VSELP codevector 2 (n/a for voiced modes)
+ *     piGsp0s[0:3] - GSP0 codewords
+ *     swVadFlag - voice activity detection flag
+ *     swSP - Speech flag
+ *
+ *   OUTPUTS:
+ *
+ *     pswBAlloc[0:20] - an array into which the coded data is moved
+ *
+ *   RETURN VALUE:
+ *
+ *     none
+ *
+ *   REFERENCES: Sub-clause 2.1 and 4.1.12 of GSM Recomendation 06.20
+ *
+ **************************************************************************/
+
+void   fillBitAlloc(int iVoicing, int iR0, int *piVqIndeces,
+                           int iSoftInterp, int *piLags,
+                           int *piCodeWrdsA, int *piCodeWrdsB,
+                           int *piGsp0s, Shortword swVadFlag,
+                           Shortword swSP, Shortword *pswBAlloc)
+{
+
+/*_________________________________________________________________________
+ |                                                                         |
+ |                            Automatic Variables                          |
+ |_________________________________________________________________________|
+*/
+
+  int    i;
+  Shortword *pswNxt;
+
+/*_________________________________________________________________________
+ |                                                                         |
+ |                            Executable Code                              |
+ |_________________________________________________________________________|
+*/
+
+  pswNxt = pswBAlloc;
+  *pswNxt++ = iR0;
+  for (i = 0; i < 3; i++)
+    *pswNxt++ = *piVqIndeces++;
+  *pswNxt++ = iSoftInterp;
+  *pswNxt++ = iVoicing;
+
+  /* check voicing mode */
+  if (iVoicing)
+  {
+    /* voiced mode */
+    for (i = 0; i < N_SUB; i++)
+    {
+      *pswNxt++ = *piLags++;
+      *pswNxt++ = *piCodeWrdsA++;
+      *pswNxt++ = *piGsp0s++;
+    }
+  }
+  else
+  {                                    /* unvoiced frame */
+    for (i = 0; i < N_SUB; i++)
+    {
+      *pswNxt++ = *piCodeWrdsA++;
+      *pswNxt++ = *piCodeWrdsB++;
+      *pswNxt++ = *piGsp0s++;
+    }
+  }
+  *pswNxt++ = swVadFlag;
+  *pswNxt++ = swSP;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgsmhr1/enc_out_order.h	Wed Jun 19 01:49:03 2024 +0000
@@ -0,0 +1,12 @@
+#ifndef enc_out_order_h
+#define enc_out_order_h
+
+#include "typedefs.h"
+
+void   fillBitAlloc(int iVoicing, int iR0, int *piVqIndeces,
+                           int iSoftInterp, int *piLags,
+                           int *piCodeWrdsA, int *piCodeWrdsB,
+                           int *piGsp0s, Shortword swVadFlag,
+                           Shortword swSP, Shortword *pswBAlloc);
+
+#endif	/* include guard */
--- a/libgsmhr1/namespace.list	Wed Jun 19 01:19:41 2024 +0000
+++ b/libgsmhr1/namespace.list	Wed Jun 19 01:49:03 2024 +0000
@@ -12,3 +12,5 @@
 L_deposit_l L_deposit_h extract_l extract_h
 round norm_l norm_s divide_s
 L_mpy_ls L_mpy_ll isSwLimit isLwLimit
+
+fillBitAlloc