comparison libgsmfr2/pp_good.c @ 256:a33edf624061

libgsmfr2: start with API definition and port of libgsmfrp code
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Apr 2024 20:49:53 +0000
parents libgsmfrp/good_frame.c@f081a6850fb5
children 573afa985df6
comparison
equal deleted inserted replaced
255:07f936338de1 256:a33edf624061
1 /*
2 * In this module we implement preprocessing of received good frames.
3 */
4
5 #include <stdint.h>
6 #include <string.h>
7 #include "tw_gsmfr.h"
8 #include "pp_internal.h"
9
10 void gsmfr_preproc_good_frame(struct gsmfr_preproc_state *st, uint8_t *frame)
11 {
12 int sid;
13
14 /* always set correct magic */
15 frame[0] = 0xD0 | frame[0] & 0x0F;
16 /* now classify by SID */
17 sid = gsmfr_preproc_sid_classify(frame);
18 switch (sid) {
19 case 0: /* good speech frame */
20 st->rx_state = SPEECH;
21 memcpy(&st->speech_frame, frame, GSMFR_RTP_FRAME_LEN);
22 return;
23 case 1: /* invalid SID frame */
24 /* state-dependent handling, similar to BFI */
25 gsmfr_preproc_invalid_sid(st, frame);
26 return;
27 case 2: /* valid SID frame */
28 st->rx_state = COMFORT_NOISE;
29 gsmfr_preproc_sid2cn(st, frame);
30 return;
31 }
32 }