diff --git a/webrtc/modules/video_coding/BUILD.gn b/webrtc/modules/video_coding/BUILD.gn index cd198324ea..7d50e87535 100644 --- a/webrtc/modules/video_coding/BUILD.gn +++ b/webrtc/modules/video_coding/BUILD.gn @@ -18,7 +18,7 @@ rtc_static_library("video_coding") { "decoding_state.h", "encoded_frame.cc", "encoded_frame.h", - "fec_tables_xor.h", + "fec_rate_table.h", "frame_buffer.cc", "frame_buffer.h", "frame_buffer2.cc", diff --git a/webrtc/modules/video_coding/fec_tables_xor.h b/webrtc/modules/video_coding/fec_rate_table.h similarity index 98% rename from webrtc/modules/video_coding/fec_tables_xor.h rename to webrtc/modules/video_coding/fec_rate_table.h index fa5bd7bde4..18f10e0591 100644 --- a/webrtc/modules/video_coding/fec_tables_xor.h +++ b/webrtc/modules/video_coding/fec_rate_table.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_VIDEO_CODING_FEC_TABLES_XOR_H_ -#define WEBRTC_MODULES_VIDEO_CODING_FEC_TABLES_XOR_H_ +#ifndef WEBRTC_MODULES_VIDEO_CODING_FEC_RATE_TABLE_H_ +#define WEBRTC_MODULES_VIDEO_CODING_FEC_RATE_TABLE_H_ // This is a private header for media_opt_util.cc. // It should not be included by other files. @@ -18,10 +18,12 @@ namespace webrtc { // Table for Protection factor (code rate) of delta frames, for the XOR FEC. // Input is the packet loss and an effective rate (bits/frame). -// Output is array kCodeRateXORTable[k], where k = rate_i*129 + loss_j; +// Output is array kFecRateTable[k], where k = rate_i*129 + loss_j; // loss_j = 0,1,..128, and rate_i varies over some range. -static const int kSizeCodeRateXORTable = 6450; -static const unsigned char kCodeRateXORTable[kSizeCodeRateXORTable] = { +// TODO(brandtr): Consider replacing this big static table with a closed-form +// expression instead. +static const int kFecRateTableSize = 6450; +static const unsigned char kFecRateTable[kFecRateTableSize] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, @@ -456,4 +458,4 @@ static const unsigned char kCodeRateXORTable[kSizeCodeRateXORTable] = { } // namespace webrtc -#endif // WEBRTC_MODULES_VIDEO_CODING_FEC_TABLES_XOR_H_ +#endif // WEBRTC_MODULES_VIDEO_CODING_FEC_RATE_TABLE_H_ diff --git a/webrtc/modules/video_coding/media_opt_util.cc b/webrtc/modules/video_coding/media_opt_util.cc index ed926e953b..3edd054108 100644 --- a/webrtc/modules/video_coding/media_opt_util.cc +++ b/webrtc/modules/video_coding/media_opt_util.cc @@ -20,7 +20,7 @@ #include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" #include "webrtc/modules/video_coding/include/video_coding_defines.h" -#include "webrtc/modules/video_coding/fec_tables_xor.h" +#include "webrtc/modules/video_coding/fec_rate_table.h" #include "webrtc/modules/video_coding/nack_fec_tables.h" namespace webrtc { @@ -309,10 +309,10 @@ bool VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) { uint16_t indexTable = rateIndexTable * kPacketLossMax + packetLoss; // Check on table index - assert(indexTable < kSizeCodeRateXORTable); + RTC_DCHECK_LT(indexTable, kFecRateTableSize); // Protection factor for P frame - codeRateDelta = kCodeRateXORTable[indexTable]; + codeRateDelta = kFecRateTable[indexTable]; if (packetLoss > lossThr && avgTotPackets > packetNumThr) { // Set a minimum based on first partition size. @@ -341,13 +341,13 @@ bool VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) { 0)); uint16_t indexTableKey = rateIndexTable * kPacketLossMax + packetLoss; - indexTableKey = VCM_MIN(indexTableKey, kSizeCodeRateXORTable); + indexTableKey = VCM_MIN(indexTableKey, kFecRateTableSize); // Check on table index - assert(indexTableKey < kSizeCodeRateXORTable); + assert(indexTableKey < kFecRateTableSize); // Protection factor for I frame - codeRateKey = kCodeRateXORTable[indexTableKey]; + codeRateKey = kFecRateTable[indexTableKey]; // Boosting for Key frame. int boostKeyProt = _scaleProtKey * codeRateDelta;