[PATCH] osmo-bts[master]: osmo-bts-trx: perform error concealment for FR frames

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Tue Jan 9 13:34:49 UTC 2018


Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5214

to look at the new patch set (#8).

osmo-bts-trx: perform error concealment for FR frames

When a bad voice frame is received, it is replaced by
a silence frame. This may cause unpleasant audio effects.

This change implements a functionality to craft a replacement
frame from the last known good frame using ECU implementation
from libosmocodec. At the moment, only FR is supported.

Depends-On: I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
---
M include/osmo-bts/gsm_data_shared.h
M src/osmo-bts-trx/scheduler_trx.c
2 files changed, 20 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/14/5214/8

diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h
index 31198fc..4ca6d64 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -5,6 +5,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 
+#include <osmocom/codec/ecu.h>
 #include <osmocom/core/timer.h>
 #include <osmocom/core/bitvec.h>
 #include <osmocom/core/statistics.h>
@@ -345,6 +346,9 @@
 	} ms_power_ctrl;
 
 	struct msgb *pending_rel_ind_msg;
+
+	/* ECU (Error Correction Unit) state */
+	struct osmo_ecu_state ecu_fr_state;
 };
 
 enum {
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index d3928f1..0e9f342 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -31,6 +31,7 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/talloc.h>
 #include <osmocom/codec/codec.h>
+#include <osmocom/codec/ecu.h>
 #include <osmocom/core/bits.h>
 #include <osmocom/gsm/a5.h>
 #include <osmocom/coding/gsm0503_coding.h>
@@ -968,6 +969,7 @@
 	uint8_t tch_data[128]; /* just to be safe */
 	int rc, amr = 0;
 	int n_errors, n_bits_total;
+	bool bfi_flag = false;
 	struct gsm_lchan *lchan =
 		get_lchan_by_chan_nr(l1t->trx, trx_chan_desc[chan].chan_nr | tn);
 
@@ -1058,11 +1060,13 @@
 	if (rc < 0) {
 		LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Received bad data (%u/%u)\n",
 			fn % l1ts->mf_period, l1ts->mf_period);
+		bfi_flag = true;
 		goto bfi;
 	}
 	if (rc < 4) {
 		LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Received bad data (%u/%u) "
 			"with invalid codec mode %d\n", fn % l1ts->mf_period, l1ts->mf_period, rc);
+		bfi_flag = true;
 		goto bfi;
 	}
 
@@ -1079,8 +1083,14 @@
 			case GSM48_CMODE_SPEECH_V1: /* FR */
 				if (lchan->tch.dtx.ul_sid)
 					return 0; /* DTXu: pause in progress */
-				memset(tch_data, 0, GSM_FR_BYTES);
-				tch_data[0] = 0xd0;
+
+				/* Perform error correction if possible */
+				rc = osmo_ecu_fr_conceal(&lchan->ecu_fr_state, tch_data);
+				if (rc) {
+					memset(tch_data, 0, GSM_FR_BYTES);
+					tch_data[0] = 0xd0;
+				}
+
 				rc = GSM_FR_BYTES;
 				break;
 			case GSM48_CMODE_SPEECH_EFR: /* EFR */
@@ -1108,6 +1118,10 @@
 	if (rsl_cmode != RSL_CMOD_SPD_SPEECH)
 		return 0;
 
+	/* Reset ECU with a good frame */
+	if (!bfi_flag && tch_mode == GSM48_CMODE_SPEECH_V1)
+		osmo_ecu_fr_reset(&lchan->ecu_fr_state, tch_data);
+
 	/* TCH or BFI */
 	return _sched_compose_tch_ind(l1t, tn, (fn + GSM_HYPERFRAME - 7) % GSM_HYPERFRAME, chan,
 		tch_data, rc);

-- 
To view, visit https://gerrit.osmocom.org/5214
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 8
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list