FreeCalypso > hg > gsm-codec-lib
annotate libgsmfr2/pp_bad.c @ 554:b66fb6be73c3
CHANGES: list those planned for inclusion in gsm-codec-lib-r4
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 07 Oct 2024 18:21:32 +0000 |
parents | 96c4ed5529bf |
children |
rev | line source |
---|---|
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
2 * In this module we implement our handling of BFI frame gaps |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
3 * and invalid SID frames. |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <string.h> |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
8 #include "tw_gsmfr.h" |
262
573afa985df6
libgsmfr2: split pp_state.h from pp_internal.h
Mychaela Falconia <falcon@freecalypso.org>
parents:
256
diff
changeset
|
9 #include "pp_state.h" |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
10 #include "pp_internal.h" |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
12 static int reduce_xmaxc(uint8_t *frame) |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 int mute_flag = 1; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 unsigned sub, xmaxc; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 for (sub = 0; sub < 4; sub++) { |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 xmaxc = ((frame[sub*7+6] & 0x1F) << 1) | (frame[sub*7+7] >> 7); |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (xmaxc > 4) { |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 xmaxc -= 4; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 mute_flag = 0; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } else |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 xmaxc = 0; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 frame[sub*7+6] &= 0xE0; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 frame[sub*7+6] |= xmaxc >> 1; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 frame[sub*7+7] &= 0x7F; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 frame[sub*7+7] |= (xmaxc & 1) << 7; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 return mute_flag; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
32 static void random_grid_pos(struct gsmfr_preproc_state *st, uint8_t *frame) |
109
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
33 { |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
34 unsigned sub, Mc; |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
35 |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
36 for (sub = 0; sub < 4; sub++) { |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
37 Mc = gsmfr_preproc_prng(st, 2); |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
38 frame[sub*7+6] &= 0x9F; |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
39 frame[sub*7+6] |= Mc << 5; |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
40 } |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
41 } |
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
42 |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
43 static int reduce_xmaxc_sid(struct gsmfr_preproc_state *st) |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
44 { |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
45 if (st->sid_xmaxc > 4) { |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
46 st->sid_xmaxc -= 4; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
47 return 0; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
48 } else { |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
49 st->sid_xmaxc = 0; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
50 return 1; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
51 } |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
52 } |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
53 |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
54 void gsmfr_preproc_bfi(struct gsmfr_preproc_state *st, int taf, uint8_t *frame) |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 { |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 int mute; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 switch (st->rx_state) { |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 case NO_DATA: |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
60 memcpy(frame, &gsmfr_preproc_silence_frame, |
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
61 GSMFR_RTP_FRAME_LEN); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
62 if (st->dtxd_nodata_count) { |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
63 st->dtxd_sid_flag = 0; |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
64 st->dtxd_nodata_count--; |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
65 } else |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
66 st->dtxd_sid_flag = 1; |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 return; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 case SPEECH: |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
69 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 st->rx_state = SPEECH_MUTING; |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
71 st->dtxd_sid_flag = 0; |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 return; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 case SPEECH_MUTING: |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 mute = reduce_xmaxc(st->speech_frame); |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
75 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); |
109
2361a7d8c1eb
libgsmfrp: randomize grid position params when muting speech,
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
76 random_grid_pos(st, frame); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
77 if (mute) { |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 st->rx_state = NO_DATA; |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
79 st->dtxd_nodata_count = 0; |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
80 } |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
81 st->dtxd_sid_flag = 0; |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 return; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 case COMFORT_NOISE: |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
84 st->dtxd_sid_flag = 1; |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 if (taf) |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 st->rx_state = LOST_SID; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
87 gsmfr_preproc_gen_cn(st, frame); |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 return; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 case LOST_SID: |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
90 st->dtxd_sid_flag = 1; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
91 if (taf) { |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
92 st->rx_state = CN_MUTING; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
93 reduce_xmaxc_sid(st); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
94 st->dtxd_sid_flag = 0; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
95 } |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 gsmfr_preproc_gen_cn(st, frame); |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
97 return; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
98 case CN_MUTING: |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
99 st->dtxd_sid_flag = 0; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
100 if (reduce_xmaxc_sid(st)) { |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 st->rx_state = NO_DATA; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
102 memcpy(frame, &gsmfr_preproc_silence_frame, |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
103 GSMFR_RTP_FRAME_LEN); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
104 st->dtxd_nodata_count = 3; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
105 } else |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
106 gsmfr_preproc_gen_cn(st, frame); |
6
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return; |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
b2255a5d0519
libgsmfrp: implement BFI handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
110 |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
111 void gsmfr_preproc_invalid_sid(struct gsmfr_preproc_state *st, uint8_t *frame) |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
112 { |
248
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
113 int mute; |
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
114 |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
115 switch (st->rx_state) { |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
116 case NO_DATA: |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
117 memcpy(frame, &gsmfr_preproc_silence_frame, |
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
118 GSMFR_RTP_FRAME_LEN); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
119 if (st->dtxd_nodata_count) { |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
120 st->dtxd_sid_flag = 0; |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
121 st->dtxd_nodata_count--; |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
122 } else |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
123 st->dtxd_sid_flag = 1; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
124 return; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
125 case SPEECH: |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
126 /* |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
127 * Make CN out of the last good speech frame, following the |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
128 * "NOTE" at the end of section 6.1.2 in TS 46.031. |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
129 */ |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
130 st->rx_state = COMFORT_NOISE; |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
131 st->dtxd_sid_flag = 1; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
132 memcpy(st->sid_prefix, &st->speech_frame, 5); |
248
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
133 st->sid_xmaxc = gsmfr_preproc_xmaxc_mean(st->speech_frame); |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
134 gsmfr_preproc_gen_cn(st, frame); |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
135 return; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
136 case SPEECH_MUTING: |
248
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
137 /* ignore invalid SID in this state and act as if we got BFI */ |
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
138 mute = reduce_xmaxc(st->speech_frame); |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
139 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); |
248
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
140 random_grid_pos(st, frame); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
141 if (mute) { |
248
6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
Mychaela Falconia <falcon@freecalypso.org>
parents:
242
diff
changeset
|
142 st->rx_state = NO_DATA; |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
143 st->dtxd_nodata_count = 0; |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
144 } |
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
145 st->dtxd_sid_flag = 0; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
146 return; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
147 case COMFORT_NOISE: |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
148 case LOST_SID: |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
149 st->rx_state = COMFORT_NOISE; |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
150 st->dtxd_sid_flag = 1; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
151 gsmfr_preproc_gen_cn(st, frame); |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
152 return; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
153 case CN_MUTING: |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
154 st->dtxd_sid_flag = 0; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
155 if (reduce_xmaxc_sid(st)) { |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
156 st->rx_state = NO_DATA; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
157 memcpy(frame, &gsmfr_preproc_silence_frame, |
256
a33edf624061
libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
158 GSMFR_RTP_FRAME_LEN); |
530
96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
Mychaela Falconia <falcon@freecalypso.org>
parents:
526
diff
changeset
|
159 st->dtxd_nodata_count = 3; |
242
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
160 } else |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
161 gsmfr_preproc_gen_cn(st, frame); |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
162 return; |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
163 } |
f081a6850fb5
libgsmfrp: new refined implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
164 } |
526
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
165 |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
166 void gsmfr_preproc_bfi_bits(struct gsmfr_preproc_state *st, |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
167 const uint8_t *bad_frame, int taf, |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
168 uint8_t *frame_out) |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
169 { |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
170 if (gsmfr_preproc_sid_classify(bad_frame) == 0) |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
171 gsmfr_preproc_bfi(st, taf, frame_out); |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
172 else |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
173 gsmfr_preproc_invalid_sid(st, frame_out); |
405a84110997
libgsmfr2: add gsmfr_preproc_bfi_bits()
Mychaela Falconia <falcon@freecalypso.org>
parents:
262
diff
changeset
|
174 } |