coding: gsm0503_tch_{fr,hr}_encode(): add ability to emit BFI

Every BTS needs to have some graceful handling for the scenario
where it is time to send out a speech frame on TCH DL, but there is
no frame to be sent.  One possible solution is to transmit dummy
FACCH, but this option is unattractive for TCH/HS where FACCH
displaces two speech frames rather than one.  A more elegant
solution is to emit a speech frame with inverted CRC3, causing
the MS receiver to declare a BFI condition to its Rx DTX handler.
Setting all u(k) bits to 0 is one way to produce such an inverted-CRC
speech frame (normal TCH FR/HR CRC3 for an all-zeros frame would be
111), and this method is in fact what sysmoBTS PHY is observed to do.
Add the same ability to gsm0503_tch_{fr,hr}_encode() functions,
indicated by payload length of 0.

Change-Id: Iade3310e16b906efb6892d28f474a0d15204e861
This commit is contained in:
Mychaela N. Falconia 2023-05-27 11:06:57 +00:00
parent 18e5af55be
commit 6e529a2c74
1 changed files with 21 additions and 1 deletions

View File

@ -1941,6 +1941,20 @@ coding_efr_fr:
osmo_conv_encode(&gsm0503_tch_fr, conv, cB);
h = 0;
break;
case 0: /* no data, induce BFI in the receiver */
/* Do the same thing that sysmoBTS PHY does when fed a 0-length
* payload for DL: set all u(k) bits to 0, and do the same
* with all class 2 bits. This operation is NOT the same as
* an FR codec frame of all zero bits: with all-zeros d(k) input
* the CRC3 function will produce 111 output, whereas we
* transmit 000 in those parity bits too. The result will be
* an induced BFI (bad frame indication) condition in the
* receiver, for both TCH/FS and TCH/EFS decoders. */
memset(conv, 0, sizeof(conv));
memset(cB + 378, 0, 78);
osmo_conv_encode(&gsm0503_tch_fr, conv, cB);
h = 0;
break;
case GSM_MACBLOCK_LEN: /* FACCH */
_xcch_encode_cB(cB, tch_data);
h = 1;
@ -2084,8 +2098,9 @@ int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len)
tch_hr_b_to_d(d, b);
osmo_crc8gen_set_bits(&gsm0503_tch_fr_crc3, d + 73, 22, p);
tch_hr_reorder(conv, d, p);
osmo_conv_encode(&gsm0503_tch_hr, conv, cB);
memcpy(cB + 211, d + 95, 17);
hr_conv_coding:
osmo_conv_encode(&gsm0503_tch_hr, conv, cB);
h = 0;
gsm0503_tch_hr_interleave(cB, iB);
for (i = 0; i < 4; i++) {
@ -2093,6 +2108,11 @@ int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len)
&bursts[i * 116], &h, i >> 1);
}
break;
case 0: /* no data, induce BFI in the receiver */
/* see comments in gsm0503_tch_fr_encode() - same deal here */
memset(conv, 0, sizeof(conv));
memset(cB + 211, 0, 17);
goto hr_conv_coding;
case GSM_MACBLOCK_LEN: /* FACCH */
_xcch_encode_cB(cB, tch_data);
h = 1;