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

Side by Side Diff: webrtc/common_audio/signal_processing/include/signal_processing_library.h

Issue 2717123004: Avoid overflow in WebRtcSpl_DotProductWithScale (Closed)
Patch Set: Move to separate target Created 3 years, 9 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 11
12 /* 12 /*
13 * This header file includes all of the fix point signal processing library (SPL ) function 13 * This header file includes all of the fix point signal processing library (SPL ) function
14 * descriptions and declarations. 14 * descriptions and declarations.
15 * For specific function calls, see bottom of file. 15 * For specific function calls, see bottom of file.
16 */ 16 */
17 17
18 #ifndef WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_ 18 #ifndef WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_
19 #define WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_ 19 #define WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_
20 20
21 #include <string.h> 21 #include <string.h>
22 #include "webrtc/common_audio/signal_processing/dot_product_with_scale.h"
22 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
23 24
24 // Macros specific for the fixed point implementation 25 // Macros specific for the fixed point implementation
25 #define WEBRTC_SPL_WORD16_MAX 32767 26 #define WEBRTC_SPL_WORD16_MAX 32767
26 #define WEBRTC_SPL_WORD16_MIN -32768 27 #define WEBRTC_SPL_WORD16_MIN -32768
27 #define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff 28 #define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff
28 #define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000 29 #define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000
29 #define WEBRTC_SPL_MAX_LPC_ORDER 14 30 #define WEBRTC_SPL_MAX_LPC_ORDER 14
30 #define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value 31 #define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value
31 #define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value 32 #define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // 602 //
602 // Input: 603 // Input:
603 // - vector1 : Vector 1 604 // - vector1 : Vector 1
604 // - vector2 : Vector 2 605 // - vector2 : Vector 2
605 // - vector_length : Number of samples used in the dot product 606 // - vector_length : Number of samples used in the dot product
606 // - scaling : The number of right bit shifts to apply on each term 607 // - scaling : The number of right bit shifts to apply on each term
607 // during calculation to avoid overflow, i.e., the 608 // during calculation to avoid overflow, i.e., the
608 // output will be in Q(-|scaling|) 609 // output will be in Q(-|scaling|)
609 // 610 //
610 // Return value : The dot product in Q(-scaling) 611 // Return value : The dot product in Q(-scaling)
611 int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, 612 // int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
hlundin-webrtc 2017/02/28 12:35:17 The declaration is intentionally left in this file
kwiberg-webrtc 2017/02/28 12:51:01 I think this is a bad idea. It's just a question o
hlundin-webrtc 2017/03/06 12:43:26 Would you like me to keep lines 601--611 in this f
kwiberg-webrtc 2017/03/06 14:35:50 I would prefer that you delete WebRtcSpl_DotProduc
hlundin-webrtc 2017/03/06 15:44:23 Done.
612 const int16_t* vector2, 613 // const int16_t* vector2,
613 size_t length, 614 // size_t length,
614 int scaling); 615 // int scaling);
615 616
616 // Filter operations. 617 // Filter operations.
617 size_t WebRtcSpl_FilterAR(const int16_t* ar_coef, 618 size_t WebRtcSpl_FilterAR(const int16_t* ar_coef,
618 size_t ar_coef_length, 619 size_t ar_coef_length,
619 const int16_t* in_vector, 620 const int16_t* in_vector,
620 size_t in_vector_length, 621 size_t in_vector_length,
621 int16_t* filter_state, 622 int16_t* filter_state,
622 size_t filter_state_length, 623 size_t filter_state_length,
623 int16_t* filter_state_low, 624 int16_t* filter_state_low,
624 size_t filter_state_low_length, 625 size_t filter_state_low_length,
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 // This function multiply a 16-bit word by a 16-bit word, and accumulate this 1634 // This function multiply a 16-bit word by a 16-bit word, and accumulate this
1634 // value to a 32-bit integer. 1635 // value to a 32-bit integer.
1635 // 1636 //
1636 // Input: 1637 // Input:
1637 // - a : The value of the first 16-bit word. 1638 // - a : The value of the first 16-bit word.
1638 // - b : The value of the second 16-bit word. 1639 // - b : The value of the second 16-bit word.
1639 // - c : The value of an 32-bit integer. 1640 // - c : The value of an 32-bit integer.
1640 // 1641 //
1641 // Return Value: The value of a * b + c. 1642 // Return Value: The value of a * b + c.
1642 // 1643 //
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698