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/****************************************************************************************
19Portions 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)
26Permission to distribute, modify and use this file under the standard license
27terms 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     Date: 05/08/2007
37
38------------------------------------------------------------------------------
39 REVISION HISTORY
40
41
42 Description:
43
44------------------------------------------------------------------------------
45 INPUT AND OUTPUT DEFINITIONS
46
47     int16 index,          (i):   12 bits index
48     int16 code[]          (o): Q9 algebraic (fixed) codebook excitation
49
50------------------------------------------------------------------------------
51 FUNCTION DESCRIPTION
52
53   12 bits algebraic codebook decoder.
54   2 tracks x 32 positions per track = 64 samples.
55
56   12 bits --> 2 pulses in a frame of 64 samples.
57
58   All pulses can have two (2) possible amplitudes: +1 or -1.
59   Each pulse can have 32 possible positions.
60
61------------------------------------------------------------------------------
62 REQUIREMENTS
63
64
65------------------------------------------------------------------------------
66 REFERENCES
67
68------------------------------------------------------------------------------
69 PSEUDO-CODE
70
71------------------------------------------------------------------------------
72*/
73
74
75/*----------------------------------------------------------------------------
76; INCLUDES
77----------------------------------------------------------------------------*/
78
79#include "pv_amr_wb_type_defs.h"
80#include "pvamrwbdecoder_basic_op.h"
81#include "pvamrwbdecoder_cnst.h"
82#include "pvamrwbdecoder_acelp.h"
83
84/*----------------------------------------------------------------------------
85; MACROS
86; Define module specific macros here
87----------------------------------------------------------------------------*/
88
89
90/*----------------------------------------------------------------------------
91; DEFINES
92; Include all pre-processor statements here. Include conditional
93; compile variables also.
94----------------------------------------------------------------------------*/
95#define L_CODE    64                       /* codevector length  */
96#define NB_TRACK  2                        /* number of track    */
97#define NB_POS    32                       /* number of position */
98
99
100/*----------------------------------------------------------------------------
101; LOCAL FUNCTION DEFINITIONS
102; Function Prototype declaration
103----------------------------------------------------------------------------*/
104
105/*----------------------------------------------------------------------------
106; LOCAL STORE/BUFFER/POINTER DEFINITIONS
107; Variable declaration - defined here and used outside this module
108----------------------------------------------------------------------------*/
109
110/*----------------------------------------------------------------------------
111; EXTERNAL FUNCTION REFERENCES
112; Declare functions defined elsewhere and referenced in this module
113----------------------------------------------------------------------------*/
114
115/*----------------------------------------------------------------------------
116; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
117; Declare variables used in this module but defined elsewhere
118----------------------------------------------------------------------------*/
119
120/*----------------------------------------------------------------------------
121; FUNCTION CODE
122----------------------------------------------------------------------------*/
123
124void dec_acelp_2p_in_64(
125    int16 index,        /* (i):   12 bits index                          */
126    int16 code[]        /* (o): Q9 algebraic (fixed) codebook excitation */
127)
128{
129    int16 i;
130
131    pv_memset(code, 0, L_CODE*sizeof(*code));
132
133    /* decode the positions and signs of pulses and build the codeword */
134
135    i = (index >> 5) & 0x003E;
136
137    if (((index >> 6) & NB_POS) == 0)
138    {
139        code[i] = 512;
140    }
141    else
142    {
143        code[i] = -512;
144    }
145
146    i = ((index & 0x001F) << 1) + 1;
147
148    if ((index & NB_POS) == 0)
149    {
150        code[i] = 512;
151    }
152    else
153    {
154        code[i] = -512;
155    }
156
157}
158