Commit Graph

65 Commits

Author SHA1 Message Date
Vadim Yanitskiy 3f4c6a8fbe coding: fix wrong n_bits_total reported for PDTCH CS2 and CS3
In gsm0503_pdtch_decode(), we decode CS2 and CS3 as if no puncturing
was employed, reordering the coded bits and setting punctured ones
to 0 manually.  Because of that, osmo_conv_decode_ber_punctured()
reports n_bits_total higher than we actually receive over the air.

Change-Id: I6b20cc450f25c48175a61da02644d66c08e22ece
Related: OS#6342, OS#6200
2024-01-31 23:10:40 +07:00
Vadim Yanitskiy 6c4be02962 coding: fix artificial bit errors for PDTCH CS2 and CS3
GPRS coding schemes CS2 and CS3 (defined in 3GPP TS 45.003 sections
5.1.2 and 5.1.3, respectively) employ so-called puncturing, which
can be described as intentional removal of coded bits.  The goal
of puncturing is to reduce the number of coded bits, so that they
fit into 4 bursts.  The receiving side recovers punctured bits,
as if they were received corrupted.

The puncturing is also used for other channel types like TCH/F9.6,
TCH/F14.4, TCH/AFS and TCH/AHS, but only for CS2 and CS3 we're
doing puncturing/depuncturing *manually*.  This explains why
we're seeing artificial bit errors only for CS2 and CS3.

gsm0503_pdtch_decode() should not be reporting punctured bits as
bit errors, fix this by using osmo_conv_decode_ber_punctured().

Change-Id: I024276d167e769396187998d881f8e7626461249
Related: OS#6342, OS#6200
2024-01-31 23:10:40 +07:00
Vadim Yanitskiy 2a72d683d3 coding: improve readability in osmo_conv_decode_ber_punctured()
Change-Id: Iaece6d0fe42f173187baa5c87fcbe3cfc60c21fc
Related: OS#6342, OS#6200
2024-01-31 23:10:35 +07:00
Vadim Yanitskiy 97374514c5 coding: fix a typo in docs for gsm0503_pdtch_decode()
Change-Id: I72e7dab116229d908add3896ecb47b59e3001f1b
2024-01-31 21:44:50 +07:00
Vadim Yanitskiy c58e4851f4 coding: gsm0503_pdtch_decode(): implement USF decoding for CS1
This patch brings decoding of the CS1 in consistency with the other
three coding schemes, for which we support decoding USF independently.

Change-Id: I61a3628741c0ac68374fc7f077cf3a07e51277c3
2023-12-08 03:35:57 +07:00
Vadim Yanitskiy 93b8eb3153 coding: clarify the USF decoding for PDCH blocks
The USF (Uplink State Flag) field is present in the MAC header of all
Downlink PDCH blocks.  It is used by the network to indicate which MS
can transmit on subsequent Uplink PDCH block(s).  This field is of a
high importance for the MS, thus the decoder API allows the caller
to obtain USF value separately from the actual data bits.

In the case of gsm0503_pdtch_decode(), if the 'usf_p' pointer is not
NULL, the USF value would be assigned for CS2/CS3/CS4 (but not CS1)
even if the CRC check fails (negative return value).  A subsequent
patch is to bring the CS1 in consistency with CS2/CS3/CS4.

In the case of gsm0503_pdtch_egprs_decode(), decoding of the USF
field separately from data bits is not implemented, and moreover
the function itself cannot be used for decoding Downlink blocks.

Change-Id: I43e8bfb4003f34766ace7c5c6080ca583ce5efbb
2023-12-08 03:27:23 +07:00
Vadim Yanitskiy ccf9aadc96 coding: fix doxygen docs for gsm0503_pdtch[_egprs]_decode()
Change-Id: I09a4c52f5704a6436eff524cd2ce5c35347aafde
2023-12-08 01:11:40 +07:00
Andreas Eversberg ebdf3dcac7 coding: gsm0503_tch_{afs,ahs}_encode(): add ability to emit BFI
Similar to Change ID Iade3310e16b906efb6892d28f474a0d15204e861, add
BFI support to TCH AFS and TCH AHS encoder.

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/AHS where FACCH
displaces two speech frames rather than one. A more elegant solution
is to emit a speech frame with inverted CRC6, causing the MS receiver
to declare a BFI condition to trigger substitution and muting procedure.
Setting all u(k) bits to 0 is one way to produce such an inverted-CRC
speech frame (normal TCH FR/HR CRC6 for an all-zeros frame would be
111111). This patch adds the abiliy to gsm0503_tch_{afs,ahs}_encode()
functions, indicated by payload length of 0.

