blob: ebd6f776f1210bc6d7e60607747841a7fc9b0b99 [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_FRAME_BLOCKER_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_FRAME_BLOCKER_H_
peahd0263542017-01-03 04:20:34 -080013
14#include <stddef.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
peahd0263542017-01-03 04:20:34 -080016#include <vector>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/array_view.h"
19#include "modules/audio_processing/aec3/aec3_common.h"
peahd0263542017-01-03 04:20:34 -080020
21namespace webrtc {
22
Per Åhgrence202a02019-09-02 17:01:19 +020023// Class for producing 64 sample multiband blocks from frames consisting of 2
24// subframes of 80 samples.
peahd0263542017-01-03 04:20:34 -080025class FrameBlocker {
26 public:
Per Åhgrence202a02019-09-02 17:01:19 +020027 FrameBlocker(size_t num_bands, size_t num_channels);
peahd0263542017-01-03 04:20:34 -080028 ~FrameBlocker();
Per Åhgrence202a02019-09-02 17:01:19 +020029 FrameBlocker(const FrameBlocker&) = delete;
30 FrameBlocker& operator=(const FrameBlocker&) = delete;
31
peahd0263542017-01-03 04:20:34 -080032 // Inserts one 80 sample multiband subframe from the multiband frame and
33 // extracts one 64 sample multiband block.
34 void InsertSubFrameAndExtractBlock(
Per Åhgrence202a02019-09-02 17:01:19 +020035 const std::vector<std::vector<rtc::ArrayView<float>>>& sub_frame,
36 std::vector<std::vector<std::vector<float>>>* block);
peahd0263542017-01-03 04:20:34 -080037 // Reports whether a multiband block of 64 samples is available for
38 // extraction.
39 bool IsBlockAvailable() const;
40 // Extracts a multiband block of 64 samples.
Per Åhgrence202a02019-09-02 17:01:19 +020041 void ExtractBlock(std::vector<std::vector<std::vector<float>>>* block);
peahd0263542017-01-03 04:20:34 -080042
43 private:
44 const size_t num_bands_;
Per Åhgrence202a02019-09-02 17:01:19 +020045 const size_t num_channels_;
46 std::vector<std::vector<std::vector<float>>> buffer_;
peahd0263542017-01-03 04:20:34 -080047};
48} // namespace webrtc
49
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020050#endif // MODULES_AUDIO_PROCESSING_AEC3_FRAME_BLOCKER_H_