forked from acouzens/open5gs
[NAS] Improve algorithm for conversion of bitrate to NAS
The improved algorithm better handles some odd bitrates. With the current version, the bitrates 63 Kbps and 65 Kbps would get converted into 48 Kbps (unit 16 Kbps x 3) and 64 Kbps (unit 64 Kbps x 1). Especially in the first case, the conversion error is quite signicant. Current version tries to find the biggest 'unit', while the 'value' is still above 0. With the updated version, the algorithm tries to find the 'unit' low enough, that the resulting 'value' can still fit into the 16-bit space without overflow.
This commit is contained in:
parent
bbc397013b
commit
22cca3eb48
|
@ -436,7 +436,7 @@ void ogs_nas_bitrate_from_uint64(ogs_nas_bitrate_t *nas, uint64_t bitrate)
|
|||
|
||||
for (nas->unit = OGS_NAS_BR_UNIT_1K;
|
||||
nas->unit < OGS_NAS_BR_UNIT_256P; nas->unit++) {
|
||||
if ((bitrate >> 2) == 0) {
|
||||
if (bitrate <= 0xFFFFUL) {
|
||||
break;
|
||||
}
|
||||
bitrate >>= 2;
|
||||
|
|
Loading…
Reference in New Issue