See §6.2 of 3GPP TS 26.191 for substitution and muting procedure.

Related: OS#6049
Change-Id: I82ce2adf995a4b42d1f378c5819f88d773b9104a
2023-11-27 16:27:32 +00:00
Vadim Yanitskiy d739e257bb coding: gsm0503_tch_a[fh]s_encode(): make *codec const
Change-Id: I9e37a47c080cf57005e0205aa0d3cd25755a75f0
2023-11-14 11:57:19 +00:00
Vadim Yanitskiy a995269c6d coding: gsm0503_tch_a[fh]s_encode(): improve cmr/ft checks
Change-Id: If03d5b015ab1c8db56a4c67bdc8e36e260c06562
2023-11-14 11:57:19 +00:00
Vadim Yanitskiy fadda01f44 coding: implement encoding/decoding API for TCH/F2.4
See 3GPP TS 45.003 section 3.6.  This channel mode is a bit special,
because unlike the other CSD specific channel modes it's interleaved
over 8 (not 22!) consecutive bursts, just like TCH/FS.

Change-Id: I4685376c8deb04db670684c9ebf685ad6fc989fa
Related: OS#1572
2023-07-08 06:42:09 +07:00
Vadim Yanitskiy f8e570a20f coding: remove redundant memset()s in gsm0503_tch_fr{96,144}_encode()
Convolutional codes terminated with CONV_TERM_FLUSH (the default)
always append k-1 zeroes at the end to "flush" the encoder state.
This is the case for both TCH/F9.6 and TCH/F14.4.

Change-Id: I4a77ecb9af72b2fd4ea92c42d6748879e73d2cf2
Related: OS#1572
2023-07-08 06:05:13 +07:00
Sylvain Munaut c87c6a3a73 gsm: Improve the TCH/H2.4 coding routines
The spec isn't super clear, but basically the conv coding is done
in two blocks of 72 bits.

The way it's currently implemented isn't "wrong" in the sense it will
produce correct output given no bit errors, but it's better to do the
decoding in two blocks because this then it makes use of the fact we
know the state of the encoder after the 72 bits, which improves the
corrective ability of the code.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id2551ffe2a0ebfd0a6df0e1d288a6f0af7e1eda7
2023-07-07 16:06:26 +02:00
Vadim Yanitskiy 7d121cbaed coding: fix a copy-paste bug in gsm0503_tch_afs_decode_dtx()
According to 3GPP TS 45.003, section 3.9.2, the convolutional coding
is *not* employed in the case of SID_FIRST.  This is why we're using
sid_first_dummy[] in this function.

The conv[] array is not initialized in the case of AFS_SID_FIRST and
passing it to tch_amr_reassemble() is highly likely a copy-paste bug.
Pass the sid_first_dummy[] instead.

Change-Id: Ic8bfc34ce9d14821fe4e82932325f0c517d443a1
Fixes: CID#272949 "Uninitialized scalar variable"
2023-06-23 16:57:52 +07:00
Mychaela N. Falconia 6e529a2c74 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
2023-05-27 11:06:57 +00:00
Mychaela N. Falconia 945f6cec0f coding cosmetic: gsm0503_tch_{fr,hr}_encode(): remove extra spacing
These two functions are structured as switch statements handling
different types of input, but they also have a lot of empty spacing
lines in strange places, making them difficult to read and even more
difficult to add new functionality while maintaining the same style.
Remove those extra spaces.

Change-Id: I595a80898283d0932fb33f582347ec39a9481d1a
2023-05-27 00:41:33 +00:00
Vadim Yanitskiy b04d59e997 coding: fix _tch_csd_burst_map(): do not overwrite FACCH
As was demonstrated in the unit test [1], FACCH bitstealing does not
work as expected in conjunction CSD specific encoding functions.

