blob: 923e4cfb53d741899272ec044cdab07c7b905dd1 [file] [log] [blame]
peahd0263542017-01-03 04:20:34 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_
peahd0263542017-01-03 04:20:34 -080013
14#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/array_view.h"
17#include "modules/audio_processing/aec3/aec3_common.h"
18#include "rtc_base/constructormagic.h"
peahd0263542017-01-03 04:20:34 -080019
20namespace webrtc {
21
22// Class for producing frames consisting of 1 or 2 subframes of 80 samples each
23// from 64 sample blocks. The class is designed to work together with the
24// FrameBlocker class which performs the reverse conversion. Used together with
25// that, this class produces output frames are the same rate as frames are
26// received by the FrameBlocker class. Note that the internal buffers will
27// overrun if any other rate of packets insertion is used.
28class BlockFramer {
29 public:
30 explicit BlockFramer(size_t num_bands);
31 ~BlockFramer();
32 // Adds a 64 sample block into the data that will form the next output frame.
33 void InsertBlock(const std::vector<std::vector<float>>& block);
34 // Adds a 64 sample block and extracts an 80 sample subframe.
35 void InsertBlockAndExtractSubFrame(
36 const std::vector<std::vector<float>>& block,
37 std::vector<rtc::ArrayView<float>>* sub_frame);
38
39 private:
40 const size_t num_bands_;
41 std::vector<std::vector<float>> buffer_;
42
43 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(BlockFramer);
44};
45} // namespace webrtc
46
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020047#endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_FRAMER_H_