浏览代码

Fix REMB bitrate calculation formula

The getBitrate() function was using pow(exp, 2) which calculates exp^2
instead of pow(2, exp) which calculates 2^exp as specified in the REMB RFC.

According to draft-alvestrand-rmcat-remb-03, the bitrate should be calculated as:
  bitrate = mantissa * 2^exp

This fix changes the formula from (mantissa * exp^2) to (mantissa * 2^exp),
which will produce correct bandwidth estimates instead of values that are
often 100-1000x too high.

Fixes incorrect REMB bandwidth estimation introduced in commit f6c8073a.
[email protected] 4 周之前
父节点
当前提交
ca9c23aaf7
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/rtp.cpp

+ 1 - 1
src/rtp.cpp

@@ -588,7 +588,7 @@ unsigned int RtcpRemb::getNumSSRC() { return ntohl(_bitrate) >> 24u; }
 unsigned int RtcpRemb::getBitrate() {
 	uint32_t br = ntohl(_bitrate);
 	uint8_t exp = (br << 8u) >> 26u;
-	return (br & 0x3FFFF) * static_cast<unsigned int>(pow(exp, 2));
+	return (br & 0x3FFFF) * static_cast<unsigned int>(pow(2, exp));
 }
 
 unsigned int RtcpPli::Size() { return sizeof(RtcpFbHeader); }