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

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

Issue 2810483002: Add SafeMin() and SafeMax(), which accept args of different types (Closed)
Patch Set: trigger error earlier Created 3 years, 8 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/base/gtest_prod_util.h" 21 #include "webrtc/base/gtest_prod_util.h"
22 #include "webrtc/base/ignore_wundef.h" 22 #include "webrtc/base/ignore_wundef.h"
23 #include "webrtc/base/protobuf_utils.h" 23 #include "webrtc/base/protobuf_utils.h"
24 #include "webrtc/base/safe_minmax.h"
24 #include "webrtc/common_audio/include/audio_util.h" 25 #include "webrtc/common_audio/include/audio_util.h"
25 #include "webrtc/common_audio/resampler/include/push_resampler.h" 26 #include "webrtc/common_audio/resampler/include/push_resampler.h"
26 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" 27 #include "webrtc/common_audio/resampler/push_sinc_resampler.h"
27 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 28 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
28 #include "webrtc/modules/audio_processing/audio_processing_impl.h" 29 #include "webrtc/modules/audio_processing/audio_processing_impl.h"
29 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h " 30 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h "
30 #include "webrtc/modules/audio_processing/common.h" 31 #include "webrtc/modules/audio_processing/common.h"
31 #include "webrtc/modules/audio_processing/include/audio_processing.h" 32 #include "webrtc/modules/audio_processing/include/audio_processing.h"
32 #include "webrtc/modules/audio_processing/level_controller/level_controller_cons tants.h" 33 #include "webrtc/modules/audio_processing/level_controller/level_controller_cons tants.h"
33 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 34 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 672
672 rewind(near_file_); 673 rewind(near_file_);
673 while (!frame_queue.empty()) { 674 while (!frame_queue.empty()) {
674 AudioFrame* frame = frame_queue.front(); 675 AudioFrame* frame = frame_queue.front();
675 frame_queue.pop(); 676 frame_queue.pop();
676 delete frame; 677 delete frame;
677 } 678 }
678 // Calculate expected delay estimate and acceptable regions. Further, 679 // Calculate expected delay estimate and acceptable regions. Further,
679 // limit them w.r.t. AEC delay estimation support. 680 // limit them w.r.t. AEC delay estimation support.
680 const size_t samples_per_ms = 681 const size_t samples_per_ms =
681 std::min(static_cast<size_t>(16), frame_->samples_per_channel_ / 10); 682 rtc::SafeMin<size_t>(16u, frame_->samples_per_channel_ / 10);
682 int expected_median = std::min(std::max(delay_ms - system_delay_ms, 683 int expected_median = std::min(std::max(delay_ms - system_delay_ms,
683 delay_min), delay_max); 684 delay_min), delay_max);
684 int expected_median_high = std::min( 685 int expected_median_high = std::min(
685 std::max(expected_median + static_cast<int>(96 / samples_per_ms), 686 std::max(expected_median + static_cast<int>(96 / samples_per_ms),
686 delay_min), 687 delay_min),
687 delay_max); 688 delay_max);
688 int expected_median_low = std::min( 689 int expected_median_low = std::min(
689 std::max(expected_median - static_cast<int>(96 / samples_per_ms), 690 std::max(expected_median - static_cast<int>(96 / samples_per_ms),
690 delay_min), 691 delay_min),
691 delay_max); 692 delay_max);
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 // TODO(peah): Remove the testing for 2878 // TODO(peah): Remove the testing for
2878 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ 2879 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2879 // is instead used to activate the level controller. 2880 // is instead used to activate the level controller.
2880 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); 2881 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2881 EXPECT_NEAR(kTargetLcPeakLeveldBFS, 2882 EXPECT_NEAR(kTargetLcPeakLeveldBFS,
2882 apm->config_.level_controller.initial_peak_level_dbfs, 2883 apm->config_.level_controller.initial_peak_level_dbfs,
2883 std::numeric_limits<float>::epsilon()); 2884 std::numeric_limits<float>::epsilon());
2884 } 2885 }
2885 2886
2886 } // namespace webrtc 2887 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/merge.cc ('k') | webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698