changeset 603:27df1cef042c

libgsmhr1: put aToRc() only in dec_func.c This function was originally static in sp_dec.c, but now it is needed both in sp_dec.c and in dec_func.c shared decoder+encoder functions. Solution: give it intermodule linkage, and let it reside in dec_func.c only.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 04 Dec 2025 19:05:38 +0000
parents 72cdae602d6e
children 54f0f1b74c25
files libgsmhr1/dec_func.c libgsmhr1/dec_func.h libgsmhr1/namespace.list libgsmhr1/sp_dec.c
diffstat 4 files changed, 5 insertions(+), 203 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmhr1/dec_func.c	Thu Dec 04 18:58:22 2025 +0000
+++ b/libgsmhr1/dec_func.c	Thu Dec 04 19:05:38 2025 +0000
@@ -93,15 +93,6 @@
 
 /*_________________________________________________________________________
  |                                                                         |
- |            Local Functions (scope is limited to this file)              |
- |_________________________________________________________________________|
-*/
-
-  static short aToRc(Shortword swAshift, Shortword pswAin[],
-                            Shortword pswRc[]);
-
-/*_________________________________________________________________________
- |                                                                         |
  |                              Local Defines                              |
  |_________________________________________________________________________|
 */
@@ -454,8 +445,7 @@
  *
  *************************************************************************/
 
