Remove er_tables_xor.h.
Removes _efficiency and _residualPacketLossFec from VCMLossProtectionLogic which are updated but never read. This frees up ~38k of local read-only data. BUG=4491 R=marpan@google.com, mflodman@webrtc.org, marpan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45899004 Cr-Commit-Position: refs/heads/master@{#8906}
This commit is contained in:
parent
1b1c15cad1
commit
9cb1f3002f
File diff suppressed because it is too large
Load Diff
@ -18,28 +18,26 @@
|
|||||||
#include "webrtc/modules/interface/module_common_types.h"
|
#include "webrtc/modules/interface/module_common_types.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
|
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
|
||||||
#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
|
#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
|
||||||
#include "webrtc/modules/video_coding/main/source/er_tables_xor.h"
|
|
||||||
#include "webrtc/modules/video_coding/main/source/fec_tables_xor.h"
|
#include "webrtc/modules/video_coding/main/source/fec_tables_xor.h"
|
||||||
#include "webrtc/modules/video_coding/main/source/nack_fec_tables.h"
|
#include "webrtc/modules/video_coding/main/source/nack_fec_tables.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
// Max value of loss rates in off-line model
|
||||||
|
static const int kPacketLossMax = 129;
|
||||||
|
|
||||||
namespace media_optimization {
|
namespace media_optimization {
|
||||||
|
|
||||||
VCMProtectionMethod::VCMProtectionMethod():
|
VCMProtectionMethod::VCMProtectionMethod()
|
||||||
_effectivePacketLoss(0),
|
: _effectivePacketLoss(0),
|
||||||
_protectionFactorK(0),
|
_protectionFactorK(0),
|
||||||
_protectionFactorD(0),
|
_protectionFactorD(0),
|
||||||
_residualPacketLossFec(0.0f),
|
_scaleProtKey(2.0f),
|
||||||
_scaleProtKey(2.0f),
|
_maxPayloadSize(1460),
|
||||||
_maxPayloadSize(1460),
|
_qmRobustness(new VCMQmRobustness()),
|
||||||
_qmRobustness(new VCMQmRobustness()),
|
_useUepProtectionK(false),
|
||||||
_useUepProtectionK(false),
|
_useUepProtectionD(true),
|
||||||
_useUepProtectionD(true),
|
_corrFecCost(1.0),
|
||||||
_corrFecCost(1.0),
|
_type(kNone) {
|
||||||
_type(kNone),
|
|
||||||
_efficiency(0)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VCMProtectionMethod::~VCMProtectionMethod()
|
VCMProtectionMethod::~VCMProtectionMethod()
|
||||||
@ -189,20 +187,6 @@ VCMNackFecMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
|||||||
_protectionFactorD = 0;
|
_protectionFactorD = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Efficiency computation is based on FEC and NACK
|
|
||||||
|
|
||||||
// Add FEC cost: ignore I frames for now
|
|
||||||
float fecRate = static_cast<float> (_protectionFactorD) / 255.0f;
|
|
||||||
_efficiency = parameters->bitRate * fecRate * _corrFecCost;
|
|
||||||
|
|
||||||
// Add NACK cost, when applicable
|
|
||||||
if (_highRttNackMs == -1 || parameters->rtt < _highRttNackMs)
|
|
||||||
{
|
|
||||||
// nackCost = (bitRate - nackCost) * (lossPr)
|
|
||||||
_efficiency += parameters->bitRate * _residualPacketLossFec /
|
|
||||||
(1.0f + _residualPacketLossFec);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Protection/fec rates obtained above are defined relative to total number
|
// Protection/fec rates obtained above are defined relative to total number
|
||||||
// of packets (total rate: source + fec) FEC in RTP module assumes
|
// of packets (total rate: source + fec) FEC in RTP module assumes
|
||||||
// protection factor is defined relative to source number of packets so we
|
// protection factor is defined relative to source number of packets so we
|
||||||
@ -240,8 +224,6 @@ VCMNackMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
|||||||
EffectivePacketLoss(parameters);
|
EffectivePacketLoss(parameters);
|
||||||
|
|
||||||
// nackCost = (bitRate - nackCost) * (lossPr)
|
// nackCost = (bitRate - nackCost) * (lossPr)
|
||||||
_efficiency = parameters->bitRate * parameters->lossPr /
|
|
||||||
(1.0f + parameters->lossPr);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,84 +275,6 @@ VCMFecMethod::UpdateProtectionFactorK(uint8_t protectionFactorK)
|
|||||||
_protectionFactorK = protectionFactorK;
|
_protectionFactorK = protectionFactorK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvgRecoveryFEC: computes the residual packet loss (RPL) 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.
|
|
||||||
float
|
|
||||||
VCMFecMethod::AvgRecoveryFEC(const VCMProtectionParameters* parameters) const
|
|
||||||
{
|
|
||||||
// Total (avg) bits available per frame: total rate over actual/sent frame
|
|
||||||
// rate units are kbits/frame
|
|
||||||
const uint16_t bitRatePerFrame = static_cast<uint16_t>
|
|
||||||
(parameters->bitRate / (parameters->frameRate));
|
|
||||||
|
|
||||||
// Total (average) number of packets per frame (source and fec):
|
|
||||||
const uint8_t avgTotPackets = 1 + static_cast<uint8_t>
|
|
||||||
(static_cast<float> (bitRatePerFrame * 1000.0) /
|
|
||||||
static_cast<float> (8.0 * _maxPayloadSize) + 0.5);
|
|
||||||
|
|
||||||
const float protectionFactor = static_cast<float>(_protectionFactorD) /
|
|
||||||
255.0;
|
|
||||||
|
|
||||||
// Round down for estimated #FEC packets/frame, to keep
|
|
||||||
// |fecPacketsPerFrame| <= |sourcePacketsPerFrame|.
|
|
||||||
uint8_t fecPacketsPerFrame = static_cast<uint8_t>
|
|
||||||
(protectionFactor * avgTotPackets);
|
|
||||||
|
|
||||||
uint8_t sourcePacketsPerFrame = avgTotPackets - fecPacketsPerFrame;
|
|
||||||
|
|
||||||
if ( (fecPacketsPerFrame == 0) || (sourcePacketsPerFrame == 0) )
|
|
||||||
{
|
|
||||||
// No protection, or rate too low: so average recovery from FEC == 0.
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Table defined up to kMaxNumPackets
|
|
||||||
if (sourcePacketsPerFrame > kMaxNumPackets)
|
|
||||||
{
|
|
||||||
sourcePacketsPerFrame = kMaxNumPackets;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Table defined up to kMaxNumPackets
|
|
||||||
if (fecPacketsPerFrame > kMaxNumPackets)
|
|
||||||
{
|
|
||||||
fecPacketsPerFrame = kMaxNumPackets;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Code index for tables: up to (kMaxNumPackets * kMaxNumPackets)
|
|
||||||
uint16_t codeIndexTable[kMaxNumPackets * kMaxNumPackets];
|
|
||||||
uint16_t k = 0;
|
|
||||||
for (uint8_t i = 1; i <= kMaxNumPackets; i++)
|
|
||||||
{
|
|
||||||
for (uint8_t j = 1; j <= i; j++)
|
|
||||||
{
|
|
||||||
codeIndexTable[(j - 1) * kMaxNumPackets + i - 1] = k;
|
|
||||||
k += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t lossRate = static_cast<uint8_t> (255.0 *
|
|
||||||
parameters->lossPr + 0.5f);
|
|
||||||
|
|
||||||
// Constrain lossRate to 50%: tables defined up to 50%
|
|
||||||
if (lossRate >= kPacketLossMax)
|
|
||||||
{
|
|
||||||
lossRate = kPacketLossMax - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint16_t codeIndex = (fecPacketsPerFrame - 1) * kMaxNumPackets +
|
|
||||||
(sourcePacketsPerFrame - 1);
|
|
||||||
|
|
||||||
const uint16_t indexTable = codeIndexTable[codeIndex] * kPacketLossMax +
|
|
||||||
lossRate;
|
|
||||||
|
|
||||||
// Check on table index
|
|
||||||
assert(indexTable < kSizeAvgFECRecoveryXOR);
|
|
||||||
float avgFecRecov = static_cast<float>(kAvgFECRecoveryXOR[indexTable]);
|
|
||||||
|
|
||||||
return avgFecRecov;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters)
|
VCMFecMethod::ProtectionFactor(const VCMProtectionParameters* parameters)
|
||||||
{
|
{
|
||||||
@ -589,14 +493,6 @@ VCMFecMethod::EffectivePacketLoss(const VCMProtectionParameters* parameters)
|
|||||||
// RPL = received/input packet loss - average_FEC_recovery
|
// RPL = received/input packet loss - average_FEC_recovery
|
||||||
// note: received/input packet loss may be filtered based on FilteredLoss
|
// note: received/input packet loss may be filtered based on FilteredLoss
|
||||||
|
|
||||||
// The packet loss:
|
|
||||||
uint8_t packetLoss = (uint8_t) (255 * parameters->lossPr);
|
|
||||||
|
|
||||||
float avgFecRecov = AvgRecoveryFEC(parameters);
|
|
||||||
|
|
||||||
// Residual Packet Loss:
|
|
||||||
_residualPacketLossFec = (float) (packetLoss - avgFecRecov) / 255.0f;
|
|
||||||
|
|
||||||
// Effective Packet Loss, NA in current version.
|
// Effective Packet Loss, NA in current version.
|
||||||
_effectivePacketLoss = 0;
|
_effectivePacketLoss = 0;
|
||||||
|
|
||||||
@ -612,25 +508,6 @@ VCMFecMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
|||||||
// Compute the effective packet loss
|
// Compute the effective packet loss
|
||||||
EffectivePacketLoss(parameters);
|
EffectivePacketLoss(parameters);
|
||||||
|
|
||||||
// Compute the bit cost
|
|
||||||
// Ignore key frames for now.
|
|
||||||
float fecRate = static_cast<float> (_protectionFactorD) / 255.0f;
|
|
||||||
if (fecRate >= 0.0f)
|
|
||||||
{
|
|
||||||
// use this formula if the fecRate (protection factor) is defined
|
|
||||||
// relative to number of source packets
|
|
||||||
// this is the case for the previous tables:
|
|
||||||
// _efficiency = parameters->bitRate * ( 1.0 - 1.0 / (1.0 + fecRate));
|
|
||||||
|
|
||||||
// in the new tables, the fecRate is defined relative to total number of
|
|
||||||
// packets (total rate), so overhead cost is:
|
|
||||||
_efficiency = parameters->bitRate * fecRate * _corrFecCost;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_efficiency = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Protection/fec rates obtained above is defined relative to total number
|
// Protection/fec rates obtained above is defined relative to total number
|
||||||
// of packets (total rate: source+fec) FEC in RTP module assumes protection
|
// of packets (total rate: source+fec) FEC in RTP module assumes protection
|
||||||
// factor is defined relative to source number of packets so we should
|
// factor is defined relative to source number of packets so we should
|
||||||
@ -657,7 +534,6 @@ _lossPrHistory(),
|
|||||||
_shortMaxLossPr255(0),
|
_shortMaxLossPr255(0),
|
||||||
_packetsPerFrame(0.9999f),
|
_packetsPerFrame(0.9999f),
|
||||||
_packetsPerFrameKey(0.9999f),
|
_packetsPerFrameKey(0.9999f),
|
||||||
_residualPacketLossFec(0),
|
|
||||||
_codecWidth(0),
|
_codecWidth(0),
|
||||||
_codecHeight(0),
|
_codecHeight(0),
|
||||||
_numLayers(1)
|
_numLayers(1)
|
||||||
@ -696,29 +572,12 @@ void VCMLossProtectionLogic::SetMethod(
|
|||||||
UpdateMethod();
|
UpdateMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
|
||||||
VCMLossProtectionLogic::RequiredBitRate() const
|
|
||||||
{
|
|
||||||
float RequiredBitRate = 0.0f;
|
|
||||||
if (_selectedMethod != NULL)
|
|
||||||
{
|
|
||||||
RequiredBitRate = _selectedMethod->RequiredBitRate();
|
|
||||||
}
|
|
||||||
return RequiredBitRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VCMLossProtectionLogic::UpdateRtt(int64_t rtt)
|
VCMLossProtectionLogic::UpdateRtt(int64_t rtt)
|
||||||
{
|
{
|
||||||
_rtt = rtt;
|
_rtt = rtt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
VCMLossProtectionLogic::UpdateResidualPacketLoss(float residualPacketLoss)
|
|
||||||
{
|
|
||||||
_residualPacketLossFec = residualPacketLoss;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VCMLossProtectionLogic::UpdateMaxLossHistory(uint8_t lossPr255,
|
VCMLossProtectionLogic::UpdateMaxLossHistory(uint8_t lossPr255,
|
||||||
int64_t now)
|
int64_t now)
|
||||||
@ -880,7 +739,6 @@ VCMLossProtectionLogic::UpdateMethod()
|
|||||||
_currentParameters.fecRateKey = _fecRateKey;
|
_currentParameters.fecRateKey = _fecRateKey;
|
||||||
_currentParameters.packetsPerFrame = _packetsPerFrame.filtered();
|
_currentParameters.packetsPerFrame = _packetsPerFrame.filtered();
|
||||||
_currentParameters.packetsPerFrameKey = _packetsPerFrameKey.filtered();
|
_currentParameters.packetsPerFrameKey = _packetsPerFrameKey.filtered();
|
||||||
_currentParameters.residualPacketLossFec = _residualPacketLossFec;
|
|
||||||
_currentParameters.codecWidth = _codecWidth;
|
_currentParameters.codecWidth = _codecWidth;
|
||||||
_currentParameters.codecHeight = _codecHeight;
|
_currentParameters.codecHeight = _codecHeight;
|
||||||
_currentParameters.numLayers = _numLayers;
|
_currentParameters.numLayers = _numLayers;
|
||||||
|
@ -48,7 +48,7 @@ struct VCMProtectionParameters
|
|||||||
VCMProtectionParameters() : rtt(0), lossPr(0.0f), bitRate(0.0f),
|
VCMProtectionParameters() : rtt(0), lossPr(0.0f), bitRate(0.0f),
|
||||||
packetsPerFrame(0.0f), packetsPerFrameKey(0.0f), frameRate(0.0f),
|
packetsPerFrame(0.0f), packetsPerFrameKey(0.0f), frameRate(0.0f),
|
||||||
keyFrameSize(0.0f), fecRateDelta(0), fecRateKey(0),
|
keyFrameSize(0.0f), fecRateDelta(0), fecRateKey(0),
|
||||||
residualPacketLossFec(0.0f), codecWidth(0), codecHeight(0),
|
codecWidth(0), codecHeight(0),
|
||||||
numLayers(1)
|
numLayers(1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -61,7 +61,6 @@ struct VCMProtectionParameters
|
|||||||
float keyFrameSize;
|
float keyFrameSize;
|
||||||
uint8_t fecRateDelta;
|
uint8_t fecRateDelta;
|
||||||
uint8_t fecRateKey;
|
uint8_t fecRateKey;
|
||||||
float residualPacketLossFec;
|
|
||||||
uint16_t codecWidth;
|
uint16_t codecWidth;
|
||||||
uint16_t codecHeight;
|
uint16_t codecHeight;
|
||||||
int numLayers;
|
int numLayers;
|
||||||
@ -110,12 +109,6 @@ public:
|
|||||||
// Return value : The protection type
|
// Return value : The protection type
|
||||||
enum VCMProtectionMethodEnum Type() const { return _type; }
|
enum VCMProtectionMethodEnum Type() const { return _type; }
|
||||||
|
|
||||||
// Returns the bit rate required by this protection method
|
|
||||||
// during these conditions.
|
|
||||||
//
|
|
||||||
// Return value : Required bit rate
|
|
||||||
virtual float RequiredBitRate() { return _efficiency; }
|
|
||||||
|
|
||||||
// Returns the effective packet loss for ER, required by this protection method
|
// Returns the effective packet loss for ER, required by this protection method
|
||||||
//
|
//
|
||||||
// Return value : Required effective packet loss
|
// Return value : Required effective packet loss
|
||||||
@ -152,7 +145,6 @@ protected:
|
|||||||
uint8_t _protectionFactorK;
|
uint8_t _protectionFactorK;
|
||||||
uint8_t _protectionFactorD;
|
uint8_t _protectionFactorD;
|
||||||
// Estimation of residual loss after the FEC
|
// Estimation of residual loss after the FEC
|
||||||
float _residualPacketLossFec;
|
|
||||||
float _scaleProtKey;
|
float _scaleProtKey;
|
||||||
int32_t _maxPayloadSize;
|
int32_t _maxPayloadSize;
|
||||||
|
|
||||||
@ -161,7 +153,6 @@ protected:
|
|||||||
bool _useUepProtectionD;
|
bool _useUepProtectionD;
|
||||||
float _corrFecCost;
|
float _corrFecCost;
|
||||||
enum VCMProtectionMethodEnum _type;
|
enum VCMProtectionMethodEnum _type;
|
||||||
float _efficiency;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VCMNackMethod : public VCMProtectionMethod
|
class VCMNackMethod : public VCMProtectionMethod
|
||||||
@ -247,22 +238,12 @@ public:
|
|||||||
// is already set, it will be deleted and replaced
|
// is already set, it will be deleted and replaced
|
||||||
void SetMethod(VCMProtectionMethodEnum newMethodType);
|
void SetMethod(VCMProtectionMethodEnum newMethodType);
|
||||||
|
|
||||||
// Return required bit rate per selected protectin method
|
|
||||||
float RequiredBitRate() const;
|
|
||||||
|
|
||||||
// Update the round-trip time
|
// Update the round-trip time
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - rtt : Round-trip time in seconds.
|
// - rtt : Round-trip time in seconds.
|
||||||
void UpdateRtt(int64_t rtt);
|
void UpdateRtt(int64_t rtt);
|
||||||
|
|
||||||
// Update residual packet loss
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - residualPacketLoss : residual packet loss:
|
|
||||||
// effective loss after FEC recovery
|
|
||||||
void UpdateResidualPacketLoss(float _residualPacketLoss);
|
|
||||||
|
|
||||||
// Update the filtered packet loss.
|
// Update the filtered packet loss.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
@ -371,7 +352,6 @@ private:
|
|||||||
uint8_t _shortMaxLossPr255;
|
uint8_t _shortMaxLossPr255;
|
||||||
rtc::ExpFilter _packetsPerFrame;
|
rtc::ExpFilter _packetsPerFrame;
|
||||||
rtc::ExpFilter _packetsPerFrameKey;
|
rtc::ExpFilter _packetsPerFrameKey;
|
||||||
float _residualPacketLossFec;
|
|
||||||
uint16_t _codecWidth;
|
uint16_t _codecWidth;
|
||||||
uint16_t _codecHeight;
|
uint16_t _codecHeight;
|
||||||
int _numLayers;
|
int _numLayers;
|
||||||
|
@ -214,7 +214,6 @@ uint32_t MediaOptimization::SetTargetRates(
|
|||||||
float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
|
float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
|
||||||
loss_prot_logic_->UpdateBitRate(target_bitrate_kbps);
|
loss_prot_logic_->UpdateBitRate(target_bitrate_kbps);
|
||||||
loss_prot_logic_->UpdateRtt(round_trip_time_ms);
|
loss_prot_logic_->UpdateRtt(round_trip_time_ms);
|
||||||
loss_prot_logic_->UpdateResidualPacketLoss(static_cast<float>(fraction_lost));
|
|
||||||
|
|
||||||
// Get frame rate for encoder: this is the actual/sent frame rate.
|
// Get frame rate for encoder: this is the actual/sent frame rate.
|
||||||
float actual_frame_rate = SentFrameRateInternal();
|
float actual_frame_rate = SentFrameRateInternal();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user