The problem is in _tch_csd_burst_map(): we don't check the stealing
flags hu(B) and hl(B) and overwrite both odd and even numbered bits
unconditionally.  Even worse, we reset these stealing flags to 0.

* Do not overwrite the hu(B) and hl(B) flags.
* Copy *even* numbered bits only if hu(B) is not set.
* Copy *odd* numbered bits only if hl(B) is not set.

Change-Id: Ib5395c70e3e725469c18ff7d4c47c62ddfdbd55d
Related: [1] Idc6decec3b84981d2aab4e27caab9ad65180f945
Related: OS#1572
2023-05-26 02:48:21 +07:00
Vadim Yanitskiy b334022aba coding: implement dedicated codec API for FACCH/[FH]
Currently FACCH/[FH] encoding and decoding is implemented as part of
the gsm0503_tch_[fh]r_{en,de}code and gsm0503_tch_a[fh]s_{en,de}code
API.  This works fine for speech because one FACCH frame completely
replaces one or two speech frames, but this is not the case for CSD.

According to 3GPP TS 45.002, sections 4.2.5 and 4.3.5, for TCH data
channels FACCH does not replace data frames but disturbs some amount
of bits from them.  Therefore we need to be able to perform FACCH
encoding and decoding independently from CSD specific coding API.

Change-Id: I0c7a9c180dcafe64e6aebe53518d3d11e1f29886
Related: OS#1572
2023-05-26 02:35:11 +07:00
Vadim Yanitskiy 9a22827cf6 coding: implement TCH/F9.6, TCH/[FH]4.8, TCH/H2.4, TCH/F14.4
Implement all CSD specific channel modes, except TCH/F2.4.  All of
these modes are more or less similar to each other.  The TCH/F2.4
is more similar to TCH/FS and slightly more complicated.

FACCH/F and FACCH/H will be implemented in a follow-up change.

Change-Id: Ib482817b5f6a4e3c7299f6e0b3841143b60fc93d
Related: OS#1572
2023-05-25 19:08:53 +07:00
Vadim Yanitskiy 8fb56473aa coding: fix API doc: TCH/AFS vs TCH/AHS
Change-Id: Iaed1653c6001545f69ec6b466760f30d42bc4386
2023-05-23 19:16:39 +00:00
Vadim Yanitskiy 98431bb3f4 coding: fix API doc: TCH/H needs 6 bursts, not 8
Change-Id: Iea787ec4c3b15a74f59d45825eae03740c5d28fa
2023-05-23 19:16:39 +00:00
Mychaela N. Falconia 57a3b3a51f gsm0503_tch_hr_decode2(): new function, emits TS101318 format
The original design of gsm0503_tch_hr_{en,de}code() functions contains
a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame
input and output, instead of "pure" (agnostic to outer RTP encoding)
form of 14 bytes.  We would like to change this design so that we can
feed pure 14-byte HR codec frames to the channel coding function and
get such frames back from the channel decoding function - however,
we cannot break libosmocoding API for existing users.  In the decoding
direction, create a new function that emits TS 101 318 format, and
turn the legacy gsm0503_tch_hr_decode() API into a wrapper function
for backward compatibility.

Related: OS#5688
Change-Id: If28ddb20789e8993b7558ca08020478615b4c708
2023-05-23 16:42:01 +00:00
Mychaela N. Falconia 8d8d5af957 gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads
The original design of gsm0503_tch_hr_{en,de}code() functions contains
a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame
input and output, instead of "pure" (agnostic to outer RTP encoding)
form of 14 bytes.  We would like to change this design so that we can
feed pure 14-byte HR codec frames to the channel coding function and
get such frames back from the channel decoding function - however,
we cannot break libosmocoding API for existing users.  In the encoding
direction, make the new format our preferred one, but support the
extra-octet format for backward compatibility.

