Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -8,141 +8,125 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_
|
||||
#define COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_
|
||||
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
|
||||
static const int16_t kSinTable1024[] = {
|
||||
0, 201, 402, 603, 804, 1005, 1206, 1406,
|
||||
1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011,
|
||||
3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608,
|
||||
4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195,
|
||||
6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766,
|
||||
7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319,
|
||||
9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849,
|
||||
11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353,
|
||||
12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827,
|
||||
14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268,
|
||||
15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672,
|
||||
16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036,
|
||||
18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357,
|
||||
19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631,
|
||||
20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855,
|
||||
22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027,
|
||||
23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143,
|
||||
24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201,
|
||||
25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198,
|
||||
26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132,
|
||||
27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001,
|
||||
28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802,
|
||||
28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534,
|
||||
29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195,
|
||||
30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783,
|
||||
30851, 30918, 30984, 31049, 31113, 31175, 31236, 31297,
|
||||
31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735,
|
||||
31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097,
|
||||
32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382,
|
||||
32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588,
|
||||
32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717,
|
||||
32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766,
|
||||
32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736,
|
||||
32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628,
|
||||
32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441,
|
||||
32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176,
|
||||
32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833,
|
||||
31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413,
|
||||
31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918,
|
||||
30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349,
|
||||
30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706,
|
||||
29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992,
|
||||
28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208,
|
||||
28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355,
|
||||
27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437,
|
||||
26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456,
|
||||
25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413,
|
||||
24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311,
|
||||
23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153,
|
||||
22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942,
|
||||
20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680,
|
||||
19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371,
|
||||
18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017,
|
||||
16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623,
|
||||
15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191,
|
||||
14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724,
|
||||
12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227,
|
||||
11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703,
|
||||
9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156,
|
||||
7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589,
|
||||
6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006,
|
||||
4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411,
|
||||
3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808,
|
||||
1607, 1406, 1206, 1005, 804, 603, 402, 201,
|
||||
0, -201, -402, -603, -804, -1005, -1206, -1406,
|
||||
-1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011,
|
||||
-3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608,
|
||||
-4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195,
|
||||
-6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766,
|
||||
-7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319,
|
||||
-9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849,
|
||||
-11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353,
|
||||
-12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827,
|
||||
-14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268,
|
||||
-15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672,
|
||||
-16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036,
|
||||
-18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357,
|
||||
-19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631,
|
||||
-20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855,
|
||||
-22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027,
|
||||
-23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143,
|
||||
-24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201,
|
||||
-25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198,
|
||||
-26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132,
|
||||
-27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001,
|
||||
-28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802,
|
||||
-28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534,
|
||||
-29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195,
|
||||
-30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783,
|
||||
-30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297,
|
||||
-31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735,
|
||||
-31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097,
|
||||
-32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382,
|
||||
-32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588,
|
||||
-32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717,
|
||||
-32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766,
|
||||
-32767, -32766, -32764, -32761, -32757, -32751, -32744, -32736,
|
||||
-32727, -32717, -32705, -32692, -32678, -32662, -32646, -32628,
|
||||
-32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441,
|
||||
-32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176,
|
||||
-32137, -32097, -32056, -32014, -31970, -31926, -31880, -31833,
|
||||
-31785, -31735, -31684, -31633, -31580, -31525, -31470, -31413,
|
||||
-31356, -31297, -31236, -31175, -31113, -31049, -30984, -30918,
|
||||
-30851, -30783, -30713, -30643, -30571, -30498, -30424, -30349,
|
||||
-30272, -30195, -30116, -30036, -29955, -29873, -29790, -29706,
|
||||
-29621, -29534, -29446, -29358, -29268, -29177, -29085, -28992,
|
||||
-28897, -28802, -28706, -28608, -28510, -28410, -28309, -28208,
|
||||
-28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355,
|
||||
-27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437,
|
||||
-26318, -26198, -26077, -25954, -25831, -25707, -25582, -25456,
|
||||
-25329, -25201, -25072, -24942, -24811, -24679, -24546, -24413,
|
||||
-24278, -24143, -24006, -23869, -23731, -23592, -23452, -23311,
|
||||
-23169, -23027, -22883, -22739, -22594, -22448, -22301, -22153,
|
||||
-22004, -21855, -21705, -21554, -21402, -21249, -21096, -20942,
|
||||
-20787, -20631, -20474, -20317, -20159, -20000, -19840, -19680,
|
||||
-19519, -19357, -19194, -19031, -18867, -18702, -18537, -18371,
|
||||
-18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017,
|
||||
-16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623,
|
||||
-15446, -15268, -15090, -14911, -14732, -14552, -14372, -14191,
|
||||
-14009, -13827, -13645, -13462, -13278, -13094, -12909, -12724,
|
||||
-12539, -12353, -12166, -11980, -11792, -11604, -11416, -11227,
|
||||
-11038, -10849, -10659, -10469, -10278, -10087, -9895, -9703,
|
||||
-9511, -9319, -9126, -8932, -8739, -8545, -8351, -8156,
|
||||
-7961, -7766, -7571, -7375, -7179, -6982, -6786, -6589,
|
||||
-6392, -6195, -5997, -5799, -5601, -5403, -5205, -5006,
|
||||
-4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411,
|
||||
-3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808,
|
||||
-1607, -1406, -1206, -1005, -804, -603, -402, -201
|
||||
};
|
||||
0, 201, 402, 603, 804, 1005, 1206, 1406, 1607,
|
||||
1808, 2009, 2209, 2410, 2610, 2811, 3011, 3211, 3411,
|
||||
3611, 3811, 4011, 4210, 4409, 4608, 4807, 5006, 5205,
|
||||
5403, 5601, 5799, 5997, 6195, 6392, 6589, 6786, 6982,
|
||||
7179, 7375, 7571, 7766, 7961, 8156, 8351, 8545, 8739,
|
||||
8932, 9126, 9319, 9511, 9703, 9895, 10087, 10278, 10469,
|
||||
10659, 10849, 11038, 11227, 11416, 11604, 11792, 11980, 12166,
|
||||
12353, 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827,
|
||||
14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268, 15446,
|
||||
15623, 15799, 15975, 16150, 16325, 16499, 16672, 16845, 17017,
|
||||
17189, 17360, 17530, 17699, 17868, 18036, 18204, 18371, 18537,
|
||||
18702, 18867, 19031, 19194, 19357, 19519, 19680, 19840, 20000,
|
||||
20159, 20317, 20474, 20631, 20787, 20942, 21096, 21249, 21402,
|
||||
21554, 21705, 21855, 22004, 22153, 22301, 22448, 22594, 22739,
|
||||
22883, 23027, 23169, 23311, 23452, 23592, 23731, 23869, 24006,
|
||||
24143, 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201,
|
||||
25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198, 26318,
|
||||
26437, 26556, 26673, 26789, 26905, 27019, 27132, 27244, 27355,
|
||||
27466, 27575, 27683, 27790, 27896, 28001, 28105, 28208, 28309,
|
||||
28410, 28510, 28608, 28706, 28802, 28897, 28992, 29085, 29177,
|
||||
29268, 29358, 29446, 29534, 29621, 29706, 29790, 29873, 29955,
|
||||
30036, 30116, 30195, 30272, 30349, 30424, 30498, 30571, 30643,
|
||||
30713, 30783, 30851, 30918, 30984, 31049, 31113, 31175, 31236,
|
||||
31297, 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735,
|
||||
31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097, 32137,
|
||||
32176, 32213, 32249, 32284, 32318, 32350, 32382, 32412, 32441,
|
||||
32468, 32495, 32520, 32544, 32567, 32588, 32609, 32628, 32646,
|
||||
32662, 32678, 32692, 32705, 32717, 32727, 32736, 32744, 32751,
|
||||
32757, 32761, 32764, 32766, 32767, 32766, 32764, 32761, 32757,
|
||||
32751, 32744, 32736, 32727, 32717, 32705, 32692, 32678, 32662,
|
||||
32646, 32628, 32609, 32588, 32567, 32544, 32520, 32495, 32468,
|
||||
32441, 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176,
|
||||
32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833, 31785,
|
||||
31735, 31684, 31633, 31580, 31525, 31470, 31413, 31356, 31297,
|
||||
31236, 31175, 31113, 31049, 30984, 30918, 30851, 30783, 30713,
|
||||
30643, 30571, 30498, 30424, 30349, 30272, 30195, 30116, 30036,
|
||||
29955, 29873, 29790, 29706, 29621, 29534, 29446, 29358, 29268,
|
||||
29177, 29085, 28992, 28897, 28802, 28706, 28608, 28510, 28410,
|
||||
28309, 28208, 28105, 28001, 27896, 27790, 27683, 27575, 27466,
|
||||
27355, 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437,
|
||||
26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456, 25329,
|
||||
25201, 25072, 24942, 24811, 24679, 24546, 24413, 24278, 24143,
|
||||
24006, 23869, 23731, 23592, 23452, 23311, 23169, 23027, 22883,
|
||||
22739, 22594, 22448, 22301, 22153, 22004, 21855, 21705, 21554,
|
||||
21402, 21249, 21096, 20942, 20787, 20631, 20474, 20317, 20159,
|
||||
20000, 19840, 19680, 19519, 19357, 19194, 19031, 18867, 18702,
|
||||
18537, 18371, 18204, 18036, 17868, 17699, 17530, 17360, 17189,
|
||||
17017, 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623,
|
||||
15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, 14009,
|
||||
13827, 13645, 13462, 13278, 13094, 12909, 12724, 12539, 12353,
|
||||
12166, 11980, 11792, 11604, 11416, 11227, 11038, 10849, 10659,
|
||||
10469, 10278, 10087, 9895, 9703, 9511, 9319, 9126, 8932,
|
||||
8739, 8545, 8351, 8156, 7961, 7766, 7571, 7375, 7179,
|
||||
6982, 6786, 6589, 6392, 6195, 5997, 5799, 5601, 5403,
|
||||
5205, 5006, 4807, 4608, 4409, 4210, 4011, 3811, 3611,
|
||||
3411, 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808,
|
||||
1607, 1406, 1206, 1005, 804, 603, 402, 201, 0,
|
||||
-201, -402, -603, -804, -1005, -1206, -1406, -1607, -1808,
|
||||
-2009, -2209, -2410, -2610, -2811, -3011, -3211, -3411, -3611,
|
||||
-3811, -4011, -4210, -4409, -4608, -4807, -5006, -5205, -5403,
|
||||
-5601, -5799, -5997, -6195, -6392, -6589, -6786, -6982, -7179,
|
||||
-7375, -7571, -7766, -7961, -8156, -8351, -8545, -8739, -8932,
|
||||
-9126, -9319, -9511, -9703, -9895, -10087, -10278, -10469, -10659,
|
||||
-10849, -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353,
|
||||
-12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827, -14009,
|
||||
-14191, -14372, -14552, -14732, -14911, -15090, -15268, -15446, -15623,
|
||||
-15799, -15975, -16150, -16325, -16499, -16672, -16845, -17017, -17189,
|
||||
-17360, -17530, -17699, -17868, -18036, -18204, -18371, -18537, -18702,
|
||||
-18867, -19031, -19194, -19357, -19519, -19680, -19840, -20000, -20159,
|
||||
-20317, -20474, -20631, -20787, -20942, -21096, -21249, -21402, -21554,
|
||||
-21705, -21855, -22004, -22153, -22301, -22448, -22594, -22739, -22883,
|
||||
-23027, -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143,
|
||||
-24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201, -25329,
|
||||
-25456, -25582, -25707, -25831, -25954, -26077, -26198, -26318, -26437,
|
||||
-26556, -26673, -26789, -26905, -27019, -27132, -27244, -27355, -27466,
|
||||
-27575, -27683, -27790, -27896, -28001, -28105, -28208, -28309, -28410,
|
||||
-28510, -28608, -28706, -28802, -28897, -28992, -29085, -29177, -29268,
|
||||
-29358, -29446, -29534, -29621, -29706, -29790, -29873, -29955, -30036,
|
||||
-30116, -30195, -30272, -30349, -30424, -30498, -30571, -30643, -30713,
|
||||
-30783, -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297,
|
||||
-31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735, -31785,
|
||||
-31833, -31880, -31926, -31970, -32014, -32056, -32097, -32137, -32176,
|
||||
-32213, -32249, -32284, -32318, -32350, -32382, -32412, -32441, -32468,
|
||||
-32495, -32520, -32544, -32567, -32588, -32609, -32628, -32646, -32662,
|
||||
-32678, -32692, -32705, -32717, -32727, -32736, -32744, -32751, -32757,
|
||||
-32761, -32764, -32766, -32767, -32766, -32764, -32761, -32757, -32751,
|
||||
-32744, -32736, -32727, -32717, -32705, -32692, -32678, -32662, -32646,
|
||||
-32628, -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441,
|
||||
-32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176, -32137,
|
||||
-32097, -32056, -32014, -31970, -31926, -31880, -31833, -31785, -31735,
|
||||
-31684, -31633, -31580, -31525, -31470, -31413, -31356, -31297, -31236,
|
||||
-31175, -31113, -31049, -30984, -30918, -30851, -30783, -30713, -30643,
|
||||
-30571, -30498, -30424, -30349, -30272, -30195, -30116, -30036, -29955,
|
||||
-29873, -29790, -29706, -29621, -29534, -29446, -29358, -29268, -29177,
|
||||
-29085, -28992, -28897, -28802, -28706, -28608, -28510, -28410, -28309,
|
||||
-28208, -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355,
|
||||
-27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437, -26318,
|
||||
-26198, -26077, -25954, -25831, -25707, -25582, -25456, -25329, -25201,
|
||||
-25072, -24942, -24811, -24679, -24546, -24413, -24278, -24143, -24006,
|
||||
-23869, -23731, -23592, -23452, -23311, -23169, -23027, -22883, -22739,
|
||||
-22594, -22448, -22301, -22153, -22004, -21855, -21705, -21554, -21402,
|
||||
-21249, -21096, -20942, -20787, -20631, -20474, -20317, -20159, -20000,
|
||||
-19840, -19680, -19519, -19357, -19194, -19031, -18867, -18702, -18537,
|
||||
-18371, -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017,
|
||||
-16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623, -15446,
|
||||
-15268, -15090, -14911, -14732, -14552, -14372, -14191, -14009, -13827,
|
||||
-13645, -13462, -13278, -13094, -12909, -12724, -12539, -12353, -12166,
|
||||
-11980, -11792, -11604, -11416, -11227, -11038, -10849, -10659, -10469,
|
||||
-10278, -10087, -9895, -9703, -9511, -9319, -9126, -8932, -8739,
|
||||
-8545, -8351, -8156, -7961, -7766, -7571, -7375, -7179, -6982,
|
||||
-6786, -6589, -6392, -6195, -5997, -5799, -5601, -5403, -5205,
|
||||
-5006, -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411,
|
||||
-3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808, -1607,
|
||||
-1406, -1206, -1005, -804, -603, -402, -201};
|
||||
|
||||
#endif // COMMON_AUDIO_SIGNAL_PROCESSING_COMPLEX_FFT_TABLES_H_
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
// For ComplexFFT(), the maximum fft order is 10;
|
||||
// WebRTC APM uses orders of only 7 and 8.
|
||||
enum {kMaxFFTOrder = 10};
|
||||
enum { kMaxFFTOrder = 10 };
|
||||
|
||||
struct RealFFT;
|
||||
|
||||
|
@ -8,11 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This header file includes all of the fix point signal processing library (SPL) function
|
||||
* descriptions and declarations.
|
||||
* For specific function calls, see bottom of file.
|
||||
* This header file includes all of the fix point signal processing library
|
||||
* (SPL) function descriptions and declarations. For specific function calls,
|
||||
* see bottom of file.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SIGNAL_PROCESSING_LIBRARY_H_
|
||||
@ -23,63 +22,58 @@
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
|
||||
// Macros specific for the fixed point implementation
|
||||
#define WEBRTC_SPL_WORD16_MAX 32767
|
||||
#define WEBRTC_SPL_WORD16_MIN -32768
|
||||
#define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff
|
||||
#define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000
|
||||
#define WEBRTC_SPL_MAX_LPC_ORDER 14
|
||||
#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value
|
||||
#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value
|
||||
#define WEBRTC_SPL_WORD16_MAX 32767
|
||||
#define WEBRTC_SPL_WORD16_MIN -32768
|
||||
#define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff
|
||||
#define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000
|
||||
#define WEBRTC_SPL_MAX_LPC_ORDER 14
|
||||
#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value
|
||||
#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value
|
||||
// TODO(kma/bjorn): For the next two macros, investigate how to correct the code
|
||||
// for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN.
|
||||
#define WEBRTC_SPL_ABS_W16(a) \
|
||||
(((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a))
|
||||
#define WEBRTC_SPL_ABS_W32(a) \
|
||||
(((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a))
|
||||
#define WEBRTC_SPL_ABS_W16(a) (((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a))
|
||||
#define WEBRTC_SPL_ABS_W32(a) (((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a))
|
||||
|
||||
#define WEBRTC_SPL_MUL(a, b) \
|
||||
((int32_t) ((int32_t)(a) * (int32_t)(b)))
|
||||
#define WEBRTC_SPL_UMUL(a, b) \
|
||||
((uint32_t) ((uint32_t)(a) * (uint32_t)(b)))
|
||||
#define WEBRTC_SPL_UMUL_32_16(a, b) \
|
||||
((uint32_t) ((uint32_t)(a) * (uint16_t)(b)))
|
||||
#define WEBRTC_SPL_MUL_16_U16(a, b) \
|
||||
((int32_t)(int16_t)(a) * (uint16_t)(b))
|
||||
#define WEBRTC_SPL_MUL(a, b) ((int32_t)((int32_t)(a) * (int32_t)(b)))
|
||||
#define WEBRTC_SPL_UMUL(a, b) ((uint32_t)((uint32_t)(a) * (uint32_t)(b)))
|
||||
#define WEBRTC_SPL_UMUL_32_16(a, b) ((uint32_t)((uint32_t)(a) * (uint16_t)(b)))
|
||||
#define WEBRTC_SPL_MUL_16_U16(a, b) ((int32_t)(int16_t)(a) * (uint16_t)(b))
|
||||
|
||||
// clang-format off
|
||||
// clang-format would choose some identation
|
||||
// leading to presubmit error (cpplint.py)
|
||||
#ifndef WEBRTC_ARCH_ARM_V7
|
||||
// For ARMv7 platforms, these are inline functions in spl_inl_armv7.h
|
||||
#ifndef MIPS32_LE
|
||||
// For MIPS platforms, these are inline functions in spl_inl_mips.h
|
||||
#define WEBRTC_SPL_MUL_16_16(a, b) \
|
||||
((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
|
||||
#define WEBRTC_SPL_MUL_16_16(a, b) ((int32_t)(((int16_t)(a)) * ((int16_t)(b))))
|
||||
#define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \
|
||||
(WEBRTC_SPL_MUL_16_16(a, b >> 16) \
|
||||
+ ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15))
|
||||
(WEBRTC_SPL_MUL_16_16(a, b >> 16) + \
|
||||
((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \
|
||||
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \
|
||||
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10))
|
||||
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \
|
||||
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10))
|
||||
#define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \
|
||||
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \
|
||||
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13))
|
||||
(WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \
|
||||
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13))
|
||||
#define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \
|
||||
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 1)) + \
|
||||
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14))
|
||||
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 1)) + \
|
||||
(((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14))
|
||||
// clang-format on
|
||||
|
||||
#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \
|
||||
(WEBRTC_SPL_MUL_16_16(a, b) >> (c))
|
||||
#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) (WEBRTC_SPL_MUL_16_16(a, b) >> (c))
|
||||
|
||||
#define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \
|
||||
((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) \
|
||||
(((int32_t)1) << ((c) - 1)))) >> (c))
|
||||
((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t)(((int32_t)1) << ((c)-1)))) >> (c))
|
||||
|
||||
// C + the 32 most significant bits of A * B
|
||||
#define WEBRTC_SPL_SCALEDIFF32(A, B, C) \
|
||||
(C + (B >> 16) * A + (((uint32_t)(B & 0x0000FFFF) * A) >> 16))
|
||||
(C + (B >> 16) * A + (((uint32_t)(B & 0x0000FFFF) * A) >> 16))
|
||||
|
||||
#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b)
|
||||
#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b)
|
||||
|
||||
// Shifting with negative numbers allowed
|
||||
// Positive means left shift
|
||||
@ -87,12 +81,11 @@
|
||||
|
||||
// Shifting with negative numbers not allowed
|
||||
// We cannot do casting here due to signed/unsigned problem
|
||||
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
|
||||
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
|
||||
|
||||
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
|
||||
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
|
||||
|
||||
#define WEBRTC_SPL_RAND(a) \
|
||||
((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff))
|
||||
#define WEBRTC_SPL_RAND(a) ((int16_t)((((int16_t)a * 18816) >> 7) & 0x00007fff))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -131,13 +124,10 @@ void WebRtcSpl_CopyFromEndW16(const int16_t* in_vector,
|
||||
size_t in_vector_length,
|
||||
size_t samples,
|
||||
int16_t* out_vector);
|
||||
void WebRtcSpl_ZerosArrayW16(int16_t* vector,
|
||||
size_t vector_length);
|
||||
void WebRtcSpl_ZerosArrayW32(int32_t* vector,
|
||||
size_t vector_length);
|
||||
void WebRtcSpl_ZerosArrayW16(int16_t* vector, size_t vector_length);
|
||||
void WebRtcSpl_ZerosArrayW32(int32_t* vector, size_t vector_length);
|
||||
// End: Copy and set operations.
|
||||
|
||||
|
||||
// Minimum and maximum operation functions and their pointers.
|
||||
// Implementation in min_max_operations.c.
|
||||
|
||||
@ -297,7 +287,6 @@ size_t WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length);
|
||||
|
||||
// End: Minimum and maximum operations.
|
||||
|
||||
|
||||
// Vector scaling operations. Implementation in vector_scaling_operations.c.
|
||||
// Description at bottom of file.
|
||||
void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector,
|
||||
@ -323,9 +312,11 @@ void WebRtcSpl_ScaleVectorWithSat(const int16_t* in_vector,
|
||||
size_t vector_length,
|
||||
int16_t right_shifts);
|
||||
void WebRtcSpl_ScaleAndAddVectors(const int16_t* in_vector1,
|
||||
int16_t gain1, int right_shifts1,
|
||||
int16_t gain1,
|
||||
int right_shifts1,
|
||||
const int16_t* in_vector2,
|
||||
int16_t gain2, int right_shifts2,
|
||||
int16_t gain2,
|
||||
int right_shifts2,
|
||||
int16_t* out_vector,
|
||||
size_t vector_length);
|
||||
|
||||
@ -777,7 +768,8 @@ typedef struct {
|
||||
int32_t S_16_8[8];
|
||||
} WebRtcSpl_State22khzTo8khz;
|
||||
|
||||
void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, int16_t* out,
|
||||
void WebRtcSpl_Resample22khzTo8khz(const int16_t* in,
|
||||
int16_t* out,
|
||||
WebRtcSpl_State22khzTo8khz* state,
|
||||
int32_t* tmpmem);
|
||||
|
||||
@ -790,7 +782,8 @@ typedef struct {
|
||||
int32_t S_11_22[8];
|
||||
} WebRtcSpl_State8khzTo22khz;
|
||||
|
||||
void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, int16_t* out,
|
||||
void WebRtcSpl_Resample8khzTo22khz(const int16_t* in,
|
||||
int16_t* out,
|
||||
WebRtcSpl_State8khzTo22khz* state,
|
||||
int32_t* tmpmem);
|
||||
|
||||
@ -830,7 +823,8 @@ typedef struct {
|
||||
int32_t S_32_16[8];
|
||||
} WebRtcSpl_State48khzTo16khz;
|
||||
|
||||
void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out,
|
||||
void WebRtcSpl_Resample48khzTo16khz(const int16_t* in,
|
||||
int16_t* out,
|
||||
WebRtcSpl_State48khzTo16khz* state,
|
||||
int32_t* tmpmem);
|
||||
|
||||
@ -842,7 +836,8 @@ typedef struct {
|
||||
int32_t S_24_48[8];
|
||||
} WebRtcSpl_State16khzTo48khz;
|
||||
|
||||
void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out,
|
||||
void WebRtcSpl_Resample16khzTo48khz(const int16_t* in,
|
||||
int16_t* out,
|
||||
WebRtcSpl_State16khzTo48khz* state,
|
||||
int32_t* tmpmem);
|
||||
|
||||
@ -855,7 +850,8 @@ typedef struct {
|
||||
int32_t S_16_8[8];
|
||||
} WebRtcSpl_State48khzTo8khz;
|
||||
|
||||
void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out,
|
||||
void WebRtcSpl_Resample48khzTo8khz(const int16_t* in,
|
||||
int16_t* out,
|
||||
WebRtcSpl_State48khzTo8khz* state,
|
||||
int32_t* tmpmem);
|
||||
|
||||
@ -868,7 +864,8 @@ typedef struct {
|
||||
int32_t S_24_48[8];
|
||||
} WebRtcSpl_State8khzTo48khz;
|
||||
|
||||
void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out,
|
||||
void WebRtcSpl_Resample8khzTo48khz(const int16_t* in,
|
||||
int16_t* out,
|
||||
WebRtcSpl_State8khzTo48khz* state,
|
||||
int32_t* tmpmem);
|
||||
|
||||
@ -881,11 +878,15 @@ void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state);
|
||||
*
|
||||
******************************************************************/
|
||||
|
||||
void WebRtcSpl_DownsampleBy2(const int16_t* in, size_t len,
|
||||
int16_t* out, int32_t* filtState);
|
||||
void WebRtcSpl_DownsampleBy2(const int16_t* in,
|
||||
size_t len,
|
||||
int16_t* out,
|
||||
int32_t* filtState);
|
||||
|
||||
void WebRtcSpl_UpsampleBy2(const int16_t* in, size_t len,
|
||||
int16_t* out, int32_t* filtState);
|
||||
void WebRtcSpl_UpsampleBy2(const int16_t* in,
|
||||
size_t len,
|
||||
int16_t* out,
|
||||
int32_t* filtState);
|
||||
|
||||
/************************************************************
|
||||
* END OF RESAMPLING FUNCTIONS
|
||||
|
@ -8,7 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
// This header file includes the inline functions in
|
||||
// the fix point signal processing library.
|
||||
|
||||
@ -73,7 +72,7 @@ static __inline int WebRtcSpl_CountLeadingZeros64(uint64_t n) {
|
||||
|
||||
#if !defined(MIPS_DSP_R1_LE)
|
||||
static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
|
||||
int16_t out16 = (int16_t) value32;
|
||||
int16_t out16 = (int16_t)value32;
|
||||
|
||||
if (value32 > 32767)
|
||||
out16 = 32767;
|
||||
@ -112,11 +111,11 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t a, int32_t b) {
|
||||
}
|
||||
|
||||
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
|
||||
return WebRtcSpl_SatW32ToW16((int32_t) a + (int32_t) b);
|
||||
return WebRtcSpl_SatW32ToW16((int32_t)a + (int32_t)b);
|
||||
}
|
||||
|
||||
static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
|
||||
return WebRtcSpl_SatW32ToW16((int32_t) var1 - (int32_t) var2);
|
||||
return WebRtcSpl_SatW32ToW16((int32_t)var1 - (int32_t)var2);
|
||||
}
|
||||
#endif // #if !defined(MIPS_DSP_R1_LE)
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/* This header file includes the inline functions for ARM processors in
|
||||
* the fix point signal processing library.
|
||||
*/
|
||||
@ -26,35 +25,37 @@
|
||||
*/
|
||||
static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) {
|
||||
int32_t tmp = 0;
|
||||
__asm __volatile ("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a));
|
||||
__asm __volatile("smulwb %0, %1, %2" : "=r"(tmp) : "r"(b), "r"(a));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static __inline int32_t WEBRTC_SPL_MUL_16_16(int16_t a, int16_t b) {
|
||||
int32_t tmp = 0;
|
||||
__asm __volatile ("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b));
|
||||
__asm __volatile("smulbb %0, %1, %2" : "=r"(tmp) : "r"(a), "r"(b));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// TODO(kma): add unit test.
|
||||
static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) {
|
||||
int32_t tmp = 0;
|
||||
__asm __volatile ("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c));
|
||||
__asm __volatile("smlabb %0, %1, %2, %3"
|
||||
: "=r"(tmp)
|
||||
: "r"(a), "r"(b), "r"(c));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
|
||||
int32_t s_sum = 0;
|
||||
|
||||
__asm __volatile ("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b));
|
||||
__asm __volatile("qadd16 %0, %1, %2" : "=r"(s_sum) : "r"(a), "r"(b));
|
||||
|
||||
return (int16_t) s_sum;
|
||||
return (int16_t)s_sum;
|
||||
}
|
||||
|
||||
static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
int32_t l_sum = 0;
|
||||
|
||||
__asm __volatile ("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2));
|
||||
__asm __volatile("qadd %0, %1, %2" : "=r"(l_sum) : "r"(l_var1), "r"(l_var2));
|
||||
|
||||
return l_sum;
|
||||
}
|
||||
@ -62,7 +63,7 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
int32_t l_sub = 0;
|
||||
|
||||
__asm __volatile ("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2));
|
||||
__asm __volatile("qsub %0, %1, %2" : "=r"(l_sub) : "r"(l_var1), "r"(l_var2));
|
||||
|
||||
return l_sub;
|
||||
}
|
||||
@ -70,7 +71,7 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
|
||||
int32_t s_sub = 0;
|
||||
|
||||
__asm __volatile ("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2));
|
||||
__asm __volatile("qsub16 %0, %1, %2" : "=r"(s_sub) : "r"(var1), "r"(var2));
|
||||
|
||||
return (int16_t)s_sub;
|
||||
}
|
||||
@ -78,7 +79,7 @@ static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
|
||||
static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
|
||||
int32_t tmp = 0;
|
||||
|
||||
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n));
|
||||
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(n));
|
||||
|
||||
return (int16_t)(32 - tmp);
|
||||
}
|
||||
@ -92,7 +93,7 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
|
||||
a ^= 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
|
||||
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a));
|
||||
|
||||
return (int16_t)(tmp - 1);
|
||||
}
|
||||
@ -100,9 +101,10 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
|
||||
static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
|
||||
int tmp = 0;
|
||||
|
||||
if (a == 0) return 0;
|
||||
if (a == 0)
|
||||
return 0;
|
||||
|
||||
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a));
|
||||
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a));
|
||||
|
||||
return (int16_t)tmp;
|
||||
}
|
||||
@ -117,7 +119,7 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
|
||||
a_32 ^= 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a_32));
|
||||
__asm __volatile("clz %0, %1" : "=r"(tmp) : "r"(a_32));
|
||||
|
||||
return (int16_t)(tmp - 17);
|
||||
}
|
||||
@ -126,7 +128,7 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
|
||||
static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
|
||||
int32_t out = 0;
|
||||
|
||||
__asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32));
|
||||
__asm __volatile("ssat %0, #16, %1" : "=r"(out) : "r"(value32));
|
||||
|
||||
return (int16_t)out;
|
||||
}
|
||||
|
@ -8,69 +8,65 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
// This header file includes the inline functions in
|
||||
// the fix point signal processing library.
|
||||
|
||||
#ifndef COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_MIPS_H_
|
||||
#define COMMON_AUDIO_SIGNAL_PROCESSING_INCLUDE_SPL_INL_MIPS_H_
|
||||
|
||||
static __inline int32_t WEBRTC_SPL_MUL_16_16(int32_t a,
|
||||
int32_t b) {
|
||||
static __inline int32_t WEBRTC_SPL_MUL_16_16(int32_t a, int32_t b) {
|
||||
int32_t value32 = 0;
|
||||
int32_t a1 = 0, b1 = 0;
|
||||
|
||||
__asm __volatile(
|
||||
#if defined(MIPS32_R2_LE)
|
||||
"seh %[a1], %[a] \n\t"
|
||||
"seh %[b1], %[b] \n\t"
|
||||
"seh %[a1], %[a] \n\t"
|
||||
"seh %[b1], %[b] \n\t"
|
||||
#else
|
||||
"sll %[a1], %[a], 16 \n\t"
|
||||
"sll %[b1], %[b], 16 \n\t"
|
||||
"sra %[a1], %[a1], 16 \n\t"
|
||||
"sra %[b1], %[b1], 16 \n\t"
|
||||
"sll %[a1], %[a], 16 \n\t"
|
||||
"sll %[b1], %[b], 16 \n\t"
|
||||
"sra %[a1], %[a1], 16 \n\t"
|
||||
"sra %[b1], %[b1], 16 \n\t"
|
||||
#endif
|
||||
"mul %[value32], %[a1], %[b1] \n\t"
|
||||
: [value32] "=r" (value32), [a1] "=&r" (a1), [b1] "=&r" (b1)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "hi", "lo");
|
||||
"mul %[value32], %[a1], %[b1] \n\t"
|
||||
: [value32] "=r"(value32), [a1] "=&r"(a1), [b1] "=&r"(b1)
|
||||
: [a] "r"(a), [b] "r"(b)
|
||||
: "hi", "lo");
|
||||
return value32;
|
||||
}
|
||||
|
||||
static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a,
|
||||
int32_t b) {
|
||||
static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) {
|
||||
int32_t value32 = 0, b1 = 0, b2 = 0;
|
||||
int32_t a1 = 0;
|
||||
|
||||
__asm __volatile(
|
||||
#if defined(MIPS32_R2_LE)
|
||||
"seh %[a1], %[a] \n\t"
|
||||
"seh %[a1], %[a] \n\t"
|
||||
#else
|
||||
"sll %[a1], %[a], 16 \n\t"
|
||||
"sra %[a1], %[a1], 16 \n\t"
|
||||
"sll %[a1], %[a], 16 \n\t"
|
||||
"sra %[a1], %[a1], 16 \n\t"
|
||||
#endif
|
||||
"andi %[b2], %[b], 0xFFFF \n\t"
|
||||
"sra %[b1], %[b], 16 \n\t"
|
||||
"sra %[b2], %[b2], 1 \n\t"
|
||||
"mul %[value32], %[a1], %[b1] \n\t"
|
||||
"mul %[b2], %[a1], %[b2] \n\t"
|
||||
"addiu %[b2], %[b2], 0x4000 \n\t"
|
||||
"sra %[b2], %[b2], 15 \n\t"
|
||||
"addu %[value32], %[value32], %[b2] \n\t"
|
||||
: [value32] "=&r" (value32), [b1] "=&r" (b1), [b2] "=&r" (b2),
|
||||
[a1] "=&r" (a1)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "hi", "lo");
|
||||
"andi %[b2], %[b], 0xFFFF \n\t"
|
||||
"sra %[b1], %[b], 16 \n\t"
|
||||
"sra %[b2], %[b2], 1 \n\t"
|
||||
"mul %[value32], %[a1], %[b1] \n\t"
|
||||
"mul %[b2], %[a1], %[b2] \n\t"
|
||||
"addiu %[b2], %[b2], 0x4000 \n\t"
|
||||
"sra %[b2], %[b2], 15 \n\t"
|
||||
"addu %[value32], %[value32], %[b2] \n\t"
|
||||
: [value32] "=&r"(value32), [b1] "=&r"(b1), [b2] "=&r"(b2), [a1] "=&r"(a1)
|
||||
: [a] "r"(a), [b] "r"(b)
|
||||
: "hi", "lo");
|
||||
return value32;
|
||||
}
|
||||
|
||||
#if defined(MIPS_DSP_R1_LE)
|
||||
static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
|
||||
__asm __volatile(
|
||||
"shll_s.w %[value32], %[value32], 16 \n\t"
|
||||
"sra %[value32], %[value32], 16 \n\t"
|
||||
: [value32] "+r" (value32)
|
||||
:);
|
||||
"shll_s.w %[value32], %[value32], 16 \n\t"
|
||||
"sra %[value32], %[value32], 16 \n\t"
|
||||
: [value32] "+r"(value32)
|
||||
:);
|
||||
int16_t out16 = (int16_t)value32;
|
||||
return out16;
|
||||
}
|
||||
@ -78,10 +74,9 @@ static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
|
||||
static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
|
||||
int32_t value32 = 0;
|
||||
|
||||
__asm __volatile(
|
||||
"addq_s.ph %[value32], %[a], %[b] \n\t"
|
||||
: [value32] "=r" (value32)
|
||||
: [a] "r" (a), [b] "r" (b) );
|
||||
__asm __volatile("addq_s.ph %[value32], %[a], %[b] \n\t"
|
||||
: [value32] "=r"(value32)
|
||||
: [a] "r"(a), [b] "r"(b));
|
||||
return (int16_t)value32;
|
||||
}
|
||||
|
||||
@ -89,9 +84,9 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
int32_t l_sum;
|
||||
|
||||
__asm __volatile(
|
||||
"addq_s.w %[l_sum], %[l_var1], %[l_var2] \n\t"
|
||||
: [l_sum] "=r" (l_sum)
|
||||
: [l_var1] "r" (l_var1), [l_var2] "r" (l_var2) );
|
||||
"addq_s.w %[l_sum], %[l_var1], %[l_var2] \n\t"
|
||||
: [l_sum] "=r"(l_sum)
|
||||
: [l_var1] "r"(l_var1), [l_var2] "r"(l_var2));
|
||||
|
||||
return l_sum;
|
||||
}
|
||||
@ -99,10 +94,9 @@ static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
|
||||
int32_t value32;
|
||||
|
||||
__asm __volatile(
|
||||
"subq_s.ph %[value32], %[var1], %[var2] \n\t"
|
||||
: [value32] "=r" (value32)
|
||||
: [var1] "r" (var1), [var2] "r" (var2) );
|
||||
__asm __volatile("subq_s.ph %[value32], %[var1], %[var2] \n\t"
|
||||
: [value32] "=r"(value32)
|
||||
: [var1] "r"(var1), [var2] "r"(var2));
|
||||
|
||||
return (int16_t)value32;
|
||||
}
|
||||
@ -111,9 +105,9 @@ static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
|
||||
int32_t l_diff;
|
||||
|
||||
__asm __volatile(
|
||||
"subq_s.w %[l_diff], %[l_var1], %[l_var2] \n\t"
|
||||
: [l_diff] "=r" (l_diff)
|
||||
: [l_var1] "r" (l_var1), [l_var2] "r" (l_var2) );
|
||||
"subq_s.w %[l_diff], %[l_var1], %[l_var2] \n\t"
|
||||
: [l_diff] "=r"(l_diff)
|
||||
: [l_var1] "r"(l_var1), [l_var2] "r"(l_var2));
|
||||
|
||||
return l_diff;
|
||||
}
|
||||
@ -124,10 +118,10 @@ static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
|
||||
int i32 = 32;
|
||||
|
||||
__asm __volatile(
|
||||
"clz %[bits], %[n] \n\t"
|
||||
"subu %[bits], %[i32], %[bits] \n\t"
|
||||
: [bits] "=&r" (bits)
|
||||
: [n] "r" (n), [i32] "r" (i32) );
|
||||
"clz %[bits], %[n] \n\t"
|
||||
"subu %[bits], %[i32], %[bits] \n\t"
|
||||
: [bits] "=&r"(bits)
|
||||
: [n] "r"(n), [i32] "r"(i32));
|
||||
|
||||
return (int16_t)bits;
|
||||
}
|
||||
@ -136,20 +130,20 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
|
||||
int zeros = 0;
|
||||
|
||||
__asm __volatile(
|
||||
".set push \n\t"
|
||||
".set noreorder \n\t"
|
||||
"bnez %[a], 1f \n\t"
|
||||
" sra %[zeros], %[a], 31 \n\t"
|
||||
"b 2f \n\t"
|
||||
" move %[zeros], $zero \n\t"
|
||||
"1: \n\t"
|
||||
"xor %[zeros], %[a], %[zeros] \n\t"
|
||||
"clz %[zeros], %[zeros] \n\t"
|
||||
"addiu %[zeros], %[zeros], -1 \n\t"
|
||||
"2: \n\t"
|
||||
".set pop \n\t"
|
||||
: [zeros]"=&r"(zeros)
|
||||
: [a] "r" (a) );
|
||||
".set push \n\t"
|
||||
".set noreorder \n\t"
|
||||
"bnez %[a], 1f \n\t"
|
||||
" sra %[zeros], %[a], 31 \n\t"
|
||||
"b 2f \n\t"
|
||||
" move %[zeros], $zero \n\t"
|
||||
"1: \n\t"
|
||||
"xor %[zeros], %[a], %[zeros] \n\t"
|
||||
"clz %[zeros], %[zeros] \n\t"
|
||||
"addiu %[zeros], %[zeros], -1 \n\t"
|
||||
"2: \n\t"
|
||||
".set pop \n\t"
|
||||
: [zeros] "=&r"(zeros)
|
||||
: [a] "r"(a));
|
||||
|
||||
return (int16_t)zeros;
|
||||
}
|
||||
@ -157,10 +151,9 @@ static __inline int16_t WebRtcSpl_NormW32(int32_t a) {
|
||||
static __inline int16_t WebRtcSpl_NormU32(uint32_t a) {
|
||||
int zeros = 0;
|
||||
|
||||
__asm __volatile(
|
||||
"clz %[zeros], %[a] \n\t"
|
||||
: [zeros] "=r" (zeros)
|
||||
: [a] "r" (a) );
|
||||
__asm __volatile("clz %[zeros], %[a] \n\t"
|
||||
: [zeros] "=r"(zeros)
|
||||
: [a] "r"(a));
|
||||
|
||||
return (int16_t)(zeros & 0x1f);
|
||||
}
|
||||
@ -170,43 +163,41 @@ static __inline int16_t WebRtcSpl_NormW16(int16_t a) {
|
||||
int a0 = a << 16;
|
||||
|
||||
__asm __volatile(
|
||||
".set push \n\t"
|
||||
".set noreorder \n\t"
|
||||
"bnez %[a0], 1f \n\t"
|
||||
" sra %[zeros], %[a0], 31 \n\t"
|
||||
"b 2f \n\t"
|
||||
" move %[zeros], $zero \n\t"
|
||||
"1: \n\t"
|
||||
"xor %[zeros], %[a0], %[zeros] \n\t"
|
||||
"clz %[zeros], %[zeros] \n\t"
|
||||
"addiu %[zeros], %[zeros], -1 \n\t"
|
||||
"2: \n\t"
|
||||
".set pop \n\t"
|
||||
: [zeros]"=&r"(zeros)
|
||||
: [a0] "r" (a0) );
|
||||
".set push \n\t"
|
||||
".set noreorder \n\t"
|
||||
"bnez %[a0], 1f \n\t"
|
||||
" sra %[zeros], %[a0], 31 \n\t"
|
||||
"b 2f \n\t"
|
||||
" move %[zeros], $zero \n\t"
|
||||
"1: \n\t"
|
||||
"xor %[zeros], %[a0], %[zeros] \n\t"
|
||||
"clz %[zeros], %[zeros] \n\t"
|
||||
"addiu %[zeros], %[zeros], -1 \n\t"
|
||||
"2: \n\t"
|
||||
".set pop \n\t"
|
||||
: [zeros] "=&r"(zeros)
|
||||
: [a0] "r"(a0));
|
||||
|
||||
return (int16_t)zeros;
|
||||
}
|
||||
|
||||
static __inline int32_t WebRtc_MulAccumW16(int16_t a,
|
||||
int16_t b,
|
||||
int32_t c) {
|
||||
static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) {
|
||||
int32_t res = 0, c1 = 0;
|
||||
__asm __volatile(
|
||||
#if defined(MIPS32_R2_LE)
|
||||
"seh %[a], %[a] \n\t"
|
||||
"seh %[b], %[b] \n\t"
|
||||
"seh %[a], %[a] \n\t"
|
||||
"seh %[b], %[b] \n\t"
|
||||
#else
|
||||
"sll %[a], %[a], 16 \n\t"
|
||||
"sll %[b], %[b], 16 \n\t"
|
||||
"sra %[a], %[a], 16 \n\t"
|
||||
"sra %[b], %[b], 16 \n\t"
|
||||
"sll %[a], %[a], 16 \n\t"
|
||||
"sll %[b], %[b], 16 \n\t"
|
||||
"sra %[a], %[a], 16 \n\t"
|
||||
"sra %[b], %[b], 16 \n\t"
|
||||
#endif
|
||||
"mul %[res], %[a], %[b] \n\t"
|
||||
"addu %[c1], %[c], %[res] \n\t"
|
||||
: [c1] "=r" (c1), [res] "=&r" (res)
|
||||
: [a] "r" (a), [b] "r" (b), [c] "r" (c)
|
||||
: "hi", "lo");
|
||||
"mul %[res], %[a], %[b] \n\t"
|
||||
"addu %[c1], %[c], %[res] \n\t"
|
||||
: [c1] "=r"(c1), [res] "=&r"(res)
|
||||
: [a] "r"(a), [b] "r"(b), [c] "r"(c)
|
||||
: "hi", "lo");
|
||||
return (c1);
|
||||
}
|
||||
|
||||
|
@ -27,17 +27,14 @@ const int kFreqDataLength = (1 << kOrder) + 2;
|
||||
const int kComplexFftDataLength = 2 << kOrder;
|
||||
// Reference data for time signal.
|
||||
const int16_t kRefData[kTimeDataLength] = {
|
||||
11739, 6848, -8688, 31980, -30295, 25242, 27085, 19410,
|
||||
-26299, 15607, -10791, 11778, -23819, 14498, -25772, 10076,
|
||||
1173, 6848, -8688, 31980, -30295, 2522, 27085, 19410,
|
||||
-2629, 5607, -3, 1178, -23819, 1498, -25772, 10076
|
||||
};
|
||||
11739, 6848, -8688, 31980, -30295, 25242, 27085, 19410,
|
||||
-26299, 15607, -10791, 11778, -23819, 14498, -25772, 10076,
|
||||
1173, 6848, -8688, 31980, -30295, 2522, 27085, 19410,
|
||||
-2629, 5607, -3, 1178, -23819, 1498, -25772, 10076};
|
||||
|
||||
class RealFFTTest : public ::testing::Test {
|
||||
protected:
|
||||
RealFFTTest() {
|
||||
WebRtcSpl_Init();
|
||||
}
|
||||
RealFFTTest() { WebRtcSpl_Init(); }
|
||||
};
|
||||
|
||||
TEST_F(RealFFTTest, CreateFailsOnBadInput) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This header file contains some internal resampling functions.
|
||||
*
|
||||
@ -23,25 +22,39 @@
|
||||
* resample_by_2_fast.c
|
||||
* Functions for internal use in the other resample functions
|
||||
******************************************************************/
|
||||
void WebRtcSpl_DownBy2IntToShort(int32_t *in, int32_t len, int16_t *out,
|
||||
int32_t *state);
|
||||
void WebRtcSpl_DownBy2IntToShort(int32_t* in,
|
||||
int32_t len,
|
||||
int16_t* out,
|
||||
int32_t* state);
|
||||
|
||||
void WebRtcSpl_DownBy2ShortToInt(const int16_t *in, int32_t len,
|
||||
int32_t *out, int32_t *state);
|
||||
void WebRtcSpl_DownBy2ShortToInt(const int16_t* in,
|
||||
int32_t len,
|
||||
int32_t* out,
|
||||
int32_t* state);
|
||||
|
||||
void WebRtcSpl_UpBy2ShortToInt(const int16_t *in, int32_t len,
|
||||
int32_t *out, int32_t *state);
|
||||
void WebRtcSpl_UpBy2ShortToInt(const int16_t* in,
|
||||
int32_t len,
|
||||
int32_t* out,
|
||||
int32_t* state);
|
||||
|
||||
void WebRtcSpl_UpBy2IntToInt(const int32_t *in, int32_t len, int32_t *out,
|
||||
int32_t *state);
|
||||
void WebRtcSpl_UpBy2IntToInt(const int32_t* in,
|
||||
int32_t len,
|
||||
int32_t* out,
|
||||
int32_t* state);
|
||||
|
||||
void WebRtcSpl_UpBy2IntToShort(const int32_t *in, int32_t len,
|
||||
int16_t *out, int32_t *state);
|
||||
void WebRtcSpl_UpBy2IntToShort(const int32_t* in,
|
||||
int32_t len,
|
||||
int16_t* out,
|
||||
int32_t* state);
|
||||
|
||||
void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, int32_t len,
|
||||
int32_t* out, int32_t* state);
|
||||
void WebRtcSpl_LPBy2ShortToInt(const int16_t* in,
|
||||
int32_t len,
|
||||
int32_t* out,
|
||||
int32_t* state);
|
||||
|
||||
void WebRtcSpl_LPBy2IntToInt(const int32_t* in, int32_t len, int32_t* out,
|
||||
void WebRtcSpl_LPBy2IntToInt(const int32_t* in,
|
||||
int32_t len,
|
||||
int32_t* out,
|
||||
int32_t* state);
|
||||
|
||||
#endif // COMMON_AUDIO_SIGNAL_PROCESSING_RESAMPLE_BY_2_INTERNAL_H_
|
||||
|
@ -15,111 +15,113 @@
|
||||
#include "test/gtest.h"
|
||||
|
||||
static const size_t kVector16Size = 9;
|
||||
static const int16_t vector16[kVector16Size] = {1, -15511, 4323, 1963,
|
||||
WEBRTC_SPL_WORD16_MAX, 0, WEBRTC_SPL_WORD16_MIN + 5, -3333, 345};
|
||||
static const int16_t vector16[kVector16Size] = {1,
|
||||
-15511,
|
||||
4323,
|
||||
1963,
|
||||
WEBRTC_SPL_WORD16_MAX,
|
||||
0,
|
||||
WEBRTC_SPL_WORD16_MIN + 5,
|
||||
-3333,
|
||||
345};
|
||||
|
||||
class SplTest : public testing::Test {
|
||||
protected:
|
||||
SplTest() {
|
||||
WebRtcSpl_Init();
|
||||
}
|
||||
virtual ~SplTest() {
|
||||
}
|
||||
SplTest() { WebRtcSpl_Init(); }
|
||||
virtual ~SplTest() {}
|
||||
};
|
||||
|
||||
TEST_F(SplTest, MacroTest) {
|
||||
// Macros with inputs.
|
||||
int A = 10;
|
||||
int B = 21;
|
||||
int a = -3;
|
||||
int b = WEBRTC_SPL_WORD32_MAX;
|
||||
// Macros with inputs.
|
||||
int A = 10;
|
||||
int B = 21;
|
||||
int a = -3;
|
||||
int b = WEBRTC_SPL_WORD32_MAX;
|
||||
|
||||
EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B));
|
||||
EXPECT_EQ(21, WEBRTC_SPL_MAX(A, B));
|
||||
EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B));
|
||||
EXPECT_EQ(21, WEBRTC_SPL_MAX(A, B));
|
||||
|
||||
EXPECT_EQ(3, WEBRTC_SPL_ABS_W16(a));
|
||||
EXPECT_EQ(3, WEBRTC_SPL_ABS_W32(a));
|
||||
EXPECT_EQ(3, WEBRTC_SPL_ABS_W16(a));
|
||||
EXPECT_EQ(3, WEBRTC_SPL_ABS_W32(a));
|
||||
|
||||
EXPECT_EQ(-63, WEBRTC_SPL_MUL(a, B));
|
||||
EXPECT_EQ(2147483651u, WEBRTC_SPL_UMUL(a, b));
|
||||
b = WEBRTC_SPL_WORD16_MAX >> 1;
|
||||
EXPECT_EQ(4294918147u, WEBRTC_SPL_UMUL_32_16(a, b));
|
||||
EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_U16(a, b));
|
||||
EXPECT_EQ(-63, WEBRTC_SPL_MUL(a, B));
|
||||
EXPECT_EQ(2147483651u, WEBRTC_SPL_UMUL(a, b));
|
||||
b = WEBRTC_SPL_WORD16_MAX >> 1;
|
||||
EXPECT_EQ(4294918147u, WEBRTC_SPL_UMUL_32_16(a, b));
|
||||
EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_U16(a, b));
|
||||
|
||||
a = b;
|
||||
b = -3;
|
||||
a = b;
|
||||
b = -3;
|
||||
|
||||
EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT16(a, b));
|
||||
EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT15(a, b));
|
||||
EXPECT_EQ(-3, WEBRTC_SPL_MUL_16_32_RSFT14(a, b));
|
||||
EXPECT_EQ(-24, WEBRTC_SPL_MUL_16_32_RSFT11(a, b));
|
||||
EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT16(a, b));
|
||||
EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT15(a, b));
|
||||
EXPECT_EQ(-3, WEBRTC_SPL_MUL_16_32_RSFT14(a, b));
|
||||
EXPECT_EQ(-24, WEBRTC_SPL_MUL_16_32_RSFT11(a, b));
|
||||
|
||||
EXPECT_EQ(-12288, WEBRTC_SPL_MUL_16_16_RSFT(a, b, 2));
|
||||
EXPECT_EQ(-12287, WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, 2));
|
||||
EXPECT_EQ(-12288, WEBRTC_SPL_MUL_16_16_RSFT(a, b, 2));
|
||||
EXPECT_EQ(-12287, WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, 2));
|
||||
|
||||
EXPECT_EQ(21, WEBRTC_SPL_SAT(a, A, B));
|
||||
EXPECT_EQ(21, WEBRTC_SPL_SAT(a, B, A));
|
||||
EXPECT_EQ(21, WEBRTC_SPL_SAT(a, A, B));
|
||||
EXPECT_EQ(21, WEBRTC_SPL_SAT(a, B, A));
|
||||
|
||||
// Shifting with negative numbers allowed
|
||||
int shift_amount = 1; // Workaround compiler warning using variable here.
|
||||
// Positive means left shift
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W32(a, shift_amount));
|
||||
// Shifting with negative numbers allowed
|
||||
int shift_amount = 1; // Workaround compiler warning using variable here.
|
||||
// Positive means left shift
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W32(a, shift_amount));
|
||||
|
||||
// Shifting with negative numbers not allowed
|
||||
// We cannot do casting here due to signed/unsigned problem
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1));
|
||||
// Shifting with negative numbers not allowed
|
||||
// We cannot do casting here due to signed/unsigned problem
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1));
|
||||
|
||||
EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1));
|
||||
EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1));
|
||||
|
||||
EXPECT_EQ(1470, WEBRTC_SPL_RAND(A));
|
||||
EXPECT_EQ(1470, WEBRTC_SPL_RAND(A));
|
||||
|
||||
EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_16(a, b));
|
||||
EXPECT_EQ(1073676289, WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_WORD16_MAX,
|
||||
WEBRTC_SPL_WORD16_MAX));
|
||||
EXPECT_EQ(1073709055, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MAX,
|
||||
WEBRTC_SPL_WORD32_MAX));
|
||||
EXPECT_EQ(1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN,
|
||||
WEBRTC_SPL_WORD32_MIN));
|
||||
EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_16(a, b));
|
||||
EXPECT_EQ(1073676289,
|
||||
WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MAX));
|
||||
EXPECT_EQ(1073709055, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MAX,
|
||||
WEBRTC_SPL_WORD32_MAX));
|
||||
EXPECT_EQ(1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN,
|
||||
WEBRTC_SPL_WORD32_MIN));
|
||||
#ifdef WEBRTC_ARCH_ARM_V7
|
||||
EXPECT_EQ(-1073741824,
|
||||
WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN,
|
||||
WEBRTC_SPL_WORD32_MAX));
|
||||
EXPECT_EQ(-1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN,
|
||||
WEBRTC_SPL_WORD32_MAX));
|
||||
#else
|
||||
EXPECT_EQ(-1073741823,
|
||||
WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN,
|
||||
WEBRTC_SPL_WORD32_MAX));
|
||||
EXPECT_EQ(-1073741823, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN,
|
||||
WEBRTC_SPL_WORD32_MAX));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(SplTest, InlineTest) {
|
||||
int16_t a16 = 121;
|
||||
int16_t b16 = -17;
|
||||
int32_t a32 = 111121;
|
||||
int32_t b32 = -1711;
|
||||
int16_t a16 = 121;
|
||||
int16_t b16 = -17;
|
||||
int32_t a32 = 111121;
|
||||
int32_t b32 = -1711;
|
||||
|
||||
EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32));
|
||||
EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32));
|
||||
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW32(0));
|
||||
EXPECT_EQ(31, WebRtcSpl_NormW32(-1));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW32(WEBRTC_SPL_WORD32_MIN));
|
||||
EXPECT_EQ(14, WebRtcSpl_NormW32(a32));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW32(0));
|
||||
EXPECT_EQ(31, WebRtcSpl_NormW32(-1));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW32(WEBRTC_SPL_WORD32_MIN));
|
||||
EXPECT_EQ(14, WebRtcSpl_NormW32(a32));
|
||||
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW16(0));
|
||||
EXPECT_EQ(15, WebRtcSpl_NormW16(-1));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW16(WEBRTC_SPL_WORD16_MIN));
|
||||
EXPECT_EQ(4, WebRtcSpl_NormW16(b32));
|
||||
for (int ii = 0; ii < 15; ++ii) {
|
||||
int16_t value = 1 << ii;
|
||||
EXPECT_EQ(14 - ii, WebRtcSpl_NormW16(value));
|
||||
EXPECT_EQ(15 - ii, WebRtcSpl_NormW16(-value));
|
||||
}
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW16(0));
|
||||
EXPECT_EQ(15, WebRtcSpl_NormW16(-1));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormW16(WEBRTC_SPL_WORD16_MIN));
|
||||
EXPECT_EQ(4, WebRtcSpl_NormW16(b32));
|
||||
for (int ii = 0; ii < 15; ++ii) {
|
||||
int16_t value = 1 << ii;
|
||||
EXPECT_EQ(14 - ii, WebRtcSpl_NormW16(value));
|
||||
EXPECT_EQ(15 - ii, WebRtcSpl_NormW16(-value));
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, WebRtcSpl_NormU32(0u));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormU32(0xffffffff));
|
||||
EXPECT_EQ(15, WebRtcSpl_NormU32(static_cast<uint32_t>(a32)));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormU32(0u));
|
||||
EXPECT_EQ(0, WebRtcSpl_NormU32(0xffffffff));
|
||||
EXPECT_EQ(15, WebRtcSpl_NormU32(static_cast<uint32_t>(a32)));
|
||||
|
||||
EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16));
|
||||
EXPECT_EQ(138, WebRtcSpl_SubSatW16(a16, b16));
|
||||
EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16));
|
||||
EXPECT_EQ(138, WebRtcSpl_SubSatW16(a16, b16));
|
||||
}
|
||||
|
||||
TEST_F(SplTest, AddSubSatW32) {
|
||||
@ -168,84 +170,83 @@ TEST_F(SplTest, CountLeadingZeros64) {
|
||||
}
|
||||
|
||||
TEST_F(SplTest, MathOperationsTest) {
|
||||
int A = 1134567892;
|
||||
int32_t num = 117;
|
||||
int32_t den = -5;
|
||||
uint16_t denU = 5;
|
||||
EXPECT_EQ(33700, WebRtcSpl_Sqrt(A));
|
||||
EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A));
|
||||
int A = 1134567892;
|
||||
int32_t num = 117;
|
||||
int32_t den = -5;
|
||||
uint16_t denU = 5;
|
||||
EXPECT_EQ(33700, WebRtcSpl_Sqrt(A));
|
||||
EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A));
|
||||
|
||||
|
||||
EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num));
|
||||
EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (int16_t)den));
|
||||
EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (int16_t)den));
|
||||
EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU));
|
||||
EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256));
|
||||
EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num));
|
||||
EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (int16_t)den));
|
||||
EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (int16_t)den));
|
||||
EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU));
|
||||
EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256));
|
||||
}
|
||||
|
||||
TEST_F(SplTest, BasicArrayOperationsTest) {
|
||||
const size_t kVectorSize = 4;
|
||||
int B[] = {4, 12, 133, 1100};
|
||||
int16_t b16[kVectorSize];
|
||||
int32_t b32[kVectorSize];
|
||||
const size_t kVectorSize = 4;
|
||||
int B[] = {4, 12, 133, 1100};
|
||||
int16_t b16[kVectorSize];
|
||||
int32_t b32[kVectorSize];
|
||||
|
||||
int16_t bTmp16[kVectorSize];
|
||||
int32_t bTmp32[kVectorSize];
|
||||
int16_t bTmp16[kVectorSize];
|
||||
int32_t bTmp32[kVectorSize];
|
||||
|
||||
WebRtcSpl_MemSetW16(b16, 3, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(3, b16[kk]);
|
||||
}
|
||||
WebRtcSpl_ZerosArrayW16(b16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(0, b16[kk]);
|
||||
}
|
||||
WebRtcSpl_MemSetW32(b32, 3, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(3, b32[kk]);
|
||||
}
|
||||
WebRtcSpl_ZerosArrayW32(b32, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(0, b32[kk]);
|
||||
}
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
bTmp16[kk] = (int16_t)kk;
|
||||
bTmp32[kk] = (int32_t)kk;
|
||||
}
|
||||
WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(b16[kk], bTmp16[kk]);
|
||||
}
|
||||
// WEBRTC_SPL_MEMCPY_W32(b32, bTmp32, kVectorSize);
|
||||
// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
// EXPECT_EQ(b32[kk], bTmp32[kk]);
|
||||
// }
|
||||
WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16);
|
||||
for (size_t kk = 0; kk < 2; ++kk) {
|
||||
EXPECT_EQ(static_cast<int16_t>(kk+2), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_MemSetW16(b16, 3, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(3, b16[kk]);
|
||||
}
|
||||
WebRtcSpl_ZerosArrayW16(b16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(0, b16[kk]);
|
||||
}
|
||||
WebRtcSpl_MemSetW32(b32, 3, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(3, b32[kk]);
|
||||
}
|
||||
WebRtcSpl_ZerosArrayW32(b32, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(0, b32[kk]);
|
||||
}
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
bTmp16[kk] = (int16_t)kk;
|
||||
bTmp32[kk] = (int32_t)kk;
|
||||
}
|
||||
WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(b16[kk], bTmp16[kk]);
|
||||
}
|
||||
// WEBRTC_SPL_MEMCPY_W32(b32, bTmp32, kVectorSize);
|
||||
// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
// EXPECT_EQ(b32[kk], bTmp32[kk]);
|
||||
// }
|
||||
WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16);
|
||||
for (size_t kk = 0; kk < 2; ++kk) {
|
||||
EXPECT_EQ(static_cast<int16_t>(kk + 2), bTmp16[kk]);
|
||||
}
|
||||
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
b32[kk] = B[kk];
|
||||
b16[kk] = (int16_t)B[kk];
|
||||
}
|
||||
WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk]>>1), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_VectorBitShiftW16(bTmp16, kVectorSize, b16, 1);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk]>>1), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_VectorBitShiftW32(bTmp32, kVectorSize, b32, 1);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk]>>1), bTmp32[kk]);
|
||||
}
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
b32[kk] = B[kk];
|
||||
b16[kk] = (int16_t)B[kk];
|
||||
}
|
||||
WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk] >> 1), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_VectorBitShiftW16(bTmp16, kVectorSize, b16, 1);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk] >> 1), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_VectorBitShiftW32(bTmp32, kVectorSize, b32, 1);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk] >> 1), bTmp32[kk]);
|
||||
}
|
||||
|
||||
WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(b16[3-kk], bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(b16[3 - kk], bTmp16[kk]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SplTest, MinMaxOperationsTest) {
|
||||
@ -253,12 +254,40 @@ TEST_F(SplTest, MinMaxOperationsTest) {
|
||||
|
||||
// Vectors to test the cases where minimum values have to be caught
|
||||
// outside of the unrolled loops in ARM-Neon.
|
||||
int16_t vector16[kVectorSize] = {-1, 7485, 0, 3333,
|
||||
-18283, 0, 12334, -29871, 988, -3333,
|
||||
345, -456, 222, 999, 888, 8774, WEBRTC_SPL_WORD16_MIN};
|
||||
int32_t vector32[kVectorSize] = {-1, 0, 283211, 3333,
|
||||
8712345, 0, -3333, 89345, -374585456, 222, 999, 122345334,
|
||||
-12389756, -987329871, 888, -2, WEBRTC_SPL_WORD32_MIN};
|
||||
int16_t vector16[kVectorSize] = {-1,
|
||||
7485,
|
||||
0,
|
||||
3333,
|
||||
-18283,
|
||||
0,
|
||||
12334,
|
||||
-29871,
|
||||
988,
|
||||
-3333,
|
||||
345,
|
||||
-456,
|
||||
222,
|
||||
999,
|
||||
888,
|
||||
8774,
|
||||
WEBRTC_SPL_WORD16_MIN};
|
||||
int32_t vector32[kVectorSize] = {-1,
|
||||
0,
|
||||
283211,
|
||||
3333,
|
||||
8712345,
|
||||
0,
|
||||
-3333,
|
||||
89345,
|
||||
-374585456,
|
||||
222,
|
||||
999,
|
||||
122345334,
|
||||
-12389756,
|
||||
-987329871,
|
||||
888,
|
||||
-2,
|
||||
WEBRTC_SPL_WORD32_MIN};
|
||||
|
||||
EXPECT_EQ(WEBRTC_SPL_WORD16_MIN,
|
||||
WebRtcSpl_MinValueW16(vector16, kVectorSize));
|
||||
@ -312,76 +341,75 @@ TEST_F(SplTest, MinMaxOperationsTest) {
|
||||
}
|
||||
|
||||
TEST_F(SplTest, VectorOperationsTest) {
|
||||
const size_t kVectorSize = 4;
|
||||
int B[] = {4, 12, 133, 1100};
|
||||
int16_t a16[kVectorSize];
|
||||
int16_t b16[kVectorSize];
|
||||
int16_t bTmp16[kVectorSize];
|
||||
const size_t kVectorSize = 4;
|
||||
int B[] = {4, 12, 133, 1100};
|
||||
int16_t a16[kVectorSize];
|
||||
int16_t b16[kVectorSize];
|
||||
int16_t bTmp16[kVectorSize];
|
||||
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
a16[kk] = B[kk];
|
||||
b16[kk] = B[kk];
|
||||
}
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
a16[kk] = B[kk];
|
||||
b16[kk] = B[kk];
|
||||
}
|
||||
|
||||
WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk]*3+7)>>2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16,
|
||||
kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk] * 3 + 7) >> 2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((B[kk] * 3 + B[kk] * 2 + 2) >> 2, bTmp16[kk]);
|
||||
}
|
||||
|
||||
WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(((B[kk] * 3 + B[kk] * 2 + 2) >> 2) + ((b16[kk] * 3 + 7) >> 2),
|
||||
bTmp16[kk]);
|
||||
}
|
||||
|
||||
WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((b16[kk] * 13) >> 2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((b16[kk] * 13) >> 2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(((a16[kk] * 13) >> 2) + ((b16[kk] * 7) >> 2), bTmp16[kk]);
|
||||
}
|
||||
|
||||
WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(B[kk] >> 1, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3],
|
||||
kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(B[kk] >> 1, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], kVectorSize, 2);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((a16[kk] * b16[3 - kk]) >> 2, bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ((a16[kk] * b16[kk]) >> 6, bTmp16[kk]);
|
||||
}
|
||||
|
||||
WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16);
|
||||
for (size_t kk = 0; kk < kVectorSize - 1; ++kk) {
|
||||
EXPECT_EQ(32767, bTmp16[kk]);
|
||||
}
|
||||
EXPECT_EQ(32749, bTmp16[kVectorSize - 1]);
|
||||
WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16);
|
||||
for (size_t kk = 0; kk < kVectorSize - 1; ++kk) {
|
||||
EXPECT_EQ(32767, bTmp16[kk]);
|
||||
}
|
||||
EXPECT_EQ(32749, bTmp16[kVectorSize - 1]);
|
||||
|
||||
EXPECT_EQ(0, WebRtcSpl_GetScalingSquare(b16, kVectorSize, 1));
|
||||
EXPECT_EQ(0, WebRtcSpl_GetScalingSquare(b16, kVectorSize, 1));
|
||||
}
|
||||
|
||||
TEST_F(SplTest, EstimatorsTest) {
|
||||
const size_t kOrder = 2;
|
||||
const int32_t unstable_filter[] = { 4, 12, 133, 1100 };
|
||||
const int32_t stable_filter[] = { 1100, 133, 12, 4 };
|
||||
int16_t lpc[kOrder + 2] = { 0 };
|
||||
int16_t refl[kOrder + 2] = { 0 };
|
||||
int16_t lpc_result[] = { 4096, -497, 15, 0 };
|
||||
int16_t refl_result[] = { -3962, 123, 0, 0 };
|
||||
const int32_t unstable_filter[] = {4, 12, 133, 1100};
|
||||
const int32_t stable_filter[] = {1100, 133, 12, 4};
|
||||
int16_t lpc[kOrder + 2] = {0};
|
||||
int16_t refl[kOrder + 2] = {0};
|
||||
int16_t lpc_result[] = {4096, -497, 15, 0};
|
||||
int16_t refl_result[] = {-3962, 123, 0, 0};
|
||||
|
||||
EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(unstable_filter, lpc, refl, kOrder));
|
||||
EXPECT_EQ(1, WebRtcSpl_LevinsonDurbin(stable_filter, lpc, refl, kOrder));
|
||||
@ -392,69 +420,61 @@ TEST_F(SplTest, EstimatorsTest) {
|
||||
}
|
||||
|
||||
TEST_F(SplTest, FilterTest) {
|
||||
const size_t kVectorSize = 4;
|
||||
const size_t kFilterOrder = 3;
|
||||
int16_t A[] = {1, 2, 33, 100};
|
||||
int16_t A5[] = {1, 2, 33, 100, -5};
|
||||
int16_t B[] = {4, 12, 133, 110};
|
||||
int16_t data_in[kVectorSize];
|
||||
int16_t data_out[kVectorSize];
|
||||
int16_t bTmp16Low[kVectorSize];
|
||||
int16_t bState[kVectorSize];
|
||||
int16_t bStateLow[kVectorSize];
|
||||
const size_t kVectorSize = 4;
|
||||
const size_t kFilterOrder = 3;
|
||||
int16_t A[] = {1, 2, 33, 100};
|
||||
int16_t A5[] = {1, 2, 33, 100, -5};
|
||||
int16_t B[] = {4, 12, 133, 110};
|
||||
int16_t data_in[kVectorSize];
|
||||
int16_t data_out[kVectorSize];
|
||||
int16_t bTmp16Low[kVectorSize];
|
||||
int16_t bState[kVectorSize];
|
||||
int16_t bStateLow[kVectorSize];
|
||||
|
||||
WebRtcSpl_ZerosArrayW16(bState, kVectorSize);
|
||||
WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize);
|
||||
WebRtcSpl_ZerosArrayW16(bState, kVectorSize);
|
||||
WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize);
|
||||
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
data_in[kk] = A[kk];
|
||||
data_out[kk] = 0;
|
||||
}
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
data_in[kk] = A[kk];
|
||||
data_out[kk] = 0;
|
||||
}
|
||||
|
||||
// MA filters.
|
||||
// Note that the input data has |kFilterOrder| states before the actual
|
||||
// data (one sample).
|
||||
WebRtcSpl_FilterMAFastQ12(&data_in[kFilterOrder], data_out, B,
|
||||
kFilterOrder + 1, 1);
|
||||
EXPECT_EQ(0, data_out[0]);
|
||||
// AR filters.
|
||||
// Note that the output data has |kFilterOrder| states before the actual
|
||||
// data (one sample).
|
||||
WebRtcSpl_FilterARFastQ12(data_in, &data_out[kFilterOrder], A,
|
||||
kFilterOrder + 1, 1);
|
||||
EXPECT_EQ(0, data_out[kFilterOrder]);
|
||||
// MA filters.
|
||||
// Note that the input data has |kFilterOrder| states before the actual
|
||||
// data (one sample).
|
||||
WebRtcSpl_FilterMAFastQ12(&data_in[kFilterOrder], data_out, B,
|
||||
kFilterOrder + 1, 1);
|
||||
EXPECT_EQ(0, data_out[0]);
|
||||
// AR filters.
|
||||
// Note that the output data has |kFilterOrder| states before the actual
|
||||
// data (one sample).
|
||||
WebRtcSpl_FilterARFastQ12(data_in, &data_out[kFilterOrder], A,
|
||||
kFilterOrder + 1, 1);
|
||||
EXPECT_EQ(0, data_out[kFilterOrder]);
|
||||
|
||||
EXPECT_EQ(kVectorSize, WebRtcSpl_FilterAR(A5,
|
||||
5,
|
||||
data_in,
|
||||
kVectorSize,
|
||||
bState,
|
||||
kVectorSize,
|
||||
bStateLow,
|
||||
kVectorSize,
|
||||
data_out,
|
||||
bTmp16Low,
|
||||
kVectorSize));
|
||||
EXPECT_EQ(kVectorSize, WebRtcSpl_FilterAR(A5, 5, data_in, kVectorSize, bState,
|
||||
kVectorSize, bStateLow, kVectorSize,
|
||||
data_out, bTmp16Low, kVectorSize));
|
||||
}
|
||||
|
||||
TEST_F(SplTest, RandTest) {
|
||||
const int kVectorSize = 4;
|
||||
int16_t BU[] = {3653, 12446, 8525, 30691};
|
||||
int16_t b16[kVectorSize];
|
||||
uint32_t bSeed = 100000;
|
||||
const int kVectorSize = 4;
|
||||
int16_t BU[] = {3653, 12446, 8525, 30691};
|
||||
int16_t b16[kVectorSize];
|
||||
uint32_t bSeed = 100000;
|
||||
|
||||
EXPECT_EQ(7086, WebRtcSpl_RandU(&bSeed));
|
||||
EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed));
|
||||
EXPECT_EQ(-9786, WebRtcSpl_RandN(&bSeed));
|
||||
EXPECT_EQ(kVectorSize, WebRtcSpl_RandUArray(b16, kVectorSize, &bSeed));
|
||||
for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(BU[kk], b16[kk]);
|
||||
}
|
||||
EXPECT_EQ(7086, WebRtcSpl_RandU(&bSeed));
|
||||
EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed));
|
||||
EXPECT_EQ(-9786, WebRtcSpl_RandN(&bSeed));
|
||||
EXPECT_EQ(kVectorSize, WebRtcSpl_RandUArray(b16, kVectorSize, &bSeed));
|
||||
for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(BU[kk], b16[kk]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SplTest, DotProductWithScaleTest) {
|
||||
EXPECT_EQ(605362796, WebRtcSpl_DotProductWithScale(vector16,
|
||||
vector16, kVector16Size, 2));
|
||||
EXPECT_EQ(605362796, WebRtcSpl_DotProductWithScale(vector16, vector16,
|
||||
kVector16Size, 2));
|
||||
}
|
||||
|
||||
TEST_F(SplTest, CrossCorrelationTest) {
|
||||
@ -464,8 +484,9 @@ TEST_F(SplTest, CrossCorrelationTest) {
|
||||
const int kStep = 1;
|
||||
const size_t kSeqDimension = 6;
|
||||
|
||||
const int16_t kVector16[kVector16Size] = {1, 4323, 1963,
|
||||
WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MIN + 5, -3333, -876, 8483, 142};
|
||||
const int16_t kVector16[kVector16Size] = {
|
||||
1, 4323, 1963, WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MIN + 5, -3333,
|
||||
-876, 8483, 142};
|
||||
int32_t vector32[kCrossCorrelationDimension] = {0};
|
||||
|
||||
WebRtcSpl_CrossCorrelation(vector32, vector16, kVector16, kSeqDimension,
|
||||
@ -473,12 +494,12 @@ TEST_F(SplTest, CrossCorrelationTest) {
|
||||
|
||||
// WebRtcSpl_CrossCorrelationC() and WebRtcSpl_CrossCorrelationNeon()
|
||||
// are not bit-exact.
|
||||
const int32_t kExpected[kCrossCorrelationDimension] =
|
||||
{-266947903, -15579555, -171282001};
|
||||
const int32_t kExpected[kCrossCorrelationDimension] = {-266947903, -15579555,
|
||||
-171282001};
|
||||
const int32_t* expected = kExpected;
|
||||
#if !defined(MIPS32_LE)
|
||||
const int32_t kExpectedNeon[kCrossCorrelationDimension] =
|
||||
{-266947901, -15579553, -171281999};
|
||||
const int32_t kExpectedNeon[kCrossCorrelationDimension] = {
|
||||
-266947901, -15579553, -171281999};
|
||||
if (WebRtcSpl_CrossCorrelation != WebRtcSpl_CrossCorrelationC) {
|
||||
expected = kExpectedNeon;
|
||||
}
|
||||
@ -491,8 +512,9 @@ TEST_F(SplTest, CrossCorrelationTest) {
|
||||
TEST_F(SplTest, AutoCorrelationTest) {
|
||||
int scale = 0;
|
||||
int32_t vector32[kVector16Size];
|
||||
const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063,
|
||||
-85221647, -17104971, 61806945, 6644603, -669329, 43};
|
||||
const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063,
|
||||
-85221647, -17104971, 61806945,
|
||||
6644603, -669329, 43};
|
||||
|
||||
EXPECT_EQ(kVector16Size,
|
||||
WebRtcSpl_AutoCorrelation(vector16, kVector16Size,
|
||||
@ -504,63 +526,60 @@ TEST_F(SplTest, AutoCorrelationTest) {
|
||||
}
|
||||
|
||||
TEST_F(SplTest, SignalProcessingTest) {
|
||||
const size_t kVectorSize = 4;
|
||||
int A[] = {1, 2, 33, 100};
|
||||
const int16_t kHanning[4] = { 2399, 8192, 13985, 16384 };
|
||||
int16_t b16[kVectorSize];
|
||||
const size_t kVectorSize = 4;
|
||||
int A[] = {1, 2, 33, 100};
|
||||
const int16_t kHanning[4] = {2399, 8192, 13985, 16384};
|
||||
int16_t b16[kVectorSize];
|
||||
|
||||
int16_t bTmp16[kVectorSize];
|
||||
int16_t bTmp16[kVectorSize];
|
||||
|
||||
int bScale = 0;
|
||||
int bScale = 0;
|
||||
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
b16[kk] = A[kk];
|
||||
}
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
b16[kk] = A[kk];
|
||||
}
|
||||
|
||||
// TODO(bjornv): Activate the Reflection Coefficient tests when refactoring.
|
||||
// WebRtcSpl_ReflCoefToLpc(b16, kVectorSize, bTmp16);
|
||||
//// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]);
|
||||
//// }
|
||||
// WebRtcSpl_LpcToReflCoef(bTmp16, kVectorSize, b16);
|
||||
//// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
//// EXPECT_EQ(a16[kk], b16[kk]);
|
||||
//// }
|
||||
// WebRtcSpl_AutoCorrToReflCoef(b32, kVectorSize, bTmp16);
|
||||
//// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]);
|
||||
//// }
|
||||
// TODO(bjornv): Activate the Reflection Coefficient tests when refactoring.
|
||||
// WebRtcSpl_ReflCoefToLpc(b16, kVectorSize, bTmp16);
|
||||
//// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]);
|
||||
//// }
|
||||
// WebRtcSpl_LpcToReflCoef(bTmp16, kVectorSize, b16);
|
||||
//// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
//// EXPECT_EQ(a16[kk], b16[kk]);
|
||||
//// }
|
||||
// WebRtcSpl_AutoCorrToReflCoef(b32, kVectorSize, bTmp16);
|
||||
//// for (int kk = 0; kk < kVectorSize; ++kk) {
|
||||
//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]);
|
||||
//// }
|
||||
|
||||
WebRtcSpl_GetHanningWindow(bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(kHanning[kk], bTmp16[kk]);
|
||||
}
|
||||
WebRtcSpl_GetHanningWindow(bTmp16, kVectorSize);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
EXPECT_EQ(kHanning[kk], bTmp16[kk]);
|
||||
}
|
||||
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
b16[kk] = A[kk];
|
||||
}
|
||||
EXPECT_EQ(11094 , WebRtcSpl_Energy(b16, kVectorSize, &bScale));
|
||||
EXPECT_EQ(0, bScale);
|
||||
for (size_t kk = 0; kk < kVectorSize; ++kk) {
|
||||
b16[kk] = A[kk];
|
||||
}
|
||||
EXPECT_EQ(11094, WebRtcSpl_Energy(b16, kVectorSize, &bScale));
|
||||
EXPECT_EQ(0, bScale);
|
||||
}
|
||||
|
||||
TEST_F(SplTest, FFTTest) {
|
||||
int16_t B[] = {1, 2, 33, 100,
|
||||
2, 3, 34, 101,
|
||||
3, 4, 35, 102,
|
||||
4, 5, 36, 103};
|
||||
int16_t B[] = {1, 2, 33, 100, 2, 3, 34, 101, 3, 4, 35, 102, 4, 5, 36, 103};
|
||||
|
||||
EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1));
|
||||
// for (int kk = 0; kk < 16; ++kk) {
|
||||
// EXPECT_EQ(A[kk], B[kk]);
|
||||
// }
|
||||
EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1));
|
||||
// for (int kk = 0; kk < 16; ++kk) {
|
||||
// EXPECT_EQ(A[kk], B[kk]);
|
||||
// }
|
||||
WebRtcSpl_ComplexBitReverse(B, 3);
|
||||
for (int kk = 0; kk < 16; ++kk) {
|
||||
// EXPECT_EQ(A[kk], B[kk]);
|
||||
}
|
||||
EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1));
|
||||
// for (int kk = 0; kk < 16; ++kk) {
|
||||
// EXPECT_EQ(A[kk], B[kk]);
|
||||
// }
|
||||
EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1));
|
||||
// for (int kk = 0; kk < 16; ++kk) {
|
||||
// EXPECT_EQ(A[kk], B[kk]);
|
||||
// }
|
||||
WebRtcSpl_ComplexBitReverse(B, 3);
|
||||
for (int kk = 0; kk < 16; ++kk) {
|
||||
// EXPECT_EQ(A[kk], B[kk]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SplTest, Resample48WithSaturationTest) {
|
||||
@ -570,14 +589,13 @@ TEST_F(SplTest, Resample48WithSaturationTest) {
|
||||
|
||||
// Saturated input vector of 48 samples.
|
||||
const int32_t kVectorSaturated[3 * kBlockSize + 7] = {
|
||||
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
|
||||
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
|
||||
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767
|
||||
};
|
||||
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
|
||||
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
|
||||
-32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
|
||||
32767, 32767, 32767, 32767, 32767, 32767, 32767};
|
||||
|
||||
// All values in |out_vector| should be |kRefValue32kHz|.
|
||||
const int32_t kRefValue32kHz1 = -1077493760;
|
||||
|
Reference in New Issue
Block a user