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 ****************************************************************************************/
32 ------------------------------------------------------------------------------
36 /*----------------------------------------------------------------------------
38 ----------------------------------------------------------------------------*/
41 /*----------------------------------------------------------------------------
43 ; [Define module specific macros here]
44 ----------------------------------------------------------------------------*/
46 /*----------------------------------------------------------------------------
48 ; [Include all pre-processor statements here. Include conditional
49 ; compile variables also.]
50 ----------------------------------------------------------------------------*/
52 /*----------------------------------------------------------------------------
53 ; LOCAL FUNCTION DEFINITIONS
54 ; [List function prototypes here]
55 ----------------------------------------------------------------------------*/
57 /*----------------------------------------------------------------------------
58 ; LOCAL VARIABLE DEFINITIONS
59 ; [Variable declaration - defined here and used outside this module]
60 ----------------------------------------------------------------------------*/
64 ------------------------------------------------------------------------------
65 FUNCTION NAME: Reorder_lsf
66 ------------------------------------------------------------------------------
67 INPUT AND OUTPUT DEFINITIONS
70 lsf = vector of LSFs (range: 0<=val<=0.5)(Word16)
71 min_dist = minimum required distance (Word16)
72 n = LPC order (Word16)
73 pOverflow = pointer to overflow (Flag)
76 pOverflow -> 1 if the add operation called by Reorder_lsf() results in
78 lsf -> reordered vector of LSFs (Word16)
83 Global Variables Used:
86 Local Variables Needed:
89 ------------------------------------------------------------------------------
92 This function makes sure that the LSFs are properly ordered keeps a certain
93 minimum distance between adjacent LSFs.
95 ------------------------------------------------------------------------------
100 ------------------------------------------------------------------------------
103 [1] reorder.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
105 ------------------------------------------------------------------------------
109 Word16 *lsf, // (i/o) : vector of LSFs (range: 0<=val<=0.5)
110 Word16 min_dist, // (i) : minimum required distance
111 Word16 n // (i) : LPC order
117 // The reference ETSI code uses a global flag for Overflow. In the actual
118 // implementation a pointer to Overflow flag is passed into the function
119 // for use by the math functions add() and sub()
122 for (i = 0; i < n; i++)
124 if (sub (lsf[i], lsf_min) < 0)
128 lsf_min = add (lsf[i], min_dist);
132 ------------------------------------------------------------------------------
134 [State any special notes, constraints or cautions for users of this function]
136 ------------------------------------------------------------------------------
139 /*----------------------------------------------------------------------------
141 ----------------------------------------------------------------------------*/
142 OSCL_EXPORT_REF void Reorder_lsf(
143 Word16 *lsf, /* (i/o) : vector of LSFs (range: 0<=val<=0.5) */
144 Word16 min_dist, /* (i) : minimum required distance */
145 Word16 n, /* (i) : LPC order */
146 Flag *pOverflow /* (i/o) : Overflow flag */
151 Word16 *p_lsf = &lsf[0];
152 OSCL_UNUSED_ARG(pOverflow);
155 for (i = 0; i < n; i++)
157 if (*(p_lsf) < lsf_min)
159 *(p_lsf++) = lsf_min;
164 lsf_min = *(p_lsf++) + min_dist;