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 - Wideband (AMR-WB) speech codec
23 Available from http://www.3gpp.org
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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
34 Filename: dec_acelp_2p_in_64.cpp
36 ------------------------------------------------------------------------------
37 INPUT AND OUTPUT DEFINITIONS
39 int16 index, (i): 12 bits index
40 int16 code[] (o): Q9 algebraic (fixed) codebook excitation
42 ------------------------------------------------------------------------------
45 12 bits algebraic codebook decoder.
46 2 tracks x 32 positions per track = 64 samples.
48 12 bits --> 2 pulses in a frame of 64 samples.
50 All pulses can have two (2) possible amplitudes: +1 or -1.
51 Each pulse can have 32 possible positions.
53 ------------------------------------------------------------------------------
57 ------------------------------------------------------------------------------
60 ------------------------------------------------------------------------------
63 ------------------------------------------------------------------------------
67 /*----------------------------------------------------------------------------
69 ----------------------------------------------------------------------------*/
71 #include "pv_amr_wb_type_defs.h"
72 #include "pvamrwbdecoder_basic_op.h"
73 #include "pvamrwbdecoder_cnst.h"
74 #include "pvamrwbdecoder_acelp.h"
76 /*----------------------------------------------------------------------------
78 ; Define module specific macros here
79 ----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------
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 */
92 /*----------------------------------------------------------------------------
93 ; LOCAL FUNCTION DEFINITIONS
94 ; Function Prototype declaration
95 ----------------------------------------------------------------------------*/
97 /*----------------------------------------------------------------------------
98 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
99 ; Variable declaration - defined here and used outside this module
100 ----------------------------------------------------------------------------*/
102 /*----------------------------------------------------------------------------
103 ; EXTERNAL FUNCTION REFERENCES
104 ; Declare functions defined elsewhere and referenced in this module
105 ----------------------------------------------------------------------------*/
107 /*----------------------------------------------------------------------------
108 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
109 ; Declare variables used in this module but defined elsewhere
110 ----------------------------------------------------------------------------*/
112 /*----------------------------------------------------------------------------
114 ----------------------------------------------------------------------------*/
116 void dec_acelp_2p_in_64(
117 int16 index, /* (i): 12 bits index */
118 int16 code[] /* (o): Q9 algebraic (fixed) codebook excitation */
123 pv_memset(code, 0, L_CODE*sizeof(*code));
125 /* decode the positions and signs of pulses and build the codeword */
127 i = (index >> 5) & 0x003E;
129 if (((index >> 6) & NB_POS) == 0)
138 i = ((index & 0x001F) << 1) + 1;
140 if ((index & NB_POS) == 0)