FreeCalypso > hg > gsm-codec-lib
annotate libgsmfr2/full_dec_wrap.c @ 536:a3300483ae74
doc/FR1-library-API: document return value from gsmfr_tfo_xfrm_*
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 21 Sep 2024 20:48:58 +0000 |
parents | f681fb758041 |
children |
rev | line source |
---|---|
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements a wrapper around the main processing functions |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * of our full decoder, handling RTP input per TW-TS-001. |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "tw_gsmfr.h" |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 int gsmfr_fulldec_rtp_in(struct gsmfr_fulldec_state *st, const uint8_t *rtp_pl, |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 unsigned rtp_pl_len, int16_t *pcm) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 { |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 switch (rtp_pl_len) { |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 case 0: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 /* BFI-no-data, but not an invalid RTP input per se */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 gsmfr_fulldec_bfi(st, 0, pcm); |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 case 1: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if ((rtp_pl[0] & 0xF6) != 0xE6) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 /* TW-TS-001 No_Data frame */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 gsmfr_fulldec_bfi(st, rtp_pl[0] & 1, pcm); |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 case GSMFR_RTP_FRAME_LEN: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if ((rtp_pl[0] & 0xF0) != 0xD0) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /* basic RTP format */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 gsmfr_fulldec_good_frame(st, rtp_pl, pcm); |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 case GSMFR_RTP_FRAME_LEN+1: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if ((rtp_pl[0] & 0xF4) != 0xE0) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if ((rtp_pl[1] & 0xF0) != 0xD0) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* extended RTP format (TW-TS-001) */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 if (rtp_pl[0] & 0x02) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 gsmfr_fulldec_bfi_bits(st, rtp_pl + 1, rtp_pl[0] & 1, |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 pcm); |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 else |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 gsmfr_fulldec_good_frame(st, rtp_pl + 1, pcm); |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 default: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 bad_rtp_input: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * Treat it like BFI-no-data, and tell the caller |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * that we received an invalid RTP payload. |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 gsmfr_fulldec_bfi(st, 0, pcm); |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 return -1; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |