niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [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_GainDequant.c |
| 16 | |
| 17 | ******************************************************************/ |
| 18 | |
| 19 | #include "defines.h" |
| 20 | #include "constants.h" |
| 21 | |
| 22 | /*----------------------------------------------------------------* |
| 23 | * decoder for quantized gains in the gain-shape coding of |
| 24 | * residual |
| 25 | *---------------------------------------------------------------*/ |
| 26 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 27 | int16_t WebRtcIlbcfix_GainDequant( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | /* (o) quantized gain value (Q14) */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 29 | int16_t index, /* (i) quantization index */ |
| 30 | int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */ |
| 31 | int16_t stage /* (i) The stage of the search */ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | ){ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 33 | int16_t scale; |
| 34 | const int16_t *gain; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
| 36 | /* obtain correct scale factor */ |
| 37 | |
| 38 | scale=WEBRTC_SPL_ABS_W16(maxIn); |
| 39 | scale = WEBRTC_SPL_MAX(1638, scale); /* if lower than 0.1, set it to 0.1 */ |
| 40 | |
| 41 | /* select the quantization table and return the decoded value */ |
| 42 | gain = WebRtcIlbcfix_kGain[stage]; |
| 43 | |
bjornv@webrtc.org | ba97ea6 | 2015-02-13 09:51:40 +0000 | [diff] [blame] | 44 | return (int16_t)((scale * gain[index] + 8192) >> 14); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | } |