FreeCalypso > hg > gsm-codec-lib
annotate libgsmefr/bfi_nodata.c @ 417:f17e42c63058
libtwamr: integrate ol_ltp.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 07 May 2024 03:21:14 +0000 |
parents | 452c1d5a6268 |
children |
rev | line source |
---|---|
99
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In the expected usage mode of our libgsmefr decoder as part of "soft TRAU" |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * uplink implementation, there will be times when the radio subsystem tells |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * us that a frame has been lost, but we don't have any errored bits to feed |
160
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
5 * to the decoder as ETSI canon calls for. Specifically, the canonical EFR |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
6 * decoder will use the "fixed codebook excitation pulses" part of errored |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
7 * frames when a BFI comes in after speech, although not when BFI comes in |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
8 * after SID. Our solution in EFR_decode_bfi_nodata(): we look in the |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
9 * decoder state to see if we are in speech mode, and if we are, we fill |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
10 * the needed parameters with a PRNG. |
99
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 */ |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "gsm_efr.h" |
160
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
15 #include "typedef.h" |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
16 #include "namespace.h" |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
17 #include "cnst.h" |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
18 #include "dtx.h" |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
19 #include "dec_state.h" |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
20 |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
21 static void random_1035(Word32 *lfsr, Word16 *param_1035) |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
22 { |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
23 Word16 *p = param_1035; |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
24 Word16 i; |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
25 |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
26 /* 5 params of bit width 4 */ |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
27 for (i = 0; i < 5; i++) |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
28 *p++ = pseudonoise(lfsr, 4); |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
29 /* another 5 params of bit width 3 */ |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
30 for (i = 0; i < 5; i++) |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
31 *p++ = pseudonoise(lfsr, 3); |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
32 } |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
33 |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
34 static void random_bad_frame(struct EFR_decoder_state *st, Word16 *params) |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
35 { |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
36 Word32 *lfsr = &st->L_pn_seed_nodata; |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
37 |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
38 random_1035(lfsr, params + 7); |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
39 random_1035(lfsr, params + 20); |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
40 random_1035(lfsr, params + 33); |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
41 random_1035(lfsr, params + 46); |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
42 } |
99
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 void EFR_decode_bfi_nodata(struct EFR_decoder_state *st, int taf, |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 int16_t *pcm_out) |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 { |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 int16_t params[EFR_NUM_PARAMS]; |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
183
452c1d5a6268
libgsmefr BFI w/o data: emit zero output after decoder reset
Mychaela Falconia <falcon@freecalypso.org>
parents:
160
diff
changeset
|
49 if (st->reset_flag_old) { |
452c1d5a6268
libgsmefr BFI w/o data: emit zero output after decoder reset
Mychaela Falconia <falcon@freecalypso.org>
parents:
160
diff
changeset
|
50 memset(pcm_out, 0, sizeof(int16_t) * L_FRAME); |
452c1d5a6268
libgsmefr BFI w/o data: emit zero output after decoder reset
Mychaela Falconia <falcon@freecalypso.org>
parents:
160
diff
changeset
|
51 return; |
452c1d5a6268
libgsmefr BFI w/o data: emit zero output after decoder reset
Mychaela Falconia <falcon@freecalypso.org>
parents:
160
diff
changeset
|
52 } |
99
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 memset(params, 0, sizeof(int16_t) * EFR_NUM_PARAMS); |
160
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
54 if (st->rxdtx_ctrl & RX_SP_FLAG) |
eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
55 random_bad_frame(st, params); |
99
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 EFR_decode_params(st, params, 1, 0, taf, pcm_out); |
7152cc7d1ca3
libgsmefr: implement EFR_decode_bfi_nodata()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |