FreeCalypso > hg > gsm-codec-lib
annotate efrtest/etsi-pcm-out.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 | 9f354d2aea13 |
children |
rev | line source |
---|---|
96
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
435
9f354d2aea13
efrtest: split etsi-dec.c for code reuse
Mychaela Falconia <falcon@freecalypso.org>
parents:
150
diff
changeset
|
2 * This C module holds some functions that have been split off from |
9f354d2aea13
efrtest: split etsi-dec.c for code reuse
Mychaela Falconia <falcon@freecalypso.org>
parents:
150
diff
changeset
|
3 * etsi-dec.c, with the goal of making it easier to build both |
9f354d2aea13
efrtest: split etsi-dec.c for code reuse
Mychaela Falconia <falcon@freecalypso.org>
parents:
150
diff
changeset
|
4 * standard-EFR and AMR-EFR versions of the ETSI-format EFR decoder. |
96
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdint.h> |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
435
9f354d2aea13
efrtest: split etsi-dec.c for code reuse
Mychaela Falconia <falcon@freecalypso.org>
parents:
150
diff
changeset
|
10 void |
150
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
11 write_pcm_be(outf, pcm) |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
12 FILE *outf; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
13 int16_t *pcm; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
14 { |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
15 uint8_t bytes[320], *dp; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
16 int16_t samp; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
17 unsigned n; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
18 |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
19 dp = bytes; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
20 for (n = 0; n < 160; n++) { |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
21 samp = pcm[n]; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
22 *dp++ = (samp >> 8) & 0xFF; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
23 *dp++ = samp & 0xFF; |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
24 } |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
25 fwrite(bytes, 2, 160, outf); |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
26 } |
da17c7f02c6c
gsmefr-etsi-dec: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
145
diff
changeset
|
27 |
435
9f354d2aea13
efrtest: split etsi-dec.c for code reuse
Mychaela Falconia <falcon@freecalypso.org>
parents:
150
diff
changeset
|
28 void |
96
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 write_pcm_le(outf, pcm) |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 FILE *outf; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 int16_t *pcm; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 { |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 uint8_t bytes[320], *dp; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 int16_t samp; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 unsigned n; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 dp = bytes; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 for (n = 0; n < 160; n++) { |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 samp = pcm[n]; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 *dp++ = samp & 0xFF; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 *dp++ = (samp >> 8) & 0xFF; |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 fwrite(bytes, 2, 160, outf); |
9cf1355bc071
gsmefr-etsi-dec test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |