FreeCalypso > hg > freecalypso-docs
annotate DSP-speech-decoder @ 108:e26623146358 default tip
new article DSP-speech-decoder
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 29 Oct 2024 22:11:41 +0000 |
parents | |
children |
rev | line source |
---|---|
108
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 As described in Calypso-digital-voice article, we can use Calypso MCSI (an |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 auxiliary hardware interface brought out on FreeCalypso dev boards) in the so- |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 called "Bluetooth headset" mode to capture the voice call downlink in digital |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 form, specifically 16-bit linear PCM, after speech decoding performed by the |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 DSP, but before D-to-A conversion for analog audio output. As of 2024-10, we |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 have a set of tools (Lattice Icestick FPGA board, a gateware design for this |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 FPGA, and corresponding host software tools - see fc-pcm-if Hg repository) that |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 puts these ideas into practice; using these tools, we can now answer some long- |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 standing questions about exactly how Calypso DSP implements speech decoding for |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 various GSM codecs. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 FRv1 decoder implementation |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 =========================== |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 The original set of Full Rate codec specs did not include the feature of in-band |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 encoder and decoder homing frames; this feature was included in HRv1 and EFR |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 from day 1, and was also back-ported to FRv1 in later versions of 06.10 spec - |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 but it was not present originally, and it is defined as optional in the later |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 spec versions. Going into these Calypso MCSI experiments, we had this question: |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 does Calypso DSP implement decoder homing frames for FRv1, or does it not? |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 Experimental observation: in-band decoder homing is NOT implemented for FRv1 in |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 this DSP. If we feed the DHF defined in later versions of 06.10 spec to our |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 Calypso MS via TCH DL, it gets treated as a regular speech frame without any |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 special handling; more specifically, we don't see PCM16 output frames consisting |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 of 0x0008 words as required by the spec when the optional in-band decoder homing |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 feature is present. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 This lack of in-band homing feature makes it difficult to test the decoder |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 against official ETSI test sequences, as we have no way of getting it into a |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 defined state. The ancient GSM 11.10 test spec provides a mechanism called DAI |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 that includes the necessary reset signal, and it appears that Calypso DSP does |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 support operating MCSI as DAI rather than "Bluetooth" mode - but we haven't done |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 any experiments with this DAI mode yet. Hence our exploration of FRv1 decoder |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 implementation in our dear Calypso DSP ends here for now. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 EFR decoder implementation |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 ========================== |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 Unlike the situation with FRv1, the in-band codec homing feature is mandatory |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 for EFR per the specs. And with Calypso DSP we got good news: it does implement |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 this feature at least in the decoding direction, which is the only one we've |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 tested so far. Exactly per the spec, the first DHF arriving from TCH DL is |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 decoded like a regular speech frame, but the decoder state is reset at the end. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 All subsequent DHFs turn into 0x0008 output, and we indeed see the latter coming |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 out on MCSI. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 Once we established that the decoder homing feature works as specified, our |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 next question was: does our dear Calypso DSP implement the original bit-exact |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 definition of EFR, or does it implement what we call the AMR-EFR hybrid? |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 Experimental observation: at least in the decoding direction, it implements the |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 original bit-exact EFR decoder! This finding is remarkable because all of our |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 experiments in this series were performed on DSP ROM version 3606, the final |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 one that not only includes AMR support, but has been subject to whatever rework |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 TI did between 3416 and 3606 ROMs. If we assume (based on some experiments in |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 past years where we disabled loading of TI's official DSP patches) that AMR |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 support is already present in the DSP ROM, as opposed to being contained |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 entirely in the patches, it follows that the DSP ROM must contain both EFR and |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 AMR codec implementations, yet the EFR implementation has not been AMR-ized. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 (In contrast, the network-side speech transcoder implementation used by T-Mobile |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 USA and Telcel Mexico appears to use maximally-shared code between EFR and AMR, |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 resulting in the AMR-EFR hybrid that differs from the original bit-exact |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 definition, but has been blessed by 3GPP as an acceptable alternative.) |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 Strange corruption bug |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 ---------------------- |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 As we fed ETSI test sequences from GSM 06.54 to our Calypso DSP under test via |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 TCH DL, checking for an exact match, we observed what appears to be a corruption |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 bug of some kind (corrupting either codec parameter bits or state variables) |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 that manifests in a manner that seems random. In our test, we concatenated all |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 21 test sequences from GSM 06.54 (test0.cod through test20.cod) and fed the |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 resulting super-long sequence into TCH DL. The test was performed twice; on |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 the second try we had 'tch record' running in fc-shell, capturing TCH DL as |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 received by the Calypso MS, and we confirmed that the entire super-long test |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 sequence was received without errors. The decoded output (captured via MCSI) |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 was then split into 21 separate robe files following frame counts: because each |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 test*.cod input sequence begins with two DHFs, the decoder resets between these |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 concatenated test sequences, allowing the output to be compared against |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 test*.out reference files with per-sequence granularity. The final diff |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 comparison between split-out robe files and the official reference decoder |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 output revealed the following oddities: |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * In the first run, decoded outputs for test0, test6, test11, test14, test15, |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 test16 and test20 showed a mismatch. The difference in test0 outputs was |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 examined closer: the diff begins on a subframe boundary and continues until |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 the next DHF. All other test sequences got a perfect match to ETSI reference |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 decoder output. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 * In the second run, a different set of sequences showed a mismatch: this time |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 the failing sequences were test1, test5, test6, test7, test15 and test16. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 The other sequences that produced mismatches in the first run produced |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 perfectly good output (matching ETSI reference decoder) in this run! |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 * test6, test15 and test16 were the three sequences that failed in both runs. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 However, diffing between the two runs shows that the errors in each of these |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 3 twice-failed sequences are different between runs, further strengthening |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 the appearance of corruption that seems totally random. |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 We do not currently have any better explanation for this oddity than a data |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 corruption bug somewhere in the DSP. For the record, these tests were performed |
e26623146358
new article DSP-speech-decoder
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 on an FCDEV3B with Calypso DSP ROM version 3606 and DSP patch version 6840. |