view libgsmefr/enc_state.h @ 581:e2d5cad04cbf

libgsmhr1 RxFE: store CN R0+LPC separately from speech In the original GSM 06.06 code the ECU for speech mode is entirely separate from the CN generator, maintaining separate state. (The main intertie between them is the speech vs CN state variable, distinguishing between speech and CN BFIs, in addition to the CN-specific function of distinguishing between initial and update SIDs.) In the present RxFE implementation I initially thought that we could use the same saved_frame buffer for both ECU and CN, overwriting just the first 4 params (R0 and LPC) when a valid SID comes in. However, I now realize it was a bad idea: the original code has a corner case (long sequence of speech-mode BFIs to put the ECU in state 6, then SID and CN-mode BFIs, then a good speech frame) that would be broken by that buffer reuse approach. We could eliminate this corner case by resetting the ECU state when passing through a CN insertion period, but doing so would needlessly increase the behavioral diffs between GSM 06.06 and our version. Solution: use a separate CN-specific buffer for CN R0+LPC parameters, and match the behavior of GSM 06.06 code in this regard.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Feb 2025 10:02:45 +0000
parents 77803ce2cc22
children
line wrap: on
line source

/*
 * In this header file we define our encoder state structure.
 * This encoder state structure is internal to libgsmefr,
 * NOT part of our external public interface!
 */

struct EFR_encoder_state {
	/* from coder.c */
	Word16 dtx_mode;
	/* from cod_12k2.c */
	Word16 old_speech[L_TOTAL];
	Word16 old_wsp[L_FRAME + PIT_MAX];
	Word16 old_exc[L_FRAME + PIT_MAX + L_INTERPOL];
	Word16 ai_zero[L_SUBFR + MP1];
	Word16 hvec[L_SUBFR * 2];
	Word16 lsp_old[M];
	Word16 lsp_old_q[M];
	Word16 mem_syn[M];
	Word16 mem_w0[M];
	Word16 mem_w[M];
	Word16 mem_err[M + L_SUBFR];
	/* from levinson.c */
	Word16 old_A[M + 1];
	/* from pre_proc.c */
	struct preproc_state {
		Word16 y2_hi;
		Word16 y2_lo;
		Word16 y1_hi;
		Word16 y1_lo;
		Word16 x0;
		Word16 x1;
	} pre_proc;
	/* from q_plsf_5.c */
	Word16 past_r2_q[M];
	Word16 lsf_p_CN[M];
	/* from q_gains.c */
	Word16 past_qua_en[4];
	Word16 pred[4];
	Word16 gcode0_CN;
	/* from dtx.c */
	Word16 txdtx_ctrl;
	Word16 CN_excitation_gain;
	Word32 L_pn_seed_tx;
	Word16 txdtx_hangover;
	Word16 txdtx_N_elapsed;
	Word16 old_CN_mem_tx[6];
	Word16 buf_p_tx;
	Word16 lsf_old_tx[DTX_HANGOVER][M];
	Word16 gain_code_old_tx[4 * DTX_HANGOVER];
	/* from vad.c */
	struct vad_state {
		Word16 rvad[9];
		Word16 scal_rvad;
		Pfloat thvad;
		Word32 L_sacf[27];
		Word32 L_sav0[36];
		Word16 pt_sacf;
		Word16 pt_sav0;
		Word32 L_lastdm;
		Word16 adaptcount;
		Word16 burstcount;
		Word16 hangcount;
		Word16 oldlagcount;
		Word16 veryoldlagcount;
		Word16 oldlag;
	} vad;
	Word16 ptch;
};