From faf89d4ed191f71378840a67292d6c269e2c0a3d Mon Sep 17 00:00:00 2001 From: Frank Galligan Date: Fri, 29 Apr 2016 16:01:34 -0700 Subject: [PATCH] Add MaxLumaSampleRate grace percent to stats. BUG=https://bugs.chromium.org/p/webm/issues/detail?id=1206 Change-Id: I29a956871bd5aa0c7b493601ed23b44a08414d32 --- common/vp9_level_stats.cc | 5 ++++- common/vp9_level_stats.h | 16 +++++++++++++++- webm_info.cc | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common/vp9_level_stats.cc b/common/vp9_level_stats.cc index 79ef967..f9bd53a 100644 --- a/common/vp9_level_stats.cc +++ b/common/vp9_level_stats.cc @@ -132,8 +132,11 @@ Vp9Level Vp9LevelStats::GetLevel() const { int level_index = 0; Vp9Level max_level = LEVEL_UNKNOWN; + const double grace_multiplier = + max_luma_sample_rate_grace_percent_ / 100.0 + 1.0; for (int i = 0; i < kNumVp9Levels; ++i) { - if (max_luma_sample_rate <= Vp9LevelTable[i].max_luma_sample_rate) { + if (max_luma_sample_rate <= + Vp9LevelTable[i].max_luma_sample_rate * grace_multiplier) { if (max_level < Vp9LevelTable[i].level) { max_level = Vp9LevelTable[i].level; level_index = i; diff --git a/common/vp9_level_stats.h b/common/vp9_level_stats.h index 143dc44..bc8c534 100644 --- a/common/vp9_level_stats.h +++ b/common/vp9_level_stats.h @@ -73,6 +73,7 @@ class Vp9LevelStats { current_luma_size_(0), max_luma_size_(0), max_luma_end_ns_(0), + max_luma_sample_rate_grace_percent_(1.5), first_altref(true), frames_since_last_altref(0), minimum_altref_distance(std::numeric_limits::max()), @@ -135,7 +136,12 @@ class Vp9LevelStats { // not explictly set by this function then this class will use end - start // as the duration. void set_duration(int64_t time_ns) { duration_ns_ = time_ns; } - + double max_luma_sample_rate_grace_percent() const { + return max_luma_sample_rate_grace_percent_; + } + void set_max_luma_sample_rate_grace_percent(double percent) { + max_luma_sample_rate_grace_percent_ = percent; + } bool estimate_last_frame_duration() const { return estimate_last_frame_duration_; } @@ -164,6 +170,14 @@ class Vp9LevelStats { int64_t max_luma_size_; int64_t max_luma_end_ns_; + // MaxLumaSampleRate = (ExampleFrameRate + ExampleFrameRate / + // MinimumAltrefDistance) * MaxLumaPictureSize. For levels 1-4 + // ExampleFrameRate / MinimumAltrefDistance is non-integer, so using a sliding + // window of one frame to calculate MaxLumaSampleRate may have frames > + // (ExampleFrameRate + ExampleFrameRate / MinimumAltrefDistance) in the + // window. In order to address this issue, a grace percent of 1.5 was added. + double max_luma_sample_rate_grace_percent_; + bool first_altref; int frames_since_last_altref; int minimum_altref_distance; diff --git a/webm_info.cc b/webm_info.cc index 0b991c6..424553a 100644 --- a/webm_info.cc +++ b/webm_info.cc @@ -35,7 +35,7 @@ using libwebm::Indent; using libwebm::kNanosecondsPerSecond; using libwebm::kNanosecondsPerSecondi; -const char VERSION_STRING[] = "1.0.4.3"; +const char VERSION_STRING[] = "1.0.4.4"; struct Options { Options();