Reland of VCMCodecTimer: Change filter from max to 95th percentile (patchset #1 id:1 of https://codereview.webrtc.org/1808693002/ )
This CL is expected to lower goog_max_decode_ms and total_delay_incl_network/receiver_time for screenshare.
Reason for revert:
This CL did not cause the unexpected goog_encode_usage_percent and goog_avg_encode_ms perf changes.
Original issue's description:
> Revert of VCMCodecTimer: Change filter from max to 95th percentile (patchset #5 id:180001 of https://codereview.webrtc.org/1742323002/ )
>
> Reason for revert:
> Caused unexpected perf stats changes, see http://crbug/594575.
>
> Original issue's description:
> > VCMCodecTimer: Change filter from max to 95th percentile
> >
> > The purpose with this change is to make the filter more robust against anomalies. googMaxDecodeMs is expected to drop a litte by this.
> >
> > BUG=b/27306053
> >
> > Committed: https://crrev.com/4bf0c717740d1834e810ea5f32b3c4306c64235f
> > Cr-Commit-Position: refs/heads/master@{#11952}
>
> TBR=stefan@webrtc.org,philipel@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=594575,b/27306053
>
> Committed: https://crrev.com/c4a74e95b545f4752d4e72961ac03c1380d4bc1f
> Cr-Commit-Position: refs/heads/master@{#12018}
TBR=stefan@webrtc.org,philipel@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=594575,b/27306053
Review URL: https://codereview.webrtc.org/1824763003
Cr-Commit-Position: refs/heads/master@{#12087}
diff --git a/webrtc/modules/video_coding/timing.cc b/webrtc/modules/video_coding/timing.cc
index 680860a..91f5f84 100644
--- a/webrtc/modules/video_coding/timing.cc
+++ b/webrtc/modules/video_coding/timing.cc
@@ -25,7 +25,7 @@
clock_(clock),
master_(false),
ts_extrapolator_(),
- codec_timer_(),
+ codec_timer_(new VCMCodecTimer()),
render_delay_ms_(kDefaultRenderDelayMs),
min_playout_delay_ms_(0),
jitter_delay_ms_(0),
@@ -78,7 +78,7 @@
void VCMTiming::Reset() {
CriticalSectionScoped cs(crit_sect_);
ts_extrapolator_->Reset(clock_->TimeInMilliseconds());
- codec_timer_.Reset();
+ codec_timer_.reset(new VCMCodecTimer());
render_delay_ms_ = kDefaultRenderDelayMs;
min_playout_delay_ms_ = 0;
jitter_delay_ms_ = 0;
@@ -88,7 +88,7 @@
void VCMTiming::ResetDecodeTime() {
CriticalSectionScoped lock(crit_sect_);
- codec_timer_.Reset();
+ codec_timer_.reset(new VCMCodecTimer());
}
void VCMTiming::set_render_delay(uint32_t render_delay_ms) {
@@ -156,8 +156,9 @@
int64_t actual_decode_time_ms) {
CriticalSectionScoped cs(crit_sect_);
uint32_t target_delay_ms = TargetDelayInternal();
- int64_t delayed_ms = actual_decode_time_ms -
- (render_time_ms - MaxDecodeTimeMs() - render_delay_ms_);
+ int64_t delayed_ms =
+ actual_decode_time_ms -
+ (render_time_ms - RequiredDecodeTimeMs() - render_delay_ms_);
if (delayed_ms < 0) {
return;
}
@@ -173,7 +174,7 @@
int64_t now_ms,
int64_t render_time_ms) {
CriticalSectionScoped cs(crit_sect_);
- codec_timer_.MaxFilter(decode_time_ms, now_ms);
+ codec_timer_->AddTiming(decode_time_ms, now_ms);
assert(decode_time_ms >= 0);
last_decode_ms_ = decode_time_ms;
@@ -216,9 +217,8 @@
}
// Must be called from inside a critical section.
-int32_t VCMTiming::MaxDecodeTimeMs(
- FrameType frame_type /*= kVideoFrameDelta*/) const {
- const int32_t decode_time_ms = codec_timer_.RequiredDecodeTimeMs(frame_type);
+int64_t VCMTiming::RequiredDecodeTimeMs() const {
+ const int64_t decode_time_ms = codec_timer_->RequiredDecodeTimeMs();
assert(decode_time_ms >= 0);
return decode_time_ms;
}
@@ -228,7 +228,7 @@
CriticalSectionScoped cs(crit_sect_);
const int64_t max_wait_time_ms =
- render_time_ms - now_ms - MaxDecodeTimeMs() - render_delay_ms_;
+ render_time_ms - now_ms - RequiredDecodeTimeMs() - render_delay_ms_;
if (max_wait_time_ms < 0) {
return 0;
@@ -239,18 +239,18 @@
bool VCMTiming::EnoughTimeToDecode(
uint32_t available_processing_time_ms) const {
CriticalSectionScoped cs(crit_sect_);
- int32_t max_decode_time_ms = MaxDecodeTimeMs();
- if (max_decode_time_ms < 0) {
+ int64_t required_decode_time_ms = RequiredDecodeTimeMs();
+ if (required_decode_time_ms < 0) {
// Haven't decoded any frames yet, try decoding one to get an estimate
// of the decode time.
return true;
- } else if (max_decode_time_ms == 0) {
+ } else if (required_decode_time_ms == 0) {
// Decode time is less than 1, set to 1 for now since
// we don't have any better precision. Count ticks later?
- max_decode_time_ms = 1;
+ required_decode_time_ms = 1;
}
- return static_cast<int32_t>(available_processing_time_ms) -
- max_decode_time_ms >
+ return static_cast<int64_t>(available_processing_time_ms) -
+ required_decode_time_ms >
0;
}
@@ -261,7 +261,9 @@
uint32_t VCMTiming::TargetDelayInternal() const {
return std::max(min_playout_delay_ms_,
- jitter_delay_ms_ + MaxDecodeTimeMs() + render_delay_ms_);
+ jitter_delay_ms_ +
+ static_cast<uint32_t>(RequiredDecodeTimeMs()) +
+ render_delay_ms_);
}
void VCMTiming::GetTimings(int* decode_ms,
@@ -273,7 +275,7 @@
int* render_delay_ms) const {
CriticalSectionScoped cs(crit_sect_);
*decode_ms = last_decode_ms_;
- *max_decode_ms = MaxDecodeTimeMs();
+ *max_decode_ms = static_cast<int>(RequiredDecodeTimeMs());
*current_delay_ms = current_delay_ms_;
*target_delay_ms = TargetDelayInternal();
*jitter_buffer_ms = jitter_delay_ms_;