summaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_processing/transient/wpd_tree.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/modules/audio_processing/transient/wpd_tree.cc')
-rw-r--r--webrtc/modules/audio_processing/transient/wpd_tree.cc33
1 files changed, 16 insertions, 17 deletions
diff --git a/webrtc/modules/audio_processing/transient/wpd_tree.cc b/webrtc/modules/audio_processing/transient/wpd_tree.cc
index 40a37a0..c8aa615 100644
--- a/webrtc/modules/audio_processing/transient/wpd_tree.cc
+++ b/webrtc/modules/audio_processing/transient/wpd_tree.cc
@@ -8,31 +8,30 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
+#include "modules/audio_processing/transient/wpd_tree.h"
-#include <assert.h>
-#include <math.h>
#include <string.h>
-#include "webrtc/base/scoped_ptr.h"
-#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
-#include "webrtc/modules/audio_processing/transient/wpd_node.h"
+#include "modules/audio_processing/transient/wpd_node.h"
+#include "rtc_base/checks.h"
namespace webrtc {
-WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
- const float* low_pass_coefficients, size_t coefficients_length,
+WPDTree::WPDTree(size_t data_length,
+ const float* high_pass_coefficients,
+ const float* low_pass_coefficients,
+ size_t coefficients_length,
int levels)
: data_length_(data_length),
levels_(levels),
num_nodes_((1 << (levels + 1)) - 1) {
- assert(data_length > (static_cast<size_t>(1) << levels) &&
- high_pass_coefficients &&
- low_pass_coefficients &&
- levels > 0);
+ RTC_DCHECK_GT(data_length, (static_cast<size_t>(1) << levels));
+ RTC_DCHECK(high_pass_coefficients);
+ RTC_DCHECK(low_pass_coefficients);
+ RTC_DCHECK_GT(levels, 0);
// Size is 1 more, so we can use the array as 1-based. nodes_[0] is never
// allocated.
- nodes_.reset(new rtc::scoped_ptr<WPDNode>[num_nodes_ + 1]);
+ nodes_.reset(new std::unique_ptr<WPDNode>[num_nodes_ + 1]);
// Create the first node
const float kRootCoefficient = 1.f; // Identity Coefficient.
@@ -66,10 +65,10 @@ WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
WPDTree::~WPDTree() {}
WPDNode* WPDTree::NodeAt(int level, int index) {
- const int kNumNodesAtLevel = 1 << level;
- if (level < 0 || level > levels_ || index < 0 || index >= kNumNodesAtLevel) {
+ if (level < 0 || level > levels_ || index < 0 || index >= 1 << level) {
return NULL;
}
+
return nodes_[(1 << level) + index].get();
}
@@ -99,8 +98,8 @@ int WPDTree::Update(const float* data, size_t data_length) {
index_left_child = index * 2;
index_right_child = index_left_child + 1;
- update_result = nodes_[index_left_child]->Update(
- nodes_[index]->data(), nodes_[index]->length());
+ update_result = nodes_[index_left_child]->Update(nodes_[index]->data(),
+ nodes_[index]->length());
if (update_result != 0) {
return -1;
}