annotate libgsmefr/dec_rtp_in.c @ 550:de333989a12b

document gsm[e]fr-decode-tw5[-r] utilities
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Oct 2024 02:16:48 +0000
parents f2d0f2f15d5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
7 #include "gsm_efr.h"
528
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
9 int EFR_decode_rtp(struct EFR_decoder_state *st, const uint8_t *rtp_pl,
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
10 unsigned rtp_pl_len, int16_t *pcm)
528
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 */
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
15 EFR_decode_bfi_nodata(st, 0, pcm);
528
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 */
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
21 EFR_decode_bfi_nodata(st, rtp_pl[0] & 1, pcm);
528
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return 0;
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
23 case EFR_RTP_FRAME_LEN:
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
24 if ((rtp_pl[0] & 0xF0) != 0xC0)
528
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 */
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
27 EFR_decode_frame(st, rtp_pl, 0, 0, pcm);
528
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return 0;
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
29 case EFR_RTP_FRAME_LEN+1:
528
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;
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
32 if ((rtp_pl[1] & 0xF0) != 0xC0)
528
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) */
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
35 EFR_decode_frame(st, rtp_pl + 1, (rtp_pl[0] & 2) >> 1,
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
36 rtp_pl[0] & 1, pcm);
528
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return 0;
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 default:
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 bad_rtp_input:
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /*
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * 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
42 * that we received an invalid RTP payload.
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 */
542
f2d0f2f15d5f libgsmefr: add wrapper for TW-TS-001 RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 528
diff changeset
44 EFR_decode_bfi_nodata(st, 0, pcm);
528
f681fb758041 libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return -1;
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 }