blob: 3128f21f4a0ee7b02e1f2ad7ec1247adc68a2f7f [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 * This function "unmutes" a vector on a sample by sample basis.
13 */
14
15#include "dsp_helpfunctions.h"
16
17#include "signal_processing_library.h"
18
19
pbos@webrtc.org0946a562013-04-09 00:28:06 +000020void WebRtcNetEQ_UnmuteSignal(int16_t *pw16_inVec, int16_t *startMuteFact,
21 int16_t *pw16_outVec, int16_t unmuteFact,
22 int16_t N)
niklase@google.com470e71d2011-07-07 08:21:25 +000023{
24 int i;
pbos@webrtc.org0946a562013-04-09 00:28:06 +000025 uint16_t w16_tmp;
26 int32_t w32_tmp;
niklase@google.com470e71d2011-07-07 08:21:25 +000027
pbos@webrtc.org0946a562013-04-09 00:28:06 +000028 w16_tmp = (uint16_t) *startMuteFact;
29 w32_tmp = WEBRTC_SPL_LSHIFT_W32((int32_t)w16_tmp,6) + 32;
niklase@google.com470e71d2011-07-07 08:21:25 +000030 for (i = 0; i < N; i++)
31 {
32 pw16_outVec[i]
pbos@webrtc.org0946a562013-04-09 00:28:06 +000033 = (int16_t) ((WEBRTC_SPL_MUL_16_16(w16_tmp, pw16_inVec[i]) + 8192) >> 14);
niklase@google.com470e71d2011-07-07 08:21:25 +000034 w32_tmp += unmuteFact;
35 w32_tmp = WEBRTC_SPL_MAX(0, w32_tmp);
pbos@webrtc.org0946a562013-04-09 00:28:06 +000036 w16_tmp = (uint16_t) WEBRTC_SPL_RSHIFT_W32(w32_tmp, 6); /* 20 - 14 = 6 */
niklase@google.com470e71d2011-07-07 08:21:25 +000037 w16_tmp = WEBRTC_SPL_MIN(16384, w16_tmp);
38 }
pbos@webrtc.org0946a562013-04-09 00:28:06 +000039 *startMuteFact = (int16_t) w16_tmp;
niklase@google.com470e71d2011-07-07 08:21:25 +000040}
41