view doc/Codec-utils @ 242:f081a6850fb5

libgsmfrp: new refined implementation The previous implementation exhibited the following defects, which are now fixed: 1) The last received valid SID was cached forever for the purpose of handling future invalid SIDs - we could have received some valid SID ages ago, then lots of speech or NO_DATA, and if we then get an invalid SID, we would resurrect the last valid SID from ancient history - a bad design. In our new design, we handle invalid SID based on the current state, much like BFI. 2) GSM 06.11 spec says clearly that after the second lost SID (received BFI=1 && TAF=1 in CN state) we need to gradually decrease the output level, rather than jump directly to emitting silence frames - we previously failed to implement such logic. 3) Per GSM 06.12 section 5.2, Xmaxc should be the same in all 4 subframes in a SID frame. What should we do if we receive an otherwise valid SID frame with different Xmaxc? Our previous approach would replicate this Xmaxc oddity in every subsequent generated CN frame, which is rather bad. In our new design, the very first CN frame (which can be seen as a transformation of the SID frame itself) retains the original 4 distinct Xmaxc, but all subsequent CN frames are based on the Xmaxc from the last subframe of the most recent SID.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 09 May 2023 05:16:31 +0000
parents 04936af99fc8
children a053cf0bac04
line wrap: on
line source

Standalone command line utilities for FR and EFR codecs
=======================================================

The pre-existing FOSS opencore-amr package includes amrnb-enc and amrnb-dec test
programs: the first reads linear PCM from a WAV file and emits AMR encoder
output in a .amr file (RFC 4867 AMR storage format), the second reads this .amr
format and emits AMR decoder output as WAV.  Inspired by these simple test
programs, the present package offers equivalent command line utilities for GSM
FR and EFR codecs.  Here they are:

gsmfr-encode	This utility reads linear PCM from a WAV file, runs libgsm
		06.10 encoder and writes the output in the classic .gsm format
		(directly abutted FR codec frames of 33 bytes each).  We don't
		currently have a Tx-side DTX implementation (VAD etc) for GSM
		FR, hence the output from gsmfr-encode will always consist of
		good speech frames only.

gsmfr-decode	This utility reads our gsmx format (see Binary-file-format
		article), which is a superset of the classic libgsm format.
		The input to gsmfr-decode may be a pure .gsm recording as
		produced by gsmfr-encode or toast from libgsm package, or it
		can also contain SID frames and/or BFI markers.  The processing
		performed by gsmfr-decode begins with our FR1 Rx DTX handler
		preprocessor, which will be an identity transform for pure .gsm
		input but becomes important for real-world input containing SIDs
		and BFIs, and is followed by gsm_decode() from libgsm.  The
		decoded output is written as WAV.

gsmefr-encode	This utility reads linear PCM from a WAV file, runs our EFR
		encoder (Themyscira libgsmefr) and writes the output in our gsmx
		format.  There is an option to enable or disable DTX: -d enables
		DTX, otherwise it is disabled.  (This option mirrors amrnb-enc.)

gsmefr-decode	This utility reads our gsmx format (which must be EFR, not FR1)
		and feeds all frames and BFIs to our EFR decoder.  The decoded
		output is written as WAV.

The above are original programs that read WAV input for encoding and write WAV
output from decoding.  We now also have raw versions that read and write our
"robe" (raw big-endian) format instead:

gsmfr-encode-r	Just like gsm[e]fr-encode, but reading "robe" instead of WAV.
gsmefr-encode-r

gsmfr-decode-r	Just like gsm[e]fr-decode, but writing "robe" instead of WAV.
gsmefr-decode-r

Please see PCM-file-formats article for the rationale.