| Index: webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
|
| index 5c090504ca07fe5b4f9f0bb4838f3ef55238a7f3..1001bf4c5ea7ec11aef6640cfa1c3ee74c8ac49f 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
|
| @@ -15,6 +15,7 @@
|
|
|
| #include <limits>
|
|
|
| +#include "webrtc/base/checks.h"
|
| #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
|
|
| namespace webrtc {
|
| @@ -300,6 +301,7 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
| && j != currentMinIndexTMMBR)
|
| {
|
| candidateSet.ClearEntry(j);
|
| + numCandidates--;
|
| }
|
| }
|
| }
|
| @@ -336,9 +338,15 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
| // set intersection value
|
| _ptrIntersectionBoundingSet[numBoundingSet] = 0;
|
| // calculate its maximum packet rate (where its line crosses x-axis)
|
| - _ptrMaxPRBoundingSet[numBoundingSet]
|
| - = _boundingSet.Tmmbr(numBoundingSet) * 1000
|
| - / float(8 * _boundingSet.PacketOH(numBoundingSet));
|
| + uint32_t packet_overhead_bits = 8 * _boundingSet.PacketOH(numBoundingSet);
|
| + if (packet_overhead_bits == 0) {
|
| + // Avoid division by zero.
|
| + _ptrMaxPRBoundingSet[numBoundingSet] = std::numeric_limits<float>::max();
|
| + } else {
|
| + _ptrMaxPRBoundingSet[numBoundingSet] =
|
| + _boundingSet.Tmmbr(numBoundingSet) * 1000 /
|
| + static_cast<float>(packet_overhead_bits);
|
| + }
|
| numBoundingSet++;
|
| // remove from candidate list
|
| candidateSet.ClearEntry(minIndexTMMBR);
|
| @@ -364,10 +372,10 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
| }
|
|
|
| bool getNewCandidate = true;
|
| - int curCandidateTMMBR = 0;
|
| - int curCandidateIndex = 0;
|
| - int curCandidatePacketOH = 0;
|
| - int curCandidateSSRC = 0;
|
| + uint32_t curCandidateTMMBR = 0;
|
| + size_t curCandidateIndex = 0;
|
| + uint32_t curCandidatePacketOH = 0;
|
| + uint32_t curCandidateSSRC = 0;
|
| do
|
| {
|
| if (getNewCandidate)
|
| @@ -389,6 +397,8 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
|
|
| // 6. Calculate packet rate and intersection of the current
|
| // line with line of last tuple in selected list
|
| + RTC_DCHECK_NE(curCandidatePacketOH,
|
| + _boundingSet.PacketOH(numBoundingSet - 1));
|
| float packetRate
|
| = float(curCandidateTMMBR
|
| - _boundingSet.Tmmbr(numBoundingSet-1))*1000
|
| @@ -418,9 +428,12 @@ TMMBRHelp::FindTMMBRBoundingSet(int32_t numCandidates, TMMBRSet& candidateSet)
|
| curCandidatePacketOH,
|
| curCandidateSSRC);
|
| _ptrIntersectionBoundingSet[numBoundingSet] = packetRate;
|
| - _ptrMaxPRBoundingSet[numBoundingSet]
|
| - = _boundingSet.Tmmbr(numBoundingSet)*1000
|
| - / float(8*_boundingSet.PacketOH(numBoundingSet));
|
| + float packet_overhead_bits =
|
| + 8 * _boundingSet.PacketOH(numBoundingSet);
|
| + RTC_DCHECK_NE(packet_overhead_bits, 0.0f);
|
| + _ptrMaxPRBoundingSet[numBoundingSet] =
|
| + _boundingSet.Tmmbr(numBoundingSet) * 1000 /
|
| + packet_overhead_bits;
|
| numBoundingSet++;
|
| }
|
| numCandidates--;
|
|
|