Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_wb / dec / src / dec_acelp_2p_in_64.cpp
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
20
21     3GPP TS 26.173
22     ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
23     Available from http://www.3gpp.org
24
25 (C) 2007, 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 ****************************************************************************************/
29 /*
30 ------------------------------------------------------------------------------
31
32
33
34  Filename: dec_acelp_2p_in_64.cpp
35
36 ------------------------------------------------------------------------------
37  INPUT AND OUTPUT DEFINITIONS
38
39      int16 index,          (i):   12 bits index
40      int16 code[]          (o): Q9 algebraic (fixed) codebook excitation
41
42 ------------------------------------------------------------------------------
43  FUNCTION DESCRIPTION
44
45    12 bits algebraic codebook decoder.
46    2 tracks x 32 positions per track = 64 samples.
47
48    12 bits --> 2 pulses in a frame of 64 samples.
49
50    All pulses can have two (2) possible amplitudes: +1 or -1.
51    Each pulse can have 32 possible positions.
52
53 ------------------------------------------------------------------------------
54  REQUIREMENTS
55
56
57 ------------------------------------------------------------------------------
58  REFERENCES
59
60 ------------------------------------------------------------------------------
61  PSEUDO-CODE
62
63 ------------------------------------------------------------------------------
64 */
65
66
67 /*----------------------------------------------------------------------------
68 ; INCLUDES
69 ----------------------------------------------------------------------------*/
70
71 #include "pv_amr_wb_type_defs.h"
72 #include "pvamrwbdecoder_basic_op.h"
73 #include "pvamrwbdecoder_cnst.h"
74 #include "pvamrwbdecoder_acelp.h"
75
76 /*----------------------------------------------------------------------------
77 ; MACROS
78 ; Define module specific macros here
79 ----------------------------------------------------------------------------*/
80
81
82 /*----------------------------------------------------------------------------
83 ; DEFINES
84 ; Include all pre-processor statements here. Include conditional
85 ; compile variables also.
86 ----------------------------------------------------------------------------*/
87 #define L_CODE    64                       /* codevector length  */
88 #define NB_TRACK  2                        /* number of track    */
89 #define NB_POS    32                       /* number of position */
90
91
92 /*----------------------------------------------------------------------------
93 ; LOCAL FUNCTION DEFINITIONS
94 ; Function Prototype declaration
95 ----------------------------------------------------------------------------*/
96
97 /*----------------------------------------------------------------------------
98 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
99 ; Variable declaration - defined here and used outside this module
100 ----------------------------------------------------------------------------*/
101
102 /*----------------------------------------------------------------------------
103 ; EXTERNAL FUNCTION REFERENCES
104 ; Declare functions defined elsewhere and referenced in this module
105 ----------------------------------------------------------------------------*/
106
107 /*----------------------------------------------------------------------------
108 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
109 ; Declare variables used in this module but defined elsewhere
110 ----------------------------------------------------------------------------*/
111
112 /*----------------------------------------------------------------------------
113 ; FUNCTION CODE
114 ----------------------------------------------------------------------------*/
115
116 void dec_acelp_2p_in_64(
117     int16 index,        /* (i):   12 bits index                          */
118     int16 code[]        /* (o): Q9 algebraic (fixed) codebook excitation */
119 )
120 {
121     int16 i;
122
123     pv_memset(code, 0, L_CODE*sizeof(*code));
124
125     /* decode the positions and signs of pulses and build the codeword */
126
127     i = (index >> 5) & 0x003E;
128
129     if (((index >> 6) & NB_POS) == 0)
130     {
131         code[i] = 512;
132     }
133     else
134     {
135         code[i] = -512;
136     }
137
138     i = ((index & 0x001F) << 1) + 1;
139
140     if ((index & NB_POS) == 0)
141     {
142         code[i] = 512;
143     }
144     else
145     {
146         code[i] = -512;
147     }
148
149 }