diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/libwebrtc/common_audio/window_generator_unittest.cc | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/common_audio/window_generator_unittest.cc')
-rw-r--r-- | third_party/libwebrtc/common_audio/window_generator_unittest.cc | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/third_party/libwebrtc/common_audio/window_generator_unittest.cc b/third_party/libwebrtc/common_audio/window_generator_unittest.cc new file mode 100644 index 0000000000..cf339327c6 --- /dev/null +++ b/third_party/libwebrtc/common_audio/window_generator_unittest.cc @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "common_audio/window_generator.h" + +#include <cstring> + +#include "test/gtest.h" + +namespace webrtc { + +TEST(WindowGeneratorTest, KaiserBesselDerived) { + float window[7]; + + memset(window, 0, sizeof(window)); + + WindowGenerator::KaiserBesselDerived(0.397856f, 2, window); + ASSERT_NEAR(window[0], 0.707106f, 1e-6f); + ASSERT_NEAR(window[1], 0.707106f, 1e-6f); + ASSERT_NEAR(window[2], 0.0f, 1e-6f); + ASSERT_NEAR(window[3], 0.0f, 1e-6f); + ASSERT_NEAR(window[4], 0.0f, 1e-6f); + ASSERT_NEAR(window[5], 0.0f, 1e-6f); + ASSERT_NEAR(window[6], 0.0f, 1e-6f); + + WindowGenerator::KaiserBesselDerived(0.397856f, 3, window); + ASSERT_NEAR(window[0], 0.598066f, 1e-6f); + ASSERT_NEAR(window[1], 0.922358f, 1e-6f); + ASSERT_NEAR(window[2], 0.598066f, 1e-6f); + ASSERT_NEAR(window[3], 0.0f, 1e-6f); + ASSERT_NEAR(window[4], 0.0f, 1e-6f); + ASSERT_NEAR(window[5], 0.0f, 1e-6f); + ASSERT_NEAR(window[6], 0.0f, 1e-6f); + + WindowGenerator::KaiserBesselDerived(0.397856f, 6, window); + ASSERT_NEAR(window[0], 0.458495038865344f, 1e-6f); + ASSERT_NEAR(window[1], 0.707106781186548f, 1e-6f); + ASSERT_NEAR(window[2], 0.888696967101760f, 1e-6f); + ASSERT_NEAR(window[3], 0.888696967101760f, 1e-6f); + ASSERT_NEAR(window[4], 0.707106781186548f, 1e-6f); + ASSERT_NEAR(window[5], 0.458495038865344f, 1e-6f); + ASSERT_NEAR(window[6], 0.0f, 1e-6f); +} + +TEST(WindowGeneratorTest, Hanning) { + float window[7]; + + memset(window, 0, sizeof(window)); + + window[0] = -1.0f; + window[1] = -1.0f; + WindowGenerator::Hanning(2, window); + ASSERT_NEAR(window[0], 0.0f, 1e-6f); + ASSERT_NEAR(window[1], 0.0f, 1e-6f); + ASSERT_NEAR(window[2], 0.0f, 1e-6f); + ASSERT_NEAR(window[3], 0.0f, 1e-6f); + ASSERT_NEAR(window[4], 0.0f, 1e-6f); + ASSERT_NEAR(window[5], 0.0f, 1e-6f); + ASSERT_NEAR(window[6], 0.0f, 1e-6f); + + window[0] = -1.0f; + window[2] = -1.0f; + WindowGenerator::Hanning(3, window); + ASSERT_NEAR(window[0], 0.0f, 1e-6f); + ASSERT_NEAR(window[1], 1.0f, 1e-6f); + ASSERT_NEAR(window[2], 0.0f, 1e-6f); + ASSERT_NEAR(window[3], 0.0f, 1e-6f); + ASSERT_NEAR(window[4], 0.0f, 1e-6f); + ASSERT_NEAR(window[5], 0.0f, 1e-6f); + ASSERT_NEAR(window[6], 0.0f, 1e-6f); + + window[0] = -1.0f; + window[5] = -1.0f; + WindowGenerator::Hanning(6, window); + ASSERT_NEAR(window[0], 0.0f, 1e-6f); + ASSERT_NEAR(window[1], 0.345491f, 1e-6f); + ASSERT_NEAR(window[2], 0.904508f, 1e-6f); + ASSERT_NEAR(window[3], 0.904508f, 1e-6f); + ASSERT_NEAR(window[4], 0.345491f, 1e-6f); + ASSERT_NEAR(window[5], 0.0f, 1e-6f); + ASSERT_NEAR(window[6], 0.0f, 1e-6f); +} + +} // namespace webrtc |