Media-opt: Added a filter type mode for the filtering of the received packet loss. This makes the filter selection explicit and easier to modify/test.

Removed the function UpdateLossPr(); the filter updates are done in the same function that returns the filtered loss.
Review URL: http://webrtc-codereview.appspot.com/333018

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1361 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
marpan@webrtc.org 2012-01-09 18:18:36 +00:00
parent 84ba60676c
commit 2dad3fbe49
3 changed files with 49 additions and 42 deletions

View File

@ -687,17 +687,6 @@ VCMLossProtectionLogic::UpdateResidualPacketLoss(float residualPacketLoss)
_residualPacketLossFec = residualPacketLoss;
}
void
VCMLossProtectionLogic::UpdateLossPr(WebRtc_UWord8 lossPr255,
int64_t nowMs)
{
UpdateMaxLossHistory(lossPr255, nowMs);
_lossPr255.Apply(static_cast<float> (nowMs - _lastPrUpdateT),
static_cast<float> (lossPr255));
_lastPrUpdateT = nowMs;
_lossPr = _lossPr255.Value() / 255.0f;
}
void
VCMLossProtectionLogic::UpdateMaxLossHistory(WebRtc_UWord8 lossPr255,
WebRtc_Word64 now)
@ -767,21 +756,34 @@ VCMLossProtectionLogic::MaxFilteredLossPr(WebRtc_Word64 nowMs) const
return maxFound;
}
WebRtc_UWord8
VCMLossProtectionLogic::FilteredLoss(int64_t nowMs) const
{
if (_selectedMethod != NULL &&
(_selectedMethod->Type() == kFec ||
_selectedMethod->Type() == kNackFec))
{
// Take the windowed max of the received loss.
return MaxFilteredLossPr(nowMs);
}
else
{
// Take the average received loss.
return static_cast<WebRtc_UWord8> (_lossPr255.Value() + 0.5);
}
WebRtc_UWord8 VCMLossProtectionLogic::FilteredLoss(
int64_t nowMs,
FilterPacketLossMode filter_mode,
WebRtc_UWord8 lossPr255) {
// Update the max window filter.
UpdateMaxLossHistory(lossPr255, nowMs);
// Update the recursive average filter.
_lossPr255.Apply(static_cast<float> (nowMs - _lastPrUpdateT),
static_cast<float> (lossPr255));
_lastPrUpdateT = nowMs;
// Filtered loss: default is received loss (no filtering).
WebRtc_UWord8 filtered_loss = lossPr255;
switch (filter_mode) {
case kNoFilter:
break;
case kAvgFilter:
filtered_loss = static_cast<WebRtc_UWord8> (_lossPr255.Value() + 0.5);
break;
case kMaxFilter:
filtered_loss = MaxFilteredLossPr(nowMs);
break;
}
return filtered_loss;
}
void

View File

@ -33,6 +33,14 @@ enum { kLossPrHistorySize = 10 };
// 1000 ms, total filter length is (kLossPrHistorySize * 1000) ms
enum { kLossPrShortFilterWinMs = 1000 };
// The type of filter used on the received packet loss reports.
enum FilterPacketLossMode {
kNoFilter, // No filtering on received loss.
kAvgFilter, // Recursive average filter.
kMaxFilter // Max-window filter, over the time interval of:
// (kLossPrHistorySize * kLossPrShortFilterWinMs) ms.
};
// Thresholds for hybrid NACK/FEC
// common to media optimization and the jitter buffer.
enum HybridNackTH {
@ -249,13 +257,6 @@ public:
// effective loss after FEC recovery
void UpdateResidualPacketLoss(float _residualPacketLoss);
// Update the loss probability.
//
// Input:
// - lossPr255 : The packet loss probability [0, 255],
// reported by RTCP.
void UpdateLossPr(WebRtc_UWord8 lossPr255, int64_t nowMs);
// Update the filtered packet loss.
//
// Input:
@ -330,10 +331,14 @@ public:
// Return the protection type of the currently selected method
VCMProtectionMethodEnum SelectedType() const;
// Returns the filtered loss probability in the interval [0, 255].
//
// Updates the filtered loss for the average and max window packet loss,
// and returns the filtered loss probability in the interval [0, 255].
// The returned filtered loss value depends on the parameter |filter_mode|.
// The input parameter |lossPr255| is the received packet loss.
// Return value : The filtered loss probability
WebRtc_UWord8 FilteredLoss(int64_t nowMs) const;
WebRtc_UWord8 FilteredLoss(int64_t nowMs, FilterPacketLossMode filter_mode,
WebRtc_UWord8 lossPr255);
void Reset(int64_t nowMs);

View File

@ -98,7 +98,6 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
{
VCMProtectionMethod *selectedMethod = _lossProtLogic->SelectedMethod();
_lossProtLogic->UpdateBitRate(static_cast<float>(bitRate));
_lossProtLogic->UpdateLossPr(fractionLost, _clock->MillisecondTimestamp());
_lossProtLogic->UpdateRtt(roundTripTimeMs);
_lossProtLogic->UpdateResidualPacketLoss(static_cast<float>(fractionLost));
@ -117,12 +116,13 @@ VCMMediaOptimization::SetTargetRates(WebRtc_UWord32 bitRate,
_fractionLost = fractionLost;
// The effective packet loss may be the received loss or filtered, i.e.,
// average or max filter may be used.
// We should think about which filter is appropriate for low/high bit rates,
// low/high loss rates, etc.
// Returns the filtered packet loss, used for the protection setting.
// The filtered loss may be the received loss (no filter), or some
// filtered value (average or max window filter).
// Use max window filter for now.
FilterPacketLossMode filter_mode = kMaxFilter;
WebRtc_UWord8 packetLossEnc = _lossProtLogic->FilteredLoss(
_clock->MillisecondTimestamp());
_clock->MillisecondTimestamp(), filter_mode, fractionLost);
// For now use the filtered loss for computing the robustness settings
_lossProtLogic->UpdateFilteredLossPr(packetLossEnc);