FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/tseq_in.c @ 429:3ce30a95769e
libtwamr: implement test sequence input
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 07 May 2024 22:34:11 +0000 |
parents | libtwamr/tseq_out.c@eced57698c03 |
children |
comparison
equal
deleted
inserted
replaced
428:ffd87f972f86 | 429:3ce30a95769e |
---|---|
1 /* | |
2 * In this module we implement decoder input conversion from 3GPP | |
3 * test sequence format to our internal struct amr_param_frame. | |
4 */ | |
5 | |
6 #include <stdint.h> | |
7 #include <string.h> | |
8 #include "tw_amr.h" | |
9 #include "namespace.h" | |
10 #include "typedef.h" | |
11 #include "cnst.h" | |
12 #include "bits2prm.h" | |
13 | |
14 int amr_frame_from_tseq(const uint16_t *cod, int use_rxtype, | |
15 struct amr_param_frame *frame) | |
16 { | |
17 enum RXFrameType rx_type; | |
18 int rc; | |
19 | |
20 if (use_rxtype) { | |
21 if (cod[0] >= RX_N_FRAMETYPES) | |
22 return -1; | |
23 rx_type = cod[0]; | |
24 } else { | |
25 rc = amr_txtype_to_rxtype(cod[0], &rx_type); | |
26 if (rc < 0) | |
27 return -1; | |
28 } | |
29 frame->type = rx_type; | |
30 if (rx_type == RX_NO_DATA) { | |
31 frame->mode = 0xFF; | |
32 return 0; | |
33 } | |
34 if (cod[MAX_SERIAL_SIZE+1] > 7) | |
35 return -2; | |
36 frame->mode = cod[MAX_SERIAL_SIZE+1]; | |
37 switch (rx_type) { | |
38 case RX_SPEECH_GOOD: | |
39 case RX_SPEECH_DEGRADED: | |
40 case RX_SPEECH_BAD: | |
41 Bits2prm(frame->mode, cod + 1, frame->param); | |
42 break; | |
43 case RX_SID_UPDATE: | |
44 case RX_SID_BAD: | |
45 Bits2prm(MRDTX, cod + 1, frame->param); | |
46 break; | |
47 } | |
48 return 0; | |
49 } |