修复twcc fci生成相关bug

This commit is contained in:
xiongziliang 2021-10-07 13:07:25 +08:00
parent 0ae1d46892
commit ea1fa03f13

View File

@ -291,7 +291,7 @@ public:
} PACKED; } PACKED;
StatusVecChunk::StatusVecChunk(bool symbol_bit, const vector<SymbolStatus> &status) { StatusVecChunk::StatusVecChunk(bool symbol_bit, const vector<SymbolStatus> &status) {
CHECK((1 + symbol_bit) * status.size() <= 14); CHECK( status.size() << symbol_bit <= 14);
uint16_t value = 0; uint16_t value = 0;
type = 1; type = 1;
symbol = symbol_bit; symbol = symbol_bit;
@ -501,14 +501,14 @@ string FCI_TWCC::create(uint32_t ref_time, uint8_t fb_pkt_count, TwccPacketStatu
auto symbol = status.begin()->second.first; auto symbol = status.begin()->second.first;
int16_t count = 0; int16_t count = 0;
for (auto &pr : status) { for (auto &pr : status) {
if (++count == (0xFFFF >> 3)) {
//RunLengthChunk 13个bit表明rtp个数最多可以表述0xFFFF >> 3个rtp状态
break;
}
if (pr.second.first != symbol) { if (pr.second.first != symbol) {
//状态发送变更了本chunk结束 //状态发送变更了本chunk结束
break; break;
} }
if (++count >= (0xFFFF >> 3)) {
//RunLengthChunk 13个bit表明rtp个数最多可以表述0xFFFF >> 3个rtp状态
break;
}
} }
if (count >= 7) { if (count >= 7) {
//连续状态相同个数大于6个时使用RunLengthChunk模式比较节省带宽 //连续状态相同个数大于6个时使用RunLengthChunk模式比较节省带宽
@ -523,7 +523,6 @@ string FCI_TWCC::create(uint32_t ref_time, uint8_t fb_pkt_count, TwccPacketStatu
//StatusVecChunk模式 //StatusVecChunk模式
//symbol_list中元素是1个bit //symbol_list中元素是1个bit
auto symbol = 0; auto symbol = 0;
int count = 0;
vector<SymbolStatus> vec; vector<SymbolStatus> vec;
for (auto &pr : status) { for (auto &pr : status) {
vec.push_back(pr.second.first); vec.push_back(pr.second.first);
@ -531,15 +530,17 @@ string FCI_TWCC::create(uint32_t ref_time, uint8_t fb_pkt_count, TwccPacketStatu
//symbol_list中元素是2个bit //symbol_list中元素是2个bit
symbol = 1; symbol = 1;
} }
if ((1 + symbol) * (++count) == 14) {
if (vec.size() << symbol >= 14) {
//symbol为0时最多存放14个rtp的状态 //symbol为0时最多存放14个rtp的状态
//symbol为1时最多存放7个rtp的状态 //symbol为1时最多存放7个rtp的状态
break; break;
} }
} }
vec.resize(MIN(vec.size(), 14 >> symbol));
StatusVecChunk chunk(symbol, vec); StatusVecChunk chunk(symbol, vec);
fci.append((char *)&chunk, StatusVecChunk::kSize); fci.append((char *)&chunk, StatusVecChunk::kSize);
appendDeltaString(delta_str, status, count); appendDeltaString(delta_str, status, vec.size());
} }
} }