blob: 623c812157b96bfdb5a1ea2b5be3f474c7307c17 [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"
Gustaf Ullbergd3ead1a2022-05-23 10:39:53 +020020#include "modules/audio_processing/aec3/block.h"
peahd0263542017-01-03 04:20:34 -080021
22namespace webrtc {
23
Per Åhgrence202a02019-09-02 17:01:19 +020024// Class for producing 64 sample multiband blocks from frames consisting of 2
25// subframes of 80 samples.
peahd0263542017-01-03 04:20:34 -080026class FrameBlocker {
27 public:
Per Åhgrence202a02019-09-02 17:01:19 +020028 FrameBlocker(size_t num_bands, size_t num_channels);
peahd0263542017-01-03 04:20:34 -080029 ~FrameBlocker();
Per Åhgrence202a02019-09-02 17:01:19 +020030 FrameBlocker(const FrameBlocker&) = delete;
31 FrameBlocker& operator=(const FrameBlocker&) = delete;
32
peahd0263542017-01-03 04:20:34 -080033 // Inserts one 80 sample multiband subframe from the multiband frame and
34 // extracts one 64 sample multiband block.
35 void InsertSubFrameAndExtractBlock(
Per Åhgrence202a02019-09-02 17:01:19 +020036 const std::vector<std::vector<rtc::ArrayView<float>>>& sub_frame,
Gustaf Ullbergd3ead1a2022-05-23 10:39:53 +020037 Block* block);
peahd0263542017-01-03 04:20:34 -080038 // Reports whether a multiband block of 64 samples is available for
39 // extraction.
40 bool IsBlockAvailable() const;
41 // Extracts a multiband block of 64 samples.
Gustaf Ullbergd3ead1a2022-05-23 10:39:53 +020042 void ExtractBlock(Block* block);
peahd0263542017-01-03 04:20:34 -080043
44 private:
45 const size_t num_bands_;
Per Åhgrence202a02019-09-02 17:01:19 +020046 const size_t num_channels_;
47 std::vector<std::vector<std::vector<float>>> buffer_;
peahd0263542017-01-03 04:20:34 -080048};
49} // namespace webrtc
50
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020051#endif // MODULES_AUDIO_PROCESSING_AEC3_FRAME_BLOCKER_H_