diff --git a/src/modules/video_coding/main/source/media_opt_util.cc b/src/modules/video_coding/main/source/media_opt_util.cc index 4d98486a97..193cf3f81a 100644 --- a/src/modules/video_coding/main/source/media_opt_util.cc +++ b/src/modules/video_coding/main/source/media_opt_util.cc @@ -43,19 +43,12 @@ VCMNackFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) { // Hybrid Nack FEC has three operational modes: - // 1. Low RTT - Nack only (Set FEC rates to zero) - // 2. High RTT - FEC Only - // 3. Medium RTT values - Hybrid ; in hybrid mode, we will only nack the - // residual following the decoding of the FEC (refer to JB logic) - - // Low RTT - NACK only mode - if (parameters->rtt < kLowRttNackMs) - { - // Set the FEC parameters to 0 - _protectionFactorK = 0; - _protectionFactorD = 0; - return true; - } + // 1. Low RTT (below kLowRttNackMs) - Nack only: Set FEC rate + // (_protectionFactorD) to zero. + // 2. High RTT (above kHighRttNackMs) - FEC Only: Keep FEC factors. + // 3. Medium RTT values - Hybrid mode: We will only nack the + // residual following the decoding of the FEC (refer to JB logic). FEC + // delta protection factor will be adjusted based on the RTT. // Otherwise: we count on FEC; if the RTT is below a threshold, then we // nack the residual, based on a decision made in the JB. @@ -66,18 +59,22 @@ VCMNackFecMethod::ProtectionFactor(const _protectionFactorK = _fecMethod->_protectionFactorK; _protectionFactorD = _fecMethod->_protectionFactorD; - // When in Hybrid mode, correct FEC rates based on the - // RTT (NACK effectiveness) + // When in Hybrid mode (RTT range), adjust FEC rates based on the + // RTT (NACK effectiveness) - adjustment factor is in the range [0,1]. if (parameters->rtt < kHighRttNackMs) { WebRtc_UWord16 rttIndex = (WebRtc_UWord16) parameters->rtt; - // TODO(mikhal): update table - float softnessRtt = (float)VCMNackFecTable[rttIndex] / (float)4096.0; + float adjustRtt = (float)VCMNackFecTable[rttIndex] / 100.0f; - // Soften FEC with NACK on (for delta frame only) + // Adjust FEC with NACK on (for delta frame only) // table depends on RTT relative to rttMax (NACK Threshold) - _protectionFactorD *= static_cast (softnessRtt); + _protectionFactorD = static_cast + (adjustRtt * + static_cast(_protectionFactorD)); + // update FEC rates after applyingadjustment softness parameter + _fecMethod->UpdateProtectionFactorD(_protectionFactorD); } + return true; } @@ -85,16 +82,6 @@ bool VCMNackFecMethod::EffectivePacketLoss(const VCMProtectionParameters* parameters) { - // NACK only mode - if (parameters->rtt < kLowRttNackMs) - { - // Effective Packet Loss, NA in current version. - _effectivePacketLoss = 0; - // No FEC applied. - _residualPacketLossFec = parameters->lossPr; - return true; - } - // Set the effective packet loss for encoder (based on FEC code). // Compute the effective packet loss and residual packet loss due to FEC. _fecMethod->EffectivePacketLoss(parameters); @@ -180,6 +167,14 @@ VCMFecMethod::ConvertFECRate(WebRtc_UWord8 codeRateRTP) const (float)(255 - codeRateRTP)))); } +// Update FEC with protectionFactorD +void +VCMFecMethod::UpdateProtectionFactorD(WebRtc_UWord8 protectionFactorD) +{ + _protectionFactorD = protectionFactorD; + +} + // AvgRecoveryFEC: computes the residual packet loss function. // This is the average recovery from the FEC, assuming random packet loss model. // Computed off-line for a range of FEC code parameters and loss rates. diff --git a/src/modules/video_coding/main/source/media_opt_util.h b/src/modules/video_coding/main/source/media_opt_util.h index 6a03ada442..96efd451c5 100644 --- a/src/modules/video_coding/main/source/media_opt_util.h +++ b/src/modules/video_coding/main/source/media_opt_util.h @@ -194,6 +194,8 @@ public: WebRtc_UWord8 ConvertFECRate(WebRtc_UWord8 codeRate) const; // Get the average effective recovery from FEC: for random loss model float AvgRecoveryFEC(const VCMProtectionParameters* parameters) const; + // Update FEC with protectionFactorD + void UpdateProtectionFactorD(WebRtc_UWord8 protectionFactorD); }; diff --git a/src/modules/video_coding/main/source/nack_fec_tables.h b/src/modules/video_coding/main/source/nack_fec_tables.h index 40cf0b5dad..88e225d1eb 100644 --- a/src/modules/video_coding/main/source/nack_fec_tables.h +++ b/src/modules/video_coding/main/source/nack_fec_tables.h @@ -14,210 +14,111 @@ namespace webrtc { -// Table for softening FEC rate for NACK/FEC protection method -const WebRtc_UWord16 VCMNackFecTable[200] = { - -27, +// Table for adjusting FEC rate for NACK/FEC protection method +// Table values are built as a sigmoid function, ranging from 0 to +// kHighRttNackMs (100), based on the HybridNackTH values defined in +// media_opt_util.h. +const WebRtc_UWord16 VCMNackFecTable[100] = { +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +1, +1, +1, +1, +1, +2, +2, +2, +3, +3, +4, +5, +6, +7, +9, +10, +12, +15, +18, +21, +24, 28, -30, -31, -33, -35, -36, -38, -40, -42, -45, -47, -49, -52, -54, -57, -60, -63, +32, +37, +41, +46, +51, +56, +61, 66, 70, -73, -77, +74, +78, 81, -85, +84, +86, 89, -94, +90, +92, +93, +95, +95, +96, +97, +97, 98, -103, -108, -114, -120, -126, -132, -138, -145, -152, -160, -168, -176, -185, -194, -203, -213, -223, -234, -246, -257, -270, -283, -296, -310, -325, -340, -356, -373, -390, -408, -427, -446, -467, -488, -510, -532, -556, -581, -606, -632, -659, -688, -717, -747, -778, -810, -843, -877, -912, -948, -985, -1022, -1061, -1101, -1142, -1183, -1226, -1269, -1314, -1359, -1404, -1451, -1498, -1546, -1594, -1643, -1693, -1743, -1793, -1843, -1894, -1945, -1996, -2048, -2099, -2150, -2201, -2252, -2302, -2352, -2402, -2452, -2501, -2549, -2597, -2644, -2691, -2736, -2781, -2826, -2869, -2912, -2953, -2994, -3034, -3073, -3110, -3147, -3183, -3218, -3252, -3285, -3317, -3348, -3378, -3407, -3436, -3463, -3489, -3514, -3539, -3563, -3585, -3607, -3628, -3649, -3668, -3687, -3705, -3722, -3739, -3755, -3770, -3785, -3799, -3812, -3825, -3838, -3849, -3861, -3872, -3882, -3892, -3901, -3910, -3919, -3927, -3935, -3943, -3950, -3957, -3963, -3969, -3975, -3981, -3987, -3992, -3997, -4001, -4006, -4010, -4014, -4018, -4022, -4025, -4029, -4032, -4035, -4038, -4041, -4043, -4046, -4048, -4050, -4053, -4055, -4057, -4059, -4060, -4062, -4064, -4065, -4067, - +98, +99, +99, +99, +99, +99, +99, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, +100, };