diff --git a/modules/video_coding/main/source/media_opt_util.cc b/modules/video_coding/main/source/media_opt_util.cc index 4c294ad0a..a0937b66e 100644 --- a/modules/video_coding/main/source/media_opt_util.cc +++ b/modules/video_coding/main/source/media_opt_util.cc @@ -341,6 +341,8 @@ VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters) (bitRate / (parameters->frameRate)); + // TODO (marpan): Incorporate frame size (bpp) into FEC setting + // Total (avg) number of packets per frame (source and fec): const WebRtc_UWord8 avgTotPackets = 1 + (WebRtc_UWord8) ((float) bitRatePerFrame * 1000.0 @@ -850,6 +852,14 @@ VCMLossProtectionLogic::UpdateKeyFrameSize(float keyFrameSize) _keyFrameSize = keyFrameSize; } +void +VCMLossProtectionLogic::UpdateFrameSize(WebRtc_UWord16 width, + WebRtc_UWord16 height) +{ + _codecWidth = width; + _codecHeight = height; +} + bool VCMLossProtectionLogic::UpdateMethod(VCMProtectionMethod *newMethod /*=NULL */) { @@ -864,6 +874,8 @@ VCMLossProtectionLogic::UpdateMethod(VCMProtectionMethod *newMethod /*=NULL */) _currentParameters.packetsPerFrameKey = _packetsPerFrameKey.Value(); _currentParameters.residualPacketLoss = _residualPacketLoss; _currentParameters.fecType = _fecType; + _currentParameters.codecWidth = _codecWidth; + _currentParameters.codecHeight = _codecHeight; if (newMethod == NULL) { diff --git a/modules/video_coding/main/source/media_opt_util.h b/modules/video_coding/main/source/media_opt_util.h index 8a834f0ea..829840656 100644 --- a/modules/video_coding/main/source/media_opt_util.h +++ b/modules/video_coding/main/source/media_opt_util.h @@ -45,7 +45,8 @@ struct VCMProtectionParameters { VCMProtectionParameters() : rtt(0), lossPr(0), bitRate(0), packetsPerFrame(0), frameRate(0), keyFrameSize(0), fecRateDelta(0), fecRateKey(0), - residualPacketLoss(0.0), fecType(kXORFec) {} + residualPacketLoss(0.0), fecType(kXORFec), codecWidth(0), + codecHeight(0) {} WebRtc_UWord32 rtt; float lossPr; @@ -57,7 +58,10 @@ struct VCMProtectionParameters WebRtc_UWord8 fecRateDelta; WebRtc_UWord8 fecRateKey; float residualPacketLoss; - VCMFecTypes fecType; + VCMFecTypes fecType; + WebRtc_UWord16 codecWidth; + WebRtc_UWord16 codecHeight; + }; @@ -236,7 +240,7 @@ public: _keyFrameSize(0.0f), _fecRateKey(0), _fecRateDelta(0), _lastPrUpdateT(0), _lossPr255(0.9999f), _lossPrHistory(), _shortMaxLossPr255(0), _packetsPerFrame(0.9999f), _packetsPerFrameKey(0.9999f), _residualPacketLoss(0), - _boostRateKey(2) + _boostRateKey(2), _codecWidth(0), _codecHeight(0) { Reset(); } ~VCMLossProtectionLogic(); @@ -308,6 +312,13 @@ public: // - frameRate : The current target frame rate. void UpdateFrameRate(float frameRate) { _frameRate = frameRate; } + // Update the frame size + // + // Input: + // - width : The codec frame width. + // - height : The codec frame height. + void UpdateFrameSize(WebRtc_UWord16 width, WebRtc_UWord16 height); + // The amount of packet loss to cover for with FEC. // // Input: @@ -372,6 +383,8 @@ private: float _residualPacketLoss; WebRtc_UWord8 _boostRateKey; VCMFecTypes _fecType; + WebRtc_UWord16 _codecWidth; + WebRtc_UWord16 _codecHeight; }; } // namespace webrtc diff --git a/modules/video_coding/main/source/media_optimization.cc b/modules/video_coding/main/source/media_optimization.cc index 4cb148056..e21598615 100644 --- a/modules/video_coding/main/source/media_optimization.cc +++ b/modules/video_coding/main/source/media_optimization.cc @@ -246,6 +246,7 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType, WebRtc_Word3 _targetBitRate = bitRate; _lossProtLogic->UpdateBitRate(static_cast(bitRate)); _lossProtLogic->UpdateFrameRate(static_cast(frameRate)); + _lossProtLogic->UpdateFrameSize(width, height); _frameDropper->Reset(); _frameDropper->SetRates(static_cast(bitRate), static_cast(frameRate)); _userFrameRate = (float)frameRate;