view libgsmhr1/enc_state.c @ 622:3ae5508f9a54 default tip

libgsmhr1/sp_sfrm.c: constify "ROM" static data
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Mar 2026 21:56:18 +0000
parents d18efcba03bc
children
line wrap: on
line source

/*
 * 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;
}