FreeCalypso > hg > gsm-codec-lib
comparison libgsmfr2/pp_bad.c @ 530:96c4ed5529bf
libgsmfr2 preproc: implement support for DTXd
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 19 Sep 2024 20:15:54 +0000 |
parents | 405a84110997 |
children |
comparison
equal
deleted
inserted
replaced
529:79cd992de3ad | 530:96c4ed5529bf |
---|---|
57 | 57 |
58 switch (st->rx_state) { | 58 switch (st->rx_state) { |
59 case NO_DATA: | 59 case NO_DATA: |
60 memcpy(frame, &gsmfr_preproc_silence_frame, | 60 memcpy(frame, &gsmfr_preproc_silence_frame, |
61 GSMFR_RTP_FRAME_LEN); | 61 GSMFR_RTP_FRAME_LEN); |
62 if (st->dtxd_nodata_count) { | |
63 st->dtxd_sid_flag = 0; | |
64 st->dtxd_nodata_count--; | |
65 } else | |
66 st->dtxd_sid_flag = 1; | |
62 return; | 67 return; |
63 case SPEECH: | 68 case SPEECH: |
64 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); | 69 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); |
65 st->rx_state = SPEECH_MUTING; | 70 st->rx_state = SPEECH_MUTING; |
71 st->dtxd_sid_flag = 0; | |
66 return; | 72 return; |
67 case SPEECH_MUTING: | 73 case SPEECH_MUTING: |
68 mute = reduce_xmaxc(st->speech_frame); | 74 mute = reduce_xmaxc(st->speech_frame); |
69 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); | 75 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); |
70 random_grid_pos(st, frame); | 76 random_grid_pos(st, frame); |
71 if (mute) | 77 if (mute) { |
72 st->rx_state = NO_DATA; | 78 st->rx_state = NO_DATA; |
79 st->dtxd_nodata_count = 0; | |
80 } | |
81 st->dtxd_sid_flag = 0; | |
73 return; | 82 return; |
74 case COMFORT_NOISE: | 83 case COMFORT_NOISE: |
84 st->dtxd_sid_flag = 1; | |
75 if (taf) | 85 if (taf) |
76 st->rx_state = LOST_SID; | 86 st->rx_state = LOST_SID; |
77 gsmfr_preproc_gen_cn(st, frame); | 87 gsmfr_preproc_gen_cn(st, frame); |
78 return; | 88 return; |
79 case LOST_SID: | 89 case LOST_SID: |
90 st->dtxd_sid_flag = 1; | |
80 if (taf) { | 91 if (taf) { |
81 st->rx_state = CN_MUTING; | 92 st->rx_state = CN_MUTING; |
82 reduce_xmaxc_sid(st); | 93 reduce_xmaxc_sid(st); |
94 st->dtxd_sid_flag = 0; | |
83 } | 95 } |
84 gsmfr_preproc_gen_cn(st, frame); | 96 gsmfr_preproc_gen_cn(st, frame); |
85 return; | 97 return; |
86 case CN_MUTING: | 98 case CN_MUTING: |
99 st->dtxd_sid_flag = 0; | |
87 if (reduce_xmaxc_sid(st)) { | 100 if (reduce_xmaxc_sid(st)) { |
88 st->rx_state = NO_DATA; | 101 st->rx_state = NO_DATA; |
89 memcpy(frame, &gsmfr_preproc_silence_frame, | 102 memcpy(frame, &gsmfr_preproc_silence_frame, |
90 GSMFR_RTP_FRAME_LEN); | 103 GSMFR_RTP_FRAME_LEN); |
104 st->dtxd_nodata_count = 3; | |
91 } else | 105 } else |
92 gsmfr_preproc_gen_cn(st, frame); | 106 gsmfr_preproc_gen_cn(st, frame); |
93 return; | 107 return; |
94 } | 108 } |
95 } | 109 } |
100 | 114 |
101 switch (st->rx_state) { | 115 switch (st->rx_state) { |
102 case NO_DATA: | 116 case NO_DATA: |
103 memcpy(frame, &gsmfr_preproc_silence_frame, | 117 memcpy(frame, &gsmfr_preproc_silence_frame, |
104 GSMFR_RTP_FRAME_LEN); | 118 GSMFR_RTP_FRAME_LEN); |
119 if (st->dtxd_nodata_count) { | |
120 st->dtxd_sid_flag = 0; | |
121 st->dtxd_nodata_count--; | |
122 } else | |
123 st->dtxd_sid_flag = 1; | |
105 return; | 124 return; |
106 case SPEECH: | 125 case SPEECH: |
107 /* | 126 /* |
108 * Make CN out of the last good speech frame, following the | 127 * Make CN out of the last good speech frame, following the |
109 * "NOTE" at the end of section 6.1.2 in TS 46.031. | 128 * "NOTE" at the end of section 6.1.2 in TS 46.031. |
110 */ | 129 */ |
111 st->rx_state = COMFORT_NOISE; | 130 st->rx_state = COMFORT_NOISE; |
131 st->dtxd_sid_flag = 1; | |
112 memcpy(st->sid_prefix, &st->speech_frame, 5); | 132 memcpy(st->sid_prefix, &st->speech_frame, 5); |
113 st->sid_xmaxc = gsmfr_preproc_xmaxc_mean(st->speech_frame); | 133 st->sid_xmaxc = gsmfr_preproc_xmaxc_mean(st->speech_frame); |
114 gsmfr_preproc_gen_cn(st, frame); | 134 gsmfr_preproc_gen_cn(st, frame); |
115 return; | 135 return; |
116 case SPEECH_MUTING: | 136 case SPEECH_MUTING: |
117 /* ignore invalid SID in this state and act as if we got BFI */ | 137 /* ignore invalid SID in this state and act as if we got BFI */ |
118 mute = reduce_xmaxc(st->speech_frame); | 138 mute = reduce_xmaxc(st->speech_frame); |
119 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); | 139 memcpy(frame, &st->speech_frame, GSMFR_RTP_FRAME_LEN); |
120 random_grid_pos(st, frame); | 140 random_grid_pos(st, frame); |
121 if (mute) | 141 if (mute) { |
122 st->rx_state = NO_DATA; | 142 st->rx_state = NO_DATA; |
143 st->dtxd_nodata_count = 0; | |
144 } | |
145 st->dtxd_sid_flag = 0; | |
123 return; | 146 return; |
124 case COMFORT_NOISE: | 147 case COMFORT_NOISE: |
125 case LOST_SID: | 148 case LOST_SID: |
126 st->rx_state = COMFORT_NOISE; | 149 st->rx_state = COMFORT_NOISE; |
150 st->dtxd_sid_flag = 1; | |
127 gsmfr_preproc_gen_cn(st, frame); | 151 gsmfr_preproc_gen_cn(st, frame); |
128 return; | 152 return; |
129 case CN_MUTING: | 153 case CN_MUTING: |
154 st->dtxd_sid_flag = 0; | |
130 if (reduce_xmaxc_sid(st)) { | 155 if (reduce_xmaxc_sid(st)) { |
131 st->rx_state = NO_DATA; | 156 st->rx_state = NO_DATA; |
132 memcpy(frame, &gsmfr_preproc_silence_frame, | 157 memcpy(frame, &gsmfr_preproc_silence_frame, |
133 GSMFR_RTP_FRAME_LEN); | 158 GSMFR_RTP_FRAME_LEN); |
159 st->dtxd_nodata_count = 3; | |
134 } else | 160 } else |
135 gsmfr_preproc_gen_cn(st, frame); | 161 gsmfr_preproc_gen_cn(st, frame); |
136 return; | 162 return; |
137 } | 163 } |
138 } | 164 } |