1/*
2 * Copyrightm (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __ECHO_SUPPRESSOR_H__
18#define __ECHO_SUPPRESSOR_H__
19
20#include <stdint.h>
21
22class EchoSuppressor
23{
24public:
25    // The sampleCount must be power of 2.
26    EchoSuppressor(int sampleCount, int tailLength);
27    ~EchoSuppressor();
28    void run(int16_t *playbacked, int16_t *recorded);
29
30private:
31    int mShift;
32    int mScale;
33    int mSampleCount;
34    int mWindowSize;
35    int mTailLength;
36    int mRecordLength;
37    int mRecordOffset;
38
39    uint16_t *mXs;
40    uint32_t *mXSums;
41    uint32_t *mX2Sums;
42    uint16_t *mXRecords;
43
44    uint32_t mYSum;
45    uint32_t mY2Sum;
46    uint32_t *mYRecords;
47    uint32_t *mY2Records;
48
49    uint32_t *mXYSums;
50    uint32_t *mXYRecords;
51
52    int32_t mLastX;
53    int32_t mLastY;
54
55    float mWeight;
56};
57
58#endif
59