gain_dequant.c revision 470e71d3649f6cac4688e83819640b012b5d38bb
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 27WebRtc_Word16 WebRtcIlbcfix_GainDequant( 28 /* (o) quantized gain value (Q14) */ 29 WebRtc_Word16 index, /* (i) quantization index */ 30 WebRtc_Word16 maxIn, /* (i) maximum of unquantized gain (Q14) */ 31 WebRtc_Word16 stage /* (i) The stage of the search */ 32 ){ 33 WebRtc_Word16 scale; 34 const WebRtc_Word16 *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((WebRtc_Word16)((WEBRTC_SPL_MUL_16_16(scale, gain[index])+8192)>>14)); 45} 46