Related: OS#5688
Change-Id: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f
2023-05-23 16:41:05 +00:00
Mychaela N. Falconia 920c0ed86f gsm0503_tch_hr_decode(): look at all 8 stealing bits
This function needs to look at hl and hu stealing bits in order to
decide if it should decode FACCH/H instead of TCH/HS traffic.
However, out of the 8 (in total) hl and hu bits that get set when
FACCH/H stealing takes place, the function only looked at 7 of them
- one was missed.  Fix this bug.

Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9
2023-05-23 14:06:53 +00:00
Vadim Yanitskiy c0305b685a coding: use GSM_MACBLOCK_LEN gsm0503_tch_fr_decode()
Change-Id: I488ca3db1ca093d19abcfba78c1516509870715d
Related: OS#1572
2023-05-20 19:05:41 +07:00
Mychaela N. Falconia f3e4745603 coding: fix decoding of EFR triplicated bits
In GSM 05.03 channel coding for EFR, there are 4 bits out of the
244-bit EFR codec frame that are triplicated before FR-like encoding,
and the decoder needs to apply a 2-out-of-3 majority voting function
to each of these triplicated bits after the FR-like decoding step.
For one of those 4 bits, this majority voting function was wrong
in the decoder implemented in gsm0503_tch_fr_decode() - fix it.

