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 Filename: /audio/gsm_amr/c/src/reorder.c
32 ------------------------------------------------------------------------------
36 1. Eliminated unused include file add.h.
37 2. Replaced array addressing by pointers
38 3. Eliminated math operations that unnecessary checked for
40 4. Replaced loop counter with decrement loops
42 Description: Replaced "int" and/or "char" with OSCL defined types.
47 ------------------------------------------------------------------------------
51 /*----------------------------------------------------------------------------
53 ----------------------------------------------------------------------------*/
56 /*----------------------------------------------------------------------------
58 ; [Define module specific macros here]
59 ----------------------------------------------------------------------------*/
61 /*----------------------------------------------------------------------------
63 ; [Include all pre-processor statements here. Include conditional
64 ; compile variables also.]
65 ----------------------------------------------------------------------------*/
67 /*----------------------------------------------------------------------------
68 ; LOCAL FUNCTION DEFINITIONS
69 ; [List function prototypes here]
70 ----------------------------------------------------------------------------*/
72 /*----------------------------------------------------------------------------
73 ; LOCAL VARIABLE DEFINITIONS
74 ; [Variable declaration - defined here and used outside this module]
75 ----------------------------------------------------------------------------*/
79 ------------------------------------------------------------------------------
80 FUNCTION NAME: Reorder_lsf
81 ------------------------------------------------------------------------------
82 INPUT AND OUTPUT DEFINITIONS
85 lsf = vector of LSFs (range: 0<=val<=0.5)(Word16)
86 min_dist = minimum required distance (Word16)
87 n = LPC order (Word16)
88 pOverflow = pointer to overflow (Flag)
91 pOverflow -> 1 if the add operation called by Reorder_lsf() results in
93 lsf -> reordered vector of LSFs (Word16)
98 Global Variables Used:
101 Local Variables Needed:
104 ------------------------------------------------------------------------------
107 This function makes sure that the LSFs are properly ordered keeps a certain
108 minimum distance between adjacent LSFs.
110 ------------------------------------------------------------------------------
115 ------------------------------------------------------------------------------
118 [1] reorder.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
120 ------------------------------------------------------------------------------
124 Word16 *lsf, // (i/o) : vector of LSFs (range: 0<=val<=0.5)
125 Word16 min_dist, // (i) : minimum required distance
126 Word16 n // (i) : LPC order
132 // The reference ETSI code uses a global flag for Overflow. In the actual
133 // implementation a pointer to Overflow flag is passed into the function
134 // for use by the math functions add() and sub()
137 for (i = 0; i < n; i++)
139 if (sub (lsf[i], lsf_min) < 0)
143 lsf_min = add (lsf[i], min_dist);
147 ------------------------------------------------------------------------------
148 RESOURCES USED [optional]
150 When the code is written for a specific target processor the
151 the resources used should be documented below.
153 HEAP MEMORY USED: x bytes
155 STACK MEMORY USED: x bytes
157 CLOCK CYCLES: (cycle count equation for this function) + (variable
158 used to represent cycle count for each subroutine
160 where: (cycle count variable) = cycle count for [subroutine
163 ------------------------------------------------------------------------------
165 [State any special notes, constraints or cautions for users of this function]
167 ------------------------------------------------------------------------------
170 /*----------------------------------------------------------------------------
172 ----------------------------------------------------------------------------*/
174 Word16 *lsf, /* (i/o) : vector of LSFs (range: 0<=val<=0.5) */
175 Word16 min_dist, /* (i) : minimum required distance */
176 Word16 n, /* (i) : LPC order */
177 Flag *pOverflow /* (i/o) : Overflow flag */
182 Word16 *p_lsf = &lsf[0];
183 OSCL_UNUSED_ARG(pOverflow);
186 for (i = 0; i < n; i++)
188 if (*(p_lsf) < lsf_min)
190 *(p_lsf++) = lsf_min;
195 lsf_min = *(p_lsf++) + min_dist;