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 ------------------------------------------------------------------------------
35 Functions: decode_3i40_14bits
37 ------------------------------------------------------------------------------
41 FUNCTION: decode_3i40_14bits (decod_ACELP())
43 PURPOSE: Algebraic codebook decoder. For details about the encoding see
47 /*----------------------------------------------------------------------------
49 ----------------------------------------------------------------------------*/
54 /*----------------------------------------------------------------------------
56 ; Define module specific macros here
57 ----------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------
61 ; Include all pre-processor statements here. Include conditional
62 ; compile variables also.
63 ----------------------------------------------------------------------------*/
64 #define NB_PULSE 3 /* number of pulses */
67 /*----------------------------------------------------------------------------
68 ; LOCAL FUNCTION DEFINITIONS
69 ; Function Prototype declaration
70 ----------------------------------------------------------------------------*/
72 /*----------------------------------------------------------------------------
73 ; LOCAL VARIABLE DEFINITIONS
74 ; Variable declaration - defined here and used outside this module
75 ----------------------------------------------------------------------------*/
78 ------------------------------------------------------------------------------
79 FUNCTION NAME: decode_3i40_14bits
80 ------------------------------------------------------------------------------
81 INPUT AND OUTPUT DEFINITIONS
84 sign -- Word16 -- signs of 3 pulses.
85 index -- Word16 -- Positions of the 3 pulses.
88 cod[] -- array of type Word16 -- algebraic (fixed) codebook excitation
93 Global Variables Used:
96 Local Variables Needed:
99 ------------------------------------------------------------------------------
103 ------------------------------------------------------------------------------
108 ------------------------------------------------------------------------------
111 d2_9pf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
113 ------------------------------------------------------------------------------
117 ------------------------------------------------------------------------------
119 [State any special notes, constraints or cautions for users of this function]
121 ------------------------------------------------------------------------------
124 void decode_3i40_14bits(
125 Word16 sign, /* i : signs of 3 pulses. */
126 Word16 index, /* i : Positions of the 3 pulses. */
127 Word16 cod[] /* o : algebraic (fixed) codebook excitation */
133 Word16 pos[NB_PULSE];
135 /* Decode the positions */
153 pos[1] = i * 5 + j * 2 + 1;
167 pos[2] = i * 5 + j * 2 + 2;
170 /* decode the signs and build the codeword */
172 for (i = 0; i < L_SUBFR; i++)
177 for (j = 0; j < NB_PULSE; j++)
181 /* This line is equivalent to...
186 * cod[pos[j]] = 8191;
190 * cod[pos[j]] = -8192;
194 cod[pos[j]] = i * 16383 - 8192;