Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Unified Diff: webrtc/modules/audio_processing/rms_level.cc

Issue 2534473004: Add a new UMA metric in APM to track incoming capture-side audio level (Closed)
Patch Set: Rebase to upstream CL Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/rms_level.cc
diff --git a/webrtc/modules/audio_processing/rms_level.cc b/webrtc/modules/audio_processing/rms_level.cc
index f77357a0006d9d8fcaa5ba5c277f3220330ba73f..8a77b3f7d9494788845c52916755ec18b67d64ff 100644
--- a/webrtc/modules/audio_processing/rms_level.cc
+++ b/webrtc/modules/audio_processing/rms_level.cc
@@ -19,7 +19,6 @@
namespace webrtc {
namespace {
static constexpr float kMaxSquaredLevel = 32768 * 32768;
-static constexpr int kMinLevelDb = 127;
// kMinLevel is the level corresponding to kMinLevelDb, that is 10^(-127/10).
static constexpr float kMinLevel = 1.995262314968883e-13f;
@@ -31,7 +30,7 @@ static constexpr float kMinLevel = 1.995262314968883e-13f;
int ComputeRms(float mean_square) {
if (mean_square <= kMinLevel * kMaxSquaredLevel) {
// Very faint; simply return the minimum value.
- return kMinLevelDb;
+ return RmsLevel::kMinLevelDb;
}
// Normalize by the max level.
const float mean_square_norm = mean_square / kMaxSquaredLevel;
@@ -39,7 +38,7 @@ int ComputeRms(float mean_square) {
// 20log_10(x^0.5) = 10log_10(x)
const float rms = 10.f * log10(mean_square_norm);
RTC_DCHECK_LE(rms, 0.f);
- RTC_DCHECK_GT(rms, -kMinLevelDb);
+ RTC_DCHECK_GT(rms, -RmsLevel::kMinLevelDb);
// Return the negated value.
return static_cast<int>(-rms + 0.5f);
}
@@ -81,7 +80,7 @@ void RmsLevel::AnalyzeMuted(size_t length) {
}
int RmsLevel::Average() {
- int rms = (sample_count_ == 0) ? kMinLevelDb
+ int rms = (sample_count_ == 0) ? RmsLevel::kMinLevelDb
: ComputeRms(sum_square_ / sample_count_);
Reset();
return rms;
@@ -92,7 +91,7 @@ RmsLevel::Levels RmsLevel::AverageAndPeak() {
// sample_count_ != 0. Also, the * operator of rtc::Optional enforces this
// with a DCHECK.
Levels levels = (sample_count_ == 0)
- ? Levels{kMinLevelDb, kMinLevelDb}
+ ? Levels{RmsLevel::kMinLevelDb, RmsLevel::kMinLevelDb}
: Levels{ComputeRms(sum_square_ / sample_count_),
ComputeRms(max_sum_square_ / *block_size_)};
Reset();
« webrtc/modules/audio_processing/rms_level.h ('K') | « webrtc/modules/audio_processing/rms_level.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698