view libgsmhr1/sp_frm.h @ 640:e0e5905261e2 default tip

document tw5b-dump and tw5c-dump
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 20 Mar 2026 06:43:50 +0000
parents fd35fd05bc8b
children
line wrap: on
line source

#ifndef __SP_FRM
#define __SP_FRM

#include "typedefs.h"
#include "sp_rom.h"


struct QuantList
{
  /* structure which points to the beginning of a block of candidate vq
   * vectors.  It also stores the residual error for each vector. */
  int    iNum;                         /* total number in list */
  int    iRCIndex;                     /* an index to the first vector of the
                                        * block */
  Shortword pswPredErr[PREQ1_NUM_OF_ROWS];  /* PREQ1 is the biggest block */
};

/*_________________________________________________________________________
 |                                                                         |
 |                            Function Prototypes                          |
 |_________________________________________________________________________|
*/

void aflat(struct gsmhr_encoder_state *st, Shortword pswSpeechToLPC[],
	   int piR0Index[], Shortword pswFinalRc[], int piVQCodewds[],
	   Shortword swPtch, Shortword *pswVadFlag, Shortword *pswSP);

Shortword aflatRecursion(struct gsmhr_encoder_state *st, Shortword pswQntRc[],
			 Shortword pswPBar[], Shortword pswVBar[],
			 Shortword *ppswPAddrs[], Shortword *ppswVAddrs[],
			 Shortword swSegmentOrder);

void getSfrmLpcTx(struct gsmhr_encoder_state *st, Shortword swPrevR0,
		  Shortword swNewR0,
		  /* last frm*/
		  Shortword pswPrevFrmKs[], Shortword pswPrevFrmAs[],
		  Shortword pswPrevFrmSNWCoef[],
		  /* this frm*/
		  Shortword pswNewFrmKs[], Shortword pswNewFrmAs[],
		  Shortword pswNewFrmSNWCoef[], Shortword pswHPFSpeech[],
		  /* output */
		  short *pswSoftInterp, struct NormSw *psnsSqrtRs,
		  Shortword ppswSynthAs[][NP], Shortword ppswSNWCoefAs[][NP]);

short compResidEnergy(struct gsmhr_encoder_state *st, Shortword pswSpeech[],
			Shortword ppswInterpCoef[][NP],
			Shortword pswPreviousCoef[],
			Shortword pswCurrentCoef[],
			struct NormSw psnsSqrtRs[]);

void getNextVec(struct gsmhr_encoder_state *st, Shortword pswRc[]);

void setupPreQ(struct gsmhr_encoder_state *st, int iSeg, int iVector);

void setupQuant(struct gsmhr_encoder_state *st, int iSeg, int iVector);

void weightSpeechFrame(struct gsmhr_encoder_state *st,
			Shortword pswSpeechFrm[],
			Shortword pswWNumSpace[], Shortword pswWDenomSpace[],
			Shortword pswWSpeechBuffBase[]);

void   iir_d(const Shortword pswCoeff[], Shortword pswIn[],
                    Shortword pswXstate[],
                    Shortword pswYstate[],
                    int npts, int shifts,
                    Shortword swPreFirDownSh,
                    Shortword swFinalUpShift);


  void   filt4_2nd(const Shortword pswCoeff[],
                          Shortword pswIn[],
                          Shortword pswXstate[],
                          Shortword pswYstate[],
                          int npts,
                          int shifts);

  void   initPBarVBarL(Longword pL_PBarFull[],
                              Shortword pswPBar[],
                              Shortword pswVBar[]);

  void   initPBarFullVBarFullL(Longword pL_CorrelSeq[],
                                      Longword pL_PBarFull[],
                                      Longword pL_VBarFull[]);

  void   aflatNewBarRecursionL(Shortword pswQntRc[],
                                      int iSegment,
                                      Longword pL_PBar[],
                                      Longword pL_VBar[],
                                      Shortword pswPBar[],
                                      Shortword pswVBar[]);


  Shortword fnExp2(Longword L_Input);

  Shortword fnLog2(Longword L_Input);

  short int fnBest_CG(Shortword pswCframe[],
                             Shortword pswGframe[],
                             Shortword *pswCmaxSqr,
                             Shortword *pswGmax,
                             short int siNumPairs);

  Shortword r0Quant(Longword L_UnqntzdR0);

  Shortword cov32(Shortword pswIn[],
                         Longword pppL_B[NP][NP][2],
                         Longword pppL_F[NP][NP][2],
                         Longword pppL_C[NP][NP][2],
                         Longword *pL_R0,
                         Longword pL_VadAcf[],
                         Shortword *pswVadScalAuto);

  Longword flat(Shortword pswSpeechIn[],
                       Shortword pswRc[],
                       int *piR0Inx,
                       Longword pL_VadAcf[],
                       Shortword *pswVadScalAuto);



  void   openLoopLagSearch(Shortword pswWSpeech[],
                                  Shortword swPrevR0Index,
                                  Shortword swCurrR0Index,
                                  Shortword *psiUVCode,
                                  Shortword pswLagList[],
                                  Shortword pswNumLagList[],
                                  Shortword pswPitchBuf[],
                                  Shortword pswHNWCoefBuf[],
                                  struct NormSw psnsWSfrmEng[],
                                  Shortword pswVadLags[],
                                  Shortword swSP);

  Shortword getCCThreshold(Shortword swRp0,
                                  Shortword swCC,
                                  Shortword swG);

  void   pitchLags(Shortword swBestIntLag,
                          Shortword pswIntCs[],
                          Shortword pswIntGs[],
                          Shortword swCCThreshold,
                          Shortword pswLPeaksSorted[],
                          Shortword pswCPeaksSorted[],
                          Shortword pswGPeaksSorted[],
                          Shortword *psiNumSorted,
                          Shortword *pswPitch,
                          Shortword *pswHNWCoef);

  short  CGInterpValid(Shortword swFullResLag,
                              Shortword pswCIn[],
                              Shortword pswGIn[],
                              Shortword pswLOut[],
                              Shortword pswCOut[],
                              Shortword pswGOut[]);

  void   CGInterp(Shortword pswLIn[],
                         short siNum,
                         Shortword pswCIn[],
                         Shortword pswGIn[],
                         short siLoIntLag,
                         Shortword pswCOut[],
                         Shortword pswGOut[]);

  Shortword quantLag(Shortword swRawLag,
                            Shortword *psiCode);

  void   findBestInQuantList(struct QuantList psqlInList,
                                    int iNumVectOut,
                                    struct QuantList psqlBestOutList[]);

  Shortword findPeak(Shortword swSingleResLag,
                            Shortword pswCIn[],
                            Shortword pswGIn[]);

  void   bestDelta(Shortword pswLagList[],
                          Shortword pswCSfrm[],
                          Shortword pswGSfrm[],
                          short int siNumLags,
                          short int siSfrmIndex,
                          Shortword pswLTraj[],
                          Shortword pswCCTraj[],
                          Shortword pswGTraj[]);

  Shortword
         maxCCOverGWithSign(Shortword pswCIn[],
                                   Shortword pswGIn[],
                                   Shortword *pswCCMax,
                                   Shortword *pswGMax,
                                   Shortword swNum);

  void   getNWCoefs(Shortword pswACoefs[],
                           Shortword pswHCoefs[]);

#endif