niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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 | |
Mirko Bonadei | 06c2aa9 | 2018-02-01 14:11:41 | [diff] [blame] | 21 | #include "modules/audio_coding/codecs/ilbc/energy_inverse.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 22 | |
| 23 | void WebRtcIlbcfix_EnergyInverse( |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 24 | int16_t *energy, /* (i/o) Energy and inverse |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 25 | energy (in Q29) */ |
Peter Kasting | dce40cf | 2015-08-24 21:52:23 | [diff] [blame] | 26 | size_t noOfEnergies) /* (i) The length of the energy |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 27 | vector */ |
| 28 | { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 29 | int32_t Nom=(int32_t)0x1FFFFFFF; |
| 30 | int16_t *energyPtr; |
Peter Kasting | dce40cf | 2015-08-24 21:52:23 | [diff] [blame] | 31 | size_t i; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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++) { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 | [diff] [blame] | 43 | (*energyPtr) = (int16_t)WebRtcSpl_DivW32W16(Nom, (*energyPtr)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 44 | energyPtr++; |
| 45 | } |
| 46 | } |