fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/27557 )

Change subject: osmo-bts-trx: rx_{tchh,tchf}_fn(): use AMR CMI lookup tables
......................................................................

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
---
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
M src/osmo-bts-trx/sched_utils.h
3 files changed, 20 insertions(+), 12 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c 
b/src/osmo-bts-trx/sched_lchan_tchf.c
index c8ad383..6a9a0f0 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -131,8 +131,7 @@
                 * 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 1778d36..369e35b 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -165,16 +165,7 @@
                        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 f76e49b..398083d 100644
--- a/src/osmo-bts-trx/sched_utils.h
+++ b/src/osmo-bts-trx/sched_utils.h
@@ -37,6 +37,24 @@
                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. */

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27557
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I46def864729c8f9063af201750456771ea5558d5
Gerrit-Change-Number: 27557
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to