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

Unified Diff: webrtc/modules/audio_processing/utility/block_fraction_calculator.h

Issue 1739993003: Adding fraction of filter divergence in AEC metrics. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: adding block_fraction_calculator and more Created 4 years, 8 months 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/utility/block_fraction_calculator.h
diff --git a/webrtc/modules/audio_processing/utility/block_fraction_calculator.h b/webrtc/modules/audio_processing/utility/block_fraction_calculator.h
new file mode 100644
index 0000000000000000000000000000000000000000..27f2717398558f00bab0293cf23dedaaa282a15a
--- /dev/null
+++ b/webrtc/modules/audio_processing/utility/block_fraction_calculator.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_BLOCK_FRACTION_CALCULATOR_H_
+#define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_BLOCK_FRACTION_CALCULATOR_H_
+
+#include <stddef.h>
+
+#include "webrtc/base/constructormagic.h"
+
+namespace webrtc {
+
+// BlockFractionCalculator calculates the fraction of the occurrence of an event
+// in a block. The fraction is updated at the end of every block.
+class BlockFractionCalculator {
peah-webrtc 2016/04/06 11:01:10 Please make this local toaec_core.cc instead.
peah-webrtc 2016/04/06 11:01:10 I think it is better if you name the class in a mo
minyue-webrtc 2016/04/06 13:35:37 ok
+ public:
+ explicit BlockFractionCalculator(size_t block_length);
+
+ // Reset.
+ void Reset();
+
+ // Add one observation. |occurred| is true if the event of interest happened,
+ // false otherwise.
+ void AddObservation(bool occurred);
+
+ // Return the latest fraction.
+ float GetLatestFraction() const;
+
+ private:
+ // Clear all values added.
+ void Clear();
+
+ const size_t block_length_;
+ size_t count_;
+ size_t occurrence_;
+ float fraction_;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(BlockFractionCalculator);
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_BLOCK_FRACTION_CALCULATOR_H_

Powered by Google App Engine
This is Rietveld 408576698