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