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
This commit is contained in:
Vadim Yanitskiy 2022-03-17 17:51:35 +03:00 committed by fixeria
parent 12b3921a4a
commit 5a8413166f
3 changed files with 20 additions and 12 deletions

View File

@ -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

View File

@ -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;

View File

@ -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. */