FreeCalypso > hg > gsm-codec-lib
comparison libgsmfrp/bad_frame.c @ 248:6ac547f0b903
libgsmfrp: yet another invalid SID logic change, for 1.0.2
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 12 May 2023 03:48:19 +0000 |
parents | f081a6850fb5 |
children |
comparison
equal
deleted
inserted
replaced
247:56d3fbacd115 | 248:6ac547f0b903 |
---|---|
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void gsmfr_preproc_invalid_sid(struct gsmfr_preproc_state *st, gsm_byte *frame) | 95 void gsmfr_preproc_invalid_sid(struct gsmfr_preproc_state *st, gsm_byte *frame) |
96 { | 96 { |
97 int mute; | |
98 | |
97 switch (st->rx_state) { | 99 switch (st->rx_state) { |
98 case NO_DATA: | 100 case NO_DATA: |
99 memcpy(frame, &gsmfr_preproc_silence_frame, sizeof(gsm_frame)); | 101 memcpy(frame, &gsmfr_preproc_silence_frame, sizeof(gsm_frame)); |
100 return; | 102 return; |
101 case SPEECH: | 103 case SPEECH: |
103 * Make CN out of the last good speech frame, following the | 105 * Make CN out of the last good speech frame, following the |
104 * "NOTE" at the end of section 6.1.2 in TS 46.031. | 106 * "NOTE" at the end of section 6.1.2 in TS 46.031. |
105 */ | 107 */ |
106 st->rx_state = COMFORT_NOISE; | 108 st->rx_state = COMFORT_NOISE; |
107 memcpy(st->sid_prefix, &st->speech_frame, 5); | 109 memcpy(st->sid_prefix, &st->speech_frame, 5); |
108 st->sid_xmaxc = ((st->speech_frame[27] & 0x1F) << 1) | | 110 st->sid_xmaxc = gsmfr_preproc_xmaxc_mean(st->speech_frame); |
109 (st->speech_frame[28] >> 7); | |
110 gsmfr_preproc_gen_cn(st, frame); | 111 gsmfr_preproc_gen_cn(st, frame); |
111 return; | 112 return; |
112 case SPEECH_MUTING: | 113 case SPEECH_MUTING: |
113 /* same as above, but set the state to CN_MUTING */ | 114 /* ignore invalid SID in this state and act as if we got BFI */ |
114 st->rx_state = CN_MUTING; | 115 mute = reduce_xmaxc(st->speech_frame); |
115 memcpy(st->sid_prefix, &st->speech_frame, 5); | 116 memcpy(frame, &st->speech_frame, sizeof(gsm_frame)); |
116 st->sid_xmaxc = ((st->speech_frame[27] & 0x1F) << 1) | | 117 random_grid_pos(st, frame); |
117 (st->speech_frame[28] >> 7); | 118 if (mute) |
118 gsmfr_preproc_gen_cn(st, frame); | 119 st->rx_state = NO_DATA; |
119 return; | 120 return; |
120 case COMFORT_NOISE: | 121 case COMFORT_NOISE: |
121 case LOST_SID: | 122 case LOST_SID: |
122 st->rx_state = COMFORT_NOISE; | 123 st->rx_state = COMFORT_NOISE; |
123 gsmfr_preproc_gen_cn(st, frame); | 124 gsmfr_preproc_gen_cn(st, frame); |