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