blob: b2bdcfffc3fce7ddafcfc391b320c76b750c2432 [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 iLBC Speech Coder ANSI-C Source Code
14
15 WebRtcIlbcfix_EnergyInverse.c
16
17******************************************************************/
18
19/* Inverses the in vector in into Q29 domain */
20
21#include "energy_inverse.h"
22
23void WebRtcIlbcfix_EnergyInverse(
pbos@webrtc.org0946a562013-04-09 00:28:06 +000024 int16_t *energy, /* (i/o) Energy and inverse
niklase@google.com470e71d2011-07-07 08:21:25 +000025 energy (in Q29) */
Peter Kastingdce40cf2015-08-24 14:52:23 -070026 size_t noOfEnergies) /* (i) The length of the energy
niklase@google.com470e71d2011-07-07 08:21:25 +000027 vector */
28{
pbos@webrtc.org0946a562013-04-09 00:28:06 +000029 int32_t Nom=(int32_t)0x1FFFFFFF;
30 int16_t *energyPtr;
Peter Kastingdce40cf2015-08-24 14:52:23 -070031 size_t i;
niklase@google.com470e71d2011-07-07 08:21:25 +000032
33 /* Set the minimum energy value to 16384 to avoid overflow */
34 energyPtr=energy;
35 for (i=0; i<noOfEnergies; i++) {
36 (*energyPtr)=WEBRTC_SPL_MAX((*energyPtr),16384);
37 energyPtr++;
38 }
39
40 /* Calculate inverse energy in Q29 */
41 energyPtr=energy;
42 for (i=0; i<noOfEnergies; i++) {
pbos@webrtc.org0946a562013-04-09 00:28:06 +000043 (*energyPtr) = (int16_t)WebRtcSpl_DivW32W16(Nom, (*energyPtr));
niklase@google.com470e71d2011-07-07 08:21:25 +000044 energyPtr++;
45 }
46}