FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/tseq_in.c @ 585:3c6bf0d26ee7 default tip
TW-TS-005 reader: fix maximum line length bug
TW-TS-005 section 4.1 states:
The maximum allowed length of each line is 80 characters, not
including the OS-specific newline encoding.
The implementation of this line length limit in the TW-TS-005 hex file
reader function in the present suite was wrong, such that lines of
the full maximum length could not be read. Fix it.
Note that this bug affects comment lines too, not just actual RTP
payloads. Neither Annex A nor Annex B features an RTP payload format
that goes to the maximum of 40 bytes, but if a comment line goes to
the maximum allowed length of 80 characters not including the
terminating newline, the bug will be triggered, necessitating
the present fix.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Feb 2025 07:49:28 +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 } |