FreeCalypso > hg > gsm-codec-lib
view doc/Binary-file-format @ 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 | f469bad44c0e |
children |
line wrap: on
line source
We (Themyscira Wireless) define our own binary file format for testing of GSM 06.10 (FR) and EFR codec functions; this format of ours is an extension of classic .gsm format from libgsm/toast. The original libgsm file format is a directly abutted sequence of 33-byte libgsm frames, equivalent to RTP frames for GSM FR, with the upper nibble of the first byte in each frame equal to 0xD, serving as a signature. We simply extend this idea: our version is still a directly abutted sequence of binary records, but each record is now one of 3 possibilities: - a 33-byte GSM FR frame in libgsm/RTP format, 0xD signature - a 31-byte GSM EFR frame in RTP format (ETSI TS 101 318), 0xC signature - a 2-byte Themyscira-extension BFI marker, 0xBF signature, see below File reading functions begin by reading only one byte; this byte, once decoded, tells us how many more bytes need to be read, and frame synchronization is thus maintained. The recommended filename suffix for extended-libgsm binary files in the present format is .gsmx; of course dot-separated filename suffixes hold absolutely no special meaning on Unix systems, but many developers still strongly prefer to have them for psychological comfort. Any gsmx file (FR or EFR) can be dumped in human-readable form with our gsmrec-dump utility. This utility turns every read frame from bytes into codec parameters with gsmfr_unpack_to_array() or EFR_frame2params(), and then displays those parameters in a sensible manner, with a per-frame header line followed by 4 lines of subframe parameters. FR and EFR frames are not expected to be mixed in the same stream recording; our low-level binary file reading function and gsmrec-dump will grok such mixing just fine, but each higher-level test program (beyond gsmrec-dump) is expected to be written for only one codec, either FR or EFR. BFI marker format ================= Every 20 ms frame in our gsmx files is either a good FR/EFR frame or a BFI (Bad Frame Indication) marker. The BFI marker format used in our gsmx file format is the same format which we (Themyscira Wireless) previously used in our GSM RAN RTP transport, before switching to our current TRAUlike RTP format. This BFI marker format is quite simple: byte 0: 0xBF signature; byte 1: least-significant bit encoding TAF per GSM 06.31 or GSM 06.81, section 6.1.1 in both documents; other bits are reserved.