aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-03-17 17:51:35 +0300
committerfixeria <vyanitskiy@sysmocom.de>2022-04-05 13:45:31 +0000
commit5a8413166f61046f15e8356ed069effee33d72f3 (patch)
tree640a0725b3086c4e5fc8da6bcb554c100e532257
parent12b3921a4acb30b847acc5f7e61d031f1b2ab571 (diff)
osmo-bts-trx: rx_{tchh,tchf}_fn(): use AMR CMI lookup tables
3GPP TS 45.009 defines that Codec Mode Indications shall be sent with speech frames having specific TDMA frame numbers of their *first* bursts, which are defined in tables 3.2.1.3-{1,2,3,4}. Performance-wise it's batter to have these tables implemented as arrays, rather then using the 'switch' statement. We can simplify things even further and have TDMA frame numbers corresponding to the *last* bursts in them. This eliminates the need of doing an additional last-to-first mapping, so that bi->fn can be used. Change-Id: I46def864729c8f9063af201750456771ea5558d5
-rw-r--r--src/osmo-bts-trx/sched_lchan_tchf.c3
-rw-r--r--src/osmo-bts-trx/sched_lchan_tchh.c11
-rw-r--r--src/osmo-bts-trx/sched_utils.h18
3 files changed, 20 insertions, 12 deletions
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index c8ad383d..6a9a0f0f 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -131,8 +131,7 @@ int rx_tchf_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
* the first FN 4,13,21 defines that CMR is included in frame.
* NOTE: A frame ends 7 FN after start.
*/
- fn_begin = trx_sched_lookup_fn(chan_state, 8);
- amr_is_cmr = !ul_amr_fn_is_cmi(fn_begin);
+ amr_is_cmr = !sched_tchf_ul_amr_cmi_map[bi->fn % 26];
/* The AFS_ONSET frame itself does not result into an RTP frame
* since it only contains a recognition pattern that marks the
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 1778d369..369e35b2 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -165,16 +165,7 @@ int rx_tchh_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
break;
}
- /* Calculate the frame number where the block begins. Note that
- * we need to traverse the measurement histort back by 6 bursts,
- * not by 4 bursts. The reason for this is that the burst shift
- * buffer we use for decoding is 6 bursts wide (one SACCH block) but
- * TCH/H blocks are only 4 bursts wide. The decoder functions look
- * at the beginning of the buffer while we shift into it at the end,
- * this means that TCH/H blocks always decoded delayed by two frame
- * number positions late. */
- fn_begin = trx_sched_lookup_fn(chan_state, 6);
- fn_is_cmi = ul_amr_fn_is_cmi(fn_begin);
+ fn_is_cmi = sched_tchh_ul_amr_cmi_map[bi->fn % 26];
/* See comment in function rx_tchf_fn() */
amr = 2;
diff --git a/src/osmo-bts-trx/sched_utils.h b/src/osmo-bts-trx/sched_utils.h
index f76e49bb..398083d9 100644
--- a/src/osmo-bts-trx/sched_utils.h
+++ b/src/osmo-bts-trx/sched_utils.h
@@ -37,6 +37,24 @@ static inline uint16_t compute_ber10k(int n_bits_total, int n_errors)
return 10000 * n_errors / n_bits_total;
}
+/* 3GPP TS 45.009, table 3.2.1.3-{1,3}: AMR on Uplink TCH/F */
+static const uint8_t sched_tchf_ul_amr_cmi_map[26] = {
+ [7] = 1, /* TCH/F: first=0 / last=7 */
+ [16] = 1, /* TCH/F: first=8 / last=16 */
+ [24] = 1, /* TCH/F: first=17 / last=24 */
+};
+
+/* 3GPP TS 45.009, table 3.2.1.3-{2,4}: AMR on Uplink TCH/H */
+static const uint8_t sched_tchh_ul_amr_cmi_map[26] = {
+ [6] = 1, /* TCH/H(0): first=0 / last=6 */
+ [15] = 1, /* TCH/H(0): first=8 / last=15 */
+ [23] = 1, /* TCH/H(0): first=17 / last=23 */
+
+ [7] = 1, /* TCH/H(1): first=1 / last=7 */
+ [16] = 1, /* TCH/H(1): first=9 / last=16 */
+ [24] = 1, /* TCH/H(1): first=18 / last=24 */
+};
+
/*! determine whether an uplink AMR block is CMI according to 3GPP TS 45.009.
* \param[in] fn_begin frame number of the beginning of the block.
* \returns true in case of CMI; false otherwise. */