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 ------------------------------------------------------------------------------
34 Filename: inter_36.cpp
36 ------------------------------------------------------------------------------
39 /*----------------------------------------------------------------------------
41 ----------------------------------------------------------------------------*/
44 #include "inter_36_tab.h"
47 /*----------------------------------------------------------------------------
49 ; Define module specific macros here
50 ----------------------------------------------------------------------------*/
53 /*----------------------------------------------------------------------------
55 ; Include all pre-processor statements here. Include conditional
56 ; compile variables also.
57 ----------------------------------------------------------------------------*/
60 /*----------------------------------------------------------------------------
61 ; LOCAL FUNCTION DEFINITIONS
62 ; Function Prototype declaration
63 ----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------
67 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
68 ; Variable declaration - defined here and used outside this module
69 ----------------------------------------------------------------------------*/
73 ------------------------------------------------------------------------------
74 FUNCTION NAME: inter_36
75 ------------------------------------------------------------------------------
76 INPUT AND OUTPUT DEFINITIONS
79 pX = pointer to input vector of type Word16
80 frac = fraction (-2..2 for 3*, -3..3 for 6*) of type Word16
81 flag3 = if set, upsampling rate = 3 (6 otherwise) of type Word16
82 pOverflow = pointer to overflow flag
90 Global Variables Used:
93 Local Variables Needed:
96 ------------------------------------------------------------------------------
100 Purpose : Interpolating the normalized correlation
101 : with 1/3 or 1/6 resolution.
103 ------------------------------------------------------------------------------
108 ------------------------------------------------------------------------------
111 inter_36.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
113 ------------------------------------------------------------------------------
118 const Word16 *c1, *c2;
123 frac = shl (frac, 1); // inter_3[k] = inter_6[2*k] -> k' = 2*k
128 frac = add (frac, UP_SAMP_MAX);
135 c2 = &inter_6[sub (UP_SAMP_MAX, frac)];
138 for (i = 0, k = 0; i < L_INTER_SRCH; i++, k += UP_SAMP_MAX)
140 s = L_mac (s, x1[-i], c1[k]);
141 s = L_mac (s, x2[i], c2[k]);
146 ------------------------------------------------------------------------------
148 [State any special notes, constraints or cautions for users of this function]
150 ------------------------------------------------------------------------------
152 Word16 Interpol_3or6( /* o : interpolated value */
153 Word16 *pX, /* i : input vector */
154 Word16 frac, /* i : fraction (-2..2 for 3*, -3..3 for 6*) */
155 Word16 flag3, /* i : if set, upsampling rate = 3 (6 otherwise) */
168 OSCL_UNUSED_ARG(pOverflow);
173 /* inter_3[k] = inter_6[2*k] -> k' = 2*k */
184 pC1 = &inter_6[frac];
185 temp1 = UP_SAMP_MAX - frac;
186 pC2 = &inter_6[temp1];
191 for (i = (L_INTER_SRCH >> 1); i != 0; i--)
193 s = amrnb_fxp_mac_16_by_16bb((Word32) * (pX1--), (Word32) pC1[k], s);
194 s = amrnb_fxp_mac_16_by_16bb((Word32) * (pX2++), (Word32) pC2[k], s);
196 s = amrnb_fxp_mac_16_by_16bb((Word32) * (pX1--), (Word32) pC1[k], s);
197 s = amrnb_fxp_mac_16_by_16bb((Word32) * (pX2++), (Word32) pC2[k], s);
201 return((Word16)(s >> 15));