| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 | 11 |
| 12 /* | 12 /* |
| 13 * This file contains the function WebRtcSpl_GetScalingSquare(). | 13 * This file contains the function WebRtcSpl_GetScalingSquare(). |
| 14 * The description header can be found in signal_processing_library.h | 14 * The description header can be found in signal_processing_library.h |
| 15 * | 15 * |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 18 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 19 | 19 |
| 20 int16_t WebRtcSpl_GetScalingSquare(int16_t* in_vector, | 20 int16_t WebRtcSpl_GetScalingSquare(int16_t* in_vector, |
| 21 int in_vector_length, | 21 size_t in_vector_length, |
| 22 int times) | 22 size_t times) |
| 23 { | 23 { |
| 24 int16_t nbits = WebRtcSpl_GetSizeInBits((uint32_t)times); | 24 int16_t nbits = WebRtcSpl_GetSizeInBits((uint32_t)times); |
| 25 int i; | 25 size_t i; |
| 26 int16_t smax = -1; | 26 int16_t smax = -1; |
| 27 int16_t sabs; | 27 int16_t sabs; |
| 28 int16_t *sptr = in_vector; | 28 int16_t *sptr = in_vector; |
| 29 int16_t t; | 29 int16_t t; |
| 30 int looptimes = in_vector_length; | 30 size_t looptimes = in_vector_length; |
| 31 | 31 |
| 32 for (i = looptimes; i > 0; i--) | 32 for (i = looptimes; i > 0; i--) |
| 33 { | 33 { |
| 34 sabs = (*sptr > 0 ? *sptr++ : -*sptr++); | 34 sabs = (*sptr > 0 ? *sptr++ : -*sptr++); |
| 35 smax = (sabs > smax ? sabs : smax); | 35 smax = (sabs > smax ? sabs : smax); |
| 36 } | 36 } |
| 37 t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); | 37 t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); |
| 38 | 38 |
| 39 if (smax == 0) | 39 if (smax == 0) |
| 40 { | 40 { |
| 41 return 0; // Since norm(0) returns 0 | 41 return 0; // Since norm(0) returns 0 |
| 42 } else | 42 } else |
| 43 { | 43 { |
| 44 return (t > nbits) ? 0 : nbits - t; | 44 return (t > nbits) ? 0 : nbits - t; |
| 45 } | 45 } |
| 46 } | 46 } |
| OLD | NEW |