-static short aToRc(Shortword swAshift, Shortword pswAin[],
-                          Shortword pswRc[])
+short aToRc(Shortword swAshift, Shortword pswAin[], Shortword pswRc[])
 {
 
 /*_________________________________________________________________________
--- a/libgsmhr1/dec_func.h	Thu Dec 04 18:58:22 2025 +0000
+++ b/libgsmhr1/dec_func.h	Thu Dec 04 19:05:38 2025 +0000
@@ -20,6 +20,9 @@
 
   void   aFlatRcDp(Longword *pL_R, Shortword *pswRc);
 
+  short aToRc(Shortword swAshift, Shortword pswAin[],
+                            Shortword pswRc[]);
+
   void   b_con(Shortword swCodeWord, short siNumBits,
                       Shortword pswVectOut[]);
 
--- a/libgsmhr1/namespace.list	Thu Dec 04 18:58:22 2025 +0000
+++ b/libgsmhr1/namespace.list	Thu Dec 04 19:05:38 2025 +0000
@@ -26,7 +26,7 @@
 
 aFlatRcDp b_con fp_ex g_corr1 g_corr1s getSfrmLpc get_ipjj interpolateCheck
 lpcFir lpcIir lpcIrZsIir lpcZiIir lpcZsFir lpcZsIir lpcZsIirP r0BasedEnergyShft
-rcToADp rcToCorrDpL res_eng rs_rr rs_rrNs scaleExcite sqroot v_con
+rcToADp rcToCorrDpL res_eng rs_rr rs_rrNs scaleExcite sqroot v_con aToRc
 
 linInterpSid linInterpSidShort
 Init_CN_interpolation CN_Interpolate_R0 CN_Interpolate_LPC
--- a/libgsmhr1/sp_dec.c	Thu Dec 04 18:58:22 2025 +0000
+++ b/libgsmhr1/sp_dec.c	Thu Dec 04 19:05:38 2025 +0000
@@ -102,9 +102,6 @@
 static Shortword lagDecode(Shortword swDeltaLag, Shortword *pswLastLag,
 			   Shortword subfrm);
 
-  static short aToRc(Shortword swAshift, Shortword pswAin[],
-                            Shortword pswRc[]);
-
   static Shortword agcGain(Shortword pswStateCurr[],
                                   struct NormSw snsInSigEnergy,
                                   Shortword swEngyRShft);
@@ -153,194 +150,6 @@
 
 /***************************************************************************
  *
- *   FUNCTION NAME: aToRc
- *
- *   PURPOSE:
- *
- *     This subroutine computes a vector of reflection coefficients, given
- *     an input vector of direct form LPC filter coefficients.
- *
- *   INPUTS:
- *
- *     NP
- *                     order of the LPC filter (global constant)
- *
- *     swAshift
- *                     The number of right shifts applied externally
- *                     to the direct form filter coefficients.
- *
- *     pswAin[0:NP-1]
- *                     The input vector of direct form LPC filter
- *                     coefficients.
- *
- *   OUTPUTS:
- *
- *     pswRc[0:NP-1]
- *                     Array containing the reflection coefficients.
- *
- *   RETURN VALUE:
- *
- *     siUnstableFlt
- *                     If stable reflection coefficients 0, 1 if unstable.
- *
- *
- *   DESCRIPTION:
- *
- *     This function performs the conversion from direct form
- *     coefficients to reflection coefficients. It is used in a_sst()
- *     and interpolateCheck().  In a_sst() reflection coefficients used
- *     as a transitional data format.  aToRc() is used for this
- *     conversion.
- *
- *     When performing interpolation, a stability check must be
- *     performed. interpolateCheck() does this by calling aToRc().
- *
- *     First coefficients are shifted down by iAshift. NP, the filter
- *     order is 10. The a's and rc's each have NP elements in them. An
- *     elaborate algorithm description can be found on page 443, of
- *     "Digital Processing of Speech Signals" by L.R. Rabiner and R.W.
- *     Schafer; Prentice-Hall; Englewood Cliffs, NJ (USA).  1978.
- *
- *   REFERENCES: Sub_Clause 4.1.6, and 4.2.3 of GSM Recomendation 06.20
- *
- *   KEYWORDS: reflectioncoefficients, parcors, conversion, atorc, ks, as
- *   KEYWORDS: parcorcoefficients, lpc, flat, vectorquantization
- *
- *************************************************************************/
-
-static short aToRc(Shortword swAshift, Shortword pswAin[],
-                          Shortword pswRc[])
-{
-
-/*_________________________________________________________________________
- |                                                                         |
- |                            Constants                                    |
- |_________________________________________________________________________|
-*/
-
-/*_________________________________________________________________________
- |                                                                         |
- |                            Automatic Variables                          |
- |_________________________________________________________________________|
-*/
-
-  Shortword pswTmpSpace[NP],
-         pswASpace[NP],
-         swNormShift,
-         swActShift,
-         swNormProd,
-         swRcOverE,
-         swDiv,
-        *pswSwap,
-        *pswTmp,
-        *pswA;
-
-  Longword L_temp;
-
-  short int siUnstableFlt,
-         i,
-         j;                            /* Loop control variables */
-
-/*_________________________________________________________________________
- |                                                                         |
- |                              Executable Code                            |
- |_________________________________________________________________________|
-*/
-
-  /* Initialize starting addresses for temporary buffers */
-  /*-----------------------------------------------------*/
-
-  pswA = pswASpace;
-  pswTmp = pswTmpSpace;
-
-  /* Copy the direct form filter coefficients to a temporary array */
-  /*---------------------------------------------------------------*/
-
-  for (i = 0; i < NP; i++)
-  {
-    pswA[i] = pswAin[i];
-  }
-
-  /* Initialize the flag for filter stability check */
-  /*------------------------------------------------*/
-
-  siUnstableFlt = 0;
-
-  /* Start computation of the reflection coefficients, Rc[9],...,Rc[1] */
-  /*-------------------------------------------------------------------*/
-
-  for (i = NP - 1; i >= 1; i--)
-  {
-
-    pswRc[i] = shl(pswA[i], swAshift); /* write Rc[i] to output array */
-
-    /* Check the stability of i-th reflection coefficient */
-    /*----------------------------------------------------*/
-
-    siUnstableFlt = siUnstableFlt | isSwLimit(pswRc[i]);
-
-    /* Precompute intermediate variables for needed for the computation */
-    /* of direct form filter of order i-1                               */
-    /*------------------------------------------------------------------*/
-
-    if (sub(pswRc[i], SW_MIN) == 0)
-    {
-      siUnstableFlt = 1;
-      swRcOverE = 0;
-      swDiv = 0;
-      swActShift = 2;
-    }
-    else
-    {
-      L_temp = LW_MAX;                 /* Load ~1.0 into accum */
-      L_temp = L_msu(L_temp, pswRc[i], pswRc[i]);       /* 1.-Rc[i]*Rc[i]  */
-      swNormShift = norm_l(L_temp);
-      L_temp = L_shl(L_temp, swNormShift);
-      swNormProd = extract_h(L_temp);
-      swActShift = add(2, swNormShift);
-      swDiv = divide_s(0x2000, swNormProd);
-      swRcOverE = mult_r(pswRc[i], swDiv);
-    }
-    /* Check stability   */
-    /*---------------------*/
-    siUnstableFlt = siUnstableFlt | isSwLimit(swRcOverE);
-
-    /* Compute direct form filter coefficients corresponding to */
-    /* a direct form filter of order i-1                        */
-    /*----------------------------------------------------------*/
-
-    for (j = 0; j <= i - 1; j++)
-    {
-      L_temp = L_mult(pswA[j], swDiv);
-      L_temp = L_msu(L_temp, pswA[i - j - 1], swRcOverE);
-      L_temp = L_shl(L_temp, swActShift);
-      pswTmp[j] = round(L_temp);
-      siUnstableFlt = siUnstableFlt | isSwLimit(pswTmp[j]);
-    }
-
-    /* Swap swA and swTmp buffers */
-    /*----------------------------*/
-
-    pswSwap = pswA;
-    pswA = pswTmp;
-    pswTmp = pswSwap;
-  }
-
-  /* Compute reflection coefficient Rc[0] */
-  /*--------------------------------------*/
-
-  pswRc[0] = shl(pswA[0], swAshift);   /* write Rc[0] to output array */
-
-  /* Check the stability of 0-th reflection coefficient */
-  /*----------------------------------------------------*/
-
-  siUnstableFlt = siUnstableFlt | isSwLimit(pswRc[0]);
-
-  return (siUnstableFlt);
-}
-
-/***************************************************************************
- *
  *   FUNCTION NAME: a_sst
  *
  *   PURPOSE: