blob: 7f00254aea50c5249ccffd7631c3df90efea1d54 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
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
Mirko Bonadei06c2aa92018-02-01 14:11:4121#include "modules/audio_coding/codecs/ilbc/energy_inverse.h"
niklase@google.com470e71d2011-07-07 08:21:2522
23void WebRtcIlbcfix_EnergyInverse(
pbos@webrtc.org0946a562013-04-09 00:28:0624 int16_t *energy, /* (i/o) Energy and inverse
niklase@google.com470e71d2011-07-07 08:21:2525 energy (in Q29) */
Peter Kastingdce40cf2015-08-24 21:52:2326 size_t noOfEnergies) /* (i) The length of the energy
niklase@google.com470e71d2011-07-07 08:21:2527 vector */
28{
pbos@webrtc.org0946a562013-04-09 00:28:0629 int32_t Nom=(int32_t)0x1FFFFFFF;
30 int16_t *energyPtr;
Peter Kastingdce40cf2015-08-24 21:52:2331 size_t i;
niklase@google.com470e71d2011-07-07 08:21:2532
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:0643 (*energyPtr) = (int16_t)WebRtcSpl_DivW32W16(Nom, (*energyPtr));
niklase@google.com470e71d2011-07-07 08:21:2544 energyPtr++;
45 }
46}