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

Unified Diff: webrtc/modules/audio_coding/neteq/merge.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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/merge.cc
diff --git a/webrtc/modules/audio_coding/neteq/merge.cc b/webrtc/modules/audio_coding/neteq/merge.cc
index 299682f60d44b260bf5a5e99fb8eb9ff5c8cb583..d50b66588a8d2e146905ea47a83a55bb4a2ada31 100644
--- a/webrtc/modules/audio_coding/neteq/merge.cc
+++ b/webrtc/modules/audio_coding/neteq/merge.cc
@@ -16,6 +16,8 @@
#include <algorithm> // min, max
#include <memory>
+#include "webrtc/base/safe_conversions.h"
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h"
#include "webrtc/modules/audio_coding/neteq/cross_correlation.h"
@@ -209,8 +211,8 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
int16_t Merge::SignalScaling(const int16_t* input, size_t input_length,
const int16_t* expanded_signal) const {
// Adjust muting factor if new vector is more or less of the BGN energy.
- const size_t mod_input_length =
- std::min(static_cast<size_t>(64 * fs_mult_), input_length);
+ const auto mod_input_length = rtc::SafeMin<size_t>(
+ 64 * rtc::dchecked_cast<size_t>(fs_mult_), input_length);
const int16_t expanded_max =
WebRtcSpl_MaxAbsValueW16(expanded_signal, mod_input_length);
int32_t factor = (expanded_max * expanded_max) /
« no previous file with comments | « webrtc/common_video/h264/sps_vui_rewriter.cc ('k') | webrtc/modules/audio_processing/audio_processing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698