• 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_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 
WebRtcIlbcfix_GainDequant(int16_t index,int16_t maxIn,int16_t stage)27 int16_t WebRtcIlbcfix_GainDequant(
28     /* (o) quantized gain value (Q14) */
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 */
32                                                 ){
33   int16_t scale;
34   const int16_t *gain;
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 
44   return (int16_t)((scale * gain[index] + 8192) >> 14);
45 }
46