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

Side by Side Diff: webrtc/modules/audio_coding/neteq/expand.cc

Issue 2616363003: Fix for left-shift of potentially negative values in NetEq. (Closed)
Patch Set: Update with Karl's suggestion. Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 WebRtcSpl_VectorBitShiftW32ToW16(best_distortion, kNumCorrelationCandidates, 434 WebRtcSpl_VectorBitShiftW32ToW16(best_distortion, kNumCorrelationCandidates,
435 best_distortion_w32, distortion_scale); 435 best_distortion_w32, distortion_scale);
436 436
437 // Find the maximizing index |i| of the cost function 437 // Find the maximizing index |i| of the cost function
438 // f[i] = best_correlation[i] / best_distortion[i]. 438 // f[i] = best_correlation[i] / best_distortion[i].
439 int32_t best_ratio = std::numeric_limits<int32_t>::min(); 439 int32_t best_ratio = std::numeric_limits<int32_t>::min();
440 size_t best_index = std::numeric_limits<size_t>::max(); 440 size_t best_index = std::numeric_limits<size_t>::max();
441 for (size_t i = 0; i < kNumCorrelationCandidates; ++i) { 441 for (size_t i = 0; i < kNumCorrelationCandidates; ++i) {
442 int32_t ratio; 442 int32_t ratio;
443 if (best_distortion[i] > 0) { 443 if (best_distortion[i] > 0) {
444 ratio = (best_correlation[i] << 16) / best_distortion[i]; 444 ratio = (best_correlation[i] * (1 << 16)) / best_distortion[i];
445 } else if (best_correlation[i] == 0) { 445 } else if (best_correlation[i] == 0) {
446 ratio = 0; // No correlation set result to zero. 446 ratio = 0; // No correlation set result to zero.
447 } else { 447 } else {
448 ratio = std::numeric_limits<int32_t>::max(); // Denominator is zero. 448 ratio = std::numeric_limits<int32_t>::max(); // Denominator is zero.
449 } 449 }
450 if (ratio > best_ratio) { 450 if (ratio > best_ratio) {
451 best_index = i; 451 best_index = i;
452 best_ratio = ratio; 452 best_ratio = ratio;
453 } 453 }
454 } 454 }
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 const size_t kMaxRandSamples = RandomVector::kRandomTableSize; 969 const size_t kMaxRandSamples = RandomVector::kRandomTableSize;
970 while (samples_generated < length) { 970 while (samples_generated < length) {
971 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples); 971 size_t rand_length = std::min(length - samples_generated, kMaxRandSamples);
972 random_vector_->IncreaseSeedIncrement(seed_increment); 972 random_vector_->IncreaseSeedIncrement(seed_increment);
973 random_vector_->Generate(rand_length, &random_vector[samples_generated]); 973 random_vector_->Generate(rand_length, &random_vector[samples_generated]);
974 samples_generated += rand_length; 974 samples_generated += rand_length;
975 } 975 }
976 } 976 }
977 977
978 } // namespace webrtc 978 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698