自适应编码实现

经过一段时间实验,关于自适应编码得到些成果,但还有很多问题,现把我的做法贴出来,欢迎高手指教!

原理:
网络传输的反馈信息是通过RTCP包中的RR(接受者报告)包得到。通过RR包中的累积丢包数等反馈信息可以计算出当前的传输丢包率。当丢包率低于预先设定的最小值时,增加编码输出速率。当丢包率大于设定的最大值时,降低编码输出速率。当网络拥塞时,发送速率乘性减小,降低对所需带宽的要求。同时设置最小发送码率,保证发送端所需的最小带宽。当网络空闲时,线性增加发送码率。同时设置最大发送码率,保证发送端不会过度占用资源。当网络负载正常时不作任何调整。
丢包率计算:
(1) 计算该发送时隙丢失的数据包数L(n):前端一个发送时隙前后接收的两个RR包中包丢失的累计数之差就是该发送时隙丢失的数据包数,即
L(n)=C(n) - C(n-I)
其中C(n)是第n个发送时隙后共丢失的数据包数。
(2) 计算该时隙中应收到的数据包的数R(n):两个接收数据包中的最高序列号扩展的差就是接收者在该时隙中应收到的数据包数,即
R(n)=H(n) - H(n-1),
其中H(n)是第n个发送时隙后收到的数据包的最高序列号。
(3) 计算该时隙中数据包丢失比例F(n):L(n)与R(n)之比即在该时隙中数据包丢失比例,即
F(n)=L(n)/R(n);
(4) 计算该时隙中数据包的丢失比率,就是每秒钟的丢包数f(n):数据包的丢失比率等于丢失比例除以两个RR中NTP时间戳的差,即
f(n) = F(n) / ( NTP(n) - NTP(n-1) )

关于时间戳如何取得&#

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
自适应霍夫曼编码的C++版本简单实现 class AdaptiveTree { public: AdaptiveTree(int rootNum); AdaptiveTree(int rootNum, string str); void swap(int first, int second); // swap two nodes of the tree void initalCode(); // initializing the data string char2code(unsigned char letter); // locate the character in the tree with its corresponding binary string and return the string string char2binary(unsigned char letter); // translating the character to the 8-bit binary string unsigned char binary2char(string bin); // translating the binary string: bin to the corresponding character int spawn(unsigned char letter); // add a new character to the original tree void updateTree(unsigned char newchar); // update the tree int highestInBlock(int count); // return the highest node to be exchanged void setString(string str); // string decodingStr() const; void encoding(); string decoding(); unsigned char code2char(string bincode); static int size(); string binStr() const; // return the binary string of string: tempString private: void run(); int findchar(unsigned char letter ); // locate the letter in the tree string tempString; //temp string to be encoded needed to be stored here string deStr;// used for storing the decoding string string bin; // used for storing the result of encoding process /* Adaptive Tree data members */ HuffmanTree *tree; int root; /* Adaptive Tree constants */ static int ALPH_SIZE; // size of the alphabet static unsigned char none; // not a unsigned character static unsigned char NYT; // Not Yet transmitted code };

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值