1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
30 ------------------------------------------------------------------------------
36 ------------------------------------------------------------------------------
40 /*----------------------------------------------------------------------------
42 ----------------------------------------------------------------------------*/
48 /*----------------------------------------------------------------------------
50 ; Define module specific macros here
51 ----------------------------------------------------------------------------*/
53 /*----------------------------------------------------------------------------
55 ; Include all pre-processor statements here. Include conditional
56 ; compile variables also.
57 ----------------------------------------------------------------------------*/
61 /*----------------------------------------------------------------------------
62 ; LOCAL FUNCTION DEFINITIONS
63 ; Function Prototype declaration
64 ----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------
67 ; LOCAL VARIABLE DEFINITIONS
68 ; Variable declaration - defined here and used outside this module
69 ----------------------------------------------------------------------------*/
72 ------------------------------------------------------------------------------
73 FUNCTION NAME: decode_2i40_11bits
74 ------------------------------------------------------------------------------
75 INPUT AND OUTPUT DEFINITIONS
78 sign -- Word16 -- signs of 2 pulses.
79 index -- Word16 -- Positions of the 2 pulses.
82 cod[] -- array of type Word16 -- algebraic (fixed) codebook excitation
87 Global Variables Used:
90 Local Variables Needed:
93 ------------------------------------------------------------------------------
97 ------------------------------------------------------------------------------
102 ------------------------------------------------------------------------------
105 d2_11pf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
107 ------------------------------------------------------------------------------
111 ------------------------------------------------------------------------------
113 [State any special notes, constraints or cautions for users of this function]
115 ------------------------------------------------------------------------------
118 void decode_2i40_11bits(
119 Word16 sign, /* i : signs of 2 pulses. */
120 Word16 index, /* i : Positions of the 2 pulses. */
121 Word16 cod[] /* o : algebraic (fixed) codebook excitation */
128 Word16 pos[NB_PULSE];
130 /* Decode the positions */
138 pos[0] = i * 5 + j * 2 + 1;
163 /* decode the signs and build the codeword */
164 for (i = 0; i < L_SUBFR; i++)
169 for (j = 0; j < NB_PULSE; j++)
173 /* This line is equivalent to...
178 * cod[pos[j]] = 8191;
182 * cod[pos[j]] = -8192;
186 cod[pos[j]] = i * 16383 - 8192;