FreeCalypso > hg > gsm-codec-lib
annotate libgsmefr/dec_rtp_in.c @ 581:e2d5cad04cbf
libgsmhr1 RxFE: store CN R0+LPC separately from speech
In the original GSM 06.06 code the ECU for speech mode is entirely
separate from the CN generator, maintaining separate state. (The
main intertie between them is the speech vs CN state variable,
distinguishing between speech and CN BFIs, in addition to the
CN-specific function of distinguishing between initial and update
SIDs.)
In the present RxFE implementation I initially thought that we could
use the same saved_frame buffer for both ECU and CN, overwriting
just the first 4 params (R0 and LPC) when a valid SID comes in.
However, I now realize it was a bad idea: the original code has a
corner case (long sequence of speech-mode BFIs to put the ECU in
state 6, then SID and CN-mode BFIs, then a good speech frame) that
would be broken by that buffer reuse approach. We could eliminate
this corner case by resetting the ECU state when passing through
a CN insertion period, but doing so would needlessly increase
the behavioral diffs between GSM 06.06 and our version.
Solution: use a separate CN-specific buffer for CN R0+LPC parameters,
and match the behavior of GSM 06.06 code in this regard.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 13 Feb 2025 10:02:45 +0000 |
| parents | f2d0f2f15d5f |
| 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> |
|
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 } |
