• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "modules/audio_coding/codecs/ilbc/energy_inverse.h"
22 
WebRtcIlbcfix_EnergyInverse(int16_t * energy,size_t noOfEnergies)23 void WebRtcIlbcfix_EnergyInverse(
24     int16_t *energy,    /* (i/o) Energy and inverse
25                                                            energy (in Q29) */
26     size_t noOfEnergies)  /* (i)   The length of the energy
27                                    vector */
28 {
29   int32_t Nom=(int32_t)0x1FFFFFFF;
30   int16_t *energyPtr;
31   size_t i;
32 
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++) {
43     (*energyPtr) = (int16_t)WebRtcSpl_DivW32W16(Nom, (*energyPtr));
44     energyPtr++;
45   }
46 }
47