diff --git a/ALVR-common/packet_types.h b/ALVR-common/packet_types.h index b6e6976c..2bbb8f4a 100644 --- a/ALVR-common/packet_types.h +++ b/ALVR-common/packet_types.h @@ -184,6 +184,8 @@ struct PacketErrorReport { static const int ALVR_MAX_VIDEO_BUFFER_SIZE = ALVR_MAX_PACKET_SIZE - sizeof(VideoFrame); +static const int ALVR_FEC_SHARDS_MAX = 20; + inline int CalculateParityShards(int dataShards, int fecPercentage) { int totalParityShards = (dataShards * fecPercentage + 99) / 100; return totalParityShards; @@ -191,15 +193,14 @@ inline int CalculateParityShards(int dataShards, int fecPercentage) { // Calculate how many packet is needed for make signal shard. inline int CalculateFECShardPackets(int len, int fecPercentage) { - int shards_max = 20; // This reed solomon implementation accept only 255 shards. // Normally, we use ALVR_MAX_VIDEO_BUFFER_SIZE as block_size and single packet becomes single shard. // If we need more than maxDataShards packets, we need to combine multiple packet to make single shrad. // NOTE: Moonlight seems to use only 255 shards for video frame. - int maxDataShards = ((shards_max - 2) * 100 + 99 + fecPercentage) / (100 + fecPercentage); + int maxDataShards = ((ALVR_FEC_SHARDS_MAX - 2) * 100 + 99 + fecPercentage) / (100 + fecPercentage); int minBlockSize = (len + maxDataShards - 1) / maxDataShards; int shardPackets = (minBlockSize + ALVR_MAX_VIDEO_BUFFER_SIZE - 1) / ALVR_MAX_VIDEO_BUFFER_SIZE; - assert(maxDataShards + CalculateParityShards(maxDataShards, fecPercentage) <= shards_max); + assert(maxDataShards + CalculateParityShards(maxDataShards, fecPercentage) <= ALVR_FEC_SHARDS_MAX); return shardPackets; } diff --git a/alvr_server/Listener.h b/alvr_server/Listener.h index bb875e40..d5ad4e39 100644 --- a/alvr_server/Listener.h +++ b/alvr_server/Listener.h @@ -143,10 +143,6 @@ class Listener : public CThread { int totalParityShards = (dataShards * m_fecPercentage + 99) / 100; int totalShards = dataShards + totalParityShards; - int dataPackets = dataShards * shardPackets; - int parityPackets = totalParityShards * shardPackets; - int totalPackets = totalShards * shardPackets; - assert(totalShards <= DATA_SHARDS_MAX); Log("reed_solomon_new. dataShards=%d totalParityShards=%d totalShards=%d blockSize=%d shardPackets=%d" diff --git a/test/gtest/rs_test.cpp b/test/gtest/rs_test.cpp index b51864d2..f13a3df7 100644 Binary files a/test/gtest/rs_test.cpp and b/test/gtest/rs_test.cpp differ