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

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

Issue 2717123004: Avoid overflow in WebRtcSpl_DotProductWithScale (Closed)
Patch Set: Remove wd4334 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
« no previous file with comments | « webrtc/common_audio/signal_processing/dot_product_with_scale.cc ('k') | 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
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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 int32_t WebRtcSpl_DivW32W16(int32_t num, int16_t den); 591 int32_t WebRtcSpl_DivW32W16(int32_t num, int16_t den);
591 int16_t WebRtcSpl_DivW32W16ResW16(int32_t num, int16_t den); 592 int16_t WebRtcSpl_DivW32W16ResW16(int32_t num, int16_t den);
592 int32_t WebRtcSpl_DivResultInQ31(int32_t num, int32_t den); 593 int32_t WebRtcSpl_DivResultInQ31(int32_t num, int32_t den);
593 int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low); 594 int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low);
594 // End: Divisions. 595 // End: Divisions.
595 596
596 int32_t WebRtcSpl_Energy(int16_t* vector, 597 int32_t WebRtcSpl_Energy(int16_t* vector,
597 size_t vector_length, 598 size_t vector_length,
598 int* scale_factor); 599 int* scale_factor);
599 600
600 // Calculates the dot product between two (int16_t) vectors.
601 //
602 // Input:
603 // - vector1 : Vector 1
604 // - vector2 : Vector 2
605 // - vector_length : Number of samples used in the dot product
606 // - scaling : The number of right bit shifts to apply on each term
607 // during calculation to avoid overflow, i.e., the
608 // output will be in Q(-|scaling|)
609 //
610 // Return value : The dot product in Q(-scaling)
611 int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
612 const int16_t* vector2,
613 size_t length,
614 int scaling);
615
616 // Filter operations. 601 // Filter operations.
617 size_t WebRtcSpl_FilterAR(const int16_t* ar_coef, 602 size_t WebRtcSpl_FilterAR(const int16_t* ar_coef,
618 size_t ar_coef_length, 603 size_t ar_coef_length,
619 const int16_t* in_vector, 604 const int16_t* in_vector,
620 size_t in_vector_length, 605 size_t in_vector_length,
621 int16_t* filter_state, 606 int16_t* filter_state,
622 size_t filter_state_length, 607 size_t filter_state_length,
623 int16_t* filter_state_low, 608 int16_t* filter_state_low,
624 size_t filter_state_low_length, 609 size_t filter_state_low_length,
625 int16_t* out_vector, 610 int16_t* out_vector,
(...skipping 1007 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 1618 // This function multiply a 16-bit word by a 16-bit word, and accumulate this
1634 // value to a 32-bit integer. 1619 // value to a 32-bit integer.
1635 // 1620 //
1636 // Input: 1621 // Input:
1637 // - a : The value of the first 16-bit word. 1622 // - a : The value of the first 16-bit word.
1638 // - b : The value of the second 16-bit word. 1623 // - b : The value of the second 16-bit word.
1639 // - c : The value of an 32-bit integer. 1624 // - c : The value of an 32-bit integer.
1640 // 1625 //
1641 // Return Value: The value of a * b + c. 1626 // Return Value: The value of a * b + c.
1642 // 1627 //
OLDNEW
« no previous file with comments | « webrtc/common_audio/signal_processing/dot_product_with_scale.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698