comparison libgsmefr/enc_main.c @ 112:035424a6ca83

libgsmefr: encoder main function put together
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Nov 2022 07:05:59 +0000
parents
children
comparison
equal deleted inserted replaced
111:756605c4850f 112:035424a6ca83
1 /*
2 * This module contains our GSM EFR encoder main function, EFR_encode_params(),
3 * that stands at the boundary between our public interface and the guts of
4 * ETSI-based codec.
5 */
6
7 #include "gsm_efr.h"
8 #include "typedef.h"
9 #include "namespace.h"
10 #include "basic_op.h"
11 #include "cnst.h"
12 #include "codec.h"
13 #include "sig_proc.h"
14 #include "memops.h"
15 #include "enc_state.h"
16 #include "e_homing.h"
17 #include "dtx.h"
18
19 void EFR_encode_params(struct EFR_encoder_state *st, const int16_t *pcm_in,
20 int16_t *params, int *sp_out, int *vad_out)
21 {
22 Word16 *new_speech = st->old_speech + L_TOTAL - L_FRAME;
23 Word16 syn[L_FRAME];
24 Word16 reset_flag;
25 Word16 i;
26
27 /* Check whether this frame is an encoder homing frame */
28 reset_flag = encoder_homing_frame_test (pcm_in);
29
30 for (i = 0; i < L_FRAME; i++) /* Delete the 3 LSBs (13-bit input) */
31 {
32 new_speech[i] = pcm_in[i] & 0xfff8;
33 }
34
35 Pre_Process (st, new_speech, L_FRAME); /* filter + downscaling */
36
37 Coder_12k2 (st, params, syn); /* Find speech parameters */
38
39 if ((st->txdtx_ctrl & TX_SP_FLAG) == 0)
40 {
41 /* Write comfort noise parameters into the parameter frame.
42 Use old parameters in case SID frame is not to be updated */
43 CN_encoding (st, params, st->txdtx_ctrl);
44 }
45
46 /* VAD and SP flag outputs */
47 if (vad_out)
48 *vad_out = ((st->txdtx_ctrl & TX_VAD_FLAG) != 0);
49
50 if (sp_out)
51 *sp_out = ((st->txdtx_ctrl & TX_SP_FLAG) != 0);
52
53 if (reset_flag != 0)
54 {
55 /* Bring the encoder, VAD and DTX to the home state */
56 EFR_encoder_reset(st, st->dtx_mode);
57 }
58 }