vad_gmm_unittest.cc (1679B)
1 /* 2 * Copyright (c) 2011 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 11 #include <cstdint> 12 13 #include "common_audio/vad/vad_unittest.h" 14 #include "test/gtest.h" 15 16 extern "C" { 17 #include "common_audio/vad/vad_gmm.h" 18 } 19 20 namespace webrtc { 21 namespace test { 22 23 // TODO(bugs.webrtc.org/345674543): Fix/enable. 24 #if defined(__has_feature) && __has_feature(undefined_behavior_sanitizer) 25 TEST_F(VadTest, DISABLED_vad_gmm) { 26 #else 27 TEST_F(VadTest, vad_gmm) { 28 #endif 29 int16_t delta = 0; 30 // Input value at mean. 31 EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(0, 0, 128, &delta)); 32 EXPECT_EQ(0, delta); 33 EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(16, 128, 128, &delta)); 34 EXPECT_EQ(0, delta); 35 EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(-16, -128, 128, &delta)); 36 EXPECT_EQ(0, delta); 37 38 // Largest possible input to give non-zero probability. 39 EXPECT_EQ(1024, WebRtcVad_GaussianProbability(59, 0, 128, &delta)); 40 EXPECT_EQ(7552, delta); 41 EXPECT_EQ(1024, WebRtcVad_GaussianProbability(75, 128, 128, &delta)); 42 EXPECT_EQ(7552, delta); 43 EXPECT_EQ(1024, WebRtcVad_GaussianProbability(-75, -128, 128, &delta)); 44 EXPECT_EQ(-7552, delta); 45 46 // Too large input, should give zero probability. 47 EXPECT_EQ(0, WebRtcVad_GaussianProbability(105, 0, 128, &delta)); 48 EXPECT_EQ(13440, delta); 49 } 50 } // namespace test 51 } // namespace webrtc