bweStr->maxBwInv = kInvBandwidth[3];
bweStr->minBwInv = kInvBandwidth[2];
- bweStr->recBwInv = WEBRTC_SPL_UDIV(1073741824, (bweStr->recBw + bweStr->recHeaderRate));
+ bweStr->recBwInv = 1073741824 / (bweStr->recBw + bweStr->recHeaderRate);
}
/* kBitsByteSec is in Q15 */
bweStr->maxBwInv = kInvBandwidth[1];
bweStr->minBwInv = kInvBandwidth[0];
- bweStr->recBwInv = WEBRTC_SPL_UDIV(1073741824, (bweStr->recBw + bweStr->recHeaderRate));
+ bweStr->recBwInv = 1073741824 / (bweStr->recBw + bweStr->recHeaderRate);
}
/* kBitsByteSec is in Q14 */
if ((arrivalTime - bweStr->lastUpdate) > FS3) {
/* Calculate expected number of received packets since last update */
- numPktsExpected = WEBRTC_SPL_UDIV(arrivalTime - bweStr->lastUpdate, frameSizeSampl);
+ numPktsExpected = (arrivalTime - bweStr->lastUpdate) / frameSizeSampl;
/* If received number of packets is more than 90% of expected (922 = 0.9 in Q10): */
/* do the update, else not */
bweStr->recBwInv = WEBRTC_SPL_RSHIFT_W32((int32_t)bweStr->recBwInv, 13);
} else {
- /* recBwInv = 1 / (INIT_BN_EST + INIT_HDR_RATE) in Q26 (Q30??)*/
- bweStr->recBwInv = WEBRTC_SPL_DIV((1073741824 +
- WEBRTC_SPL_LSHIFT_W32(((int32_t)INIT_BN_EST + INIT_HDR_RATE), 1)), INIT_BN_EST + INIT_HDR_RATE);
+ static const uint32_t kInitRate = INIT_BN_EST + INIT_HDR_RATE;
+ /* recBwInv = 1 / kInitRate in Q26 (Q30??)*/
+ bweStr->recBwInv = (1073741824 + kInitRate / 2) / kInitRate;
}
/* reset time-since-update counter */
and NOT right shifting recBwAvg 5 bits to an integer
At max 13 bits are used
shift to Q5 */
- recBwAvgInv = WEBRTC_SPL_UDIV((uint32_t)(0x80000000 + WEBRTC_SPL_RSHIFT_U32(bweStr->recBwAvg, 1)),
- bweStr->recBwAvg);
+ recBwAvgInv = (0x80000000 + bweStr->recBwAvg / 2) / bweStr->recBwAvg;
/* Calculate Projected arrival time difference */
bweStr->prevSendTime = sendTime;
/* Replace bweStr->recBw by the new value */
- bweStr->recBw = WEBRTC_SPL_UDIV(1073741824, bweStr->recBwInv) - bweStr->recHeaderRate;
+ bweStr->recBw = 1073741824 / bweStr->recBwInv - bweStr->recHeaderRate;
if (immediateSet) {
/* delay correction factor is in Q10 */
bweStr->recJitterShortTerm = 0;
- bweStr->recBwInv = WEBRTC_SPL_UDIV(1073741824, bweStr->recBw + bweStr->recHeaderRate);
+ bweStr->recBwInv = 1073741824 / (bweStr->recBw + bweStr->recHeaderRate);
immediateSet = 0;
}
/* Q18 rec jitter short term abs is in Q13, multiply it by 2^13 to save precision
2^18 then needs to be shifted 13 bits to 2^31 */
- rec_jitter_short_term_abs_inv = WEBRTC_SPL_UDIV(0x80000000, bweStr->recJitterShortTermAbs);
+ rec_jitter_short_term_abs_inv = 0x80000000u / bweStr->recJitterShortTermAbs;
/* Q27 = 9 + 18 */
jitter_sign = WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTerm, 4), (int32_t)rec_jitter_short_term_abs_inv);
} else {
/* handle burst */
if (State->BurstCounter) {
- if (State->StillBuffered < WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL((512 - WEBRTC_SPL_DIV(512, BURST_LEN)), DelayBuildUp), 9)) {
+ if (State->StillBuffered <
+ (((512 - 512 / BURST_LEN) * DelayBuildUp) >> 9)) {
/* max bps derived from BottleNeck and DelayBuildUp values */
- inv_Q12 = WEBRTC_SPL_DIV(4096, WEBRTC_SPL_MUL(BURST_LEN, FrameSamples));
+ inv_Q12 = 4096 / (BURST_LEN * FrameSamples);
MinRate = WEBRTC_SPL_MUL(512 + WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(DelayBuildUp, inv_Q12), 3)), BottleNeck);
} else {
/* max bps derived from StillBuffered and DelayBuildUp values */
- inv_Q12 = WEBRTC_SPL_DIV(4096, FrameSamples);
+ inv_Q12 = 4096 / FrameSamples;
if (DelayBuildUp > State->StillBuffered) {
MinRate = WEBRTC_SPL_MUL(512 + WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(DelayBuildUp - State->StillBuffered, inv_Q12), 3)), BottleNeck);
} else if ((den = WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, (State->StillBuffered - DelayBuildUp))) >= FrameSamples) {
//round and shift before conversion
MinRate += 256;
MinRate = WEBRTC_SPL_RSHIFT_W32(MinRate, 9);
- MinBytes = (uint16_t)WEBRTC_SPL_UDIV(WEBRTC_SPL_MUL(MinRate, FrameSamples), FS8);
+ MinBytes = MinRate * FrameSamples / FS8;
/* StreamSize will be adjusted if less than MinBytes */
if (StreamSize < MinBytes) {
/* keep track of when bottle neck was last exceeded by at least 1% */
//517/512 ~ 1.01
- if (WEBRTC_SPL_DIV(WEBRTC_SPL_MUL(StreamSize, FS8), FrameSamples) > (WEBRTC_SPL_MUL(517, BottleNeck) >> 9)) {
+ if ((StreamSize * (int32_t)FS8) / FrameSamples > (517 * BottleNeck) >> 9) {
if (State->PrevExceed) {
/* bottle_neck exceded twice in a row, decrease ExceedAgo */
- State->ExceedAgo -= WEBRTC_SPL_DIV(BURST_INTERVAL, BURST_LEN - 1);
+ State->ExceedAgo -= BURST_INTERVAL / (BURST_LEN - 1);
if (State->ExceedAgo < 0) {
State->ExceedAgo = 0;
}
/* Update buffer delay */
- TransmissionTime = (int16_t)WEBRTC_SPL_DIV(WEBRTC_SPL_MUL(StreamSize, 8000), BottleNeck); /* ms */
+ TransmissionTime = (StreamSize * 8000) / BottleNeck; /* ms */
State->StillBuffered += TransmissionTime;
State->StillBuffered -= (int16_t)WEBRTC_SPL_RSHIFT_W16(FrameSamples, 4); //>>4 = SAMPLES_PER_MSEC /* ms */
if (State->StillBuffered < 0) {
const int16_t FrameSamples, /* samples per frame */
const int16_t BottleNeck) /* bottle neck rate; excl headers (bps) */
{
- int16_t TransmissionTime;
+ const int16_t TransmissionTime = (StreamSize * 8000) / BottleNeck; /* ms */
/* avoid the initial "high-rate" burst */
State->InitCounter = 0;
/* Update buffer delay */
- TransmissionTime = (int16_t)WEBRTC_SPL_DIV(WEBRTC_SPL_MUL(WEBRTC_SPL_MUL(StreamSize, 8), 1000), BottleNeck); /* ms */
State->StillBuffered += TransmissionTime;
State->StillBuffered -= (int16_t)WEBRTC_SPL_RSHIFT_W16(FrameSamples, 4); /* ms */
if (State->StillBuffered < 0) {