FreeCalypso > hg > gsm-codec-lib
comparison libgsmefr/bfi_nodata.c @ 160:eefef9f6d533
libgsmefr: randomize d1035pf params in no-data BFI case
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 15 Dec 2022 07:23:18 +0000 |
parents | 7152cc7d1ca3 |
children | 452c1d5a6268 |
comparison
equal
deleted
inserted
replaced
159:aa4cdab30dc8 | 160:eefef9f6d533 |
---|---|
1 /* | 1 /* |
2 * In the expected usage mode of our libgsmefr decoder as part of "soft TRAU" | 2 * In the expected usage mode of our libgsmefr decoder as part of "soft TRAU" |
3 * uplink implementation, there will be times when the radio subsystem tells | 3 * uplink implementation, there will be times when the radio subsystem tells |
4 * us that a frame has been lost, but we don't have any errored bits to feed | 4 * us that a frame has been lost, but we don't have any errored bits to feed |
5 * to the decoder as ETSI canon calls for. We could of course call | 5 * to the decoder as ETSI canon calls for. Specifically, the canonical EFR |
6 * EFR_decode_frame() with a dummy frame of all zeros and BFI=1, but the | 6 * decoder will use the "fixed codebook excitation pulses" part of errored |
7 * EFR_decode_bfi_nodata() function provided in this module accomplishes | 7 * frames when a BFI comes in after speech, although not when BFI comes in |
8 * the same effect more efficiently. | 8 * after SID. Our solution in EFR_decode_bfi_nodata(): we look in the |
9 * decoder state to see if we are in speech mode, and if we are, we fill | |
10 * the needed parameters with a PRNG. | |
9 */ | 11 */ |
10 | 12 |
11 #include <string.h> | 13 #include <string.h> |
12 #include "gsm_efr.h" | 14 #include "gsm_efr.h" |
15 #include "typedef.h" | |
16 #include "namespace.h" | |
17 #include "cnst.h" | |
18 #include "dtx.h" | |
19 #include "dec_state.h" | |
20 | |
21 static void random_1035(Word32 *lfsr, Word16 *param_1035) | |
22 { | |
23 Word16 *p = param_1035; | |
24 Word16 i; | |
25 | |
26 /* 5 params of bit width 4 */ | |
27 for (i = 0; i < 5; i++) | |
28 *p++ = pseudonoise(lfsr, 4); | |
29 /* another 5 params of bit width 3 */ | |
30 for (i = 0; i < 5; i++) | |
31 *p++ = pseudonoise(lfsr, 3); | |
32 } | |
33 | |
34 static void random_bad_frame(struct EFR_decoder_state *st, Word16 *params) | |
35 { | |
36 Word32 *lfsr = &st->L_pn_seed_nodata; | |
37 | |
38 random_1035(lfsr, params + 7); | |
39 random_1035(lfsr, params + 20); | |
40 random_1035(lfsr, params + 33); | |
41 random_1035(lfsr, params + 46); | |
42 } | |
13 | 43 |
14 void EFR_decode_bfi_nodata(struct EFR_decoder_state *st, int taf, | 44 void EFR_decode_bfi_nodata(struct EFR_decoder_state *st, int taf, |
15 int16_t *pcm_out) | 45 int16_t *pcm_out) |
16 { | 46 { |
17 int16_t params[EFR_NUM_PARAMS]; | 47 int16_t params[EFR_NUM_PARAMS]; |
18 | 48 |
19 memset(params, 0, sizeof(int16_t) * EFR_NUM_PARAMS); | 49 memset(params, 0, sizeof(int16_t) * EFR_NUM_PARAMS); |
50 if (st->rxdtx_ctrl & RX_SP_FLAG) | |
51 random_bad_frame(st, params); | |
20 EFR_decode_params(st, params, 1, 0, taf, pcm_out); | 52 EFR_decode_params(st, params, 1, 0, taf, pcm_out); |
21 } | 53 } |