falconia submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
codec: add some constant frames for HR and EFR

With all 3 classic GSM codecs (FR, HR and EFR) sometimes a need
arises for a constant fill frame, to be inserted when no good speech
frame is available. For GSM-FR codec the substitution/muting spec
(GSM 06.11) explicitly defines a silence frame for this purpose,
but no such officially defined fill frames exist for HR or EFR.
Those newer codecs do, however, have homing frames that all decoders
are required to implement, and there is an unofficial silence frame
for GSM-HR, observed as the output from the official encoder fed with
all-zeros input.

Add these 3 constant frames (HR silence, HR homing, EFR homing) to
libosmocodec in order to make them easily usable in any application
that may need them, including applications that cannot have ThemWi
codec libraries as dependencies.

Change-Id: I2c510ac62a0786c137115c45eee7a48b9736265f
---
M include/osmocom/codec/codec.h
M src/codec/gsm620.c
M src/codec/gsm660.c
3 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h
index 7a23e7f..008eab1 100644
--- a/include/osmocom/codec/codec.h
+++ b/include/osmocom/codec/codec.h
@@ -34,6 +34,9 @@
extern const uint16_t gsm690_4_75_bitorder[]; /* AMR 4.75 kbits */

extern const uint8_t osmo_gsm611_silence_frame[GSM_FR_BYTES];
+extern const uint8_t osmo_gsm620_silence_frame[GSM_HR_BYTES];
+extern const uint8_t osmo_gsm620_homing_frame[GSM_HR_BYTES];
+extern const uint8_t osmo_gsm660_homing_frame[GSM_EFR_BYTES];

extern const struct value_string osmo_amr_type_names[];

diff --git a/src/codec/gsm620.c b/src/codec/gsm620.c
index 49ee724..a24d762 100644
--- a/src/codec/gsm620.c
+++ b/src/codec/gsm620.c
@@ -263,6 +263,37 @@
81, /* Code 3:7 */
};

+/*
+ * There is no officially defined silence frame for GSM-HR codec like there is
+ * for GSM-FR. However, if one feeds all-zeros (complete silence) linear PCM
+ * input to the official GSM-HR encoder, the result will be an endless stream
+ * of these frames:
+ *
+ * R0=00 LPC=164,171,cb Int=0 Mode=0
+ * s1=00,00,00 s2=00,00,00 s3=00,00,00 s4=00,00,00
+ *
+ * The following const datum is the above unofficial GSM-HR silence frame in
+ * the packed RTP format of TS 101 318.
+ */
+const uint8_t osmo_gsm620_silence_frame[GSM_HR_BYTES] = {
+ 0x01, 0x64, 0xB8, 0xE5, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/*
+ * GSM 06.20 defines, by reference to GSM 06.06 C code and GSM 06.07 test
+ * sequences, a special frame of codec parameters called the decoder homing
+ * frame (DHF). When a spec-compliant speech decoder processes this frame,
+ * it resets itself to the spec-defined home state.
+ *
+ * The following const datum is GSM-HR DHF in the packed RTP format of
+ * TS 101 318.
+ */
+const uint8_t osmo_gsm620_homing_frame[GSM_HR_BYTES] = {
+ 0x03, 0x71, 0xAF, 0x61, 0xC8, 0xF2, 0x80,
+ 0x25, 0x31, 0xC0, 0x00, 0x00, 0x00, 0x00
+};
+
/*! Check whether RTP frame contains HR SID code word according to
* TS 101 318 ยง5.2.2
* \param[in] rtp_payload Buffer with RTP payload
diff --git a/src/codec/gsm660.c b/src/codec/gsm660.c
index b15bdf3..fbb69c4 100644
--- a/src/codec/gsm660.c
+++ b/src/codec/gsm660.c
@@ -258,6 +258,21 @@
246, /* 259 -> PULSE 4_10: b0 */
};

+/*
+ * GSM 06.60 defines (in Table 7) a special frame of codec parameters called
+ * the decoder homing frame (DHF). When a spec-compliant speech decoder
+ * processes this frame, it resets itself to the spec-defined home state.
+ *
+ * The following const datum is GSM-EFR DHF in the packed RTP format of
+ * TS 101 318 or RFC 3551.
+ */
+const uint8_t osmo_gsm660_homing_frame[GSM_EFR_BYTES] = {
+ 0xC0, 0x85, 0xEB, 0x49, 0x0F, 0xAA, 0xD6, 0x03,
+ 0xE3, 0xA1, 0x86, 0x07, 0xB0, 0xC4, 0x2C, 0x08,
+ 0x04, 0x80, 0x55, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
static const uint8_t sid_code_word_bits[95] = {
/* bit numbers are relative to "pure" EFR frame beginning,
* not counting the signature bits. */

To view, visit change 39636. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2c510ac62a0786c137115c45eee7a48b9736265f
Gerrit-Change-Number: 39636
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon@freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <falcon@freecalypso.org>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>