view libgsmfrp/internal.h @ 183:452c1d5a6268

libgsmefr BFI w/o data: emit zero output after decoder reset In real-life usage, each EFR decoder session will most likely begin with lots of BFI frames before the first real frame arrives. However, because the spec-defined home state of the decoder is speech rather than CN, our regular logic for BFI w/o data would have to feed pseudorandom noise to the decoder (in the "fixed codebook excitation pulses" part), which is silly to do at the beginning of the decoder session right out of reset. Therefore, let's check reset_flag_old, and if we are still in the reset state, simply emit zero output.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 03 Jan 2023 00:12:18 +0000
parents 3b64f255689a
children f081a6850fb5
line wrap: on
line source

/*
 * This header file is internal to libgsmfrp;
 * here we define our state structure.
 */

enum rx_state {
	NO_DATA = 0,
	SPEECH,
	SPEECH_MUTING,
	COMFORT_NOISE,
	LOST_SID,
};

struct gsmfr_preproc_state {
	enum rx_state	rx_state;
	int		got_valid_sid;
	gsm_frame	speech_frame;
	gsm_byte	sid_prefix[5];
	uint8_t		sid_xmaxc[4];
	uint32_t	cn_random_lfsr;
	unsigned	cn_random_6fold;
};

/* we use the same LFSR PRNG for CN as ETSI EFR implementation */
#define PN_INITIAL_SEED 0x70816958L   /* Pseudo noise generator seed value  */

/* internal functions */
extern void gsmfr_preproc_gen_cn(struct gsmfr_preproc_state *state,
				 gsm_byte *frame);
extern uint16_t gsmfr_preproc_prng(struct gsmfr_preproc_state *state,
				   uint16_t no_bits);