Change-Id: I47def75cdb066ed6372df4567404cc828589ed53
2023-05-19 08:44:35 +00:00
Vadim Yanitskiy fed02e01d9 coding: fix doxygen doc for _xcch_encode_cB()
Change-Id: I09ed28bd3060b9c2c958f0f465a92af7d6bacadd
2023-05-15 16:50:08 +00:00
Pau Espin 0158b05337 Move libosmogsm TS 44.060 declarations under include/osmocom/gsm/
Currently there's a big mess where include dir osmocom/gprs/ is used by
both libosmogsm and libosmogb.
Most of the header files under osmocom/gprs/ are actually all the
headers of libosmogb (there's no osmocom/gb/ dir). But a couple files
are actually RLC/MAC (TS 44.060) related are are also stored in there.
Those files have no relation/use in Gb, and are actually interused with
GSM (eg System Information 13 Rest Octets).
Hence, it makes sense to have the RLC/MAC related parts inside
osmocom/gsm/ as they should be in libosmogsm (and they actually are,
see gprs_rlc.h function implemented in src/gsm/gsm48_rest_octets.c).

The fact that some libosmogsm headers were placed in osmocom/gprs
instead of osmocom/gsm already created some issues, like
libosmocore.spec.in putting "%_includedir/%name/osmocom/gprs/" under
libosmogb, which is wrong.

As a first step to fix the mess, we move the 2 RLC/MAC headers currently
under osmocom/gprs/{gprs_rlc,protocol/gsm_04_60}.h under a single header
gsm/protocol/gsm_44_060.h
The two old headers are left existing for backward compatibility and now
simply include the new libosmogsm header, plus a warning asking users to
switch to the new header so we can eventually get rid of them.
This means libosmogb depends on libosmogsm, which is fine and was
already the case beforehand (libosmogb using functions like
gsm48_encode_ra() and linking against it in src/gb/Makefile.am).

Change-Id: I70cc21bf25a7081070738abacb409ed19094c3b2
2023-02-20 12:21:30 +01:00
Vadim Yanitskiy b57e6392fb coding: separate gsm0503_tch_a[fh]s_decode_inband()
These functions can be re-used for parsing in-band data from DTX
specific frames like SID_FIRST, SID_UPDATE, SID_ONSET, etc.

Change-Id: I0106de7a7f87517006e323299b2dc08457d1c6cf
Related: OS#5570
2022-05-27 08:31:30 +00:00
Vadim Yanitskiy cc4213e927 coding: add gsm0503_detect_a[fh]s_dtx_frame2()
The new functions accept an additional mode_id poiner, which is
currently set for the following frames: AFS_ONSET, AHS_ONSET,
AHS_SID_FIRST_P2 with N * 16 - M bit pattern.

Also, the new API accepts soft-bits instead of hard-bits.
Converting bits from soft to hard is now performed internally.

Change-Id: Ibcac395f800bb64150c97fcdaca3523ecfc5fcee
Related: OS#5570
2022-05-27 08:31:30 +00:00
Vadim Yanitskiy d6dca0c2f9 coding: do not reset codec ID on receipt of DTX frames
Parsing of CMI/CMC/CMR from AMR's special DTX frames is currently
not implemented.  It's better to keep the old stored value rather
than resetting it to 0 every time we receive such a frame.
Add TODO comments for each DTX frame type.

Change-Id: Ic4edbb8ab873fe0bdd69a8710803628bc4f447d0
Related: OS#5570
2022-05-25 13:34:31 +00:00
Vadim Yanitskiy 7790459c8e coding: fix decoding of AHS_SID_UPDATE frames (BER ~50%)
As was demonstrated in [1], there is a TCH/AHS specific problem in
libosmocoding causing unexpected BER ~50% in decoded AHS_SID_UPDATE
frames.  The reason is that A[H]S_SID_UPDATE employs quite tricky
interleaving algorithm, which is different from the algorithm used
by normal TCH/AHS speech frames or A[F]S_SID_UPDATE frames.

An AHS_SID_UPDATE frame consists of two halves (228 bits each):

  +---------+--------------------|---------+--------------------+
  | in-band |     SID marker     | in-band |     coded data     |
  +---------+--------------------|---------+--------------------+
  | 16 bits |      212 bits      | 16 bits |      212 bits      |

The first half contains coded in-band signalling data (16 bits) and
the identification marker (212 bits), which allows to detect that
it's an AHS_SID_UPDATE.  This half is carried by even bits of the
first two bursts and odd bits of the last two bursts.

The other half also contains the in-band data (16 bits), while the
remaining 212 bits contain encoded SID_UPDATE (212 bits).  This
half is carried by even bits of the last two bursts and odd bits
of the first two bursts.

Current implementation does not use odd bits of the first two
bursts at all, so buffer cB[] in gsm0503_tch_ahs_decode_dtx()
contains only 114 out of 228 bits.

This patch changes the logic, so that gsm0503_tch_ahs_decode_dtx()
would not split AHS_SID_UPDATE onto two frames anymore like its
TCH/AFS equivalent does, but attempt to deinterleave the second
half and attempt to decode the payload immediately.

Change-Id: I8686d895e96fa0e606c1898b6574cc80a8f46983
Related: [1] I434157e2091a306c039123cea08d84bd8533c937
Related: SYS#5853
2022-05-25 13:34:31 +00:00
Vadim Yanitskiy a2bee8bc88 coding: prevent marking FACCH frames as AMR's special DTX frames
Both gsm0503_tch_a[fh]s_decode_dtx() functions accept an optional
'dtx' pointer, which is used to indicate type of a received AMR
block to the caller in DTX mode of operation.  If not NULL, it's
expected to be updated by gsm0503_detect_a[fh]s_dtx_frame() every
time one of the mentioned functions is called.

However, in case of FACCH both functions return early, so the value
of dtx remains unchanged and thus FACCH frames may be misinterpreted
as AMR's special DTX frames.  This is rather critical during the DTX
silence periods, when all special DTX frames (e.g. SID_UPDATE) are
being treated as SUB frames.  Each unsuccessful FACCH decoding
attempt will 'poison' SUB measurements, causing unexpected RxQual-
SUB values in the Uplink measurement reports.

Fix this by resetting *dtx to AMR_OTHER in the FACCH specific path.

Change-Id: I2e6f4b748c6445725211e264ab5f3f5a2712087a
Related: SYS#5853
2022-05-16 20:13:13 +03:00
Vadim Yanitskiy 71e8091c9d coding: properly handle AFS_SID_UPDATE frames in DTX mode
There are two similar values in enum gsm0503_amr_dtx_frames:

  * AFS_SID_UPDATE - precursor of SID UPDATE,
  * AFS_SID_UPDATE_CN - the actual SID UPDATE.

The former is internally used by libosmocoding to mark the current
frame as a precursor of the actual SID UPDATE frame - the later.

  +---+---+---+---+---+---+---+---+
  | _ | _ | _ | _ | a | b | c | d |  AFS_SID_UPDATE
  +---+---+---+---+---+---+---+---+
  | a | b | c | d | _ | _ | _ | _ |  AFS_SID_UPDATE_CN
  +---+---+---+---+---+---+---+---+

This is required because function gsm0503_tch_afs_decode_dtx() is
invoked by TDMA scheduler on every 4th received burst, while the
burst buffer is 8 bursts wide.

Currently, whenever gsm0503_detect_afs_dtx_frame() detects an
AFS_SID_UPDATE frame, we still attempt to decode it as a speech
or data below in gsm0503_tch_afs_decode_dtx().  This is indeed
a bug, which results in unexpected BER values:

  * expected BER 0/212,
  * actual BER 252/448.

We should return immediately once we have detected an AFS_SID_UPDATE.
This patch fixes unexpected BER-SUB values during DTXu silence periods.

Change-Id: I813081a4c0865958eee2496fe251ae17235ac842
Related: SYS#5853
2022-05-16 00:51:57 +03:00
Vadim Yanitskiy eebaccdae5 coding: use switch statement in gsm0503_tch_a[fh]s_decode_dtx()
Change-Id: Ib63b6f582b305746c3618563f2f85128fffd8e90
Related: SYS#5853
2022-05-16 00:51:57 +03:00
Vadim Yanitskiy bf2d5e9b6f coding: cosmetic: move 'dtx_prev' to the scope where it's used
Change-Id: I147f44f1c071e53febeff425a0a7837a0ff10436
Related: SYS#5853
2022-05-16 00:51:30 +03:00
Pau Espin 6c58d155eb coding: Use ARRAY_SIZE macro
Change-Id: I6b7a2a3a7be6a1d92038ff3b249e539fcd0f639e
2022-05-13 14:09:43 +02:00
Pau Espin d2737e6027 coding: Refactor function to avoid gcc false positive warn
"""
/libosmocore/src/coding/gsm0503_coding.c: In function 'osmo_conv_decode_ber_punctured':
/libosmocore/src/coding/gsm0503_coding.c:563:31: error: 'coded_len' may be used uninitialized [-Werror=maybe-uninitialized]
  563 |                 *n_bits_total = coded_len;
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~~
/libosmocore/src/coding/gsm0503_coding.c:541:21: note: 'coded_len' was declared here
  541 |         int res, i, coded_len;
      |                     ^~~~~~~~~
"""

This error is really a false positive. However, it is true that the code
used to be a bit more complex than required, since the 2 later conditions
could be inside the first one.
Let's simply do early termination to simplify the function, and get rid
of the gcc warning.

Change-Id: I31ebf0c4be61daf6395d9a9fac05c7fdceb8bcb9
2022-05-13 13:07:23 +02:00
Oliver Smith 04bfb7165b treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I5050285e75cf120407a1d883e99b3c4bcae8ffd7
2021-12-14 12:44:03 +01:00
Philipp Maier cfea39ba13 gsm0503_coding: use ahs tables when encoding ahs codec id
The encoder function gsm0503_tch_ahs_encode uses gsm0503_afs_ic_ubit
when encoding the CMR or FT (depends on the frame number). This is not
correct. It should use gsm0503_ahs_ic_ubit instead.

Change-Id: Id250b2102ac79ff222bd3ad9d1abc4b60abdd12b
Related: SYS#5549
2021-08-31 16:05:20 +02:00
Philipp Maier 898c9c6af8 dtx: add decoding for AMR-DTX frames
gsm0503_coding contains AMR decoder functions for HR and FR. Those can
only decode AMR payload frames but not amr DTX frames. Lets add
functionality to detect DTX frames. Also lets add decoding for SID_UPDATE
frames as well as error checking for the SID frame recognition patterns.

Related: OS#2978
Change-Id: I2bbdb39ea20461ca08b2e6f1a33532cb55cd5195
2020-04-14 13:22:44 +00:00
Pau Espin 63ebc368af gsm0503_coding: Fix USF encoding in MCS1-4
osmo-gsm-tester raised an ASan warning in osmo-bts-trx  during execution
of a test with EGPRS enabled and a modem connecting to it (see OS#4483
for full trace):
==12388==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7fa20b9ab8d0 at pc 0x7fa20b982894 bp 0x7ffdfea8b9c0 sp 0x7ffdfea8b9b8
READ of size 1 at 0x7fa20b9ab8d0 thread T0
 #0 0x7fa20b982893 in gsm0503_mcs1_dl_interleave /home/osmocom-build/jenkins/workspace/osmo-gsm-tester_build-osmo-bts/libosmocore/src/coding/gsm0503_interleaving.c:165

Function gsm0503_mcs1_dl_interleave() was being passed the 6-bit USF
encoding while clrearly expecting a 12 element array. TS 05.03 5.1.5.1.2
"USF precoding" also clearly states that 12bit encoding is to be used
for MCS1-4.

Fixes: OS#4483
Change-Id: I94db14de770070b17894a9071aa14391d26e776c
2020-04-07 13:15:38 +02:00
Pau Espin f62f073c79 gsm0503_coding: Fix misleading comment UL vs DL
Change-Id: I563c60271e218f9953e26f9bf0304d442c6acd43
2020-04-07 13:12:21 +02:00
Vadim Yanitskiy 9e713f3828 coding: fix bit ordering in 11-bit RACH coding functions
According to 3GPP TS 44.004, figure 7.4a.b, the format of 11-bit
RACH uplink / Uplink access burst block is as defined follows:

  <---------------------------------------------------

      8     7     6     5     4     3     2     1
  +--------------------------------------------------+
  |  11 bit RACH uplink / Uplink access burst block  | OCT1
  +--------------------------------------------------+
                                 |                   | OCT2
                                 +-------------------+

As was (correctly) assumed in [1], the bit ordering in 11-bit RACH
coding functions is wrong. The problem is that neither of generic
functions from bit16gen.h can be used to load / store the RA11
value (regardless of the endianness), because they assume that
the payload is 16 bit long.

With this patch applied, RA11 values from [1] look correct:

  < EGPRS Packet channel request message content > ::=
    < Signalling : 110011  < RandomBits : 00111 > > |
    < Signalling : 110011  < RandomBits : 00110 > > |
    < Signalling : 110011  < RandomBits : 01111 > > |
    < Signalling : 110011  < RandomBits : 01100 > > |
    < Signalling : 110011  < RandomBits : 00111 > > |
    < Signalling : 110011  < RandomBits : 10110 > > ;

[1] Id80e471d252b9416217b56f4c8c0a8f5f1289fee

Change-Id: I43d30611dd69f77f2b3b46f4b56056a8891d3c24
Related: OS#1548
2020-04-01 01:09:31 +07:00
Vadim Yanitskiy 8055cddbe2 coding: fix documentation of PDTCH encoding functions
Change-Id: Ia38723fb9424551eaf5747d736ae73ab20873def
2020-03-31 15:37:27 +07:00
Alexander Chemeris 50f7d74fca coding: Always initialize bit counters in gsm0503_pdtch_egprs_decode().
Previsouly there were a lot of valid code paths which returned from the function
before setting bit counters which led to bogus BER output in osmo-bts-trx logs
when those code paths were hit.

Change-Id: I4722cae3794ccbb12001113c991d9cf345a52a96
2018-09-05 16:08:34 +03:00
Alexander Chemeris 9444326158 coding: Correctly count bits when decoding EDGE bursts with MCS >= 7.
They consist of two blocks, so we should count both blocks.

Change-Id: I560de192212dae4705054a1665726369b83d213a
2018-09-05 16:08:16 +03:00
Pau Espin f81d03f7dd libosmocoding: clarify return values for TCH decoding functions
Change-Id: I7d6c61e6a1b5d1fae26f385b420ff55246c4b62f
2018-07-19 18:30:07 +02:00
Alexander Chemeris ed7d2ddb15 coding: Documentation typo fix.
Change-Id: I6ca873b3decaf50e7b79b5ab2269919c862a4fe0
2018-07-14 21:12:47 +02:00
Alexander Chemeris 147051f1a1 coding: Fix (E)GPRS BER calculation to correctly account for puncturing.
Previously we didn't take into account puncturing and BER was always around
30% for GPRS/EDGE bursts because of they use puncturing coding unlike
"classical" GSM bursts.

Change-Id: I9da22e7051522d06d923fcec3b63cbed8db93910
2018-07-14 21:12:46 +02:00