blob: 8f29da8d9b3c05c79eafc16130d5342a357c74c9 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11
12/*
13 * This file contains the function WebRtcSpl_GetHanningWindow().
14 * The description header can be found in signal_processing_library.h
15 *
16 */
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "common_audio/signal_processing/include/signal_processing_library.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
bjornv@webrtc.org132feb12011-12-01 15:40:50 +000020// Hanning table with 256 entries
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000021static const int16_t kHanningTable[] = {
bjornv@webrtc.org132feb12011-12-01 15:40:50 +000022 1, 2, 6, 10, 15, 22, 30, 39,
23 50, 62, 75, 89, 104, 121, 138, 157,
24 178, 199, 222, 246, 271, 297, 324, 353,
25 383, 413, 446, 479, 513, 549, 586, 624,
26 663, 703, 744, 787, 830, 875, 920, 967,
27 1015, 1064, 1114, 1165, 1218, 1271, 1325, 1381,
28 1437, 1494, 1553, 1612, 1673, 1734, 1796, 1859,
29 1924, 1989, 2055, 2122, 2190, 2259, 2329, 2399,
30 2471, 2543, 2617, 2691, 2765, 2841, 2918, 2995,
31 3073, 3152, 3232, 3312, 3393, 3475, 3558, 3641,
32 3725, 3809, 3895, 3980, 4067, 4154, 4242, 4330,
33 4419, 4509, 4599, 4689, 4781, 4872, 4964, 5057,
34 5150, 5244, 5338, 5432, 5527, 5622, 5718, 5814,
35 5910, 6007, 6104, 6202, 6299, 6397, 6495, 6594,
36 6693, 6791, 6891, 6990, 7090, 7189, 7289, 7389,
37 7489, 7589, 7690, 7790, 7890, 7991, 8091, 8192,
38 8293, 8393, 8494, 8594, 8694, 8795, 8895, 8995,
39 9095, 9195, 9294, 9394, 9493, 9593, 9691, 9790,
40 9889, 9987, 10085, 10182, 10280, 10377, 10474, 10570,
4110666, 10762, 10857, 10952, 11046, 11140, 11234, 11327,
4211420, 11512, 11603, 11695, 11785, 11875, 11965, 12054,
4312142, 12230, 12317, 12404, 12489, 12575, 12659, 12743,
4412826, 12909, 12991, 13072, 13152, 13232, 13311, 13389,
4513466, 13543, 13619, 13693, 13767, 13841, 13913, 13985,
4614055, 14125, 14194, 14262, 14329, 14395, 14460, 14525,
4714588, 14650, 14711, 14772, 14831, 14890, 14947, 15003,
4815059, 15113, 15166, 15219, 15270, 15320, 15369, 15417,
4915464, 15509, 15554, 15597, 15640, 15681, 15721, 15760,
5015798, 15835, 15871, 15905, 15938, 15971, 16001, 16031,
5116060, 16087, 16113, 16138, 16162, 16185, 16206, 16227,
5216246, 16263, 16280, 16295, 16309, 16322, 16334, 16345,
5316354, 16362, 16369, 16374, 16378, 16382, 16383, 16384
54};
55
Peter Kastingdce40cf2015-08-24 14:52:23 -070056void WebRtcSpl_GetHanningWindow(int16_t *v, size_t size)
niklase@google.com470e71d2011-07-07 08:21:25 +000057{
Peter Kastingdce40cf2015-08-24 14:52:23 -070058 size_t jj;
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000059 int16_t *vptr1;
niklase@google.com470e71d2011-07-07 08:21:25 +000060
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000061 int32_t index;
62 int32_t factor = ((int32_t)0x40000000);
niklase@google.com470e71d2011-07-07 08:21:25 +000063
Peter Kastingdce40cf2015-08-24 14:52:23 -070064 factor = WebRtcSpl_DivW32W16(factor, (int16_t)size);
niklase@google.com470e71d2011-07-07 08:21:25 +000065 if (size < 513)
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000066 index = (int32_t)-0x200000;
niklase@google.com470e71d2011-07-07 08:21:25 +000067 else
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000068 index = (int32_t)-0x100000;
niklase@google.com470e71d2011-07-07 08:21:25 +000069 vptr1 = v;
70
71 for (jj = 0; jj < size; jj++)
72 {
73 index += factor;
bjornv@webrtc.org132feb12011-12-01 15:40:50 +000074 (*vptr1++) = kHanningTable[index >> 22];
niklase@google.com470e71d2011-07-07 08:21:25 +000075 }
76
77}