FreeCalypso > hg > gsm-codec-lib
changeset 610:d18efcba03bc
libgsmhr1: capture speech encoder state
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 05 Mar 2026 00:56:30 +0000 |
| parents | a2b2ca082dd7 |
| children | f8759c856006 |
| files | libgsmhr1/Makefile libgsmhr1/enc_state.c libgsmhr1/enc_state.h |
| diffstat | 3 files changed, 124 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libgsmhr1/Makefile Tue Feb 24 04:16:57 2026 +0000 +++ b/libgsmhr1/Makefile Thu Mar 05 00:56:30 2026 +0000 @@ -1,12 +1,12 @@ OBJS= dec_func.o dec_state.o dhf_packed.o dhf_params.o dtx_dec.o dtx_rxfe.o \ - enc_out_order.o err_conc.o mathdp31.o mathhalf.o pack_frame.o \ - paramval_cod.o paramval_common.o paramval_dec.o rtp_in.o \ + enc_out_order.o enc_state.o err_conc.o mathdp31.o mathhalf.o \ + pack_frame.o paramval_cod.o paramval_common.o paramval_dec.o rtp_in.o \ rtp_in_direct.o rxfe.o rxfe_create.o sid_cw_params.o sid_detect.o \ sid_reset.o sp_dec.o sp_rom.o tfo.o twts002_in.o twts002_out.o \ unpack_frame.o HDRS= dec_func.h dec_state.h dtx_const.h dtx_dec.h dtx_rxfe.h enc_out_order.h\ - err_conc.h mathdp31.h mathhalf.h namespace.h rxfe.h sp_rom.h tw_gsmhr.h\ - typedefs.h + enc_state.h err_conc.h mathdp31.h mathhalf.h namespace.h rxfe.h \ + sp_rom.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_state.c Thu Mar 05 00:56:30 2026 +0000 @@ -0,0 +1,43 @@ +/* + * Here we implement gsmhr_encoder_create() and gsmhr_encoder_reset() + * functions: allocation and initialization of speech encoder state. + */ + +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include "tw_gsmhr.h" +#include "typedefs.h" +#include "namespace.h" +#include "enc_state.h" + +struct gsmhr_encoder_state *gsmhr_encoder_create(int dtx) +{ + struct gsmhr_encoder_state *st; + + st = malloc(sizeof(struct gsmhr_encoder_state)); + if (st) + gsmhr_encoder_reset(st, dtx); + return st; +} + +static void vad_init_nonzero(struct vad_state *vst) +{ + vst->pswRvad[0] = 24576; + vst->swNormRvad = 7; + vst->swE_thvad = 21; + vst->swM_thvad = 21875; + vst->swHangCount = -1; + vst->swOldLag = 21; +} + +void gsmhr_encoder_reset(struct gsmhr_encoder_state *st, int dtx) +{ + int i; + + memset(st, 0, sizeof(struct gsmhr_encoder_state)); + st->dtx_mode = dtx; + vad_init_nonzero(&st->vad); + st->swPtch = 1; + st->swNElapsed = 50; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmhr1/enc_state.h Thu Mar 05 00:56:30 2026 +0000 @@ -0,0 +1,77 @@ +/* + * This library-internal header file provides definition for + * struct gsmhr_encoder_state, the state structure for our speech + * encoder engine. + */ + +#ifndef enc_state_h +#define enc_state_h + +#include "typedefs.h" + +#define CG_INT_MACS 6 /* Number of Multiply-Accumulates in */ + /* one interpolation */ +#define LMAX 142 /* largest lag (integer sense) */ +#define LSMAX (LMAX+ CG_INT_MACS/2) /* Lag Search Array Length */ +#define LPCSTARTINDEX 25 /* Where the LPC analysis window + * starts */ +#define INBUFFSZ LPCSTARTINDEX + A_LEN /* Input buffer size */ + +#define HNW_BUFF_LEN LSMAX +#define LTP_LEN 147 /* 147==0x93 length of LTP history */ + +struct gsmhr_encoder_state { + int dtx_mode; + /* state variables from sp_enc.c */ + Shortword swOldR0; + Shortword swOldR0Index; + struct NormSw psnsWSfrmEngSpace[2 * N_SUB]; + Shortword pswHPFXState[4]; + Shortword pswHPFYState[8]; + Shortword pswOldFrmKs[NP]; + Shortword pswOldFrmAs[NP]; + Shortword pswOldFrmSNWCoefs[NP]; + Shortword pswWgtSpeechSpace[F_LEN + LMAX + CG_INT_MACS / 2]; + Shortword pswSpeech[INBUFFSZ]; /* input speech */ + Shortword swPtch; + /* DTX state variables from sp_enc.c */ + Shortword swTxGsHistPtr; + Shortword pswCNVSCode1[N_SUB]; + Shortword pswCNVSCode2[N_SUB]; + Shortword pswCNGsp0Code[N_SUB]; + Shortword pswCNLpc[3]; + Shortword swCNR0; + /* DTX state variables from dtx.c */ + Shortword swVadFrmCnt; + short int siUpdPointer; + Shortword swNElapsed; + Longword pL_GsHist[N_SUB * (OVERHANG - 1)]; + /* state variables from sp_frm.c */ + Shortword pswAnalysisState[NP]; + Shortword pswWStateNum[NP]; + Shortword pswWStateDenom[NP]; + /* state variables from sp_sfrm.c */ + Shortword pswLtpStateBase[LTP_LEN + S_LEN]; + Shortword pswHState[NP]; + Shortword pswHNWState[HNW_BUFF_LEN]; + /* from vad.c */ + struct vad_state { + Shortword pswRvad[9]; + Shortword swNormRvad; + Shortword swPt_sacf; + Shortword swPt_sav0; + Shortword swE_thvad; + Shortword swM_thvad; + Shortword swAdaptCount; + Shortword swBurstCount; + Shortword swHangCount; + Shortword swOldLagCount; + Shortword swVeryOldLagCount; + Shortword swOldLag; + Longword pL_sacf[27]; + Longword pL_sav0[36]; + Longword L_lastdm; + } vad; +}; + +#endif
