peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_ |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "api/array_view.h" |
| 17 | #include "modules/audio_processing/aec3/aec3_common.h" |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
Per Åhgren | ce202a0 | 2019-09-02 17:01:19 +0200 | [diff] [blame] | 21 | // Class for producing frames consisting of 2 subframes of 80 samples each |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 22 | // from 64 sample blocks. The class is designed to work together with the |
| 23 | // FrameBlocker class which performs the reverse conversion. Used together with |
| 24 | // that, this class produces output frames are the same rate as frames are |
| 25 | // received by the FrameBlocker class. Note that the internal buffers will |
| 26 | // overrun if any other rate of packets insertion is used. |
| 27 | class BlockFramer { |
| 28 | public: |
Per Åhgren | ce202a0 | 2019-09-02 17:01:19 +0200 | [diff] [blame] | 29 | BlockFramer(size_t num_bands, size_t num_channels); |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 30 | ~BlockFramer(); |
Per Åhgren | ce202a0 | 2019-09-02 17:01:19 +0200 | [diff] [blame] | 31 | BlockFramer(const BlockFramer&) = delete; |
| 32 | BlockFramer& operator=(const BlockFramer&) = delete; |
| 33 | |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 34 | // Adds a 64 sample block into the data that will form the next output frame. |
Per Åhgren | ce202a0 | 2019-09-02 17:01:19 +0200 | [diff] [blame] | 35 | void InsertBlock(const std::vector<std::vector<std::vector<float>>>& block); |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 36 | // Adds a 64 sample block and extracts an 80 sample subframe. |
| 37 | void InsertBlockAndExtractSubFrame( |
Per Åhgren | ce202a0 | 2019-09-02 17:01:19 +0200 | [diff] [blame] | 38 | const std::vector<std::vector<std::vector<float>>>& block, |
| 39 | std::vector<std::vector<rtc::ArrayView<float>>>* sub_frame); |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 40 | |
| 41 | private: |
| 42 | const size_t num_bands_; |
Per Åhgren | ce202a0 | 2019-09-02 17:01:19 +0200 | [diff] [blame] | 43 | const size_t num_channels_; |
| 44 | std::vector<std::vector<std::vector<float>>> buffer_; |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 45 | }; |
| 46 | } // namespace webrtc |
| 47 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 48 | #endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_ |