block_framer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2016 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_AEC3_BLOCK_FRAMER_H_
  11. #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_
  12. #include <vector>
  13. #include "api/array_view.h"
  14. #include "modules/audio_processing/aec3/aec3_common.h"
  15. namespace webrtc {
  16. // Class for producing frames consisting of 2 subframes of 80 samples each
  17. // from 64 sample blocks. The class is designed to work together with the
  18. // FrameBlocker class which performs the reverse conversion. Used together with
  19. // that, this class produces output frames are the same rate as frames are
  20. // received by the FrameBlocker class. Note that the internal buffers will
  21. // overrun if any other rate of packets insertion is used.
  22. class BlockFramer {
  23. public:
  24. BlockFramer(size_t num_bands, size_t num_channels);
  25. ~BlockFramer();
  26. BlockFramer(const BlockFramer&) = delete;
  27. BlockFramer& operator=(const BlockFramer&) = delete;
  28. // Adds a 64 sample block into the data that will form the next output frame.
  29. void InsertBlock(const std::vector<std::vector<std::vector<float>>>& block);
  30. // Adds a 64 sample block and extracts an 80 sample subframe.
  31. void InsertBlockAndExtractSubFrame(
  32. const std::vector<std::vector<std::vector<float>>>& block,
  33. std::vector<std::vector<rtc::ArrayView<float>>>* sub_frame);
  34. private:
  35. const size_t num_bands_;
  36. const size_t num_channels_;
  37. std::vector<std::vector<std::vector<float>>> buffer_;
  38. };
  39. } // namespace webrtc
  40. #endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_