From 771ca422df9033ee3bc660daeb59023a35eac123 Mon Sep 17 00:00:00 2001 From: "marpan@google.com" Date: Tue, 16 Aug 2011 20:51:04 +0000 Subject: [PATCH] Fixed assert error in media_opt_util that may have caused index for look-up table to be out of range. Review URL: http://webrtc-codereview.appspot.com/112005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@385 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/video_coding/main/source/media_opt_util.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 29224d9a88..da516ba23c 100644 --- a/src/modules/video_coding/main/source/media_opt_util.cc +++ b/src/modules/video_coding/main/source/media_opt_util.cc @@ -208,9 +208,9 @@ VCMFecMethod::AvgRecoveryFEC(const VCMProtectionParameters* parameters) const WebRtc_UWord8 sourcePacketsPerFrame = avgTotPackets - fecPacketsPerFrame; - if (fecPacketsPerFrame == 0) + if ( (fecPacketsPerFrame == 0) || (sourcePacketsPerFrame == 0) ) { - // No protection, so average recovery from FEC == 0. + // No protection, or rate too low: so average recovery from FEC == 0. return 0.0; } @@ -220,6 +220,12 @@ VCMFecMethod::AvgRecoveryFEC(const VCMProtectionParameters* parameters) const sourcePacketsPerFrame = codeSize; } + // Table defined up to codeSizexcodeSize code + if (fecPacketsPerFrame > codeSize) + { + fecPacketsPerFrame = codeSize; + } + // Check: protection factor is maxed at 50%, so this should never happen assert(sourcePacketsPerFrame >= 1);