wpd_node.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
  11. #define MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
  12. #include <memory>
  13. namespace webrtc {
  14. class FIRFilter;
  15. // A single node of a Wavelet Packet Decomposition (WPD) tree.
  16. class WPDNode {
  17. public:
  18. // Creates a WPDNode. The data vector will contain zeros. The filter will have
  19. // the coefficients provided.
  20. WPDNode(size_t length, const float* coefficients, size_t coefficients_length);
  21. ~WPDNode();
  22. // Updates the node data. |parent_data| / 2 must be equals to |length_|.
  23. // Returns 0 if correct, and -1 otherwise.
  24. int Update(const float* parent_data, size_t parent_data_length);
  25. const float* data() const { return data_.get(); }
  26. // Returns 0 if correct, and -1 otherwise.
  27. int set_data(const float* new_data, size_t length);
  28. size_t length() const { return length_; }
  29. private:
  30. std::unique_ptr<float[]> data_;
  31. size_t length_;
  32. std::unique_ptr<FIRFilter> filter_;
  33. };
  34. } // namespace webrtc
  35. #endif // MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_