A new GSM codec libraries and utilities package

Mychaela Falconia falcon at freecalypso.org
Sun Feb 19 01:44:59 UTC 2023


Hello GSM community,

I am pleased to announce the first release of Themyscira GSM codec
libraries and utilities package:

ftp://ftp.freecalypso.org/pub/GSM/codecs/gsm-codec-lib-r1.tar.bz2

The two principal libraries contained in this package, libgsmefr and
libgsmfrp, continue the tradition that was started back in 1990s with
the first release of libgsm, a Unix-oriented, C-library-embodied, Free
Software implementation of GSM 06.10 speech transcoder.  The original
libgsm was written and released long before anyone in the hacker
community even dreamed of running their own GSM network or building
their own GSM MS, but it is now used somewhere deep under the hood
(under lots of higher layers) by every GSM network-side implementation
that includes an RTP transcoding gateway to other voice networks,
activated whenever a GSM voice call is connected using good old FR
codec rather than AMR, and is likewise used for the same purpose by
anyone seeking to achieve working voice in an SDR-based GSM MS
implementation.

The present gsm-codec-lib release - a public works project of the
Women's Republic of Themyscira - continues in the spirit of libgsm by
offering two more similar libraries:

1) libgsmefr is a librified (turned into a library) version of the EFR
reference code from ETSI, with all state variables converted from
global vars into proper state structures, and with additional code
clean-up to make it function as a speech encoder and decoder library
on the same principle as libgsm, but for EFR codec instead of FR1.
All beyond-speech functions of the original EFR reference code (VAD,
DTX, comfort noise, error concealment) are included in libgsmefr,
allowing this library to be used to implement a *proper* speech
transcoder for GSM-EFR voice service.

I have previously noted that the general trend in the FOSS GSM
community is to use the popular AMR library libopencore-amrnb not only
for AMR, but also for EFR.  However, this approach is incorrect: the
SID and comfort noise mechanism of EFR is different from AMR, and if
you feed the uplink of a GSM-EFR call, containing SIDs and BFI skipped
frames, to libopencore-amrnb decoder, there will be strange noises in
the output in places where the GSM MS sent SID.  Decoding EFR from a
GSM call uplink requires a proper EFR library, not AMR, and I wasn't
able to find any workable pre-existing implementation prior to
producing Themyscira libgsmefr.

2) libgsmfrp is a preprocessor intended to be called prior to
gsm_decode() from libgsm, implementing Rx DTX handler functions of GSM
06.11, 06.12 and 06.31.  This preprocessor is required for anyone
seeking to implement GSM FR service in the traditional way depicted in
Figure 1 in 3GPP TS 46.001, as opposed to the "cut corners" way that
seems to be favored in the land of Osmocom.

When used as part of GSM network deployment, as opposed to lab
experimentation on the mobile side of GSM, the two just-released
Themyscira libraries work best together with this patch to osmo-bts:

https://www.freecalypso.org/hg/themwi-system-sw/file/tip/osmo-patches/osmo-bts-rtp-bfi.patch

implementing this extension to RTP transport format:

https://www.freecalypso.org/hg/themwi-system-sw/file/tip/doc/RTP-BFI-extension

The "go along to get along" community appears to operate on a consensus
that the RTP stream should be paused when the uplink is in DTX, or
when a traffic frame was stolen for FACCH or lost to radio errors -
but I disagree with that approach, and instead operate my GSM network
on the principle of sending an RTP packet in *every* 20 ms slot, be it
rain or shine.  In the "consensus" approach the speech decoding path
in the transcoding MGW never executes at all during frame stream pauses
(when no RTP packets are sent), but in my "traditionalist" approach
(mimicking the ways of TDM) that decoding function does get called
every 20 ms, and it must produce *some* output toward PSTN in every
20 ms window, whether the MS was transmitting or not, and whether this
MS output was received or lost.  The Rx DTX handler becomes essential
in such operation: when there is no speech traffic from the MS,
libgsmfrp fills in comfort noise or previous speech frame substitution
and muting as appropriate per the rules of GSM 06.31.  In the case of
EFR this functionality is integral to the original reference code from
ETSI and thus appears in libgsmefr, but in the case of FR1 codec this
functionality takes the form of a preprocessor, implemented in
libgsmfrp.

In any case, the two newly released libraries are intended to sit on
the same "rank" in the software integration hierarchy as classic libgsm
from 1990s, and higher-level projects by various parties should feel
free to use them in the same manner how they currently use libgsm and
libopencore-amrnb.  I encourage gapk and various people's transcoding
MGW implementations to take advantages of these newly available
production quality GSM codec libraries.

With devotion to GSM Forever,
(Hasta la Victoria, Siempre,)
Mother Mychaela


More information about the Community mailing list