作者热门文章
- Java锁的逻辑(结合对象头和ObjectMonitor)
- 还在用饼状图?来瞧瞧这些炫酷的百分比可视化新图形(附代码实现)⛵
- 自动注册实体类到EntityFrameworkCore上下文,并适配ABP及ABPVNext
- 基于Sklearn机器学习代码实战
想起博客园帐号了,回来填点webrtc qos的坑, 本文分析个很好用的直方图算法,不仅可以在音频里面计算抖动延迟,我发现用来统计丢包率也很好用. 。
DelayManager::Update()->Histogram::Add() 会根据计算的iat_packet(inter arrival times, =实际包间间隔 / 打包时长),将该iat_packet插入IATVector直方图对应数组下标内。并更新该直方图的数据下标下概率参数。[M88 SRC] 。
一共有四步操作:
1、用遗忘因子,对历史数据的出现概率进行遗忘, 并统计概率合 。
2、增大本次计算到的IAT的概率值.
假如历史bucket 数据为:
buckets_ = {0,0,1,0}
遗忘因子为 0.9:
forget_factor = 0.9
新来的抖动延迟数据为66ms, 桶间为20ms一个单位, 那插入位置为 66 / 20 = 3,则更新后
buckets = {0,0,0.9,0.1}
假若使用%95分位的值作为目标延迟, 则更新后的目标延迟为 60ms.
3、调整本次计算到的IAT的概率,使整个IAT的概率分布之和近似为1。调整方式为假设当前概率分布之和为tempSum,则:
4、更新forget_factor_, 使遗忘因子forget_factor_逼近base_forget_factor_ 。
a.使用start_forget_weight_更新(默认初始值start_forget_weight_ = 2,base_forget_factor_=0.9993) 。
依据probability获取此百分位的值作为目标延迟(初始值0.97) 。
int Histogram::Quantile(int probability) {
// Find the bucket for which the probability of observing an
// inter-arrival time larger than or equal to |index| is larger than or
// equal to |probability|. The sought probability is estimated using
// the histogram as the reverse cumulant PDF, i.e., the sum of elements from
// the end up until |index|. Now, since the sum of all elements is 1
// (in Q30) by definition, and since the solution is often a low value for
// |iat_index|, it is more efficient to start with |sum| = 1 and subtract
// elements from the start of the histogram.
int inverse_probability = (1 << 30) - probability;
size_t index = 0; // Start from the beginning of |buckets_|.
int sum = 1 << 30; // Assign to 1 in Q30.
sum -= buckets_[index];
while ((sum > inverse_probability) && (index < buckets_.size() - 1)) {
// Subtract the probabilities one by one until the sum is no longer greater
// than |inverse_probability|.
++index;
sum -= buckets_[index];
}
return static_cast<int>(index);
}
。
测试曲线,调整遗忘因子提高抖动估计灵敏度
#include <iostream>
#include <cstdint>
#include <vector>
uint32_t packet_loss_rate_ = 0;
int main()
{
std::vector<int> input;
std::vector<float> buckets;
float forget_factor = 0.9993;
float val = 0;
for (size_t k = 0; k < 1000; k ++) {
val = val * forget_factor + (1-forget_factor);
buckets.push_back(val);
}
for (int i = 0; i < 1000; ++i) {
std::cout << buckets[i]<< " ";
}
return 0;
}
最后此篇关于webrtcQOS笔记一Neteq直方图算法浅读的文章就讲到这里了,如果你想了解更多关于webrtcQOS笔记一Neteq直方图算法浅读的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我是一名优秀的程序员,十分优秀!