annotate doc/AMR-EFR-performance @ 497:a1599eaf51f9

top Makefile: add libgsmhr1
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 18 Jun 2024 23:57:26 +0000
parents cd1f0fa936cc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
487
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 Performance of libgsmefr and libtwamr, compared to competition
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ==============================================================
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 Both libgsmefr and libtwamr are based on reference C code from ETSI/3GPP:
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 libgsmefr is a librified version of GSM 06.53 reference code, and libtwamr is a
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 librified version of TS 26.073 reference code. Both of those reference sources
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 were officially presented as simulations, not as production code for running on
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 general-purpose x86 servers implementing transcoding MGW functionality, and the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 code is extremely inefficient.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 The problem of poor performance (taking too much CPU percentage per transcoded
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 call) would not be so acute if Themyscira GSM codec libraries existed in a
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 vacuum without competition - but we do have a competitor in the form of
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 libopencore-amrnb, part of the slightly larger opencore-amr package. Just like
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 libtwamr, that library is a derivative work based on the original AMR C code
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 from 3GPP, but by a more circuitous route: first PacketVideo created an
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 implementation of AMR for Android based on 3GPP reference code, then the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 creators of opencore-amr took PV's Android implementation (named OpenCORE) and
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ported it from Android to standard Unix/Linux userspace.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 Aside from its peculiar genealogy, there are practical problems with
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 libopencore-amrnb that made it unattractive for Themyscira Wireless, and thus
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 created the impetus for producing the present alternative:
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 * That library implements only AMR and not EFR, whereas for ThemWi good support
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 for EFR is a higher priority than good (or any) support for AMR.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * The idea of reshuffling bits in the manner of our gsm-amr2efr and gsm-efr2amr
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 hack-utilities (see AMR-EFR-conversion article) in order to implement "poor
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 man's EFR" via libopencore-amrnb was considered, but then rejected on
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 philosophical and aesthetic grounds: it feels philosophically wrong to
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 reshuffle bits in the application wrapper only to have internal code within
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 the library shuffle them back into the natural order of codec parameters.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * Like any AMR-and-not-EFR library, libopencore-amrnb cannot grok EFR SID
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 frames. Therefore, an implementation of "poor man's EFR" using that library
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 would have to operate with DTXu disabled, needlessly burning battery capacity
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 in the MS.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * Even for "pure" AMR and not EFR, libopencore-amrnb exhibits one serious
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 defect: it omits the in-band homing feature in both the encoder and the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 decoder, even though this feature is mandatory per 3GPP specs. (It is not
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 clear if this removal of homing functions was the work of PacketVideo in the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 world of Android, or if it happened at the time of subsequent opencore-amr
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 port to standard Unix/Linux userspace.) Furthermore, because the interface
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 wrapper module of libopencore-amrnb does not expose any state reset functions,
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 it is impossible to implement the homing feature externally to the library.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 This lack of homing makes it impossible to test libopencore-amrnb against the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 full set of 3GPP test sequences for AMR.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 In the present time, as of this release of Themyscira gsm-codec-lib, libgsmefr
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 is intended for production use while libtwamr is intended for lab use only,
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 matching test sequences and modeling bit-exact operation of other people's
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 network elements in reverse engineering workflows. Based on this difference in
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 applicability to production, more work has been put into improving performance
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 of libgsmefr compared to libtwamr. Libgsmefr version 1.1.0 exhibits
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 approximately 2x performance improvement over the original version, but it is
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 still significantly slower than libopencore-amrnb.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 The following performance numbers were obtained on Mother Mychaela's development
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 laptop, Intel Core2 Duo P8600 CPU @ 2.40 GHz, running 32-bit version of
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 Slackware, i.e., running only i686 code and not x86_64 despite the CPU having
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 the 'lm' feature. All tests involve encoding TEST4.INP sequence from GSM 06.54
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 set (301 frames in total, 6.020 s audio duration), then decoding the output of
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 the encoder run.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 Implementation Encoding time Decoding time
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 ---------------------------------------------
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 libgsmefr 183 ms 23 ms
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 libtwamr 359 ms 52 ms
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 opencore-amr 53 ms 13 ms
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 libgsmfr2 (FR) 13 ms 6 ms
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 FRv1 encoding and decoding of the same TEST4.INP was included in the test in
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 order to convince ourselves that FRv1 is not in any need of performance
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 optimization. In a network deployment that generally prefers EFR over FRv1,
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 almost all calls between a local GSM MS and the outside world (PSTN) will
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 involve the EFR transcoder rather than FRv1. If on rare occasion the network
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 selects FRv1 instead of EFR because the subscriber is using a super-old
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 non-EFR-capable handset (or has artificially restricted the speech version list
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 to FRv1 only), there will be some CPU cycles saved "for free" by using the much
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 less computationally expensive FRv1 codec - but CPU capacity planning for the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 transcoding MGW has to be based on EFR performance numbers rather than FRv1.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 In terms of EFR or MR122 encoder and decoder CPU cycle demand, libtwamr is
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 currently the worst performer; the first version of libgsmefr exhibited the
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 same poor performance. The current version of libgsmefr exhibits somewhat
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 better performance because most saturation arithmetic "basic ops" have been
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 inlined (eliminating the use of a function call for every elementary operation),
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 and the implementation code of those newly-inlined functions has been
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 streamlined for performance, as much as possible with immediately obvious
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 programming methods. The result is about 2x improvement over the original -
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 but sadly, still significantly slower than libopencore-amrnb on the same
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 machine with the same 32-bit execution mode and ABI.
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 Given that we (Themyscira Wireless) have a ton of other work tasks in our queue
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 besides the present problem of performance-optimizing libgsmefr to match
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 opencore-amr, this problem is currently shelved. We are releasing our libraries
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 as they currently stand, with the ~2x improvement in libgsmefr over the original
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 but still not matching opencore-amr, and leaving the problem of further
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 performance improvement to be addressed later, after other work of higher
cd1f0fa936cc doc/AMR-EFR-performance: new article
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 priority.