Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1116)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_unittest.cc

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Changed parameter name from initial_level to the more correct initial_peak_level Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <math.h> 11 #include <math.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <limits> 15 #include <limits>
16 #include <memory> 16 #include <memory>
17 #include <queue> 17 #include <queue>
18 18
19 #include "webrtc/base/arraysize.h" 19 #include "webrtc/base/arraysize.h"
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/common_audio/include/audio_util.h" 21 #include "webrtc/common_audio/include/audio_util.h"
22 #include "webrtc/common_audio/resampler/include/push_resampler.h" 22 #include "webrtc/common_audio/resampler/include/push_resampler.h"
23 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" 23 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
24 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 24 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
25 #include "webrtc/modules/audio_processing/audio_processing_impl.h"
25 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h " 26 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h "
26 #include "webrtc/modules/audio_processing/common.h" 27 #include "webrtc/modules/audio_processing/common.h"
27 #include "webrtc/modules/audio_processing/include/audio_processing.h" 28 #include "webrtc/modules/audio_processing/include/audio_processing.h"
28 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 29 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
29 #include "webrtc/modules/audio_processing/test/test_utils.h" 30 #include "webrtc/modules/audio_processing/test/test_utils.h"
30 #include "webrtc/modules/include/module_common_types.h" 31 #include "webrtc/modules/include/module_common_types.h"
31 #include "webrtc/system_wrappers/include/event_wrapper.h" 32 #include "webrtc/system_wrappers/include/event_wrapper.h"
32 #include "webrtc/system_wrappers/include/trace.h" 33 #include "webrtc/system_wrappers/include/trace.h"
33 #include "webrtc/test/testsupport/fileutils.h" 34 #include "webrtc/test/testsupport/fileutils.h"
34 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 35 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after
2767 std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), 2768 std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15),
2768 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), 2769 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35),
2769 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), 2770 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0),
2770 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), 2771 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20),
2771 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), 2772 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20),
2772 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20), 2773 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20),
2773 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); 2774 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
2774 #endif 2775 #endif
2775 2776
2776 } // namespace 2777 } // namespace
2778
2779 TEST(ApmConfiguration, LevelController) {
2780 const float kTolerance = 0.0001f;
2781 // Verify that the level controller is default off, it can be activate using
hlundin-webrtc 2016/09/19 12:03:03 activate -> activated
peah-webrtc 2016/09/19 16:37:10 Done.
2782 // the config, and that the default initial level is maintained after the
2783 // config has been appied.
hlundin-webrtc 2016/09/19 12:03:03 appied -> applied
peah-webrtc 2016/09/19 16:37:10 Done.
2784 std::unique_ptr<AudioProcessingImpl> apm(
2785 new AudioProcessingImpl(webrtc::Config()));
2786 AudioProcessing::Config config;
2787 EXPECT_FALSE(apm->config_.level_controller.enabled);
2788 // TODO(peah): Add test for the existence of the level controller object once
2789 // that is created only when the that is specified in the config.
the sun 2016/09/16 12:40:24 "the that"
peah-webrtc 2016/09/19 16:37:10 Done.
2790 // TODO(peah): Remove the testing for
2791 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2792 // is instead used to activate the level controller.
2793 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2794 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
2795 kTolerance);
2796 config.level_controller.enabled = true;
2797 apm->ApplyConfig(config);
2798 EXPECT_TRUE(apm->config_.level_controller.enabled);
2799 // TODO(peah): Add test for the existence of the level controller object once
2800 // that is created only when the that is specified in the config.
2801 // TODO(peah): Remove the testing for
2802 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2803 // is instead used to activate the level controller.
2804 EXPECT_TRUE(apm->capture_nonlocked_.level_controller_enabled);
2805 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
2806 kTolerance);
2807
2808 // Verify that the initial level can be specified and is retained after the
2809 // config has been applied.
2810 apm.reset(new AudioProcessingImpl(webrtc::Config()));
the sun 2016/09/16 12:40:24 Split up into several test cases instead - it shou
hlundin-webrtc 2016/09/19 12:03:03 Acknowledged.
peah-webrtc 2016/09/19 16:37:10 Acknowledged.
peah-webrtc 2016/09/19 16:37:10 I'm all in for that, but in order to limit the num
the sun 2016/09/19 18:53:56 Agree declaring friends all over APMImpl is not th
peah-webrtc 2016/09/22 06:00:06 Acknowledged.
2811 config = AudioProcessing::Config();
2812 config.level_controller.initial_peak_level = -50.f;
2813 apm->ApplyConfig(config);
2814 EXPECT_FALSE(apm->config_.level_controller.enabled);
2815 // TODO(peah): Add test for the existence of the level controller object once
2816 // that is created only when the that is specified in the config.
2817 // TODO(peah): Remove the testing for
2818 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2819 // is instead used to activate the level controller.
2820 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2821 EXPECT_NEAR(-50.f, apm->config_.level_controller.initial_peak_level,
2822 kTolerance);
2823
2824 // Verify that the config is properly reset when nonproper values are applied
2825 // for the initial level.
2826 apm.reset(new AudioProcessingImpl(webrtc::Config()));
2827 config = AudioProcessing::Config();
2828 config.level_controller.enabled = true;
2829 config.level_controller.initial_peak_level = -101.f;
2830 apm->ApplyConfig(config);
2831 EXPECT_FALSE(apm->config_.level_controller.enabled);
2832 // TODO(peah): Add test for the existence of the level controller object once
2833 // that is created only when the that is specified in the config.
2834 // TODO(peah): Remove the testing for
2835 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2836 // is instead used to activate the level controller.
2837 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2838 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
2839 kTolerance);
2840
2841 apm.reset(new AudioProcessingImpl(webrtc::Config()));
2842 config = AudioProcessing::Config();
2843 config.level_controller.enabled = true;
2844 config.level_controller.initial_peak_level = 1.f;
2845 apm->ApplyConfig(config);
2846 EXPECT_FALSE(apm->config_.level_controller.enabled);
2847 // TODO(peah): Add test for the existence of the level controller object once
2848 // that is created only when the that is specified in the config.
2849 // TODO(peah): Remove the testing for
2850 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2851 // is instead used to activate the level controller.
2852 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2853 EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
2854 kTolerance);
2855 }
2856
2777 } // namespace webrtc 2857 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698